summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Cristau <[email protected]>2009-06-28 17:41:50 +0200
committerJulien Cristau <[email protected]>2009-06-28 17:41:50 +0200
commitadafe6d60781aff60e41afe8a3ab5be29848565e (patch)
treeece5cf08b59db3f0373128d866a7899a7673cb7e
parentc38bc21cf522647db69f1e5cdbd4b152c728183c (diff)
parent418987ff05f892d3c33ed4ddbe856c496b05ea14 (diff)
Merge commit 'mesa_7_5_rc4' into debian-experimental
Conflicts: progs/fp/point-position.c progs/fp/tri-depth.c progs/fp/tri-depth2.c progs/fp/tri-depthwrite.c progs/fp/tri-depthwrite2.c progs/fp/tri-inv.c progs/fp/tri-param.c progs/fp/tri-tex.c progs/tests/.gitignore progs/tests/Makefile progs/tests/zreaddraw.c
-rw-r--r--Makefile2
-rwxr-xr-xbin/mklib19
-rw-r--r--configure.ac5
-rw-r--r--docs/devinfo.html40
-rw-r--r--docs/install.html52
-rw-r--r--docs/news.html15
-rw-r--r--docs/relnotes-7.4.3.html79
-rw-r--r--docs/relnotes-7.4.4.html68
-rw-r--r--docs/relnotes-7.5.html4
-rw-r--r--docs/relnotes.html9
-rw-r--r--include/GL/glew.h6
-rw-r--r--progs/demos/Makefile7
-rw-r--r--progs/demos/fbotexture.c108
-rw-r--r--progs/demos/fslight.c8
-rw-r--r--progs/fp/SConscript17
-rw-r--r--progs/fp/abs.txt5
-rw-r--r--progs/fp/add-swz.txt5
-rw-r--r--progs/fp/add.txt5
-rw-r--r--progs/fp/cmp.txt5
-rw-r--r--progs/fp/cos.txt8
-rw-r--r--progs/fp/dp3.txt4
-rw-r--r--progs/fp/dp4.txt4
-rw-r--r--progs/fp/dph.txt4
-rw-r--r--progs/fp/dst.txt3
-rw-r--r--progs/fp/ex2.txt5
-rw-r--r--progs/fp/flr.txt5
-rw-r--r--progs/fp/fp-tri.c256
-rw-r--r--progs/fp/frc.txt5
-rw-r--r--progs/fp/kil-pos.txt9
-rw-r--r--progs/fp/kil-texcoord-sgt.txt8
-rw-r--r--progs/fp/kil.txt6
-rw-r--r--progs/fp/lg2.txt5
-rw-r--r--progs/fp/lit.txt5
-rw-r--r--progs/fp/local.txt11
-rw-r--r--progs/fp/lrp.txt4
-rw-r--r--progs/fp/mad.txt4
-rw-r--r--progs/fp/max.txt3
-rw-r--r--progs/fp/min.txt3
-rw-r--r--progs/fp/mov.txt3
-rw-r--r--progs/fp/mul-swz.txt3
-rw-r--r--progs/fp/mul.txt3
-rw-r--r--progs/fp/negate.txt6
-rw-r--r--progs/fp/position.txt4
-rw-r--r--progs/fp/pow.txt4
-rw-r--r--progs/fp/rcp.txt5
-rw-r--r--progs/fp/rsq.txt5
-rwxr-xr-xprogs/fp/run.sh7
-rw-r--r--progs/fp/scs.txt5
-rw-r--r--progs/fp/sge.txt3
-rw-r--r--progs/fp/sge2.txt8
-rw-r--r--progs/fp/sin.txt8
-rw-r--r--progs/fp/slt.txt3
-rw-r--r--progs/fp/sub.txt3
-rw-r--r--progs/fp/swz.txt3
-rw-r--r--progs/fp/swz2.txt4
-rw-r--r--progs/fp/swz3.txt5
-rw-r--r--progs/fp/tex-pos-kil-1.txt7
-rw-r--r--progs/fp/tex-pos-kil.txt8
-rw-r--r--progs/fp/tex-pos.txt6
-rw-r--r--progs/fp/tex.txt3
-rw-r--r--progs/fp/xpd.txt3
-rw-r--r--progs/tests/SConscript137
-rw-r--r--progs/tests/bug_texstore_i8.c196
-rw-r--r--progs/tests/bumpmap.c208
-rw-r--r--progs/tests/calibrate_rast.c397
-rw-r--r--progs/tests/fillrate.c204
-rw-r--r--progs/tests/glutfx.c189
-rw-r--r--progs/tests/mapbufrange.c205
-rw-r--r--progs/tests/mapvbo.c139
-rw-r--r--progs/tests/mipgen.c207
-rw-r--r--progs/tests/mipmap_comp.c295
-rw-r--r--progs/tests/mipmap_view.c435
-rw-r--r--progs/tests/occlude.c234
-rw-r--r--progs/tests/quads.c259
-rw-r--r--progs/tests/streaming_rect.c327
-rw-r--r--progs/tests/subtex.c225
-rw-r--r--progs/tests/texdown.c477
-rw-r--r--progs/tests/texobj.c284
-rw-r--r--progs/tests/zcomp.c224
-rw-r--r--progs/tests/zdrawpix.c193
-rw-r--r--progs/util/extfuncs.h101
-rw-r--r--progs/wgl/sharedtex_mt/sharedtex_mt.c30
-rw-r--r--progs/wgl/wglthreads/wglthreads.c64
-rw-r--r--progs/xdemos/glxcontexts.c160
-rw-r--r--scons/crossmingw.py2
-rw-r--r--scons/dxsdk.py66
-rw-r--r--scons/gallium.py62
-rw-r--r--scons/generic.py8
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_elts.c3
-rw-r--r--src/gallium/auxiliary/indices/u_indices.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer.h14
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c6
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c6
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr.h20
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c8
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c30
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c26
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c6
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c20
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c36
-rw-r--r--src/gallium/auxiliary/rtasm/rtasm_ppc.c6
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_dump.c18
-rw-r--r--src/gallium/auxiliary/util/u_gen_mipmap.c2
-rw-r--r--src/gallium/auxiliary/util/u_snprintf.c2
-rw-r--r--src/gallium/drivers/cell/ppu/cell_screen.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_context.c16
-rw-r--r--src/gallium/drivers/softpipe/sp_context.h2
-rw-r--r--src/gallium/drivers/softpipe/sp_draw_arrays.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_flush.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_screen.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_setup.c9
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_sample.c2
-rw-r--r--src/gallium/drivers/trace/tr_dump.c4
-rw-r--r--src/gallium/drivers/trace/tr_dump.h6
-rw-r--r--src/gallium/include/pipe/p_defines.h1
-rw-r--r--src/gallium/include/pipe/p_format.h28
-rw-r--r--src/gallium/include/pipe/p_refcnt.h28
-rw-r--r--src/gallium/include/pipe/p_thread.h1
-rw-r--r--src/gallium/state_trackers/dri/dri_drawable.c2
-rw-r--r--src/gallium/state_trackers/glx/xlib/fakeglx.c2
-rwxr-xr-xsrc/gallium/state_trackers/python/retrace/interpreter.py46
-rwxr-xr-xsrc/gallium/state_trackers/python/tests/base.py8
-rwxr-xr-xsrc/gallium/state_trackers/python/tests/texture_sample.py243
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_context.c82
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_device.c42
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_framebuffer.c144
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_framebuffer.h13
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_tls.c33
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_tls.h6
-rw-r--r--src/glew/glew.c4
-rw-r--r--src/glew/glewinfo.c2
-rw-r--r--src/glx/x11/dri_common.c4
-rw-r--r--src/glx/x11/glxcmds.c14
-rw-r--r--src/glx/x11/glxcurrent.c2
-rw-r--r--src/mesa/drivers/common/driverfuncs.c1
-rw-r--r--src/mesa/drivers/dri/common/dri_util.c6
-rw-r--r--src/mesa/drivers/dri/i915/i830_state.c21
-rw-r--r--src/mesa/drivers/dri/i915/i915_tex_layout.c5
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.h5
-rw-r--r--src/mesa/drivers/dri/i965/brw_sf_state.c7
-rw-r--r--src/mesa/drivers/dri/i965/brw_vs_constval.c44
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm.c14
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm.h3
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_fp.c21
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_glsl.c32
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_pass2.c21
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_sampler_state.c10
-rw-r--r--src/mesa/drivers/dri/intel/intel_buffer_objects.c55
-rw-r--r--src/mesa/drivers/dri/intel/intel_buffer_objects.h3
-rw-r--r--src/mesa/drivers/dri/intel/intel_buffers.c2
-rw-r--r--src/mesa/drivers/dri/intel/intel_clear.c8
-rw-r--r--src/mesa/drivers/dri/intel/intel_context.c13
-rw-r--r--src/mesa/drivers/dri/intel/intel_context.h6
-rw-r--r--src/mesa/drivers/dri/intel/intel_pixel_bitmap.c10
-rw-r--r--src/mesa/drivers/dri/intel/intel_pixel_draw.c22
-rw-r--r--src/mesa/drivers/dri/intel/intel_screen.c26
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_image.c12
-rw-r--r--src/mesa/drivers/dri/r200/r200_context.c2
-rw-r--r--src/mesa/drivers/dri/r300/r300_context.c2
-rw-r--r--src/mesa/drivers/dri/radeon/radeon_context.c2
-rw-r--r--src/mesa/drivers/x11/fakeglx.c2
-rw-r--r--src/mesa/main/api_noop.c16
-rw-r--r--src/mesa/main/api_validate.c4
-rw-r--r--src/mesa/main/attrib.c90
-rw-r--r--src/mesa/main/compiler.h4
-rw-r--r--src/mesa/main/config.h8
-rw-r--r--src/mesa/main/context.c41
-rw-r--r--src/mesa/main/context.h3
-rw-r--r--src/mesa/main/debug.c2
-rw-r--r--src/mesa/main/dlist.c40
-rw-r--r--src/mesa/main/enums.c10
-rw-r--r--src/mesa/main/fbobject.c5
-rw-r--r--src/mesa/main/image.c2
-rw-r--r--src/mesa/main/macros.h14
-rw-r--r--src/mesa/main/matrix.c10
-rw-r--r--src/mesa/main/mipmap.c3
-rw-r--r--src/mesa/main/mtypes.h6
-rw-r--r--src/mesa/main/queryobj.c16
-rw-r--r--src/mesa/main/queryobj.h3
-rw-r--r--src/mesa/main/texenv.c4
-rw-r--r--src/mesa/main/texenvprogram.c1
-rw-r--r--src/mesa/main/texformat_tmp.h28
-rw-r--r--src/mesa/main/texgetimage.c6
-rw-r--r--src/mesa/main/teximage.c2
-rw-r--r--src/mesa/main/texobj.c65
-rw-r--r--src/mesa/main/texobj.h3
-rw-r--r--src/mesa/main/texstate.c9
-rw-r--r--src/mesa/main/texstore.c39
-rw-r--r--src/mesa/main/varray.c29
-rw-r--r--src/mesa/main/version.h2
-rw-r--r--src/mesa/main/viewport.c4
-rw-r--r--src/mesa/shader/arbprogparse.c5
-rw-r--r--src/mesa/shader/shader_api.c1
-rw-r--r--src/mesa/shader/slang/slang_codegen.c1279
-rw-r--r--src/mesa/shader/slang/slang_codegen.h17
-rw-r--r--src/mesa/shader/slang/slang_compile.c3
-rw-r--r--src/mesa/shader/slang/slang_compile_operation.c68
-rw-r--r--src/mesa/shader/slang/slang_compile_operation.h62
-rw-r--r--src/mesa/shader/slang/slang_compile_variable.h1
-rw-r--r--src/mesa/shader/slang/slang_link.c21
-rw-r--r--src/mesa/shader/slang/slang_preprocess.c94
-rw-r--r--src/mesa/shader/slang/slang_print.c10
-rw-r--r--src/mesa/state_tracker/st_atom_shader.c57
-rw-r--r--src/mesa/state_tracker/st_cb_accum.c244
-rw-r--r--src/mesa/state_tracker/st_cb_bufferobjects.c5
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c18
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c30
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c147
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.h13
-rw-r--r--src/mesa/state_tracker/st_cb_readpixels.c13
-rw-r--r--src/mesa/state_tracker/st_context.c15
-rw-r--r--src/mesa/state_tracker/st_extensions.c5
-rw-r--r--src/mesa/state_tracker/st_format.c14
-rw-r--r--src/mesa/state_tracker/st_format.h4
-rw-r--r--src/mesa/state_tracker/st_framebuffer.c28
-rw-r--r--src/mesa/state_tracker/st_gen_mipmap.c3
-rw-r--r--src/mesa/state_tracker/st_program.c43
-rw-r--r--src/mesa/swrast/s_context.c1
-rw-r--r--src/mesa/swrast/s_texfilter.c2
-rw-r--r--src/mesa/vbo/vbo_attrib_tmp.h16
-rw-r--r--src/mesa/vbo/vbo_context.h2
-rw-r--r--src/mesa/vbo/vbo_exec_api.c36
-rw-r--r--src/mesa/vbo/vbo_exec_array.c4
225 files changed, 3571 insertions, 6723 deletions
diff --git a/Makefile b/Makefile
index 22334d6ee48..f7361d6198d 100644
--- a/Makefile
+++ b/Makefile
@@ -182,7 +182,7 @@ ultrix-gcc:
# Rules for making release tarballs
-VERSION=7.5-rc3
+VERSION=7.5-rc4
DIRECTORY = Mesa-$(VERSION)
LIB_NAME = MesaLib-$(VERSION)
DEMO_NAME = MesaDemos-$(VERSION)
diff --git a/bin/mklib b/bin/mklib
index 2fd95ba7751..24449450068 100755
--- a/bin/mklib
+++ b/bin/mklib
@@ -885,6 +885,17 @@ case $ARCH in
CYGWIN*)
# GCC-based environment
+ if [ $NOPREFIX = 1 ] ; then
+ # No "lib" or ".so" part
+ echo "mklib: Making CYGWIN shared library: " ${LIBNAME}
+ OPTS="-shared -Wl,--enable-auto-image-base"
+ if [ "${ALTOPTS}" ] ; then
+ OPTS=${ALTOPTS}
+ fi
+ rm -f ${LIBNAME}
+ ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
+ FINAL_LIBS=${LIBNAME}
+ else
CYGNAME="cyg${LIBNAME}" # prefix with "cyg"
LIBNAME="lib${LIBNAME}" # prefix with "lib"
@@ -901,11 +912,11 @@ case $ARCH in
# finish up
FINAL_LIBS=${LIBNAME}.a
else
- OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a"
+ OPTS="-shared -Wl,--enable-auto-image-base -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a"
if [ "${ALTOPTS}" ] ; then
OPTS=${ALTOPTS}
fi
- echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}-${MAJOR}.dll
+ echo "mklib: Making" $ARCH "shared library: " ${CYGNAME}-${MAJOR}.dll
if [ $CPLUSPLUS = 1 ] ; then
LINK="g++"
@@ -914,7 +925,8 @@ case $ARCH in
fi
# rm any old libs
- rm -f ${LIBNAME}-${MAJOR}.dll
+ rm -f ${CYGNAME}-${MAJOR}.dll
+ rm -f ${LIBNAME}-${MAJOR}.dll.a
rm -f ${LIBNAME}.dll.a
rm -f ${LIBNAME}.a
@@ -927,6 +939,7 @@ case $ARCH in
# special case for installing in bin
FINAL_BINS="${CYGNAME}-${MAJOR}.dll"
fi
+ fi
;;
'example')
diff --git a/configure.ac b/configure.ac
index 48b8022736d..2a9ac1ed9cd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -222,6 +222,8 @@ else
case "$host_os" in
darwin* )
LIB_EXTENSION='dylib' ;;
+ cygwin* )
+ LIB_EXTENSION='dll' ;;
* )
LIB_EXTENSION='so' ;;
esac
@@ -1073,6 +1075,9 @@ if test "x$APP_LIB_DEPS" = x; then
solaris*)
APP_LIB_DEPS="-lX11 -lsocket -lnsl -lm"
;;
+ cygwin*)
+ APP_LIB_DEPS="-lX11"
+ ;;
*)
APP_LIB_DEPS="-lm"
;;
diff --git a/docs/devinfo.html b/docs/devinfo.html
index 3cebf5f36db..0fb816749ed 100644
--- a/docs/devinfo.html
+++ b/docs/devinfo.html
@@ -123,20 +123,21 @@ These are the instructions for making a new Mesa release.
<H3>Get latest source files</H3>
<p>
-Use "cvs update -dAP " to get the latest Mesa files from CVS.
+Use git to get the latest Mesa files from the git repository, from whatever
+branch is relevant.
</p>
<H3>Verify and update version info</H3>
<p>
-Create/edit the docs/RELNOTES-X.Y file to document what's new in the release.
-Add the new RELNOTES-X.Y file to <a href="relnotes.html">relnotes.html</a>.
-Update the docs/VERSIONS file too.
+Create/edit the docs/relnotes-x.y.html file to document what's new in the release.
+Add the new relnotes-x.y.html file to <a href="relnotes.html">relnotes.html</a>.
</p>
<p>
-Edit the MESA_MAJOR, MESA_MINOR and MESA_TINY version numbers in
+Update the MESA_MAJOR, MESA_MINOR and MESA_TINY version numbers in
configs/default.
+Also update the VERSION line in the top-level Makefile.
</p>
<p>
@@ -144,27 +145,24 @@ Make sure the values in src/mesa/main/version.h are correct.
</p>
<p>
-Edit the top-level Makefile and verify that DIRECTORY, LIB_NAME and
-DEMO_NAME are correct.
-</p>
-
-<p>
Update the docs/news.html file and docs/download.html files.
</p>
<p>
-Check in all updates to CVS.
+Check in all updates to git.
</p>
<p>
-Tag the CVS files with the release name (in the form <b>mesa_X_Y</b>).
+Tag the files with the release name (in the form <b>mesa_X_Y</b>)
+with: <code>git tag -a mesa_X_Y</code>
+Then: <code>git push origin mesa_X_Y</code>
</p>
<H3>Make the tarballs</H3>
<p>
Make a symbolic link from $(DIRECTORY) to 'Mesa'. For example,
-ln -s Mesa Mesa-6.3
+<code>ln -s Mesa Mesa-7.5</code>
This is needed in order to make a correct tar file in the next step.
</p>
@@ -177,7 +175,7 @@ Make the distribution files. From inside the Mesa directory:
<p>
After the tarballs are created, the md5 checksums for the files will
be computed.
-Add them to the docs/news.html file.
+Add them to the docs/relnotes-X.Y.html file.
</p>
<p>
@@ -192,8 +190,20 @@ uploading the tarballs.
</p>
<p>
+Basically, to upload the tarball files with:
+<br>
+<code>
+rsync -avP ssh Mesa*-X.Y.* [email protected]:uploads/
+</code>
+</p>
+
+<p>
Update the web site by copying the docs/ directory's files to
-/home/users/b/br/brianp/mesa-www/htdocs/
+/home/users/b/br/brianp/mesa-www/htdocs/ with:
+<br>
+<code>
+sftp USERNAME,[email protected]
+</code>
</p>
<p>
diff --git a/docs/install.html b/docs/install.html
index be61ef30433..953d2094d5b 100644
--- a/docs/install.html
+++ b/docs/install.html
@@ -21,6 +21,7 @@
<li><a href="#pkg-config">Building OpenGL programs with pkg-config
</ul>
<li><a href="#windows">Windows</a>
+<li><a href="#scons">SCons</a>
<li><a href="#other">Other</a>
</ol>
<br>
@@ -328,13 +329,60 @@ For example, compiling and linking a GLUT application can be done with:
<H2>2. Windows Compilation and Installation</H1>
<p>
-Please see the <a href="README.WIN32">README.WIN32</a> file.
+Please see the <a href="#scons">instructions on building with SCons</a>.
+Alternatively see <a href="README.WIN32">README.WIN32</a> file.
</p>
+<a name="scons">
+<H2>3. Building with SCons</H1>
+
+<p>
+To build Mesa with SCons on Linux or Windows do
+</p>
+<pre>
+ scons
+</pre>
+<p>
+The build output will be placed in
+build/<i>platform</i>-<i>machine</i>-<i>debug</i>/..., where <i>platform</i> is for
+example linux or windows, <i>machine</i> is x86 or x86_64, optionally followed
+by -debug for debug builds.
+</p>
+
+<p>
+The sample programs are built seperately. To build them do
+<pre>
+ scons -C progs
+</pre>
+And the build output will be placed in progs/build/...
+</p>
+
+<p>
+To build Mesa with SCons for Windows on Linux using the MinGW crosscompiler toolchain do
+</p>
+<pre>
+ scons platform=windows toolchain=crossmingw machine=x86 statetrackers=mesa drivers=softpipe,trace winsys=gdi
+ scons -C progs platform=windows toolchain=crossmingw machine=x86 -k
+</pre>
+<p>
+This will create:
+</p>
+<ul>
+<li>build/windows-x86-debug/gallium/winsys/gdi/opengl32.dll &mdash; Mesa + Gallium + softpipe, binary compatible with Windows's opengl32.dll
+<li>build/windows-x86-debug/glut/glx/glut32.dll
+<li>progs/build/windows-x86-debug/wgl/wglinfo.exe
+<li>progs/build/windows-x86-debug/trivial/tri.exe
+<li>and many other samples in progs/build/windows-x86-debug/...
+</ul>
+<p>
+Put them all in the same directory to test them.
+</p>
+
+
<a name="other">
-<H2>3. Other systems</H1>
+<H2>4. Other systems</H1>
<p>
Documentation for other environments (some may be very out of date):
diff --git a/docs/news.html b/docs/news.html
index 8cf2f91dd03..ee4a86c2a21 100644
--- a/docs/news.html
+++ b/docs/news.html
@@ -11,6 +11,21 @@
<H1>News</H1>
+<h2>June 23, 2009</h2>
+<p>
+<a href="relnotes-7.4.4.html">Mesa 7.4.4</a> is released.
+This is a stable release that fixes a regression in the i915/i965 drivers
+that slipped into the 7.4.3 release.
+</p>
+
+
+<h2>June 19, 2009</h2>
+<p>
+<a href="relnotes-7.4.3.html">Mesa 7.4.3</a> is released.
+This is a stable release fixing bugs since the 7.4.2 release.
+</p>
+
+
<h2>May 15, 2009</h2>
<p>
<a href="relnotes-7.4.2.html">Mesa 7.4.2</a> is released.
diff --git a/docs/relnotes-7.4.3.html b/docs/relnotes-7.4.3.html
new file mode 100644
index 00000000000..35b5dccbb0a
--- /dev/null
+++ b/docs/relnotes-7.4.3.html
@@ -0,0 +1,79 @@
+<HTML>
+
+<TITLE>Mesa Release Notes</TITLE>
+
+<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<body bgcolor="#eeeeee">
+
+<H1>Mesa 7.4.3 Release Notes / 19 June 2009</H1>
+
+<p>
+Mesa 7.4.3 is a stable development release fixing bugs since the 7.4.2 release.
+</p>
+<p>
+Mesa 7.4.3 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>
+34c5a6c47ed51f31c4fa36e269831352 MesaLib-7.4.3.tar.gz
+70a983ba3deaa8bd63b18bbab283f698 MesaLib-7.4.3.tar.bz2
+34f21b3205b271d575030aa98a2dda51 MesaLib-7.4.3.zip
+56752b7adede212e6097afb10d0c0d59 MesaDemos-7.4.3.tar.gz
+8ffa51c4833b1e298300a005e2d7ca2a MesaDemos-7.4.3.tar.bz2
+0037d24d41400d6fb9800ae55b8c863f MesaDemos-7.4.3.zip
+20e24f6692c0c90e7e3b220f79c4108d MesaGLUT-7.4.3.tar.gz
+03a4beeef74fc5ef0b1d6d04710e5a8a MesaGLUT-7.4.3.tar.bz2
+273788230adbdb9d57371309adedcf5f MesaGLUT-7.4.3.zip
+</pre>
+
+
+<h2>Bug fixes</h2>
+<ul>
+<li>Fixed texture object reference counting bug (bug 21756)
+<li>Allow depth/stencil textures to be attached to GL_STENCIL_ATTACHMENT point
+ (SF bug 2793846)
+<li>Added missing glGet case for GL_VERTEX_ARRAY_BINDING_APPLE
+<li>Fixed some OSMesa build issues
+<li>Fixed a vertex buffer object crash
+<li>Fixed broken glTexImage3D() when image type = GL_BITMAP
+<li>Fixed some GLSL preprocessor bugs
+<li>Fixed framebuffer mem leak in i945/i965 DRI drivers
+<li>Fixed texture coordinate repeat bug in swrast (bug 21872)
+<li>Fixed incorrect viewport clamping (lower bound is zero, not one)
+<li>GLX fix for glean's makeCurrent test case
+</ul>
+
+
+
+<h2>Driver Status</h2>
+
+<pre>
+Driver Status
+---------------------- ----------------------
+DRI drivers varies with the driver
+XMesa/GLX (on Xlib) implements OpenGL 2.1
+OSMesa (off-screen) implements OpenGL 2.1
+Windows/Win32 implements OpenGL 2.1
+Glide (3dfx Voodoo1/2) implements OpenGL 1.3
+SVGA unsupported
+Wind River UGL unsupported
+DJGPP unsupported
+GGI unsupported
+BeOS unsupported
+Allegro unsupported
+D3D unsupported
+</pre>
+
+</body>
+</html>
diff --git a/docs/relnotes-7.4.4.html b/docs/relnotes-7.4.4.html
new file mode 100644
index 00000000000..2a34568a7e4
--- /dev/null
+++ b/docs/relnotes-7.4.4.html
@@ -0,0 +1,68 @@
+<HTML>
+
+<TITLE>Mesa Release Notes</TITLE>
+
+<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<body bgcolor="#eeeeee">
+
+<H1>Mesa 7.4.4 Release Notes / 23 June 2009</H1>
+
+<p>
+Mesa 7.4.4 is a stable development release fixing bugs since the 7.4.3 release.
+</p>
+<p>
+Mesa 7.4.4 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>
+0b56fe5a88ab0c3c5b2da5068f63f416 MesaLib-7.4.4.tar.gz
+b66528d314c574dccbe0ed963cac5e93 MesaLib-7.4.4.tar.bz2
+2818076f3ba23fa87fdfe4602a637a18 MesaLib-7.4.4.zip
+3e77b208386c47b18165bce5ae317e2c MesaDemos-7.4.4.tar.gz
+628142ec9a54cd28cc027e6ce26cff47 MesaDemos-7.4.4.tar.bz2
+d08a30d30ab7174859aa709cba6c726d MesaDemos-7.4.4.zip
+e6e91ba16e274d40cf3a97ad3218af01 MesaGLUT-7.4.4.tar.gz
+e14bbb52517e8121b31f1387515365ab MesaGLUT-7.4.4.tar.bz2
+f10ed20469753c2b3d68c99854f80fd4 MesaGLUT-7.4.4.zip
+</pre>
+
+
+<h2>Bug fixes</h2>
+<ul>
+<li>Fixed i965/i915 segfault in screen destruction (bug 22408)
+</ul>
+
+
+
+<h2>Driver Status</h2>
+
+<pre>
+Driver Status
+---------------------- ----------------------
+DRI drivers varies with the driver
+XMesa/GLX (on Xlib) implements OpenGL 2.1
+OSMesa (off-screen) implements OpenGL 2.1
+Windows/Win32 implements OpenGL 2.1
+Glide (3dfx Voodoo1/2) implements OpenGL 1.3
+SVGA unsupported
+Wind River UGL unsupported
+DJGPP unsupported
+GGI unsupported
+BeOS unsupported
+Allegro unsupported
+D3D unsupported
+</pre>
+
+</body>
+</html>
diff --git a/docs/relnotes-7.5.html b/docs/relnotes-7.5.html
index d47b21d827e..045692113df 100644
--- a/docs/relnotes-7.5.html
+++ b/docs/relnotes-7.5.html
@@ -68,12 +68,16 @@ including GL_ATI_separate_stencil, GL_EXT_stencil_two_side and OpenGL 2.0
<li>GL_EXT_texture_swizzle extension (software drivers, i965 driver)
<li>Updated SPARC assembly optimizations (David S. Miller)
<li>Initial support for separate compilation units in GLSL compiler.
+<li>Increased max number of generic GLSL varying variables to 16 (formerly 8).
+<li>GLSL linker now detects when too many varying variables are used.
</ul>
<h2>Bug fixes</h2>
<ul>
<li>Lots of i965 driver bug fixes
+<li>Fixed some GLSL preprocessor bugs
+<li>GLSL: continue inside of a for-loop didn't work
</ul>
diff --git a/docs/relnotes.html b/docs/relnotes.html
index 45746268af9..4764eb689d8 100644
--- a/docs/relnotes.html
+++ b/docs/relnotes.html
@@ -9,18 +9,13 @@
<H1>Release Notes</H1>
<p>
-Mesa uses an even/odd version number scheme like the Linux kernel.
-Odd numbered versions (such as 6.5) designate new developmental releases.
-Even numbered versions (such as 6.4) designate stable releases.
-</p>
-
-
-<p>
The release notes summarize what's new or changed in each Mesa release.
</p>
<UL>
<LI><A HREF="relnotes-7.5.html">7.5 release notes</A>
+<LI><A HREF="relnotes-7.4.4.html">7.4.4 release notes</A>
+<LI><A HREF="relnotes-7.4.3.html">7.4.3 release notes</A>
<LI><A HREF="relnotes-7.4.2.html">7.4.2 release notes</A>
<LI><A HREF="relnotes-7.4.1.html">7.4.1 release notes</A>
<LI><A HREF="relnotes-7.4.html">7.4 release notes</A>
diff --git a/include/GL/glew.h b/include/GL/glew.h
index 2014092e877..7932a1ce199 100644
--- a/include/GL/glew.h
+++ b/include/GL/glew.h
@@ -2702,7 +2702,7 @@ typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target);
typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint* framebuffers);
typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint* renderbuffers);
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
-typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURLAYERPROC) (GLenum target,GLenum attachment, GLuint texture,GLint level,GLint layer);
+typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target,GLenum attachment, GLuint texture,GLint level,GLint layer);
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer);
@@ -2723,7 +2723,7 @@ typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum targ
#define glDeleteFramebuffers GLEW_GET_FUN(__glewDeleteFramebuffers)
#define glDeleteRenderbuffers GLEW_GET_FUN(__glewDeleteRenderbuffers)
#define glFramebufferRenderbuffer GLEW_GET_FUN(__glewFramebufferRenderbuffer)
-#define glFramebufferTexturLayer GLEW_GET_FUN(__glewFramebufferTexturLayer)
+#define glFramebufferTextureLayer GLEW_GET_FUN(__glewFramebufferTextureLayer)
#define glFramebufferTexture1D GLEW_GET_FUN(__glewFramebufferTexture1D)
#define glFramebufferTexture2D GLEW_GET_FUN(__glewFramebufferTexture2D)
#define glFramebufferTexture3D GLEW_GET_FUN(__glewFramebufferTexture3D)
@@ -10563,7 +10563,7 @@ GLEW_FUN_EXPORT PFNGLCHECKFRAMEBUFFERSTATUSPROC __glewCheckFramebufferStatus;
GLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSPROC __glewDeleteFramebuffers;
GLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSPROC __glewDeleteRenderbuffers;
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFERPROC __glewFramebufferRenderbuffer;
-GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURLAYERPROC __glewFramebufferTexturLayer;
+GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYERPROC __glewFramebufferTextureLayer;
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DPROC __glewFramebufferTexture1D;
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DPROC __glewFramebufferTexture2D;
GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DPROC __glewFramebufferTexture3D;
diff --git a/progs/demos/Makefile b/progs/demos/Makefile
index c17595ec794..65fdbaaad8e 100644
--- a/progs/demos/Makefile
+++ b/progs/demos/Makefile
@@ -145,6 +145,13 @@ engine.o: engine.c trackball.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) engine.c
+fbotexture: fbotexture.o
+ $(APP_CC) $(CFLAGS) $(LDFLAGS) fbotexture.o $(LIBS) -o $@
+
+fbotexture.o: fbotexture.c extfuncs.h
+ $(APP_CC) -c -I$(INCDIR) $(CFLAGS) fbotexture.c
+
+
fslight: fslight.o
$(APP_CC) $(CFLAGS) $(LDFLAGS) fslight.o $(LIBS) -o $@
diff --git a/progs/demos/fbotexture.c b/progs/demos/fbotexture.c
index 50a4b00afce..3b36f755a04 100644
--- a/progs/demos/fbotexture.c
+++ b/progs/demos/fbotexture.c
@@ -9,13 +9,13 @@
*/
-#include <GL/glew.h>
#include <GL/glut.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
+#include "extfuncs.h"
/* For debug */
#define DEPTH 1
@@ -80,9 +80,9 @@ RenderTexture(void)
glTranslatef(0.0, 0.0, -15.0);
/* draw to texture image */
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
+ glBindFramebuffer_func(GL_FRAMEBUFFER_EXT, MyFB);
- status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+ status = glCheckFramebufferStatus_func(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
printf("Framebuffer incomplete!!!\n");
}
@@ -171,7 +171,7 @@ RenderTexture(void)
#if DRAW
/* Bind normal framebuffer */
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+ glBindFramebuffer_func(GL_FRAMEBUFFER_EXT, 0);
#endif
CheckError(__LINE__);
@@ -252,12 +252,12 @@ static void
CleanUp(void)
{
#if DEPTH
- glDeleteRenderbuffersEXT(1, &DepthRB);
+ glDeleteRenderbuffers_func(1, &DepthRB);
#endif
#if STENCIL
- glDeleteRenderbuffersEXT(1, &StencilRB);
+ glDeleteRenderbuffers_func(1, &StencilRB);
#endif
- glDeleteFramebuffersEXT(1, &MyFB);
+ glDeleteFramebuffers_func(1, &MyFB);
glDeleteTextures(1, &TexObj);
@@ -318,14 +318,14 @@ AttachDepthAndStencilBuffers(GLuint fbo,
*depthRbOut = *stencilRbOut = 0;
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
+ glBindFramebuffer_func(GL_FRAMEBUFFER_EXT, fbo);
if (tryDepthStencil) {
GLuint rb;
- glGenRenderbuffersEXT(1, &rb);
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);
- glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,
+ glGenRenderbuffers_func(1, &rb);
+ glBindRenderbuffer_func(GL_RENDERBUFFER_EXT, rb);
+ glRenderbufferStorage_func(GL_RENDERBUFFER_EXT,
GL_DEPTH24_STENCIL8_EXT,
width, height);
if (glGetError())
@@ -333,7 +333,7 @@ AttachDepthAndStencilBuffers(GLuint fbo,
if (bindDepthStencil) {
/* attach to both depth and stencil at once */
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
+ glFramebufferRenderbuffer_func(GL_FRAMEBUFFER_EXT,
GL_DEPTH_STENCIL_ATTACHMENT,
GL_RENDERBUFFER_EXT, rb);
if (glGetError())
@@ -341,21 +341,21 @@ AttachDepthAndStencilBuffers(GLuint fbo,
}
else {
/* attach to depth attachment point */
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
+ glFramebufferRenderbuffer_func(GL_FRAMEBUFFER_EXT,
GL_DEPTH_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, rb);
if (glGetError())
return GL_FALSE;
/* and attach to stencil attachment point */
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
+ glFramebufferRenderbuffer_func(GL_FRAMEBUFFER_EXT,
GL_STENCIL_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, rb);
if (glGetError())
return GL_FALSE;
}
- status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+ status = glCheckFramebufferStatus_func(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
return GL_FALSE;
@@ -367,22 +367,22 @@ AttachDepthAndStencilBuffers(GLuint fbo,
{
GLuint rb;
- glGenRenderbuffersEXT(1, &rb);
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);
- glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,
+ glGenRenderbuffers_func(1, &rb);
+ glBindRenderbuffer_func(GL_RENDERBUFFER_EXT, rb);
+ glRenderbufferStorage_func(GL_RENDERBUFFER_EXT,
GL_DEPTH_COMPONENT,
width, height);
if (glGetError())
return GL_FALSE;
/* attach to depth attachment point */
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
+ glFramebufferRenderbuffer_func(GL_FRAMEBUFFER_EXT,
GL_DEPTH_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, rb);
if (glGetError())
return GL_FALSE;
- status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+ status = glCheckFramebufferStatus_func(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
return GL_FALSE;
@@ -393,26 +393,26 @@ AttachDepthAndStencilBuffers(GLuint fbo,
{
GLuint rb;
- glGenRenderbuffersEXT(1, &rb);
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);
- glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,
+ glGenRenderbuffers_func(1, &rb);
+ glBindRenderbuffer_func(GL_RENDERBUFFER_EXT, rb);
+ glRenderbufferStorage_func(GL_RENDERBUFFER_EXT,
GL_STENCIL_INDEX,
width, height);
if (glGetError())
return GL_FALSE;
/* attach to depth attachment point */
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
+ glFramebufferRenderbuffer_func(GL_FRAMEBUFFER_EXT,
GL_STENCIL_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, rb);
if (glGetError())
return GL_FALSE;
- status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+ status = glCheckFramebufferStatus_func(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
- glDeleteRenderbuffersEXT(1, depthRbOut);
+ glDeleteRenderbuffers_func(1, depthRbOut);
*depthRbOut = 0;
- glDeleteRenderbuffersEXT(1, &rb);
+ glDeleteRenderbuffers_func(1, &rb);
return GL_FALSE;
}
@@ -463,6 +463,37 @@ ParseArgs(int argc, char *argv[])
}
+static void
+SetupFunctionPointers(void)
+{
+ GetExtensionFuncs();
+
+ if (Use_ARB_fbo) {
+ /* no-op: use the ARB functions as-is */
+ }
+ else {
+ /* set the ARB-flavor function pointers to point to the EXT functions */
+ glIsRenderbuffer_func = glIsRenderbufferEXT_func;
+ glBindRenderbuffer_func = glBindRenderbufferEXT_func;
+ glDeleteRenderbuffers_func = glDeleteRenderbuffersEXT_func;
+ glGenRenderbuffers_func = glGenRenderbuffersEXT_func;
+ glRenderbufferStorage_func = glRenderbufferStorageEXT_func;
+ glGetRenderbufferParameteriv_func = glGetRenderbufferParameterivEXT_func;
+ glIsFramebuffer_func = glIsFramebufferEXT_func;
+ glBindFramebuffer_func = glBindFramebufferEXT_func;
+ glDeleteFramebuffers_func = glDeleteFramebuffersEXT_func;
+ glGenFramebuffers_func = glGenFramebuffersEXT_func;
+ glCheckFramebufferStatus_func = glCheckFramebufferStatusEXT_func;
+ glFramebufferTexture1D_func = glFramebufferTexture1DEXT_func;
+ glFramebufferTexture2D_func = glFramebufferTexture2DEXT_func;
+ glFramebufferTexture3D_func = glFramebufferTexture3DEXT_func;
+ glFramebufferRenderbuffer_func = glFramebufferRenderbufferEXT_func;
+ glGetFramebufferAttachmentParameteriv_func = glGetFramebufferAttachmentParameterivEXT_func;
+ glGenerateMipmap_func = glGenerateMipmapEXT_func;
+ }
+}
+
+
/*
* Make FBO to render into given texture.
*/
@@ -472,10 +503,10 @@ MakeFBO_RenderTexture(GLuint TexObj)
GLuint fb;
GLint sizeFudge = 0;
- glGenFramebuffersEXT(1, &fb);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
+ glGenFramebuffers_func(1, &fb);
+ glBindFramebuffer_func(GL_FRAMEBUFFER_EXT, fb);
/* Render color to texture */
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+ glFramebufferTexture2D_func(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
TexTarget, TexObj, TextureLevel);
if (Use_ARB_fbo) {
@@ -512,26 +543,26 @@ MakeFBO_RenderTexture(GLuint TexObj)
{
GLint bits, w, h;
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, DepthRB);
- glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
+ glBindRenderbuffer_func(GL_RENDERBUFFER_EXT, DepthRB);
+ glGetRenderbufferParameteriv_func(GL_RENDERBUFFER_EXT,
GL_RENDERBUFFER_WIDTH_EXT, &w);
- glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
+ glGetRenderbufferParameteriv_func(GL_RENDERBUFFER_EXT,
GL_RENDERBUFFER_HEIGHT_EXT, &h);
printf("Color/Texture size: %d x %d\n", TexWidth, TexHeight);
printf("Depth buffer size: %d x %d\n", w, h);
- glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
+ glGetRenderbufferParameteriv_func(GL_RENDERBUFFER_EXT,
GL_RENDERBUFFER_DEPTH_SIZE_EXT, &bits);
printf("Depth renderbuffer size = %d bits\n", bits);
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, StencilRB);
- glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT,
+ glBindRenderbuffer_func(GL_RENDERBUFFER_EXT, StencilRB);
+ glGetRenderbufferParameteriv_func(GL_RENDERBUFFER_EXT,
GL_RENDERBUFFER_STENCIL_SIZE_EXT, &bits);
printf("Stencil renderbuffer size = %d bits\n", bits);
}
/* bind the regular framebuffer */
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+ glBindFramebuffer_func(GL_FRAMEBUFFER_EXT, 0);
return fb;
}
@@ -547,6 +578,8 @@ Init(void)
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ SetupFunctionPointers();
+
/* lighting */
{
static const GLfloat mat[4] = { 1.0, 0.5, 0.5, 1.0 };
@@ -605,7 +638,6 @@ main(int argc, char *argv[])
glutInitWindowSize(Width, Height);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
Win = glutCreateWindow(argv[0]);
- glewInit();
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
glutDisplayFunc(Display);
diff --git a/progs/demos/fslight.c b/progs/demos/fslight.c
index 41a13cc9f46..f0d76a4a06f 100644
--- a/progs/demos/fslight.c
+++ b/progs/demos/fslight.c
@@ -583,10 +583,14 @@ ParseOptions(int argc, char *argv[])
int i;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-fs") == 0) {
- FragProgFile = argv[i+1];
+ FragProgFile = argv[++i];
}
else if (strcmp(argv[i], "-vs") == 0) {
- VertProgFile = argv[i+1];
+ VertProgFile = argv[++i];
+ }
+ else {
+ fprintf(stderr, "unknown option %s\n", argv[i]);
+ break;
}
}
}
diff --git a/progs/fp/SConscript b/progs/fp/SConscript
deleted file mode 100644
index 553799758b0..00000000000
--- a/progs/fp/SConscript
+++ /dev/null
@@ -1,17 +0,0 @@
-Import('env')
-
-if not env['GLUT']:
- Return()
-
-env = env.Clone()
-
-env.Prepend(CPPPATH = [
- '../util',
-])
-
-env.Prepend(LIBS = ['$GLUT_LIB'])
-
-env.Program(
- target = 'fp-tri',
- source = ['fp-tri.c'],
- )
diff --git a/progs/fp/abs.txt b/progs/fp/abs.txt
deleted file mode 100644
index 61ef952b053..00000000000
--- a/progs/fp/abs.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-SUB R0, {0.5}.x, fragment.color;
-ABS result.color, R0;
-END
diff --git a/progs/fp/add-swz.txt b/progs/fp/add-swz.txt
deleted file mode 100644
index 5ec51bcb84a..00000000000
--- a/progs/fp/add-swz.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-ADD R0, fragment.color, fragment.color;
-ADD result.color, R0.xxxx, R0;
-END
diff --git a/progs/fp/add.txt b/progs/fp/add.txt
deleted file mode 100644
index 031076df0fc..00000000000
--- a/progs/fp/add.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-ADD R0, fragment.color, fragment.color;
-ADD result.color, R0, R0;
-END
diff --git a/progs/fp/cmp.txt b/progs/fp/cmp.txt
deleted file mode 100644
index 78451609a3f..00000000000
--- a/progs/fp/cmp.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-SUB R0, {0.5}.x, fragment.color;
-CMP result.color, R0, fragment.color, {0.0}.x;
-END
diff --git a/progs/fp/cos.txt b/progs/fp/cos.txt
deleted file mode 100644
index d51b13b63a7..00000000000
--- a/progs/fp/cos.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-MUL R0, fragment.color, {3.14}.x;
-COS result.color.x, R0.x;
-COS result.color.y, R0.y;
-COS result.color.z, R0.z;
-END
-
diff --git a/progs/fp/dp3.txt b/progs/fp/dp3.txt
deleted file mode 100644
index 75532f88a70..00000000000
--- a/progs/fp/dp3.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-DP3 result.color, fragment.color, fragment.color;
-END
diff --git a/progs/fp/dp4.txt b/progs/fp/dp4.txt
deleted file mode 100644
index 8d09c8dbf67..00000000000
--- a/progs/fp/dp4.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-DP4 result.color, fragment.color.xxxx, fragment.color;
-END
diff --git a/progs/fp/dph.txt b/progs/fp/dph.txt
deleted file mode 100644
index 6eb59a410d7..00000000000
--- a/progs/fp/dph.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-DPH result.color, fragment.color, fragment.color.xyzx;
-END
diff --git a/progs/fp/dst.txt b/progs/fp/dst.txt
deleted file mode 100644
index 6ebabbd5ea6..00000000000
--- a/progs/fp/dst.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-!!ARBfp1.0
-DST result.color, fragment.color, fragment.color;
-END
diff --git a/progs/fp/ex2.txt b/progs/fp/ex2.txt
deleted file mode 100644
index b540f7b1929..00000000000
--- a/progs/fp/ex2.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-EX2 R0, fragment.color.x;
-SUB result.color, R0, {1.0}.x;
-END
diff --git a/progs/fp/flr.txt b/progs/fp/flr.txt
deleted file mode 100644
index c3479c7bd5e..00000000000
--- a/progs/fp/flr.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-ADD R0, fragment.color, {0.5}.x;
-FLR result.color, R0;
-END
diff --git a/progs/fp/fp-tri.c b/progs/fp/fp-tri.c
deleted file mode 100644
index 6c15540d38d..00000000000
--- a/progs/fp/fp-tri.c
+++ /dev/null
@@ -1,256 +0,0 @@
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#ifndef WIN32
-#include <unistd.h>
-#include <signal.h>
-#endif
-
-#include <GL/glew.h>
-#include <GL/glut.h>
-
-#include "readtex.c"
-
-
-#define TEXTURE_FILE "../images/bw.rgb"
-
-unsigned show_fps = 0;
-unsigned int frame_cnt = 0;
-void alarmhandler(int);
-static const char *filename = NULL;
-
-static void usage(char *name)
-{
- fprintf(stderr, "usage: %s [ options ] shader_filename\n", name);
-#ifndef WIN32
- fprintf(stderr, "\n" );
- fprintf(stderr, "options:\n");
- fprintf(stderr, " -fps show frames per second\n");
-#endif
-}
-
-#ifndef WIN32
-void alarmhandler (int sig)
-{
- if (sig == SIGALRM) {
- printf("%d frames in 5.0 seconds = %.3f FPS\n", frame_cnt,
- frame_cnt / 5.0);
-
- frame_cnt = 0;
- }
- signal(SIGALRM, alarmhandler);
- alarm(5);
-}
-#endif
-
-static void args(int argc, char *argv[])
-{
- GLint i;
-
- for (i = 1; i < argc; i++) {
- if (strcmp(argv[i], "-fps") == 0) {
- show_fps = 1;
- }
- else if (i == argc - 1) {
- filename = argv[i];
- }
- else {
- usage(argv[0]);
- exit(1);
- }
- }
-
- if (!filename) {
- usage(argv[0]);
- exit(1);
- }
-}
-
-static void Init( void )
-{
- GLuint Texture;
- GLint errno;
- GLuint prognum;
- char buf[4096];
- GLuint sz;
- FILE *f;
-
- if ((f = fopen(filename, "r")) == NULL) {
- fprintf(stderr, "Couldn't open %s\n", filename);
- exit(1);
- }
-
- sz = fread(buf, 1, sizeof(buf), f);
- if (!feof(f)) {
- fprintf(stderr, "file too long\n");
- exit(1);
- }
- fprintf(stderr, "%.*s\n", sz, buf);
-
- if (!glutExtensionSupported("GL_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, &prognum);
- glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prognum);
- glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
- sz, (const GLubyte *)buf);
-
- errno = glGetError();
- printf("glGetError = 0x%x\n", errno);
- if (errno != GL_NO_ERROR) {
- GLint errorpos;
-
- glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
- printf("errorpos: %d\n", errorpos);
- printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
- (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
- }
- glEnable(GL_FRAGMENT_PROGRAM_ARB);
-
-
- /* Load texture */
- glGenTextures(1, &Texture);
- glBindTexture(GL_TEXTURE_2D, Texture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- if (!LoadRGBMipmaps(TEXTURE_FILE, GL_RGB)) {
- printf("Error: couldn't load texture image file %s\n", TEXTURE_FILE);
- exit(1);
- }
-
-
- glGenTextures(1, &Texture);
- glActiveTextureARB(GL_TEXTURE0_ARB + 1);
- glBindTexture(GL_TEXTURE_2D, Texture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-
- {
- GLubyte data[32][32];
- int width = 32;
- int height = 32;
- int i;
- int j;
-
- for (i = 0; i < 32; i++)
- for (j = 0; j < 32; j++)
- {
- /**
- ** +-----------+
- ** | W |
- ** | +-----+ |
- ** | | | |
- ** | | B | |
- ** | | | |
- ** | +-----+ |
- ** | |
- ** +-----------+
- **/
- int i2 = i - height / 2;
- int j2 = j - width / 2;
- int h8 = height / 8;
- int w8 = width / 8;
- if ( -h8 <= i2 && i2 <= h8 && -w8 <= j2 && j2 <= w8 ) {
- data[i][j] = 0x00;
- } else if ( -2 * h8 <= i2 && i2 <= 2 * h8 && -2 * w8 <= j2 && j2 <= 2 * w8 ) {
- data[i][j] = 0x55;
- } else if ( -3 * h8 <= i2 && i2 <= 3 * h8 && -3 * w8 <= j2 && j2 <= 3 * w8 ) {
- data[i][j] = 0xaa;
- } else {
- data[i][j] = 0xff;
- }
- }
-
- glTexImage2D( GL_TEXTURE_2D, 0,
- GL_ALPHA8,
- 32, 32, 0,
- GL_ALPHA, GL_UNSIGNED_BYTE, data );
- }
-
-
- glClearColor(.1, .3, .5, 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:
- return;
- }
-
- glutPostRedisplay();
-}
-
-static void Display(void)
-{
- glClear(GL_COLOR_BUFFER_BIT);
-
- glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, 1.0, 1.0, 0.0, 0.0);
- glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, 0.0, 0.0, 1.0, 1.0);
- glBegin(GL_TRIANGLES);
-
- glColor3f(0,0,1);
- glTexCoord3f(1,1,0);
- glVertex3f( 0.9, -0.9, -30.0);
-
- glColor3f(1,0,0);
- glTexCoord3f(1,-1,0);
- glVertex3f( 0.9, 0.9, -30.0);
-
- glColor3f(0,1,0);
- glTexCoord3f(-1,0,0);
- glVertex3f(-0.9, 0.0, -30.0);
- glEnd();
-
- glFlush();
- if (show_fps) {
- ++frame_cnt;
- glutPostRedisplay();
- }
-}
-
-
-int main(int argc, char **argv)
-{
- glutInit(&argc, argv);
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(250, 250);
- glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH);
- args(argc, argv);
- glutCreateWindow(filename);
- glewInit();
- glutReshapeFunc(Reshape);
- glutKeyboardFunc(Key);
- glutDisplayFunc(Display);
- Init();
-#ifndef WIN32
- if (show_fps) {
- signal(SIGALRM, alarmhandler);
- alarm(5);
- }
-#endif
- glutMainLoop();
- return 0;
-}
diff --git a/progs/fp/frc.txt b/progs/fp/frc.txt
deleted file mode 100644
index efacaa8f927..00000000000
--- a/progs/fp/frc.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-MUL R0, fragment.color, {3.0}.x;
-FRC result.color, R0;
-END
diff --git a/progs/fp/kil-pos.txt b/progs/fp/kil-pos.txt
deleted file mode 100644
index 5ff4f6f2c84..00000000000
--- a/progs/fp/kil-pos.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-SUB R0.xy, fragment.position, {125}.x;
-MOV R0.zw, {0}.x;
-DP3 R0, R0, R0;
-SUB R0.x, R0, {10000}.x;
-KIL -R0.x;
-MOV result.color, fragment.color;
-END
diff --git a/progs/fp/kil-texcoord-sgt.txt b/progs/fp/kil-texcoord-sgt.txt
deleted file mode 100644
index c74fd10dacb..00000000000
--- a/progs/fp/kil-texcoord-sgt.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-MUL R0.xy, fragment.texcoord[0], fragment.texcoord[0];
-ADD R0.x, R0.x, R0.y;
-SGE R0.y, R0.x, fragment.texcoord[0].w;
-KIL -R0.y;
-MOV result.color, fragment.color;
-END
diff --git a/progs/fp/kil.txt b/progs/fp/kil.txt
deleted file mode 100644
index d95deb0a9e9..00000000000
--- a/progs/fp/kil.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-SUB R0, fragment.color, {0.5,0,0,0};
-KIL R0;
-MOV result.color, R0;
-END
diff --git a/progs/fp/lg2.txt b/progs/fp/lg2.txt
deleted file mode 100644
index 6707d7cb6d5..00000000000
--- a/progs/fp/lg2.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-MUL R0, fragment.color, {4.0}.x;
-LG2 result.color, R0.x;
-END
diff --git a/progs/fp/lit.txt b/progs/fp/lit.txt
deleted file mode 100644
index 333c50d3cca..00000000000
--- a/progs/fp/lit.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-SUB R0, {0.5}.x, fragment.color;
-LIT result.color, R0;
-END
diff --git a/progs/fp/local.txt b/progs/fp/local.txt
deleted file mode 100644
index 6cb2a2f13cc..00000000000
--- a/progs/fp/local.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-PARAM c[4] = { { 0, 0, 0, 0 },
- program.local[0..1],
- { 1, 1, 1, 1 } };
-MOV R0, c[1];
-SUB R0, R0, c[0];
-ADD R0, R0, c[2];
-MUL R0, R0, c[3];
-MOV result.color, R0;
-END
diff --git a/progs/fp/lrp.txt b/progs/fp/lrp.txt
deleted file mode 100644
index 56cb5f51528..00000000000
--- a/progs/fp/lrp.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-!!ARBfp1.0
-TEMP R0, R1;
-LRP result.color, fragment.color.z, {1,0,0,1}, {0,1,0,1};
-END
diff --git a/progs/fp/mad.txt b/progs/fp/mad.txt
deleted file mode 100644
index 77ffac49cf1..00000000000
--- a/progs/fp/mad.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-!!ARBfp1.0
-TEMP R0, R1;
-MAD result.color, fragment.color.z, {1,0,0,1}, fragment.color;
-END
diff --git a/progs/fp/max.txt b/progs/fp/max.txt
deleted file mode 100644
index 0f3bffd6a50..00000000000
--- a/progs/fp/max.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-!!ARBfp1.0
-MAX result.color, {0.5}.x, fragment.color;
-END
diff --git a/progs/fp/min.txt b/progs/fp/min.txt
deleted file mode 100644
index 06d8f911c37..00000000000
--- a/progs/fp/min.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-!!ARBfp1.0
-MIN result.color, {0.5}.x, fragment.color;
-END
diff --git a/progs/fp/mov.txt b/progs/fp/mov.txt
deleted file mode 100644
index 4c67baec5e5..00000000000
--- a/progs/fp/mov.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-!!ARBfp1.0
-MOV result.color, fragment.color;
-END
diff --git a/progs/fp/mul-swz.txt b/progs/fp/mul-swz.txt
deleted file mode 100644
index 7ef2f58633f..00000000000
--- a/progs/fp/mul-swz.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-!!ARBfp1.0
-MUL result.color, fragment.color.zyxw, fragment.color;
-END
diff --git a/progs/fp/mul.txt b/progs/fp/mul.txt
deleted file mode 100644
index 907155de783..00000000000
--- a/progs/fp/mul.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-!!ARBfp1.0
-MUL result.color, fragment.color, fragment.color;
-END
diff --git a/progs/fp/negate.txt b/progs/fp/negate.txt
deleted file mode 100644
index 3d00a04a587..00000000000
--- a/progs/fp/negate.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-!!ARBfp1.0
-# this should result in fragment color passing through unchanged
-TEMP R0;
-ADD R0, fragment.color, fragment.color;
-ADD result.color, R0, -fragment.color;
-END
diff --git a/progs/fp/position.txt b/progs/fp/position.txt
deleted file mode 100644
index 1875897d781..00000000000
--- a/progs/fp/position.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-!!ARBfp1.0
-MOV result.color, {0}.x;
-MUL result.color.xy, fragment.position, {.005}.x;
-END
diff --git a/progs/fp/pow.txt b/progs/fp/pow.txt
deleted file mode 100644
index 35c738556ea..00000000000
--- a/progs/fp/pow.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-POW result.color, fragment.color.x, fragment.color.y;
-END
diff --git a/progs/fp/rcp.txt b/progs/fp/rcp.txt
deleted file mode 100644
index 122161c49e5..00000000000
--- a/progs/fp/rcp.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-ADD R0, fragment.color.x, fragment.color.x;
-RCP result.color, R0.x;
-END
diff --git a/progs/fp/rsq.txt b/progs/fp/rsq.txt
deleted file mode 100644
index b28de4bdb6c..00000000000
--- a/progs/fp/rsq.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-MUL R0, fragment.color, {3.0}.x;
-RSQ result.color, R0.x;
-END
diff --git a/progs/fp/run.sh b/progs/fp/run.sh
deleted file mode 100755
index 480f8108a35..00000000000
--- a/progs/fp/run.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-for i in *.txt ; do
-echo $i
-./fp-tri $i
-done
-
diff --git a/progs/fp/scs.txt b/progs/fp/scs.txt
deleted file mode 100644
index 5a8c9f16e9e..00000000000
--- a/progs/fp/scs.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-MUL R0, fragment.color, {3.14}.x;
-SCS result.color, R0.x;
-END
diff --git a/progs/fp/sge.txt b/progs/fp/sge.txt
deleted file mode 100644
index 53856924676..00000000000
--- a/progs/fp/sge.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-!!ARBfp1.0
-SGE result.color, {0.5}.x, fragment.color;
-END
diff --git a/progs/fp/sge2.txt b/progs/fp/sge2.txt
deleted file mode 100644
index e02a50d4772..00000000000
--- a/progs/fp/sge2.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-TEMP R1;
-SGE R0, fragment.color, fragment.color.yzxw;
-SGE R1, fragment.color, fragment.color.zxyw;
-MUL R0, R0, R1;
-MUL result.color, R0, fragment.color;
-END
diff --git a/progs/fp/sin.txt b/progs/fp/sin.txt
deleted file mode 100644
index 4a8cdb69f98..00000000000
--- a/progs/fp/sin.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-MUL R0, fragment.color, {3.14}.x;
-MOV result.color, {0.0}.x;
-SIN result.color.x, R0.x;
-SIN result.color.y, R0.y;
-SIN result.color.z, R0.z;
-END
diff --git a/progs/fp/slt.txt b/progs/fp/slt.txt
deleted file mode 100644
index a3b3ff5656a..00000000000
--- a/progs/fp/slt.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-!!ARBfp1.0
-SLT result.color, {0.5}.x, fragment.color;
-END
diff --git a/progs/fp/sub.txt b/progs/fp/sub.txt
deleted file mode 100644
index b4e5cc0e9f8..00000000000
--- a/progs/fp/sub.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-!!ARBfp1.0
-SUB result.color, fragment.color.yzxw, fragment.color;
-END
diff --git a/progs/fp/swz.txt b/progs/fp/swz.txt
deleted file mode 100644
index e28f112b14e..00000000000
--- a/progs/fp/swz.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-!!ARBfp1.0
-SWZ result.color, fragment.color, 1,x,y,z;
-END
diff --git a/progs/fp/swz2.txt b/progs/fp/swz2.txt
deleted file mode 100644
index 5c12b848154..00000000000
--- a/progs/fp/swz2.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-!!ARBfp1.0
-TEMP R0, R1;
-SWZ result.color, fragment.color, 1, 0, 0, 1;
-END
diff --git a/progs/fp/swz3.txt b/progs/fp/swz3.txt
deleted file mode 100644
index 382f5880d3c..00000000000
--- a/progs/fp/swz3.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-!!ARBfp1.0
-TEMP R0, R1;
-MOV R0, -fragment.color;
-SWZ result.color, R0, -y, -x, z, 1;
-END
diff --git a/progs/fp/tex-pos-kil-1.txt b/progs/fp/tex-pos-kil-1.txt
deleted file mode 100644
index 3f01e79ffe7..00000000000
--- a/progs/fp/tex-pos-kil-1.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-MUL R0, fragment.position, {0.03125}.x;
-TEX R0, R0, texture[1], 2D;
-KIL -R0;
-MOV result.color, fragment.color;
-END
diff --git a/progs/fp/tex-pos-kil.txt b/progs/fp/tex-pos-kil.txt
deleted file mode 100644
index b7aaa9f7c88..00000000000
--- a/progs/fp/tex-pos-kil.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-MUL R0, fragment.position, {0.008}.x;
-TEX R0, R0, texture[0], 2D;
-SUB R0, R0, {0.25}.x;
-KIL R0.xyzz;
-MOV result.color, fragment.color;
-END
diff --git a/progs/fp/tex-pos.txt b/progs/fp/tex-pos.txt
deleted file mode 100644
index b969f423f57..00000000000
--- a/progs/fp/tex-pos.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-!!ARBfp1.0
-TEMP R0;
-MOV R0, {0.0}.x;
-MUL R0.xy, fragment.position, {0.008}.x;
-TEX result.color, R0, texture[0], 2D;
-END
diff --git a/progs/fp/tex.txt b/progs/fp/tex.txt
deleted file mode 100644
index b3a885d9e07..00000000000
--- a/progs/fp/tex.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-!!ARBfp1.0
-TEX result.color, fragment.color, texture[0], 2D;
-END
diff --git a/progs/fp/xpd.txt b/progs/fp/xpd.txt
deleted file mode 100644
index d8dc08dcf7f..00000000000
--- a/progs/fp/xpd.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-!!ARBfp1.0
-XPD result.color, fragment.color, {2,2,2,0};
-END
diff --git a/progs/tests/SConscript b/progs/tests/SConscript
deleted file mode 100644
index 453fcecd9c1..00000000000
--- a/progs/tests/SConscript
+++ /dev/null
@@ -1,137 +0,0 @@
-Import('*')
-
-if not env['GLUT']:
- Return()
-
-env = env.Clone()
-
-env.Prepend(CPPPATH = [
- '../util',
-])
-
-env.Prepend(LIBS = [
- util,
- '$GLUT_LIB'
-])
-
-if env['platform'] == 'windows':
- env.Append(CPPDEFINES = ['NOMINMAX'])
- env.Prepend(LIBS = ['winmm'])
-
-linux_progs = [
- 'api_speed',
-]
-
-glx_progs = [
- 'auxbuffer',
- 'getprocaddress',
- 'jkrahntest',
- 'sharedtex',
- 'texcompress2',
- 'texobjshare',
-]
-
-mesa_progs = [
- 'debugger',
-]
-
-progs = [
- 'afsmultiarb',
- 'antialias',
- 'arbfpspec',
- 'arbfptest1',
- 'arbfptexture',
- 'arbfptrig',
- 'arbnpot',
- 'arbnpot-mipmap',
- 'arbvptest1',
- 'arbvptest3',
- 'arbvptorus',
- 'arbvpwarpmesh',
- 'arraytexture',
- 'blendminmax',
- 'blendsquare',
- 'blendxor',
- 'bufferobj',
- 'bug_3050',
- 'bug_3101',
- 'bug_3195',
- 'bug_texstore_i8',
- 'calibrate_rast',
- 'copypixrate',
- 'crossbar',
- 'cva',
- 'drawbuffers',
- 'exactrast',
- 'ext422square',
- 'fbotest1',
- 'fbotest2',
- 'fillrate',
- 'floattex',
- 'fog',
- 'fogcoord',
- 'fptest1',
- 'fptexture',
- 'glutfx',
- 'interleave',
- 'invert',
- 'lineclip',
- 'manytex',
- 'mapbufrange',
- 'mapvbo',
- 'minmag',
- 'mipgen',
- 'mipmap_comp',
- 'mipmap_limits',
- 'mipmap_view',
- 'multipal',
- 'multitexarray',
- 'multiwindow',
- 'no_s3tc',
- 'packedpixels',
- 'pbo',
- 'prog_parameter',
- 'quads',
- 'random',
- 'readrate',
- 'rubberband',
- 'seccolor',
- 'shader_api',
- 'stencil_twoside',
- 'stencil_wrap',
- 'stencilwrap',
- 'streaming_rect',
- 'subtex',
- 'subtexrate',
- 'tex1d',
- 'texcmp',
- 'texcompress2',
- 'texdown',
- 'texfilt',
- 'texgenmix',
- 'texline',
- 'texobj',
- 'texrect',
- 'texwrap',
- 'unfilledclip',
- 'vao-01',
- 'vao-02',
- 'vparray',
- 'vpeval',
- 'vptest1',
- 'vptest2',
- 'vptest3',
- 'vptorus',
- 'vpwarpmesh',
- 'yuvrect',
- 'yuvsquare',
- 'zcomp',
- 'zdrawpix',
- 'zreaddraw',
-]
-
-for prog in progs:
- env.Program(
- target = prog,
- source = prog + '.c',
- )
diff --git a/progs/tests/bug_texstore_i8.c b/progs/tests/bug_texstore_i8.c
deleted file mode 100644
index 10e5eba7c5e..00000000000
--- a/progs/tests/bug_texstore_i8.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that (i) the above copyright notices and this permission notice appear in
- * all copies of the software and related documentation, and (ii) the name of
- * Silicon Graphics may not be used in any advertising or
- * publicity relating to the software without the specific, prior written
- * permission of Silicon Graphics.
- *
- * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
- * ANY KIND,
- * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
- * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
- *
- * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
- * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
- * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
- * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-/*
- * Based on the trivial/quad-tex-2d program.
- * Modified by Jakob Bornecrantz <[email protected]>
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <GL/glew.h>
-#include <GL/glut.h>
-
-static GLenum Target = GL_TEXTURE_2D;
-static GLenum Filter = GL_NEAREST;
-GLenum doubleBuffer;
-static float Rot = 0;
-static int win = 0;
-
-static void Init(void)
-{
- int internalFormat;
- int sourceFormat;
-
- fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
- fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
- fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
-
- glClearColor(0.0, 0.0, 1.0, 0.0);
-
-#define SIZE 16
- {
- GLubyte tex2d[SIZE][SIZE][4];
- GLint s, t;
-
- for (s = 0; s < SIZE; s++) {
- for (t = 0; t < SIZE; t++) {
- tex2d[t][s][0] = 0xff;
- tex2d[t][s][1] = 0xff;
- tex2d[t][s][2] = 0xff;
- tex2d[t][s][3] = 0xff;
- }
- }
-
- internalFormat = GL_LUMINANCE8;
- sourceFormat = GL_RGBA;
-
- glTexImage2D(Target,
- 0,
- internalFormat,
- SIZE, SIZE,
- 0,
- sourceFormat,
- GL_UNSIGNED_BYTE,
- //GL_UNSIGNED_INT,
- tex2d);
-
- glEnable(Target);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
- glTexParameterf(Target, GL_TEXTURE_WRAP_R, GL_REPEAT);
- glTexParameterf(Target, GL_TEXTURE_MIN_FILTER, Filter);
- glTexParameterf(Target, GL_TEXTURE_MAG_FILTER, Filter);
- }
-}
-
-static void Reshape(int width, int height)
-{
- glViewport(0, 0, (GLint)width, (GLint)height);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
-#if 0
- glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
-#else
- glFrustum(-1, 1, -1, 1, 10, 20);
-#endif
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glTranslatef(0, 0, -15);
-}
-
-static void Key(unsigned char key, int x, int y)
-{
- switch (key) {
- case 'r':
- Rot += 10.0;
- break;
- case 'R':
- Rot -= 10.0;
- break;
- case 27:
- glutDestroyWindow(win);
- exit(0);
- default:
- return;
- }
- glutPostRedisplay();
-}
-
-static void Draw(void)
-{
- glClear(GL_COLOR_BUFFER_BIT);
-
- glPushMatrix();
- glRotatef(Rot, 0, 1, 0);
-
- glBegin(GL_QUADS);
- glTexCoord2f(1,0);
- glVertex3f( 0.9, -0.9, 0.0);
- glTexCoord2f(1,1);
- glVertex3f( 0.9, 0.9, 0.0);
- glTexCoord2f(0,1);
- glVertex3f(-0.9, 0.9, 0.0);
- glTexCoord2f(0,0);
- glVertex3f(-0.9, -0.9, 0.0);
- glEnd();
-
- glPopMatrix();
-
- glFlush();
-
- if (doubleBuffer) {
- glutSwapBuffers();
- }
-}
-
-static GLenum Args(int argc, char **argv)
-{
- GLint i;
-
- doubleBuffer = GL_FALSE;
-
- for (i = 1; i < argc; i++) {
- if (strcmp(argv[i], "-sb") == 0) {
- doubleBuffer = GL_FALSE;
- } else if (strcmp(argv[i], "-db") == 0) {
- doubleBuffer = GL_TRUE;
- } else {
- fprintf(stderr, "%s (Bad option).\n", argv[i]);
- return GL_FALSE;
- }
- }
- return GL_TRUE;
-}
-
-int main(int argc, char **argv)
-{
- GLenum type;
-
- glutInit(&argc, argv);
-
- if (Args(argc, argv) == GL_FALSE) {
- exit(1);
- }
-
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(250, 250);
-
- type = GLUT_RGB;
- type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
- glutInitDisplayMode(type);
-
- win = glutCreateWindow("Tex test");
- glewInit();
- if (!win) {
- exit(1);
- }
-
- Init();
-
- glutReshapeFunc(Reshape);
- glutKeyboardFunc(Key);
- glutDisplayFunc(Draw);
- glutMainLoop();
- return 0;
-}
diff --git a/progs/tests/bumpmap.c b/progs/tests/bumpmap.c
deleted file mode 100644
index 1b7ec2c135c..00000000000
--- a/progs/tests/bumpmap.c
+++ /dev/null
@@ -1,208 +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
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * Simple test for testing ATI_envmap_bumpmap support.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <GL/glut.h>
-
-#include "readtex.h"
-
-static PFNGLGETTEXBUMPPARAMETERFVATIPROC glGetTexBumpParameterfvATI_func = NULL;
-static PFNGLGETTEXBUMPPARAMETERIVATIPROC glGetTexBumpParameterivATI_func = NULL;
-static PFNGLTEXBUMPPARAMETERFVATIPROC glTexBumpParameterfvATI_func = NULL;
-
-static const char *TexFile = "../images/arch.rgb";
-
-static const GLfloat Near = 5.0, Far = 25.0;
-
-static void Display( void )
-{
- /* together with the construction of dudv map, do fixed translation
- in y direction (up), some cosine deformation in x and more
- deformation in y dir */
- GLfloat bumpMatrix[4] = {0.1, 0.0, 0.2, 0.1};
-
-
- glClearColor(0.2, 0.2, 0.8, 0);
- glClear( GL_COLOR_BUFFER_BIT );
-
- glPushMatrix();
-
- /* this is the base map */
- glActiveTexture( GL_TEXTURE0 );
- glEnable( GL_TEXTURE_2D );
- glBindTexture( GL_TEXTURE_2D, 1 );
- glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE );
- glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE );
- glTexEnvf( GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE );
-
- /* bump map */
- glActiveTexture( GL_TEXTURE1 );
- glEnable( GL_TEXTURE_2D );
- glBindTexture( GL_TEXTURE_2D, 2 );
- glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE );
- glTexEnvf( GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_BUMP_ENVMAP_ATI );
- glTexEnvf( GL_TEXTURE_ENV, GL_BUMP_TARGET_ATI, GL_TEXTURE0);
-
- glTexBumpParameterfvATI_func(GL_BUMP_ROT_MATRIX_ATI, bumpMatrix);
-
- glCallList(1);
-
- glPopMatrix();
-
- glutSwapBuffers();
-}
-
-
-static void Reshape( int width, int height )
-{
- GLfloat ar = (float) width / (float) height;
- glViewport( 0, 0, width, height );
- glMatrixMode( GL_PROJECTION );
- glLoadIdentity();
- glFrustum( -ar, ar, -1.0, 1.0, Near, Far );
- glMatrixMode( GL_MODELVIEW );
- glLoadIdentity();
- glTranslatef( 0.0, 0.0, -6.0 );
-}
-
-
-static void Key( unsigned char key, int x, int y )
-{
- (void) x;
- (void) y;
- switch (key) {
- case 27:
- exit(0);
- break;
- }
- glutPostRedisplay();
-}
-
-
-static void Init( void )
-{
- const char * const ver_string = (const char * const)
- glGetString( GL_VERSION );
- GLfloat temp[16][16][2];
- GLubyte *image = NULL;
- GLint imgWidth, imgHeight;
- GLenum imgFormat;
- GLint i,j;
- GLint param, paramArray[16];
- GLfloat paramMat[4];
-
- printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
- printf("GL_VERSION = %s\n", ver_string);
-
- if ( !glutExtensionSupported("GL_ATI_envmap_bumpmap")) {
- printf("\nSorry, this program requires GL_ATI_envmap_bumpmap\n");
- exit(1);
- }
-
- glGetTexBumpParameterfvATI_func = glutGetProcAddress("glGetTexBumpParameterfvATI");
- glGetTexBumpParameterivATI_func = glutGetProcAddress("glGetTexBumpParameterivATI");
- glTexBumpParameterfvATI_func = glutGetProcAddress("glTexBumpParameterfvATI");
-
- glGetTexBumpParameterivATI_func(GL_BUMP_ROT_MATRIX_SIZE_ATI, &param);
- printf("BUMP_ROT_MATRIX_SIZE_ATI = %d\n", param);
- glGetTexBumpParameterivATI_func(GL_BUMP_NUM_TEX_UNITS_ATI, &param);
- printf("BUMP_NUM_TEX_UNITS_ATI = %d\n", param);
- glGetTexBumpParameterfvATI_func(GL_BUMP_ROT_MATRIX_ATI, paramMat);
- printf("initial rot matrix %f %f %f %f\n", paramMat[0], paramMat[1], paramMat[2], paramMat[3]);
- glGetTexBumpParameterivATI_func(GL_BUMP_TEX_UNITS_ATI, paramArray);
- printf("units supporting bump mapping: ");
- for (i = 0; i < param; i++)
- printf("%d ", paramArray[i] - GL_TEXTURE0);
- printf("\n");
-
- image = LoadRGBImage(TexFile, &imgWidth, &imgHeight, &imgFormat);
- if (!image) {
- printf("Couldn't read %s\n", TexFile);
- exit(0);
- }
-
- glBindTexture( GL_TEXTURE_2D, 1 );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
- glTexImage2D( GL_TEXTURE_2D, 0, imgFormat, imgWidth, imgHeight, 0,
- imgFormat, GL_UNSIGNED_BYTE, image );
-
- for (j = 0; j < 16; j++) {
- for (i = 0; i < 16; i++) {
- temp[j][i][0] = cos((float)(i) * 3.1415 / 16.0);
- temp[j][i][1] = -0.5;
- }
- }
- glBindTexture( GL_TEXTURE_2D, 2 );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
- glTexImage2D( GL_TEXTURE_2D, 0, GL_DU8DV8_ATI, 16, 16, 0,
- GL_DUDV_ATI, GL_FLOAT, temp );
-
-
- glNewList( 1, GL_COMPILE );
- glBegin(GL_QUADS);
- glColor3f( 0.9, 0.0, 0.0 );
- glMultiTexCoord2f( GL_TEXTURE0, 0.0, 0.0 );
- glMultiTexCoord2f( GL_TEXTURE1, 0.0, 0.0 );
- glVertex2f(-1, -1);
- glMultiTexCoord2f( GL_TEXTURE0, 1.0, 0.0 );
- glMultiTexCoord2f( GL_TEXTURE1, 1.0, 0.0 );
- glVertex2f( 1, -1);
- glMultiTexCoord2f( GL_TEXTURE0, 1.0, 1.0 );
- glMultiTexCoord2f( GL_TEXTURE1, 1.0, 1.0 );
- glVertex2f( 1, 1);
- glMultiTexCoord2f( GL_TEXTURE0, 0.0, 1.0 );
- glMultiTexCoord2f( GL_TEXTURE1, 0.0, 1.0 );
- glVertex2f(-1, 1);
- glEnd();
- glEndList();
-}
-
-
-int main( int argc, char *argv[] )
-{
- glutInit( &argc, argv );
- glutInitWindowPosition( 0, 0 );
- glutInitWindowSize( 400, 400 );
- glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
- glutCreateWindow( "GL_ATI_envmap_bumpmap test" );
- glutReshapeFunc( Reshape );
- glutKeyboardFunc( Key );
- glutDisplayFunc( Display );
- Init();
- glutMainLoop();
- return 0;
-}
diff --git a/progs/tests/calibrate_rast.c b/progs/tests/calibrate_rast.c
deleted file mode 100644
index 5d89ff79c55..00000000000
--- a/progs/tests/calibrate_rast.c
+++ /dev/null
@@ -1,397 +0,0 @@
-/*
- * Automatic primitive rasterization precision test.
- *
- * Draw prims at various sub-pixel offsets and examine where the quad is
- * actually drawn.
- * Check if the range of offsets which paint the right pixels falls within
- * OpenGL's specification.
- * In case of failures, report the coordinate bias needed to fix the problem.
- *
- * Note that even Mesa/swrast fails some line tests. This is because some
- * window coordinates wind up as 53.9999 instead of 54, for example. Enabling
- * the small translation factor below fixes that. Revisit someday...
- *
- * Brian Paul
- * 28 Feb 2008
- */
-
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <GL/glew.h>
-#include <GL/glut.h>
-
-
-static int Width = 100, Height = 100;
-static int Win;
-static float Step = 0.125;
-#if 0
-/* This tiny offset fixes errors in Mesa/Xlib */
-static float Xtrans = 0.5 * 0.125;
-static float Ytrans = 0.5 * 0.125;
-#else
-static float Xtrans = 0.0;
-static float Ytrans = 0.0;
-#endif
-
-
-static void
-PointCalibrate(int xpos, int ypos)
-{
- GLfloat rgba[4];
- float x, y;
- float xmin, ymin, xmax, ymax;
-
- xmin = ymin = 1000.0;
- xmax = ymax = -1000.0;
-
- for (y = -1.0; y <= 1.0; y += Step) {
- for (x = -1.0; x <= 1.0; x += Step) {
- glClear(GL_COLOR_BUFFER_BIT);
- glBegin(GL_POINTS);
- glVertex2f(xpos + x, ypos + y);
- glEnd();
- glReadPixels(xpos, ypos, 1, 1, GL_RGBA, GL_FLOAT, rgba);
- if (rgba[0] == 1.0 && rgba[1] == 1.0 && rgba[2] == 1.0) {
- /* hit */
- if (x < xmin)
- xmin = x;
- if (y < ymin)
- ymin = y;
- if (x > xmax)
- xmax = x;
- if (y > ymax)
- ymax = y;
- }
- }
- }
-
- printf("Point at (%2d, %2d) drawn for x in [%6.3f, %6.3f] and y in [%6.3f, %6.3f]\n",
- xpos, ypos,
- xpos + xmin, xpos + xmax,
- ypos + ymin, ypos + ymax);
-
- if (xmax - xmin != 1.0 - Step) {
- printf(" => Inconsistant X-axis rasterization!\n");
- }
- if (ymax - ymin != 1.0 - Step) {
- printf(" => Inconsistant Y-axis rasterization!\n");
- }
- if (xmin < 0.0) {
- printf(" => Points should be X biased by about %f\n", xmin);
- }
- if (ymin < 0.0) {
- printf(" => Points should be Y biased by about %f\n", ymin);
- }
- if (xmax > 1.0) {
- printf(" => Points should be X biased by about %f\n", 1.0 - xmax);
- }
- if (ymax > 1.0) {
- printf(" => Points should be Y biased by about %f\n", 1.0 - ymax);
- }
-
-}
-
-
-/**
- * XXX Implement VLineCalibrate() someday
- */
-static void
-HLineCalibrate(int xpos, int ypos, int len)
-{
- GLfloat rgba[2][4];
- float x, y;
- float ymin, ymax;
- float xmin_left, xmax_left, xmin_right, xmax_right;
-
- xmin_left = xmin_right = 1000.0;
- xmax_left = xmax_right = -1000.0;
- ymin = 1000;
- ymax = -1000.0;
-
- /*
- * First, check vertical positioning of the horizontal line
- */
- for (y = -1.0; y <= 1.0; y += Step) {
- glClear(GL_COLOR_BUFFER_BIT);
- glBegin(GL_LINES);
- glVertex2f(xpos, ypos + y);
- glVertex2f(xpos + len, ypos + y);
- glEnd();
-
- glReadPixels(xpos + len / 2, ypos, 1, 1, GL_RGBA, GL_FLOAT, rgba);
- if (rgba[0][0] == 1.0) {
- /* hit */
- if (y < ymin)
- ymin = y;
- if (y > ymax)
- ymax = y;
- }
- }
-
- printf("H-line at Y=%2d drawn for y in [%6.3f, %6.3f]\n",
- ypos,
- ypos + ymin, ypos + ymax);
-
- if (ymax - ymin != 1.0 - Step) {
- printf(" => Inconsistant Y-axis rasterization!\n");
- }
-
- if (ymin > 0.5 ) {
- printf(" => Lines should be Y biased by about %f\n", ymin - 0.5);
- }
-
- if (ymax < 0.5 ) {
- printf(" => Lines should be Y biased by about %f\n", 0.5 - ymax);
- }
-
- /*
- * Second, check endpoints (for Y at 1/2 pixel)
- */
- for (x = -1.0; x <= 1.0; x += Step) {
- glClear(GL_COLOR_BUFFER_BIT);
- glBegin(GL_LINES);
- glVertex2f(xpos + x, ypos + 0.5f);
- glVertex2f(xpos + x + len, ypos + 0.5f);
- glEnd();
-
- /* left end */
- glReadPixels(xpos - 1, ypos, 2, 1, GL_RGBA, GL_FLOAT, rgba);
- if (rgba[0][0] == 0.0 && rgba[1][0] == 1.0) {
- /* hit */
- if (x < xmin_left)
- xmin_left = x;
- if (x > xmax_left)
- xmax_left = x;
- }
-
- /* right end */
- glReadPixels(xpos + len - 1, ypos, 2, 1, GL_RGBA, GL_FLOAT, rgba);
- if (rgba[0][0] == 1.0 && rgba[1][0] == 0.0) {
- /* hit */
- if (x < xmin_right)
- xmin_right = x;
- if (x > xmax_right)
- xmax_right = x;
- }
- }
-
- printf("H-line [%d..%d) hit left end for x in [%6.3f, %6.3f] "
- "hit right end for x in [%6.3f, %6.3f]\n",
- xpos, xpos + len,
- xpos + xmin_left, xpos + xmax_left,
- xpos + len + xmin_right, xpos + len + xmax_right);
-
- if (xmax_left - xmin_left > 1.0 - Step) {
- printf(" => Inconsistant left-end rasterization!\n");
- }
- if (xmax_right - xmin_right > 1.0 - Step) {
- printf(" => Inconsistant right-end rasterization!\n");
- }
-
- if (xmin_left != xmin_right ||
- xmax_left != xmax_right) {
- printf(" => Inconsistant length!\n");
- }
-
- if (xmin_left < 0.0) {
- printf(" => Coords should be X biased by about %f\n", xmin_left );
- }
- if (xmin_right < 0.0) {
- printf(" => Coords should be X biased by about %f\n", xmin_right );
- }
- if (xmax_left >= 1.0) {
- printf(" => Coords should be X biased by about %f\n", -xmax_right + 1.0);
- }
- if (xmax_right >= 1.0) {
- printf(" => Coords should be X biased by about %f\n", -xmax_right + 1.0);
- }
-
-}
-
-
-static void
-QuadCalibrate(int xpos, int ypos, int width, int height)
-{
- GLfloat rgba1[2][4];
- GLfloat rgba2[2][4];
- float x, y;
- float xmin, ymin, xmax, ymax;
-
- xmin = ymin = 1000.0;
- xmax = ymax = -1000.0;
-
- for (y = -1.0; y <= 1.0; y += Step) {
- for (x = -1.0; x <= 1.0; x += Step) {
- glClear(GL_COLOR_BUFFER_BIT);
- glBegin(GL_QUADS);
- glVertex2f(xpos + x, ypos + y);
- glVertex2f(xpos + x + width, ypos + y);
- glVertex2f(xpos + x + width, ypos + y + height);
- glVertex2f(xpos + x, ypos + y + height);
- glEnd();
-
- /* horizontal measurement */
- glReadPixels(xpos - 1, ypos + 2, 2, 1, GL_RGBA, GL_FLOAT, rgba1);
- glReadPixels(xpos + width - 1, ypos + 2, 2, 1, GL_RGBA, GL_FLOAT, rgba2);
- if (rgba1[0][0] == 0.0 && rgba1[1][0] == 1.0 &&
- rgba2[0][0] == 1.0 && rgba2[1][0] == 0.0) {
- if (x < xmin)
- xmin = x;
- if (x > xmax)
- xmax = x;
- }
-
- /* vertical measurement */
- glReadPixels(xpos + 2, ypos - 1, 1, 2, GL_RGBA, GL_FLOAT, rgba1);
- glReadPixels(xpos + 2, ypos + height - 1, 1, 2, GL_RGBA, GL_FLOAT, rgba2);
- if (rgba1[0][0] == 0.0 && rgba1[1][0] == 1.0 &&
- rgba2[0][0] == 1.0 && rgba2[1][0] == 0.0) {
- if (y < ymin)
- ymin = y;
- if (y > ymax)
- ymax = y;
- }
- }
- }
-
- printf("Quad at (%2d, %2d)..(%2d, %2d) drawn"
- " for x in [%6.3f, %6.3f] and y in [%6.3f, %6.3f]\n",
- xpos, ypos,
- xpos + width, ypos + height,
- xpos + xmin, xpos + xmax,
- ypos + ymin, ypos + ymax);
-
- if (xmax - xmin != 1.0 - Step) {
- printf(" => Inconsistant X-axis rasterization/size!\n");
- }
- if (ymax - ymin != 1.0 - Step) {
- printf(" => Inconsistant Y-axis rasterization/size!\n");
- }
-
- if (xmin < -0.5) {
- printf(" => Coords should be X biased by about %f\n", 0.5 + xmin );
- }
- if (ymin < -0.5) {
- printf(" => Coords should be Y biased by about %f\n", 0.5 + ymin);
- }
- if (xmax > 0.5) {
- printf(" => Coords should be X biased by about %f\n", -xmax + 0.5);
- }
- if (ymax > 0.5) {
- printf(" => Coords should be Y biased by about %f\n", -ymax + 0.5);
- }
-}
-
-
-/**
- * Misc/disabled code for debugging.
- */
-static void
-DebugTest(void)
-{
- glClear(GL_COLOR_BUFFER_BIT);
- glEnable(GL_BLEND);
- glBlendFunc(GL_ONE, GL_ONE);
-
- glColor3f(.5, .5, .5);
-
- glBegin(GL_LINES);
- glVertex2f(30, 35.5);
- glVertex2f(54, 35.5);
- glVertex2f(54, 35.5);
- glVertex2f(66, 35.5);
- glEnd();
-
- glDisable(GL_BLEND);
- glColor3f(1,1,1);
-}
-
-
-static void
-Draw(void)
-{
- glClear(GL_COLOR_BUFFER_BIT);
-
- glPushMatrix();
- glTranslatef(Xtrans, Ytrans, 0);
-
- PointCalibrate(1, 1);
- PointCalibrate(50, 50);
- PointCalibrate(28, 17);
- PointCalibrate(17, 18);
- printf("\n");
-
- HLineCalibrate(5, 10, 10);
- HLineCalibrate(25, 22, 12);
- HLineCalibrate(54, 33, 12);
- HLineCalibrate(54+12, 33, 12);
- printf("\n");
-
- QuadCalibrate(2, 2, 10, 10);
- QuadCalibrate(50, 50, 10, 10);
- QuadCalibrate(28, 17, 12, 12);
- QuadCalibrate(17, 28, 12, 12);
-
- (void) DebugTest;
-
- glPopMatrix();
-
- glutSwapBuffers();
-}
-
-
-static void
-Reshape(int width, int height)
-{
- Width = width;
- Height = height;
- glViewport(0, 0, width, height);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0, width, 0, height, -1, 1);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-}
-
-
-static void
-Key(unsigned char key, int x, int y)
-{
- (void) x;
- (void) y;
- switch (key) {
- case 27:
- glutDestroyWindow(Win);
- exit(0);
- break;
- }
- glutPostRedisplay();
-}
-
-
-static void
-Init(void)
-{
- printf("Measurement/callibration for basic prim rasterization...\n");
- printf("GL_RENDERER: %s\n", (char*) glGetString(GL_RENDERER));
-}
-
-
-int
-main(int argc, char *argv[])
-{
- glutInit(&argc, argv);
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(Width, Height);
- glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
- Win = glutCreateWindow(argv[0]);
- glewInit();
- glutReshapeFunc(Reshape);
- glutKeyboardFunc(Key);
- glutDisplayFunc(Draw);
- Init();
- glutMainLoop();
- return 0;
-}
diff --git a/progs/tests/fillrate.c b/progs/tests/fillrate.c
deleted file mode 100644
index 1e58df281e1..00000000000
--- a/progs/tests/fillrate.c
+++ /dev/null
@@ -1,204 +0,0 @@
-/**
- * Measure fill rates for basic shading/texturing modes.
- *
- * Brian Paul
- * 1 April 2008
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <GL/glew.h>
-#include <GL/glut.h>
-#include "readtex.h"
-
-#define TEXTURE_1_FILE "../images/tile.rgb"
-#define TEXTURE_2_FILE "../images/reflect.rgb"
-
-static int Win;
-static int Width = 1010, Height = 1010;
-static GLuint Textures[2];
-
-
-/**
- * Draw quad 10 pixels shorter, narrower than window size.
- */
-static void
-DrawQuad(void)
-{
- glBegin(GL_POLYGON);
-
- glColor3f(1.0, 0.5, 0.5);
- glMultiTexCoord2f(GL_TEXTURE0, 0, 0);
- glMultiTexCoord2f(GL_TEXTURE1, 0, 0);
- glVertex2f(5, 5);
-
- glColor3f(0.5, 1.0, 0.5);
- glMultiTexCoord2f(GL_TEXTURE0, 1, 0);
- glMultiTexCoord2f(GL_TEXTURE1, 1, 0);
- glVertex2f(Width - 5, 5);
-
- glColor3f(0.5, 0.5, 1.0);
- glMultiTexCoord2f(GL_TEXTURE0, 1, 1);
- glMultiTexCoord2f(GL_TEXTURE1, 1, 1);
- glVertex2f(Width - 5, Height - 5);
-
- glColor3f(1.0, 0.5, 1.0);
- glMultiTexCoord2f(GL_TEXTURE0, 0, 1);
- glMultiTexCoord2f(GL_TEXTURE1, 0, 1);
- glVertex2f(5, Height - 5);
-
- glEnd();
-}
-
-
-/**
- * Compute rate for drawing large quad with given shading/texture state.
- */
-static void
-RunTest(GLenum shading, GLuint numTextures, GLenum texFilter)
-{
- const GLdouble minPeriod = 2.0;
- GLdouble t0, t1;
- GLdouble pixels, rate;
- GLint i, iters;
-
- glActiveTexture(GL_TEXTURE0);
- if (numTextures > 0) {
- glBindTexture(GL_TEXTURE_2D, Textures[0]);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texFilter);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texFilter);
- glEnable(GL_TEXTURE_2D);
- }
- else {
- glDisable(GL_TEXTURE_2D);
- }
-
- glActiveTexture(GL_TEXTURE1);
- if (numTextures > 1) {
- glBindTexture(GL_TEXTURE_2D, Textures[1]);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texFilter);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texFilter);
- glEnable(GL_TEXTURE_2D);
- }
- else {
- glDisable(GL_TEXTURE_2D);
- }
-
- glShadeModel(shading);
-
-
- glFinish();
-
- iters = 1;
- do {
- iters *= 4;
- t0 = glutGet(GLUT_ELAPSED_TIME) * 0.001;
- for (i = 0; i < iters; i++) {
- DrawQuad();
- }
- glFinish();
- t1 = glutGet(GLUT_ELAPSED_TIME) * 0.001;
- } while (t1 - t0 < minPeriod);
-
- glutSwapBuffers();
-
- pixels = (double) iters * (Width - 10) * (Height - 10);
- rate = pixels / (t1 - t0);
- rate /= 1000000.0; /* megapixels/second */
-
- printf("%s ", shading == GL_FLAT ? "GL_FLAT" : "GL_SMOOTH");
- printf("Textures=%u ", numTextures);
- printf("Filter=%s: ", texFilter == GL_LINEAR ? "GL_LINEAR" : "GL_NEAREST");
- printf("%g MPixels/sec\n", rate);
-}
-
-
-static void
-Draw(void)
-{
- glClear(GL_COLOR_BUFFER_BIT);
-
- RunTest(GL_FLAT, 0, GL_NEAREST);
- RunTest(GL_SMOOTH, 0, GL_NEAREST);
- RunTest(GL_SMOOTH, 1, GL_NEAREST);
- RunTest(GL_SMOOTH, 1, GL_LINEAR);
- RunTest(GL_SMOOTH, 2, GL_NEAREST);
- RunTest(GL_SMOOTH, 2, GL_LINEAR);
-
- glutSwapBuffers();
-}
-
-
-static void
-Reshape(int width, int height)
-{
- glViewport(0, 0, width, height);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0, width, 0, height, -1, 1);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- Width = width;
- Height = height;
-}
-
-
-static void
-Key(unsigned char key, int x, int y)
-{
- (void) x;
- (void) y;
- switch (key) {
- case 27:
- glutDestroyWindow(Win);
- exit(0);
- break;
- }
- glutPostRedisplay();
-}
-
-
-static void
-Init(void)
-{
- printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
-
- glGenTextures(2, Textures);
-
- glBindTexture(GL_TEXTURE_2D, Textures[0]);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
- if (!LoadRGBMipmaps(TEXTURE_1_FILE, GL_RGB)) {
- printf("Error: couldn't load texture image\n");
- exit(1);
- }
-
- glBindTexture(GL_TEXTURE_2D, Textures[1]);
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
- if (!LoadRGBMipmaps(TEXTURE_2_FILE, GL_RGB)) {
- printf("Error: couldn't load texture image\n");
- exit(1);
- }
-
-}
-
-
-int
-main(int argc, char *argv[])
-{
- glutInit(&argc, argv);
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(Width, Height);
- glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
- Win = glutCreateWindow(argv[0]);
- glewInit();
- glutReshapeFunc(Reshape);
- glutKeyboardFunc(Key);
- glutDisplayFunc(Draw);
- Init();
- glutMainLoop();
- return 0;
-}
diff --git a/progs/tests/glutfx.c b/progs/tests/glutfx.c
deleted file mode 100644
index 8bf55823897..00000000000
--- a/progs/tests/glutfx.c
+++ /dev/null
@@ -1,189 +0,0 @@
-
-/*
- * Example of how one might use GLUT with the 3Dfx driver in full-screen mode.
- * Note: this only works with X since we're using Mesa's GLX "hack" for
- * using Glide.
- *
- * Goals:
- * easy setup and input event handling with GLUT
- * use 3Dfx hardware
- * automatically set MESA environment variables
- * don't lose mouse input focus
- *
- * Brian Paul This file is in the public domain.
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <GL/glut.h>
-
-
-#define WIDTH 640
-#define HEIGHT 480
-
-
-static int Window = 0;
-static int ScreenWidth, ScreenHeight;
-static GLuint Torus = 0;
-static GLfloat Xrot = 0.0, Yrot = 0.0;
-
-
-
-static void Display( void )
-{
- static GLfloat blue[4] = {0.2, 0.2, 1.0, 1.0};
- static GLfloat red[4] = {1.0, 0.2, 0.2, 1.0};
- static GLfloat green[4] = {0.2, 1.0, 0.2, 1.0};
-
- glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
-
- glPushMatrix();
- glRotatef(Xrot, 1, 0, 0);
- glRotatef(Yrot, 0, 1, 0);
-
- glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blue);
- glCallList(Torus);
-
- glRotatef(90.0, 1, 0, 0);
- glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, red);
- glCallList(Torus);
-
- glRotatef(90.0, 0, 1, 0);
- glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, green);
- glCallList(Torus);
-
- glPopMatrix();
-
- glutSwapBuffers();
-}
-
-
-static void Reshape( int width, int height )
-{
- float ratio = (float) width / (float) height;
-
- ScreenWidth = width;
- ScreenHeight = height;
-
- /*
- * The 3Dfx driver is limited to 640 x 480 but the X window may be larger.
- * Enforce that here.
- */
- if (width > WIDTH)
- width = WIDTH;
- if (height > HEIGHT)
- height = HEIGHT;
-
- glViewport( 0, 0, width, height );
- glMatrixMode( GL_PROJECTION );
- glLoadIdentity();
- glFrustum( -ratio, ratio, -1.0, 1.0, 5.0, 30.0 );
- glMatrixMode( GL_MODELVIEW );
- glLoadIdentity();
- glTranslatef( 0.0, 0.0, -20.0 );
-}
-
-
-static void Key( unsigned char key, int x, int y )
-{
- (void) x;
- (void) y;
- switch (key) {
- case 27:
- glutDestroyWindow(Window);
- exit(0);
- break;
- }
- glutPostRedisplay();
-}
-
-
-static void SpecialKey( int key, int x, int y )
-{
- (void) x;
- (void) y;
- switch (key) {
- case GLUT_KEY_UP:
- break;
- case GLUT_KEY_DOWN:
- break;
- case GLUT_KEY_LEFT:
- break;
- case GLUT_KEY_RIGHT:
- break;
- }
- glutPostRedisplay();
-}
-
-
-static void MouseMove( int x, int y )
-{
- Xrot = y - ScreenWidth / 2;
- Yrot = x - ScreenHeight / 2;
- glutPostRedisplay();
-}
-
-
-static void Init( void )
-{
- Torus = glGenLists(1);
- glNewList(Torus, GL_COMPILE);
- glutSolidTorus(0.5, 2.0, 10, 20);
- glEndList();
-
- glEnable(GL_LIGHTING);
- glEnable(GL_LIGHT0);
-
- glEnable(GL_DEPTH_TEST);
- glEnable(GL_CULL_FACE);
-}
-
-
-int main( int argc, char *argv[] )
-{
-#ifndef _WIN32
- printf("NOTE: if you've got 3Dfx VooDoo hardware you must run this");
- printf(" program as root.\n\n");
- printf("Move the mouse. Press ESC to exit.\n\n");
-#endif
-
- /* Tell Mesa GLX to use 3Dfx driver in fullscreen mode. */
- putenv("MESA_GLX_FX=fullscreen");
-
- /* Disable 3Dfx Glide splash screen */
- putenv("FX_GLIDE_NO_SPLASH=");
-
- /* Give an initial size and position so user doesn't have to place window */
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(WIDTH, HEIGHT);
- glutInit( &argc, argv );
-
- glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
-
- Window = glutCreateWindow(argv[0]);
- if (!Window) {
- printf("Error, couldn't open window\n");
- exit(1);
- }
-
- /*
- * Want the X window to fill the screen so that we don't have to
- * worry about losing the mouse input focus.
- * Note that we won't actually see the X window since we never draw
- * to it, hence, the original X screen's contents aren't disturbed.
- */
- glutFullScreen();
-
- Init();
-
- glutReshapeFunc( Reshape );
- glutKeyboardFunc( Key );
- glutSpecialFunc( SpecialKey );
- glutDisplayFunc( Display );
- glutPassiveMotionFunc( MouseMove );
-
- glutMainLoop();
- return 0;
-}
diff --git a/progs/tests/mapbufrange.c b/progs/tests/mapbufrange.c
deleted file mode 100644
index 0021bb26071..00000000000
--- a/progs/tests/mapbufrange.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Test glMapBuffer() and glMapBufferRange()
- *
- * Fill a VBO with vertex data to draw several colored quads.
- * On each redraw, update the geometry for just one rect in the VBO.
- *
- * Brian Paul
- * 4 March 2009
- */
-
-
-#include <assert.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <GL/glew.h>
-#include <GL/glew.h>
-#include <GL/glut.h>
-
-static GLuint Win;
-static const GLuint NumRects = 10;
-static GLuint BufferID;
-static GLboolean Anim = GL_TRUE;
-static GLboolean UseBufferRange = GL_FALSE;
-
-
-
-static const float RectData[] = {
- /* vertex */ /* color */
- 0, -1, 0, 1, 0, 0,
- 1, 0, 0, 1, 1, 0,
- 0, 1, 0, 0, 1, 1,
- -1, 0, 0, 1, 0, 1
-};
-
-
-/**
- * The buffer contains vertex positions (float[3]) and colors (float[3])
- * for 'NumRects' quads.
- * This function updates/rotates one quad in the buffer.
- */
-static void
-UpdateRect(int r, float angle)
-{
- float *rect;
- int i;
-
- assert(r < NumRects);
-
- glBindBufferARB(GL_ARRAY_BUFFER_ARB, BufferID);
- if (UseBufferRange) {
- GLintptr offset = r * sizeof(RectData);
- GLsizeiptr length = sizeof(RectData);
- GLbitfield access = GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT;
- float *buf = (float *) glMapBufferRange(GL_ARRAY_BUFFER_ARB,
- offset, length, access);
- rect = buf;
- }
- else {
- /* map whole buffer */
- float *buf = (float *)
- glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
- rect = buf + r * 24;
- }
-
- /* set rect verts/colors */
- memcpy(rect, RectData, sizeof(RectData));
-
- /* loop over four verts, updating vertices */
- for (i = 0; i < 4; i++) {
- float x = 0.2 * RectData[i*6+0];
- float y = 0.2 * RectData[i*6+1];
- float xpos = -2.5 + 0.5 * r;
- float ypos = 0.0;
-
- /* translate and rotate vert */
- rect[i * 6 + 0] = xpos + x * cos(angle) + y * sin(angle);
- rect[i * 6 + 1] = ypos + x * sin(angle) - y * cos(angle);
- }
-
- glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
-}
-
-
-static void
-LoadBuffer(void)
-{
- static int frame = 0;
- float angle = glutGet(GLUT_ELAPSED_TIME) * 0.001;
- UpdateRect(frame % NumRects, angle);
- frame++;
-}
-
-
-static void
-Draw(void)
-{
- glBindBufferARB(GL_ARRAY_BUFFER_ARB, BufferID);
- glVertexPointer(3, GL_FLOAT, 24, 0);
- glEnable(GL_VERTEX_ARRAY);
-
- glColorPointer(3, GL_FLOAT, 24, (void*) 12);
- glEnable(GL_COLOR_ARRAY);
-
- glDrawArrays(GL_QUADS, 0, NumRects * 4);
-
- if (0)
- glFinish();
-}
-
-
-static void
-Display(void)
-{
- glClear(GL_COLOR_BUFFER_BIT);
- Draw();
- glutSwapBuffers();
-}
-
-
-static void
-Reshape(int width, int height)
-{
- glViewport(0, 0, width, height);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(-3.0, 3.0, -1.0, 1.0, -1.0, 1.0);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-}
-
-
-static void
-Idle(void)
-{
- LoadBuffer();
- glutPostRedisplay();
-}
-
-
-static void
-Key(unsigned char key, int x, int y)
-{
- (void) x;
- (void) y;
- if (key == 'a') {
- Anim = !Anim;
- glutIdleFunc(Anim ? Idle : NULL);
- }
- else if (key == 's') {
- LoadBuffer();
- }
- else if (key == 27) {
- glutDestroyWindow(Win);
- exit(0);
- }
- glutPostRedisplay();
-}
-
-
-static void
-Init(void)
-{
- GLuint BufferSize = NumRects * sizeof(RectData);
- float *buf;
-
- if (!glutExtensionSupported("GL_ARB_vertex_buffer_object")) {
- printf("GL_ARB_vertex_buffer_object not found!\n");
- exit(0);
- }
-
- UseBufferRange = glutExtensionSupported("GL_ARB_map_buffer_range");
- printf("Use GL_ARB_map_buffer_range: %c\n", "NY"[UseBufferRange]);
-
- printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
-
- /* initially load buffer with zeros */
- buf = (float *) calloc(1, BufferSize);
-
- glGenBuffersARB(1, &BufferID);
- glBindBufferARB(GL_ARRAY_BUFFER_ARB, BufferID);
- glBufferDataARB(GL_ARRAY_BUFFER_ARB, BufferSize, buf, GL_DYNAMIC_DRAW_ARB);
-
- free(buf);
-}
-
-
-int
-main(int argc, char *argv[])
-{
- glutInit(&argc, argv);
- glutInitWindowSize(800, 200);
- glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
- Win = glutCreateWindow(argv[0]);
- glewInit();
- glewInit();
- glutReshapeFunc(Reshape);
- glutKeyboardFunc(Key);
- glutDisplayFunc(Display);
- glutIdleFunc(Anim ? Idle : NULL);
- Init();
- glutMainLoop();
- return 0;
-}
diff --git a/progs/tests/mapvbo.c b/progs/tests/mapvbo.c
deleted file mode 100644
index c392e768358..00000000000
--- a/progs/tests/mapvbo.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Test glMapBuffer() call immediately after glDrawArrays().
- * See details below.
- *
- * NOTE: Do not use freeglut with this test! It calls the Display()
- * callback twice right away instead of just once.
- *
- * Brian Paul
- * 27 Feb 2009
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <GL/glew.h>
-#include <GL/glut.h>
-
-static GLuint BufferID;
-
-
-static GLuint Win;
-
-
-
-
-/*
- * Create VBO (position and color) and load with data.
- */
-static void
-SetupBuffers(void)
-{
- static const GLfloat data[] = {
- /* vertex */ /* color */
- 0, -1, 0, 1, 1, 0,
- 1, 0, 0, 1, 1, 0,
- 0, 1, 0, 1, 1, 0,
- -1, 0, 0, 1, 1, 0
- };
-
- glGenBuffersARB(1, &BufferID);
- glBindBufferARB(GL_ARRAY_BUFFER_ARB, BufferID);
- glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(data), data,
- GL_STATIC_DRAW_ARB);
-}
-
-
-static void
-Draw(void)
-{
- static int count = 1;
-
- printf("Draw Frame %d\n", count);
- count++;
-
- glBindBufferARB(GL_ARRAY_BUFFER_ARB, BufferID);
- glVertexPointer(3, GL_FLOAT, 24, 0);
- glEnable(GL_VERTEX_ARRAY);
-
- glColorPointer(3, GL_FLOAT, 24, (void*) 12);
- glEnable(GL_COLOR_ARRAY);
-
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
-
- if (0)
- glFinish();
-
- /* Immediately map the color buffer and change something.
- * This should not effect the first glDrawArrays above, but the
- * next time we draw we should see a black vertex.
- */
- if (1) {
- GLfloat *m = (GLfloat *) glMapBufferARB(GL_ARRAY_BUFFER_ARB,
- GL_WRITE_ONLY_ARB);
- m[3] = m[4] = m[5] = 0.0f; /* black vertex */
- glUnmapBufferARB(GL_ARRAY_BUFFER_ARB);
- }
-}
-
-
-static void Display( void )
-{
- glClear( GL_COLOR_BUFFER_BIT );
- Draw();
- glutSwapBuffers();
-}
-
-
-static void Reshape( int width, int height )
-{
- float ar = (float) width / (float) height;
- glViewport( 0, 0, width, height );
- glMatrixMode( GL_PROJECTION );
- glLoadIdentity();
- glFrustum( -ar, ar, -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 )
-{
- (void) x;
- (void) y;
- if (key == 27) {
- glutDestroyWindow(Win);
- exit(0);
- }
- glutPostRedisplay();
-}
-
-
-static void Init( void )
-{
- if (!glutExtensionSupported("GL_ARB_vertex_buffer_object")) {
- printf("GL_ARB_vertex_buffer_object not found!\n");
- exit(0);
- }
- printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
-
- SetupBuffers();
-}
-
-
-int main( int argc, char *argv[] )
-{
- glutInit( &argc, argv );
- glutInitWindowPosition( 0, 0 );
- glutInitWindowSize( 300, 300 );
- glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
- Win = glutCreateWindow(argv[0]);
- glewInit();
- glutReshapeFunc( Reshape );
- glutKeyboardFunc( Key );
- glutDisplayFunc( Display );
- Init();
- glutMainLoop();
- return 0;
-}
diff --git a/progs/tests/mipgen.c b/progs/tests/mipgen.c
deleted file mode 100644
index 088f643215c..00000000000
--- a/progs/tests/mipgen.c
+++ /dev/null
@@ -1,207 +0,0 @@
-/* Test GL_TEXTURE_BASE_LEVEL and GL_TEXTURE_MAX_LEVEL
- * Brian Paul
- * 10 May 2006
- */
-
-
-/* Copyright (c) Mark J. Kilgard, 1994. */
-
-/*
- * (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
- * any purpose and without fee is hereby granted, provided that the above
- * copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
- * the name of Silicon Graphics, Inc. not be used in advertising
- * or publicity pertaining to distribution of the software without specific,
- * written prior permission.
- *
- * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
- * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
- * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
- * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
- * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
- * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
- * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
- * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
- * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
- * Use, duplication, or disclosure by the Government is subject to
- * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
- * (c)(1)(ii) of the Rights in Technical Data and Computer Software
- * clause at DFARS 252.227-7013 and/or in similar or successor
- * clauses in the FAR or the DOD or NASA FAR Supplement.
- * Unpublished-- rights reserved under the copyright laws of the
- * United States. Contractor/manufacturer is Silicon Graphics,
- * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
- *
- * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <GL/glew.h>
-#include <GL/glut.h>
-
-#include "readtex.h"
-
-
-static GLfloat LodBias = 6.0; /* make smallest miplevel visible */
-static GLuint texImage;
-
-#define WIDTH 2
-#define HEIGHT 2
-
-static void
-InitValues(void)
-{
- LodBias = 6.0; /* make smallest miplevel visible */
-}
-
-
-static void MakeImage(void)
-{
- const GLubyte color0[4] = { 0xff, 0x80, 0x20, 0xff };
- const GLubyte color1[4] = { 0x10, 0x20, 0x40, 0xff };
-
- GLubyte img[WIDTH*HEIGHT*3];
- int i, j;
- for (i = 0; i < HEIGHT; i++) {
- for (j = 0; j < WIDTH; j++) {
- int k = (i * WIDTH + j) * 3;
- int p = ((i+j)%2);
- if (p == 0) {
- img[k + 0] = color0[0];
- img[k + 1] = color0[1];
- img[k + 2] = color0[2];
- }
- else {
- img[k + 0] = color1[0];
- img[k + 1] = color1[1];
- img[k + 2] = color1[2];
- }
- }
- }
-
- glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, WIDTH, HEIGHT, 0,
- GL_RGB, GL_UNSIGNED_BYTE, img);
- glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_FALSE);
-}
-
-
-
-static void myinit(void)
-{
- InitValues();
-
- glShadeModel(GL_FLAT);
-
- glTranslatef(0.0, 0.0, -3.6);
-
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glGenTextures(1, &texImage);
- glBindTexture(GL_TEXTURE_2D, texImage);
- MakeImage();
-
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
- glEnable(GL_TEXTURE_2D);
-
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);
-
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, -1);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 1);
-
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
- GL_NEAREST_MIPMAP_NEAREST);
-}
-
-
-
-static void display(void)
-{
- GLfloat tcm = 1.0;
- glBindTexture(GL_TEXTURE_2D, texImage);
-
- printf("Bias=%.2g\n", LodBias);
- fflush(stdout);
-
- glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, LodBias);
-
- glClear(GL_COLOR_BUFFER_BIT);
- glBegin(GL_QUADS);
- glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0);
- glTexCoord2f(0.0, tcm); glVertex3f(-2.0, 1.0, 0.0);
- glTexCoord2f(tcm * 3000.0, tcm); glVertex3f(3000.0, 1.0, -6000.0);
- glTexCoord2f(tcm * 3000.0, 0.0); glVertex3f(3000.0, -1.0, -6000.0);
- glEnd();
- glFlush();
-}
-
-static void myReshape(int w, int h)
-{
- glViewport(0, 0, w, h);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluPerspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 30000.0);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-}
-
-static void
-key(unsigned char k, int x, int y)
-{
- (void) x;
- (void) y;
- switch (k) {
- case 'l':
- LodBias -= 0.25;
- break;
- case 'L':
- LodBias += 0.25;
- break;
- case ' ':
- InitValues();
- break;
- case 27: /* Escape */
- exit(0);
- break;
- default:
- return;
- }
- glutPostRedisplay();
-}
-
-
-static void usage(void)
-{
- printf("usage:\n");
- printf(" l/L decrease/increase GL_TEXTURE_LOD_BIAS\n");
- printf(" SPACE reset values\n");
-}
-
-
-int main(int argc, char** argv)
-{
- glutInit(&argc, argv);
- glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB );
- glutInitWindowSize (600, 600);
- glutCreateWindow (argv[0]);
- glewInit();
- myinit();
- glutReshapeFunc (myReshape);
- glutDisplayFunc(display);
- glutKeyboardFunc(key);
- usage();
- glutMainLoop();
- return 0; /* ANSI C requires main to return int. */
-}
diff --git a/progs/tests/mipmap_comp.c b/progs/tests/mipmap_comp.c
deleted file mode 100644
index 5842e2b8805..00000000000
--- a/progs/tests/mipmap_comp.c
+++ /dev/null
@@ -1,295 +0,0 @@
-/* Copyright (c) Mark J. Kilgard, 1994. */
-/*
- * (c) Copyright 1993, Silicon Graphics, Inc.
- * ALL RIGHTS RESERVED
- * Permission to use, copy, modify, and distribute this software for
- * any purpose and without fee is hereby granted, provided that the above
- * copyright notice appear in all copies and that both the copyright notice
- * and this permission notice appear in supporting documentation, and that
- * the name of Silicon Graphics, Inc. not be used in advertising
- * or publicity pertaining to distribution of the software without specific,
- * written prior permission.
- *
- * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
- * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
- * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
- * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
- * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
- * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
- * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
- * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
- * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * US Government Users Restricted Rights
- * Use, duplication, or disclosure by the Government is subject to
- * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
- * (c)(1)(ii) of the Rights in Technical Data and Computer Software
- * clause at DFARS 252.227-7013 and/or in similar or successor
- * clauses in the FAR or the DOD or NASA FAR Supplement.
- * Unpublished-- rights reserved under the copyright laws of the
- * United States. Contractor/manufacturer is Silicon Graphics,
- * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
- *
- * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
- */
-
-/* mipmap_comp
- * Test compressed texture mipmaps
- *
- * Based on mipmap_limits
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <GL/glew.h>
-#include <GL/glut.h>
-
-#include "readtex.h"
-
-#define SIZE 16 /* not larger then 16 */
-
-static GLint BaseLevel = 0, MaxLevel = 9;
-static GLfloat MinLod = -1, MaxLod = 9;
-static GLfloat LodBias = 0.0;
-static GLboolean NearestFilter = GL_TRUE;
-static GLuint texImage;
-
-
-static void
-initValues(void)
-{
- BaseLevel = 0;
- MaxLevel = 9;
- MinLod = -1;
- MaxLod = 2;
- LodBias = 5.0;
- NearestFilter = GL_TRUE;
-}
-
-
-static void
-makeImage(int level, int width, int height)
-{
-#if 0
- GLubyte img[SIZE*SIZE*3];
- int i, j;
-
- (void)size;
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++) {
- int k = (i * width + j) * 3;
- img[k + 0] = 255 * ((level + 1) % 2);
- img[k + 1] = 255 * ((level + 1) % 2);
- img[k + 2] = 255 * ((level + 1) % 2);
- }
- }
-
- glTexImage2D(GL_TEXTURE_2D, level, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, width, height, 0,
- GL_RGB, GL_UNSIGNED_BYTE, img);
-#else
- GLubyte img[128];
- GLint size[] = {
- 128, /* 16x16 */
- 32, /* 8x8 */
- 8, /* 4x4 */
- 8, /* 2x2 */
- 8, /* 1x1 */
- };
- int i;
- int value = ((level + 1) % 2) * 0xffffffff;
- memset(img, 0, 128);
-
- /* generate black and white mipmap levels */
- if (value)
- for (i = 0; i < size[level] / 4; i += 2)
- ((int*)img)[i] = value;
-
- glCompressedTexImage2D(GL_TEXTURE_2D, level,
- GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
- width, height, 0,
- size[level], img);
-#endif
-}
-
-
-static void
-makeImages(void)
-{
- int i, sz;
-
- for (i = 0, sz = SIZE; sz >= 1; i++, sz /= 2) {
- makeImage(i, sz, sz);
- printf("Level %d size: %d x %d\n", i, sz, sz);
- }
-}
-
-
-static void
-myInit(void)
-{
-
- initValues();
-
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LESS);
- glShadeModel(GL_FLAT);
-
- glTranslatef(0.0, 0.0, -3.6);
-
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glGenTextures(1, &texImage);
- glBindTexture(GL_TEXTURE_2D, texImage);
- makeImages();
-
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
- glEnable(GL_TEXTURE_2D);
-}
-
-
-static void
-display(void)
-{
- GLfloat tcm = 1.0;
- glBindTexture(GL_TEXTURE_2D, texImage);
-
- printf("BASE_LEVEL=%d MAX_LEVEL=%d MIN_LOD=%.2g MAX_LOD=%.2g Bias=%.2g Filter=%s\n",
- BaseLevel, MaxLevel, MinLod, MaxLod, LodBias,
- NearestFilter ? "NEAREST" : "LINEAR");
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, BaseLevel);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, MaxLevel);
-
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, MinLod);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, MaxLod);
-
- if (NearestFilter) {
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
- GL_NEAREST_MIPMAP_NEAREST);
- }
- else {
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
- GL_LINEAR_MIPMAP_LINEAR);
- }
-
- glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, LodBias);
-
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glBegin(GL_QUADS);
- glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0);
- glTexCoord2f(0.0, tcm); glVertex3f(-2.0, 1.0, 0.0);
- glTexCoord2f(tcm * 3000.0, tcm); glVertex3f(3000.0, 1.0, -6000.0);
- glTexCoord2f(tcm * 3000.0, 0.0); glVertex3f(3000.0, -1.0, -6000.0);
- glEnd();
- glFlush();
-}
-
-
-static void
-myReshape(int w, int h)
-{
- glViewport(0, 0, w, h);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluPerspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 30000.0);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-}
-
-
-static void
-key(unsigned char k, int x, int y)
-{
- (void) x;
- (void) y;
- switch (k) {
- case 'b':
- BaseLevel--;
- if (BaseLevel < 0)
- BaseLevel = 0;
- break;
- case 'B':
- BaseLevel++;
- if (BaseLevel > 10)
- BaseLevel = 10;
- break;
- case 'm':
- MaxLevel--;
- if (MaxLevel < 0)
- MaxLevel = 0;
- break;
- case 'M':
- MaxLevel++;
- if (MaxLevel > 10)
- MaxLevel = 10;
- break;
- case 'l':
- LodBias -= 0.25;
- break;
- case 'L':
- LodBias += 0.25;
- break;
- case 'n':
- MinLod -= 0.25;
- break;
- case 'N':
- MinLod += 0.25;
- break;
- case 'x':
- MaxLod -= 0.25;
- break;
- case 'X':
- MaxLod += 0.25;
- break;
- case 'f':
- NearestFilter = !NearestFilter;
- break;
- case ' ':
- initValues();
- break;
- case 27: /* Escape */
- exit(0);
- break;
- default:
- return;
- }
- glutPostRedisplay();
-}
-
-
-static void
-usage(void)
-{
- printf("usage:\n");
- printf(" b/B decrease/increase GL_TEXTURE_BASE_LEVEL\n");
- printf(" m/M decrease/increase GL_TEXTURE_MAX_LEVEL\n");
- printf(" n/N decrease/increase GL_TEXTURE_MIN_LOD\n");
- printf(" x/X decrease/increase GL_TEXTURE_MAX_LOD\n");
- printf(" l/L decrease/increase GL_TEXTURE_LOD_BIAS\n");
- printf(" f toggle nearest/linear filtering\n");
- printf(" SPACE reset values\n");
-}
-
-
-int
-main(int argc, char** argv)
-{
- glutInit(&argc, argv);
- glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
- glutInitWindowSize (600, 600);
- glutCreateWindow (argv[0]);
- glewInit();
- myInit();
- glutReshapeFunc (myReshape);
- glutDisplayFunc(display);
- glutKeyboardFunc(key);
- usage();
- glutMainLoop();
- return 0; /* ANSI C requires main to return int. */
-}
diff --git a/progs/tests/mipmap_view.c b/progs/tests/mipmap_view.c
deleted file mode 100644
index 808d348699c..00000000000
--- a/progs/tests/mipmap_view.c
+++ /dev/null
@@ -1,435 +0,0 @@
-/*
- * Test mipmap generation and lod bias.
- *
- * Brian Paul
- * 17 March 2008
- */
-
-
-#include <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <math.h>
-#include <GL/glew.h>
-#include <GL/glut.h>
-#include <GL/glext.h>
-
-#include "readtex.h"
-
-#define TEXTURE_FILE "../images/arch.rgb"
-
-#define LEVELS 8
-#define SIZE (1<<LEVELS)
-static int TexWidth = SIZE, TexHeight = SIZE;
-static int WinWidth = 1044, WinHeight = 900;
-static GLfloat Bias = 0.0;
-static GLboolean ScaleQuads = GL_FALSE;
-static GLboolean Linear = GL_FALSE;
-static GLint Win = 0;
-static GLint RenderTextureLevel = 0;
-static GLuint TexObj;
-
-
-
-static void
-CheckError(int line)
-{
- GLenum err = glGetError();
- if (err) {
- printf("GL Error 0x%x at line %d\n", (int) err, line);
- }
-}
-
-
-
-static void
-PrintString(const char *s)
-{
- while (*s) {
- glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int) *s);
- s++;
- }
-}
-
-
-
-
-static void
-MipGenTexture( void )
-{
- /* test auto mipmap generation */
- GLint width, height, i;
- GLenum format;
- GLubyte *image = LoadRGBImage(TEXTURE_FILE, &width, &height, &format);
- if (!image) {
- printf("Error: could not load texture image %s\n", TEXTURE_FILE);
- exit(1);
- }
- /* resize to TexWidth x TexHeight */
- if (width != TexWidth || height != TexHeight) {
- GLubyte *newImage = malloc(TexWidth * TexHeight * 4);
-
- fprintf(stderr, "rescale %d %d to %d %d\n", width, height,
- TexWidth, TexHeight);
- fflush(stderr);
-
- gluScaleImage(format, width, height, GL_UNSIGNED_BYTE, image,
- TexWidth, TexHeight, GL_UNSIGNED_BYTE, newImage);
- free(image);
- image = newImage;
- }
- printf("Using GL_SGIS_generate_mipmap\n");
- glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
- glTexImage2D(GL_TEXTURE_2D, 0, format, TexWidth, TexHeight, 0,
- format, GL_UNSIGNED_BYTE, image);
- free(image);
-
- /* make sure mipmap was really generated correctly */
- width = TexWidth;
- height = TexHeight;
- for (i = 0; i < 9; i++) {
- GLint w, h;
- glGetTexLevelParameteriv(GL_TEXTURE_2D, i, GL_TEXTURE_WIDTH, &w);
- glGetTexLevelParameteriv(GL_TEXTURE_2D, i, GL_TEXTURE_HEIGHT, &h);
- printf("Level %d size: %d x %d\n", i, w, h);
- assert(w == width);
- assert(h == height);
- width /= 2;
- height /= 2;
- }
-
-
- glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_FALSE);
-}
-
-
-
-static void
-ResetTextureLevel( int i )
-{
- GLubyte tex2d[SIZE*SIZE][4];
-
- {
- GLint Width = TexWidth / (1 << i);
- GLint Height = TexHeight / (1 << i);
- GLint s, t;
-
- for (s = 0; s < Width; s++) {
- for (t = 0; t < Height; t++) {
- tex2d[t*Width+s][0] = ((s / 16) % 2) ? 0 : 255;
- tex2d[t*Width+s][1] = ((t / 16) % 2) ? 0 : 255;
- tex2d[t*Width+s][2] = 128;
- tex2d[t*Width+s][3] = 255;
- }
- }
-
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-
- glTexImage2D(GL_TEXTURE_2D, i, GL_RGB, Width, Height, 0,
- GL_RGBA, GL_UNSIGNED_BYTE, tex2d);
- }
-}
-
-
-static void
-ResetTexture( void )
-{
-#if 0
- /* This doesn't work so well as the arch texture is 512x512.
- */
- LoadRGBMipmaps(TEXTURE_FILE, GL_RGB);
-#else
- {
- int i;
-
- for (i = 0; i <= LEVELS; i++)
- {
- ResetTextureLevel(i);
- }
- }
-#endif
-}
-
-
-
-
-
-
-
-static void
-RenderTexture( void )
-{
- GLenum status;
- GLuint MyFB;
-
- fprintf(stderr, "RenderTextureLevel %d\n", RenderTextureLevel);
- fflush(stderr);
-
- /* gen framebuffer id, delete it, do some assertions, just for testing */
- glGenFramebuffersEXT(1, &MyFB);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB);
- assert(glIsFramebufferEXT(MyFB));
-
- CheckError(__LINE__);
-
- /* Render color to texture */
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
- GL_COLOR_ATTACHMENT0_EXT,
- GL_TEXTURE_2D, TexObj,
- RenderTextureLevel);
-
-
-
- CheckError(__LINE__);
-
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glTranslatef(0.0, 0.0, -15.0);
-
- status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
- if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
- printf("Framebuffer incomplete!!!\n");
- }
-
- glViewport(0, 0,
- TexWidth / (1 << RenderTextureLevel),
- TexHeight / (1 << RenderTextureLevel));
-
- glClearColor(0.5, 0.5, 1.0, 0.0);
- glClear(GL_COLOR_BUFFER_BIT);
-
- CheckError(__LINE__);
-
- glBegin(GL_POLYGON);
- glColor3f(1, 0, 0);
- glVertex2f(-1, -1);
- glColor3f(0, 1, 0);
- glVertex2f(1, -1);
- glColor3f(0, 0, 1);
- glVertex2f(0, 1);
- glEnd();
-
-
- /* Bind normal framebuffer */
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- CheckError(__LINE__);
-
- glDeleteFramebuffersEXT(1, &MyFB);
- CheckError(__LINE__);
-
- glClearColor(0, 0, 0, 0);
-}
-
-static void
-Display(void)
-{
- int x, y, bias;
- char str[100];
- int texWidth = TexWidth, texHeight = TexHeight;
-
- glViewport(0, 0, WinHeight, WinHeight);
-
- glClear(GL_COLOR_BUFFER_BIT);
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glOrtho(0, WinWidth, 0, WinHeight, -1, 1);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
-
- glColor3f(1,1,1);
-
- if (Linear) {
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- }
- else {
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- }
-
- y = WinHeight - 300;
- x = 4;
-
- for (bias = -1; bias < 11; bias++) {
-
- if (ScaleQuads) {
- if (bias > 0) {
- if (texWidth == 1 && texHeight == 1)
- break;
- texWidth = TexWidth >> bias;
- texHeight = TexHeight >> bias;
- if (texWidth < 1)
- texWidth = 1;
- if (texHeight < 1)
- texHeight = 1;
- }
- glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0.0);
- }
- else {
- glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, bias);
- }
-
- glRasterPos2f(x, y + TexHeight + 5);
- if (ScaleQuads)
- sprintf(str, "Texture Level %d: %d x %d",
- (bias < 0 ? 0 : bias),
- texWidth, texHeight);
- else
- sprintf(str, "Texture LOD Bias = %d", bias);
- PrintString(str);
-
- glPushMatrix();
- glTranslatef(x, y, 0);
-
- glEnable(GL_TEXTURE_2D);
-
- glBegin(GL_POLYGON);
- glTexCoord2f(0, 0); glVertex2f(0, 0);
- glTexCoord2f(1, 0); glVertex2f(texWidth, 0);
- glTexCoord2f(1, 1); glVertex2f(texWidth, texHeight);
- glTexCoord2f(0, 1); glVertex2f(0, texHeight);
- glEnd();
-
- glPopMatrix();
-
- glDisable(GL_TEXTURE_2D);
-
- x += TexWidth + 4;
- if (x >= WinWidth) {
- x = 4;
- y -= 300;
- }
- }
-
- glutSwapBuffers();
-}
-
-
-static void
-Reshape(int width, int height)
-{
- WinWidth = width;
- WinHeight = height;
-}
-
-
-static void
-Key(unsigned char key, int x, int y)
-{
- (void) x;
- (void) y;
- switch (key) {
- case 'b':
- Bias -= 10;
- break;
- case 'B':
- Bias += 10;
- break;
- case 'l':
- Linear = !Linear;
- break;
- case 'v':
- RenderTextureLevel++;
- break;
- case 'V':
- RenderTextureLevel--;
- break;
- case 'r':
- RenderTexture();
- break;
- case 'X':
- ResetTexture();
- break;
- case 'x':
- ResetTextureLevel(RenderTextureLevel);
- break;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- Bias = 100.0 * (key - '0');
- break;
- case 's':
- ScaleQuads = !ScaleQuads;
- break;
- case ' ':
- MipGenTexture();
- Bias = 0;
- Linear = 0;
- RenderTextureLevel = 0;
- ScaleQuads = 0;
- break;
-
- case 27:
- glutDestroyWindow(Win);
- exit(0);
- break;
- }
- glutPostRedisplay();
-}
-
-
-static void
-Init(void)
-{
- GLfloat maxBias;
-
- if (!glutExtensionSupported("GL_EXT_texture_lod_bias")) {
- printf("Sorry, GL_EXT_texture_lod_bias not supported by this renderer.\n");
- exit(1);
- }
-
- if (!glutExtensionSupported("GL_SGIS_generate_mipmap")) {
- printf("Sorry, GL_SGIS_generate_mipmap not supported by this renderer.\n");
- exit(1);
- }
-
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-
- glGenTextures(1, &TexObj);
- glBindTexture(GL_TEXTURE_2D, TexObj);
-
- if (1)
- MipGenTexture();
- else
- ResetTexture();
-
- /* mipmapping required for this extension */
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-
- glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS_EXT, &maxBias);
-
- printf("GL_RENDERER: %s\n", (char*) glGetString(GL_RENDERER));
- printf("LOD bias range: [%g, %g]\n", -maxBias, maxBias);
-
- printf("Press 's' to toggle quad scaling\n");
-}
-
-
-int
-main(int argc, char *argv[])
-{
- glutInit(&argc, argv);
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(WinWidth, WinHeight);
- glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
- Win = glutCreateWindow(argv[0]);
- glewInit();
- glutReshapeFunc(Reshape);
- glutKeyboardFunc(Key);
- glutDisplayFunc(Display);
- Init();
- glutMainLoop();
- return 0;
-}
diff --git a/progs/tests/occlude.c b/progs/tests/occlude.c
deleted file mode 100644
index 8f7b90984e0..00000000000
--- a/progs/tests/occlude.c
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * GL_HP_occlustion_test demo
- *
- * Brian Paul
- * 31 March 2000
- *
- * Copyright (C) 2000 Brian Paul 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
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <GL/glut.h>
-#include <GL/glext.h>
-
-
-static GLfloat Xpos = 0;
-static GLboolean Anim = GL_TRUE;
-
-
-static void
-PrintString(const char *s)
-{
- while (*s) {
- glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int) *s);
- s++;
- }
-}
-
-
-
-static void Idle(void)
-{
- static int lastTime = 0;
- static int sign = +1;
- int time = glutGet(GLUT_ELAPSED_TIME);
- float step;
-
- if (lastTime == 0)
- lastTime = time;
- else if (time - lastTime < 20) /* 50Hz update */
- return;
-
- step = (time - lastTime) / 1000.0 * sign;
- lastTime = time;
-
- Xpos += step;
-
- if (Xpos > 2.5) {
- Xpos = 2.5;
- sign = -1;
- }
- else if (Xpos < -2.5) {
- Xpos = -2.5;
- sign = +1;
- }
- glutPostRedisplay();
-}
-
-
-static void Display( void )
-{
- GLboolean result;
-
- glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
-
- 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 );
-
- /* draw the occluding polygons */
- glColor3f(0, 0.6, 0.8);
- glBegin(GL_QUADS);
- glVertex2f(-1.6, -1.5);
- glVertex2f(-0.4, -1.5);
- glVertex2f(-0.4, 1.5);
- glVertex2f(-1.6, 1.5);
-
- glVertex2f( 0.4, -1.5);
- glVertex2f( 1.6, -1.5);
- glVertex2f( 1.6, 1.5);
- glVertex2f( 0.4, 1.5);
- glEnd();
-
- /* draw the test polygon with occlusion testing */
- glPushMatrix();
- glTranslatef(Xpos, 0, -0.5);
- glScalef(0.3, 0.3, 1.0);
- glRotatef(-90.0 * Xpos, 0, 0, 1);
-
- glEnable(GL_OCCLUSION_TEST_HP); /* NOTE: enabling the occlusion test */
- /* doesn't clear the result flag! */
- glColorMask(0, 0, 0, 0);
- glDepthMask(GL_FALSE);
- /* this call clear's the result flag. Not really needed for this demo. */
- glGetBooleanv(GL_OCCLUSION_TEST_RESULT_HP, &result);
-
- glBegin(GL_POLYGON);
- glVertex3f(-1, -1, 0);
- glVertex3f( 1, -1, 0);
- glVertex3f( 1, 1, 0);
- glVertex3f(-1, 1, 0);
- glEnd();
-
- glGetBooleanv(GL_OCCLUSION_TEST_RESULT_HP, &result);
- /* turn off occlusion testing */
- glDisable(GL_OCCLUSION_TEST_HP);
- glColorMask(1, 1, 1, 1);
- glDepthMask(GL_TRUE);
-
- /* draw the green rect, so we can see what's going on */
- glColor3f(0.8, 0.5, 0);
- glBegin(GL_POLYGON);
- glVertex3f(-1, -1, 0);
- glVertex3f( 1, -1, 0);
- glVertex3f( 1, 1, 0);
- glVertex3f(-1, 1, 0);
- glEnd();
-
- glPopMatrix();
-
-
- /* Print result message */
- glMatrixMode( GL_PROJECTION );
- glLoadIdentity();
- glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 );
- glMatrixMode( GL_MODELVIEW );
- glLoadIdentity();
-
- glColor3f(1, 1, 1);
- glRasterPos3f(-0.25, -0.7, 0);
-
- if (result)
- PrintString(" Visible");
- else
- PrintString("Fully Occluded");
-
- glutSwapBuffers();
-}
-
-
-static void Reshape( int width, int height )
-{
- glViewport( 0, 0, width, height );
-}
-
-
-static void Key( unsigned char key, int x, int y )
-{
- (void) x;
- (void) y;
- switch (key) {
- case 'a':
- Anim = !Anim;
- if (Anim)
- glutIdleFunc( Idle );
- else
- glutIdleFunc( NULL );
- break;
- case 27:
- exit(0);
- break;
- }
- glutPostRedisplay();
-}
-
-
-static void SpecialKey( int key, int x, int y )
-{
- const GLfloat step = 0.1;
- (void) x;
- (void) y;
- switch (key) {
- case GLUT_KEY_LEFT:
- Xpos -= step;
- break;
- case GLUT_KEY_RIGHT:
- Xpos += step;
- break;
- }
- glutPostRedisplay();
-}
-
-
-static void Init( void )
-{
- const char *ext = (const char *) glGetString(GL_EXTENSIONS);
- if (!strstr(ext, "GL_HP_occlusion_test")) {
- printf("Sorry, this demo requires the GL_HP_occlusion_test extension\n");
- exit(-1);
- }
-
- glEnable(GL_DEPTH_TEST);
-}
-
-
-int main( int argc, char *argv[] )
-{
- glutInit( &argc, argv );
- glutInitWindowPosition( 0, 0 );
- glutInitWindowSize( 400, 400 );
- glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
- glutCreateWindow(argv[0]);
- glutReshapeFunc( Reshape );
- glutKeyboardFunc( Key );
- glutSpecialFunc( SpecialKey );
- glutIdleFunc( Idle );
- glutDisplayFunc( Display );
- Init();
- glutMainLoop();
- return 0;
-}
diff --git a/progs/tests/quads.c b/progs/tests/quads.c
deleted file mode 100644
index 2098b51ccd2..00000000000
--- a/progs/tests/quads.c
+++ /dev/null
@@ -1,259 +0,0 @@
-/**
- * Draw colored quads.
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <GL/glew.h>
-#include <GL/glut.h>
-
-#define NUM_QUADS 20
-
-
-static int Win;
-static GLfloat Xrot = 40, Yrot = 0, Zrot = 0;
-static GLboolean Anim = GL_TRUE;
-static GLuint Vbuffer = 0;
-
-static GLfloat buf[NUM_QUADS * 6 * 4];
-
-static GLboolean doSwapBuffers = GL_TRUE;
-
-static GLint Frames = 0, T0 = 0;
-
-
-static void
-Idle(void)
-{
- Xrot += 3.0;
- Yrot += 4.0;
- Zrot += 2.0;
- glutPostRedisplay();
-}
-
-
-static void
-Draw(void)
-{
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- glPushMatrix();
- glRotatef(Xrot, 1, 0, 0);
- glRotatef(Yrot, 0, 1, 0);
- glRotatef(Zrot, 0, 0, 1);
-
- glDrawArrays(GL_QUADS, 0, NUM_QUADS*4);
-
- glPopMatrix();
-
- if (doSwapBuffers)
- glutSwapBuffers();
- /*
- else
- glFinish();
- */
-
- {
- GLint t = glutGet(GLUT_ELAPSED_TIME);
- Frames++;
- 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);
- T0 = t;
- Frames = 0;
- }
- }
-}
-
-
-static void
-Reshape(int width, int 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, -8.0);
-}
-
-
-static void
-Key(unsigned char key, int x, int y)
-{
- const GLfloat step = 3.0;
- (void) x;
- (void) y;
- switch (key) {
- case 's':
- doSwapBuffers = !doSwapBuffers;
- break;
- case 'a':
- Anim = !Anim;
- if (Anim)
- glutIdleFunc(Idle);
- else
- glutIdleFunc(NULL);
- break;
- 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();
-}
-
-
-static void
-quad(float x, float y, float z, float *v)
-{
- int k = 0;
-
- /* color */
- v[k++] = x * 0.5 + 0.5;
- v[k++] = y * 0.5 + 0.5;
- v[k++] = z * 0.5 + 0.5;
- /* vert */
- v[k++] = x;
- v[k++] = y;
- v[k++] = z;
-
- /* color */
- v[k++] = -x * 0.5 + 0.5;
- v[k++] = -y * 0.5 + 0.5;
- v[k++] = z * 0.5 + 0.5;
- /* vert */
- v[k++] = -x;
- v[k++] = -y;
- v[k++] = z;
-
- /* color */
- v[k++] = -x * 0.5 + 0.5;
- v[k++] = -y * 0.5 + 0.5;
- v[k++] = -z * 0.5 + 0.5;
- /* vert */
- v[k++] = -x;
- v[k++] = -y;
- v[k++] = -z;
-
- /* color */
- v[k++] = x * 0.5 + 0.5;
- v[k++] = y * 0.5 + 0.5;
- v[k++] = -z * 0.5 + 0.5;
- /* vert */
- v[k++] = x;
- v[k++] = y;
- v[k++] = -z;
-}
-
-static void
-gen_quads(GLfloat *buf)
-{
- float *v = buf;
- float r = 1.0;
- int i;
-
- for (i = 0; i < NUM_QUADS; i++) {
- float angle = i / (float) NUM_QUADS * M_PI;
- float x = r * cos(angle);
- float y = r * sin(angle);
- float z = 1.10;
- quad(x, y, z, v);
- v += 24;
- }
-
- if (0) {
- float *p = buf;
- for (i = 0; i < NUM_QUADS * 4 * 2; i++) {
- printf("%d: %f %f %f\n", i, p[0], p[1], p[2]);
- p += 3;
- }
- }
-}
-
-
-static void
-Init(void)
-{
- int bytes = NUM_QUADS * 4 * 2 * 3 * sizeof(float);
- GLfloat *f;
-
-#if 1
- glGenBuffers(1, &Vbuffer);
- glBindBuffer(GL_ARRAY_BUFFER, Vbuffer);
- glBufferData(GL_ARRAY_BUFFER_ARB, bytes, NULL, GL_STATIC_DRAW_ARB);
- f = (float *) glMapBuffer(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
- gen_quads(f);
- glUnmapBuffer(GL_ARRAY_BUFFER_ARB);
- glColorPointer(3, GL_FLOAT, 6*sizeof(float), (void *) 0);
- glVertexPointer(3, GL_FLOAT, 6*sizeof(float), (void *) 12);
-#else
- f = buf;
- gen_quads(f);
- glColorPointer(3, GL_FLOAT, 6*sizeof(float), buf);
- glVertexPointer(3, GL_FLOAT, 6*sizeof(float), buf + 3);
-#endif
-
- glEnableClientState(GL_COLOR_ARRAY);
- glEnableClientState(GL_VERTEX_ARRAY);
-
- glEnable(GL_DEPTH_TEST);
-
- glClearColor(0.5, 0.5, 0.5, 0.0);
-}
-
-
-int
-main(int argc, char *argv[])
-{
- glutInit(&argc, argv);
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(600, 600);
- glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
- Win = glutCreateWindow(argv[0]);
- glewInit();
- glutReshapeFunc(Reshape);
- glutKeyboardFunc(Key);
- glutSpecialFunc(SpecialKey);
- glutDisplayFunc(Draw);
- if (Anim)
- glutIdleFunc(Idle);
- Init();
- glutMainLoop();
- return 0;
-}
diff --git a/progs/tests/streaming_rect.c b/progs/tests/streaming_rect.c
deleted file mode 100644
index f65ac4ce36c..00000000000
--- a/progs/tests/streaming_rect.c
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * GL_ARB_pixel_buffer_object test
- *
- * Command line options:
- * -w WIDTH -h HEIGHT sets window size
- *
- */
-
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <GL/glew.h>
-#include <GL/glut.h>
-
-#include "readtex.h"
-
-
-#define ANIMATE 10
-#define PBO 11
-#define QUIT 100
-
-static GLuint DrawPBO;
-
-static GLboolean Animate = GL_TRUE;
-static GLboolean use_pbo = 1;
-static GLboolean whole_rect = 1;
-
-static GLfloat Drift = 0.0;
-static GLfloat drift_increment = 1/255.0;
-static GLfloat Xrot = 20.0, Yrot = 30.0;
-
-static GLuint Width = 1024;
-static GLuint Height = 512;
-
-
-static void Idle( void )
-{
- if (Animate) {
-
- Drift += drift_increment;
- if (Drift >= 1.0)
- Drift = 0.0;
-
- glutPostRedisplay();
- }
-}
-
-/*static int max( int a, int b ) { return a > b ? a : b; }*/
-
-#ifndef min
-static int min( int a, int b ) { return a < b ? a : b; }
-#endif
-
-static void DrawObject()
-{
- GLint size = Width * Height * 4;
-
- if (use_pbo) {
- /* XXX: This is extremely important - semantically makes the buffer
- * contents undefined, but in practice means that the driver can
- * release the old copy of the texture and allocate a new one
- * without waiting for outstanding rendering to complete.
- */
- glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, DrawPBO);
- glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_EXT, size, NULL, GL_STREAM_DRAW_ARB);
-
- {
- char *image = glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, GL_WRITE_ONLY_ARB);
-
- printf("char %d\n", (unsigned char)(Drift * 255));
-
- memset(image, (unsigned char)(Drift * 255), size);
-
- glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT);
- }
-
-
- /* BGRA is required for most hardware paths:
- */
- glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, Width, Height, 0,
- GL_BGRA, GL_UNSIGNED_BYTE, NULL);
- }
- else {
- static char *image = NULL;
-
- if (image == NULL)
- image = malloc(size);
-
- glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
-
- memset(image, (unsigned char)(Drift * 255), size);
-
- /* BGRA should be the fast path for regular uploads as well.
- */
- glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, Width, Height, 0,
- GL_BGRA, GL_UNSIGNED_BYTE, image);
- }
-
- {
- int x,y,w,h;
-
- if (whole_rect) {
- x = y = 0;
- w = Width;
- h = Height;
- }
- else {
- x = y = 0;
- w = min(10, Width);
- h = min(10, Height);
- }
-
- glBegin(GL_QUADS);
-
- glTexCoord2f( x, y);
- glVertex2f( x, y );
-
- glTexCoord2f( x, y + h);
- glVertex2f( x, y + h);
-
- glTexCoord2f( x + w + .5, y + h);
- glVertex2f( x + w, y + h );
-
- glTexCoord2f( x + w, y + .5);
- glVertex2f( x + w, y );
-
- glEnd();
- }
-}
-
-
-
-static void Display( void )
-{
- static GLint T0 = 0;
- static GLint Frames = 0;
- GLint t;
-
- glClear( GL_COLOR_BUFFER_BIT );
-
- glPushMatrix();
- DrawObject();
- glPopMatrix();
-
- glutSwapBuffers();
-
- Frames++;
-
- t = glutGet(GLUT_ELAPSED_TIME);
- if (t - T0 >= 1000) {
- 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);
-
- drift_increment = 2.2 * seconds / Frames;
- T0 = t;
- Frames = 0;
- }
-}
-
-
-static void Reshape( int width, int height )
-{
- glViewport( 0, 0, width, height );
- glMatrixMode( GL_PROJECTION );
- glLoadIdentity();
-/* glFrustum( -1.0, 1.0, -1.0, 1.0, 10.0, 100.0 ); */
- gluOrtho2D( 0, width, height, 0 );
- glMatrixMode( GL_MODELVIEW );
- glLoadIdentity();
- glTranslatef(0.375, 0.375, 0);
-}
-
-
-static void ModeMenu(int entry)
-{
- if (entry==ANIMATE) {
- Animate = !Animate;
- }
- else if (entry==PBO) {
- use_pbo = !use_pbo;
- }
- else if (entry==QUIT) {
- exit(0);
- }
-
- glutPostRedisplay();
-}
-
-
-static void Key( unsigned char key, int x, int y )
-{
- (void) x;
- (void) y;
- switch (key) {
- case 27:
- exit(0);
- break;
- }
- glutPostRedisplay();
-}
-
-
-static void SpecialKey( int key, int x, int y )
-{
- float 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();
-}
-
-
-static void Init( int argc, char *argv[] )
-{
- const char *exten = (const char *) glGetString(GL_EXTENSIONS);
- GLuint texObj;
- GLint size;
-
-
- if (!strstr(exten, "GL_ARB_pixel_buffer_object")) {
- printf("Sorry, GL_ARB_pixel_buffer_object not supported by this renderer.\n");
- exit(1);
- }
-
- glGetIntegerv(GL_MAX_TEXTURE_SIZE, &size);
- printf("%d x %d max texture size\n", size, size);
-
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-
- /* allocate two texture objects */
- glGenTextures(1, &texObj);
-
- /* setup the texture objects */
- glActiveTextureARB(GL_TEXTURE0_ARB);
- glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texObj);
-
- glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-
- glGenBuffersARB(1, &DrawPBO);
-
- glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, DrawPBO);
- glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_EXT,
- Width * Height * 4, NULL, GL_STREAM_DRAW);
-
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-
- glEnable(GL_TEXTURE_RECTANGLE_ARB);
-
- glShadeModel(GL_SMOOTH);
- glClearColor(0.3, 0.3, 0.4, 1.0);
-
- if (argc > 1 && strcmp(argv[1], "-info")==0) {
- printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
- printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
- printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
- printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
- }
-}
-
-
-int main( int argc, char *argv[] )
-{
- GLint i;
-
- glutInit( &argc, argv );
-
- for (i = 1; i < argc; i++) {
- if (strcmp(argv[i], "-w") == 0) {
- Width = atoi(argv[i+1]);
- if (Width <= 0) {
- printf("Error, bad width\n");
- exit(1);
- }
- i++;
- }
- else if (strcmp(argv[i], "-h") == 0) {
- Height = atoi(argv[i+1]);
- if (Height <= 0) {
- printf("Error, bad height\n");
- exit(1);
- }
- i++;
- }
- }
-
- glutInitWindowSize( Width, Height );
- glutInitWindowPosition( 0, 0 );
- glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
- glutCreateWindow(argv[0] );
- glewInit();
-
- Init( argc, argv );
-
- glutReshapeFunc( Reshape );
- glutKeyboardFunc( Key );
- glutSpecialFunc( SpecialKey );
- glutDisplayFunc( Display );
- glutIdleFunc( Idle );
-
- glutCreateMenu(ModeMenu);
- glutAddMenuEntry("Toggle Animation", ANIMATE);
- glutAddMenuEntry("Toggle PBO", PBO);
- glutAddMenuEntry("Quit", QUIT);
- glutAttachMenu(GLUT_RIGHT_BUTTON);
-
- glutMainLoop();
- return 0;
-}
diff --git a/progs/tests/subtex.c b/progs/tests/subtex.c
deleted file mode 100644
index 86b737c01fa..00000000000
--- a/progs/tests/subtex.c
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Test glTexSubImage mid-way through a frame.
- *
- * The same texture is used for both quads but it gets redefined
- * with glTexSubImage (or glTexImage) after the first quad.
- */
-
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "GL/glew.h"
-#include "GL/glut.h"
-
-static GLuint Window = 0;
-static GLboolean Anim = GL_FALSE;
-static GLfloat Angle = 0.0f;
-
-
-
-static void
-first_texture(void)
-{
- static int width=8, height=8;
- static GLubyte tex1[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 1, 0, 0, 0,
- 0, 0, 0, 1, 1, 0, 0, 0,
- 0, 0, 0, 0, 1, 0, 0, 0,
- 0, 0, 0, 0, 1, 0, 0, 0,
- 0, 0, 0, 0, 1, 0, 0, 0,
- 0, 0, 0, 1, 1, 1, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0 };
-
- GLubyte tex[64][3];
- GLint i, j;
-
- /* red on white */
- for (i=0;i<height;i++) {
- for (j=0;j<width;j++) {
- int p = i*width+j;
- if (tex1[(height-i-1)*width+j]) {
- tex[p][0] = 255; tex[p][1] = 0; tex[p][2] = 0;
- }
- else {
- tex[p][0] = 255; tex[p][1] = 255; tex[p][2] = 255;
- }
- }
- }
-
- glTexImage2D( GL_TEXTURE_2D, 0, 3, width, height, 0,
- GL_RGB, GL_UNSIGNED_BYTE, tex );
-}
-
-
-static void
-second_texture(void)
-{
- static int width=8, height=8;
-
- static GLubyte tex2[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 2, 2, 0, 0, 0,
- 0, 0, 2, 0, 0, 2, 0, 0,
- 0, 0, 0, 0, 0, 2, 0, 0,
- 0, 0, 0, 0, 2, 0, 0, 0,
- 0, 0, 0, 2, 0, 0, 0, 0,
- 0, 0, 2, 2, 2, 2, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0 };
-
- GLubyte tex[64][3];
- GLint i, j;
-
- /* green on blue */
- for (i=0;i<height;i++) {
- for (j=0;j<width;j++) {
- int p = i*width+j;
- if (tex2[(height-i-1)*width+j]) {
- tex[p][0] = 0; tex[p][1] = 255; tex[p][2] = 0;
- }
- else {
- tex[p][0] = 0; tex[p][1] = 0; tex[p][2] = 255;
- }
- }
- }
-#if 0
- glTexImage2D( GL_TEXTURE_2D, 0, 3, width, height, 0,
- GL_RGB, GL_UNSIGNED_BYTE, tex );
-#else
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height,
- GL_RGB, GL_UNSIGNED_BYTE, tex );
-#endif
-}
-
-
-
-static void draw( void )
-{
- glClear( GL_COLOR_BUFFER_BIT );
-
- glColor3f( 1.0, 1.0, 1.0 );
-
- /* draw first polygon */
- glPushMatrix();
- glTranslatef( -1.0, 0.0, 0.0 );
- glRotatef( Angle, 0.0, 0.0, 1.0 );
-
- first_texture();
-
- glBegin( GL_POLYGON );
- glTexCoord2f( 0.0, 0.0 ); glVertex2f( -1.0, -1.0 );
- glTexCoord2f( 1.0, 0.0 ); glVertex2f( 1.0, -1.0 );
- glTexCoord2f( 1.0, 1.0 ); glVertex2f( 1.0, 1.0 );
- glTexCoord2f( 0.0, 1.0 ); glVertex2f( -1.0, 1.0 );
- glEnd();
- glPopMatrix();
-
- /* draw second polygon */
- glPushMatrix();
- glTranslatef( 1.0, 0.0, 0.0 );
- glRotatef( Angle-90.0, 0.0, 1.0, 0.0 );
-
- second_texture();
-
- glBegin( GL_POLYGON );
- glTexCoord2f( 0.0, 0.0 ); glVertex2f( -1.0, -1.0 );
- glTexCoord2f( 1.0, 0.0 ); glVertex2f( 1.0, -1.0 );
- glTexCoord2f( 1.0, 1.0 ); glVertex2f( 1.0, 1.0 );
- glTexCoord2f( 0.0, 1.0 ); glVertex2f( -1.0, 1.0 );
- glEnd();
- glPopMatrix();
-
- glutSwapBuffers();
-}
-
-
-
-static void idle( void )
-{
- static double t0 = -1.;
- double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
- if (t0 < 0.0)
- t0 = t;
- dt = t - t0;
- t0 = t;
- Angle += 120.0*dt;
- glutPostRedisplay();
-}
-
-
-
-/* change view Angle, exit upon ESC */
-static void key(unsigned char k, int x, int y)
-{
- (void) x;
- (void) y;
- switch (k) {
- case 'a':
- Anim = !Anim;
- if (Anim)
- glutIdleFunc( idle );
- else
- glutIdleFunc( NULL );
- break;
- case 27:
- glutDestroyWindow(Window);
- exit(0);
- }
-}
-
-
-
-/* new window size or exposure */
-static void reshape( int width, int height )
-{
- glViewport(0, 0, (GLint)width, (GLint)height);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- /* glOrtho( -3.0, 3.0, -3.0, 3.0, -10.0, 10.0 );*/
- glFrustum( -2.0, 2.0, -2.0, 2.0, 6.0, 20.0 );
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glTranslatef( 0.0, 0.0, -8.0 );
-}
-
-
-static void init( void )
-{
- /* Setup texturing */
- glEnable( GL_TEXTURE_2D );
- glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
-
-
- glBindTexture( GL_TEXTURE_2D, 0 );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
-}
-
-
-
-int main( int argc, char *argv[] )
-{
- glutInit(&argc, argv);
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(300, 300);
- glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
-
- Window = glutCreateWindow("Texture Objects");
- glewInit();
- if (!Window) {
- exit(1);
- }
-
- init();
-
- glutReshapeFunc( reshape );
- glutKeyboardFunc( key );
- if (Anim)
- glutIdleFunc( idle );
- glutDisplayFunc( draw );
- glutMainLoop();
- return 0;
-}
diff --git a/progs/tests/texdown.c b/progs/tests/texdown.c
deleted file mode 100644
index 7e460458325..00000000000
--- a/progs/tests/texdown.c
+++ /dev/null
@@ -1,477 +0,0 @@
-
-/*
- * Copyright (C) 1999 Brian Paul 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
- * BRIAN PAUL 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.
- */
-
-
-/*
- * texdown
- *
- * Measure texture download speed.
- * Use keyboard to change texture size, format, datatype, scale/bias,
- * subimageload, etc.
- *
- * Brian Paul 28 January 2000
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <GL/glut.h>
-
-
-static GLsizei MaxSize = 2048;
-static GLsizei TexWidth = 1024, TexHeight = 1024, TexBorder = 0;
-static GLboolean ScaleAndBias = GL_FALSE;
-static GLboolean SubImage = GL_FALSE;
-static GLdouble DownloadRate = 0.0; /* texels/sec */
-
-static GLuint Mode = 0;
-
-
-/* Try and avoid L2 cache effects by cycling through a small number of
- * textures.
- *
- * At the initial size of 1024x1024x4 == 4mbyte, say 8 textures will
- * keep us out of most caches at 32mb total.
- *
- * This turns into a fairly interesting question of what exactly you
- * expect to be in cache in normal usage, and what you think should be
- * outside. There's no rules for this, no reason to favour one usage
- * over another except what the application you care about happens to
- * resemble most closely.
- *
- * - Should the client texture image be in L2 cache? Has it just been
- * generated or read from disk?
- * - Does the application really use >1 texture, or is it constantly
- * updating one image in-place?
- *
- * Different answers will favour different texture upload mechanisms.
- * To upload an image that is purely outside of cache, a DMA-based
- * upload will probably win, whereas for small, in-cache textures,
- * copying looks good.
- */
-#define NR_TEXOBJ 4
-static GLuint TexObj[NR_TEXOBJ];
-
-
-struct FormatRec {
- GLenum Format;
- GLenum Type;
- GLenum IntFormat;
- GLint TexelSize;
-};
-
-
-static const struct FormatRec FormatTable[] = {
- /* Format Type IntFormat TexelSize */
- { GL_BGRA, GL_UNSIGNED_BYTE, GL_RGBA, 4 },
- { GL_RGB, GL_UNSIGNED_BYTE, GL_RGB, 3 },
- { GL_RGBA, GL_UNSIGNED_BYTE, GL_RGBA, 4 },
- { GL_RGBA, GL_UNSIGNED_BYTE, GL_RGB, 4 },
- { GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_RGB, 2 },
- { GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_LUMINANCE, 1 },
- { GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_LUMINANCE_ALPHA, 2 },
- { GL_ALPHA, GL_UNSIGNED_BYTE, GL_ALPHA, 1 },
-};
-static GLint Format;
-
-#define NUM_FORMATS (sizeof(FormatTable)/sizeof(FormatTable[0]))
-
-static int
-BytesPerTexel(GLint format)
-{
- return FormatTable[format].TexelSize;
-}
-
-
-static const char *
-FormatStr(GLenum format)
-{
- switch (format) {
- case GL_RGB:
- return "GL_RGB";
- case GL_RGBA:
- return "GL_RGBA";
- case GL_BGRA:
- return "GL_BGRA";
- case GL_LUMINANCE:
- return "GL_LUMINANCE";
- case GL_LUMINANCE_ALPHA:
- return "GL_LUMINANCE_ALPHA";
- case GL_ALPHA:
- return "GL_ALPHA";
- default:
- return "";
- }
-}
-
-
-static const char *
-TypeStr(GLenum type)
-{
- switch (type) {
- case GL_UNSIGNED_BYTE:
- return "GL_UNSIGNED_BYTE";
- case GL_UNSIGNED_SHORT:
- return "GL_UNSIGNED_SHORT";
- case GL_UNSIGNED_SHORT_5_6_5:
- return "GL_UNSIGNED_SHORT_5_6_5";
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- return "GL_UNSIGNED_SHORT_5_6_5_REV";
- default:
- return "";
- }
-}
-
-/* On x86, there is a performance cliff for memcpy to texture memory
- * for sources below 64 byte alignment. We do our best with this in
- * the driver, but it is better if the images are correctly aligned to
- * start with:
- */
-#define ALIGN (1<<12)
-
-static unsigned long align(unsigned long value, unsigned long a)
-{
- return (value + a - 1) & ~(a-1);
-}
-
-static void
-MeasureDownloadRate(void)
-{
- const int w = TexWidth + 2 * TexBorder;
- const int h = TexHeight + 2 * TexBorder;
- const int image_bytes = align(w * h * BytesPerTexel(Format), ALIGN);
- const int bytes = image_bytes * NR_TEXOBJ;
- GLubyte *orig_texImage, *orig_getImage;
- GLubyte *texImage, *getImage;
- GLdouble t0, t1, time;
- int count;
- int i;
- int offset = 0;
- GLdouble total = 0; /* ints will tend to overflow */
-
- printf("allocating %d bytes for %d %dx%d images\n",
- bytes, NR_TEXOBJ, w, h);
-
- orig_texImage = (GLubyte *) malloc(bytes + ALIGN);
- orig_getImage = (GLubyte *) malloc(image_bytes + ALIGN);
- if (!orig_texImage || !orig_getImage) {
- DownloadRate = 0.0;
- return;
- }
-
- printf("alloc %p %p\n", orig_texImage, orig_getImage);
-
- texImage = (GLubyte *)align((unsigned long)orig_texImage, ALIGN);
- getImage = (GLubyte *)align((unsigned long)orig_getImage, ALIGN);
-
- for (i = 1; !(((unsigned long)texImage) & i); i<<=1)
- ;
- printf("texture image alignment: %d bytes (%p)\n", i, texImage);
-
- for (i = 0; i < bytes; i++) {
- texImage[i] = i & 0xff;
- }
-
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glPixelStorei(GL_PACK_ALIGNMENT, 1);
-
- if (ScaleAndBias) {
- glPixelTransferf(GL_RED_SCALE, 0.5);
- glPixelTransferf(GL_GREEN_SCALE, 0.5);
- glPixelTransferf(GL_BLUE_SCALE, 0.5);
- glPixelTransferf(GL_RED_BIAS, 0.5);
- glPixelTransferf(GL_GREEN_BIAS, 0.5);
- glPixelTransferf(GL_BLUE_BIAS, 0.5);
- }
- else {
- 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);
- }
-
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glEnable(GL_TEXTURE_2D);
-
- count = 0;
- t0 = glutGet(GLUT_ELAPSED_TIME) * 0.001;
- do {
- int img = count%NR_TEXOBJ;
- GLubyte *img_ptr = texImage + img * image_bytes;
-
- glBindTexture(GL_TEXTURE_2D, TexObj[img]);
-
- if (SubImage && count > 0) {
- /* Only update a portion of the image each iteration. This
- * is presumably why you'd want to use texsubimage, otherwise
- * you may as well just call teximage again.
- *
- * A bigger question is whether to use a pointer that moves
- * with each call, ie does the incoming data come from L2
- * cache under normal circumstances, or is it pulled from
- * uncached memory?
- *
- * There's a good argument to say L2 cache, ie you'd expect
- * the data to have been recently generated. It's possible
- * that it could have come from a file read, which may or may
- * not have gone through the cpu.
- */
- glTexSubImage2D(GL_TEXTURE_2D, 0,
- -TexBorder,
- -TexBorder + offset * h/8,
- w,
- h/8,
- FormatTable[Format].Format,
- FormatTable[Format].Type,
-#if 1
- texImage /* likely in L2$ */
-#else
- img_ptr + offset * bytes/8 /* unlikely in L2$ */
-#endif
- );
- offset += 1;
- offset %= 8;
- total += w * h / 8;
- }
- else {
- glTexImage2D(GL_TEXTURE_2D, 0,
- FormatTable[Format].IntFormat, w, h, TexBorder,
- FormatTable[Format].Format,
- FormatTable[Format].Type,
- img_ptr);
- total += w*h;
- }
-
- /* draw a tiny polygon to force texture into texram */
- glBegin(GL_TRIANGLES);
- glTexCoord2f(0, 0); glVertex2f(1, 1);
- glTexCoord2f(1, 0); glVertex2f(3, 1);
- glTexCoord2f(0.5, 1); glVertex2f(2, 3);
- glEnd();
-
- t1 = glutGet(GLUT_ELAPSED_TIME) * 0.001;
- time = t1 - t0;
- count++;
- } while (time < 3.0);
-
- glDisable(GL_TEXTURE_2D);
-
- printf("total texels=%f time=%f\n", total, time);
- DownloadRate = total / time;
-
-
- free(orig_texImage);
- free(orig_getImage);
-
- {
- GLint err = glGetError();
- if (err)
- printf("GL error %d\n", err);
- }
-}
-
-
-static void
-PrintString(const char *s)
-{
- while (*s) {
- glutBitmapCharacter(GLUT_BITMAP_8_BY_13, (int) *s);
- s++;
- }
-}
-
-
-static void
-Display(void)
-{
- const int w = TexWidth + 2 * TexBorder;
- const int h = TexHeight + 2 * TexBorder;
- char s[1000];
-
- glClear(GL_COLOR_BUFFER_BIT);
-
- glRasterPos2i(10, 80);
- sprintf(s, "Texture size[cursor]: %d x %d Border[b]: %d", w, h, TexBorder);
- PrintString(s);
-
- glRasterPos2i(10, 65);
- sprintf(s, "Format[f]: %s Type: %s IntFormat: %s",
- FormatStr(FormatTable[Format].Format),
- TypeStr( FormatTable[Format].Type),
- FormatStr(FormatTable[Format].IntFormat));
- PrintString(s);
-
- glRasterPos2i(10, 50);
- sprintf(s, "Pixel Scale&Bias[p]: %s TexSubImage[s]: %s",
- ScaleAndBias ? "Yes" : "No",
- SubImage ? "Yes" : "No");
- PrintString(s);
-
- if (Mode == 0) {
- glRasterPos2i(200, 10);
- sprintf(s, "...Measuring...");
- PrintString(s);
- glutSwapBuffers();
- glutPostRedisplay();
- Mode++;
- }
- else if (Mode == 1) {
- MeasureDownloadRate();
- glutPostRedisplay();
- Mode++;
- }
- else {
- /* show results */
- glRasterPos2i(10, 10);
- sprintf(s, "Download rate: %g Mtexels/second %g MB/second",
- DownloadRate / 1000000.0,
- DownloadRate * BytesPerTexel(Format) / 1000000.0);
- PrintString(s);
- {
- GLint r, g, b, a, l, i;
- glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &r);
- glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_SIZE, &g);
- glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_SIZE, &b);
- glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE, &a);
- glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_LUMINANCE_SIZE, &l);
- glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTENSITY_SIZE, &i);
- sprintf(s, "TexelBits: R=%d G=%d B=%d A=%d L=%d I=%d", r, g, b, a, l, i);
- glRasterPos2i(10, 25);
- PrintString(s);
- }
-
- glutSwapBuffers();
- }
-}
-
-
-static void
-Reshape(int width, int height)
-{
- glViewport( 0, 0, width, height );
- glMatrixMode( GL_PROJECTION );
- glLoadIdentity();
- glOrtho(0, width, 0, height, -1, 1);
- glMatrixMode( GL_MODELVIEW );
- glLoadIdentity();
-}
-
-
-
-static void
-Key(unsigned char key, int x, int y)
-{
- (void) x;
- (void) y;
- switch (key) {
- case ' ':
- Mode = 0;
- break;
- case 'b':
- /* toggle border */
- TexBorder = 1 - TexBorder;
- Mode = 0;
- break;
- case 'f':
- /* change format */
- Format = (Format + 1) % NUM_FORMATS;
- Mode = 0;
- break;
- case 'F':
- /* change format */
- Format = (Format - 1) % NUM_FORMATS;
- Mode = 0;
- break;
- case 'p':
- /* toggle border */
- ScaleAndBias = !ScaleAndBias;
- Mode = 0;
- break;
- case 's':
- SubImage = !SubImage;
- Mode = 0;
- break;
- case 27:
- exit(0);
- break;
- }
- glutPostRedisplay();
-}
-
-
-static void
-SpecialKey(int key, int x, int y)
-{
- (void) x;
- (void) y;
- switch (key) {
- case GLUT_KEY_UP:
- if (TexHeight < MaxSize)
- TexHeight *= 2;
- break;
- case GLUT_KEY_DOWN:
- if (TexHeight > 1)
- TexHeight /= 2;
- break;
- case GLUT_KEY_LEFT:
- if (TexWidth > 1)
- TexWidth /= 2;
- break;
- case GLUT_KEY_RIGHT:
- if (TexWidth < MaxSize)
- TexWidth *= 2;
- break;
- }
- Mode = 0;
- glutPostRedisplay();
-}
-
-
-static void
-Init(void)
-{
- printf("GL_VENDOR = %s\n", (const char *) glGetString(GL_VENDOR));
- printf("GL_VERSION = %s\n", (const char *) glGetString(GL_VERSION));
- printf("GL_RENDERER = %s\n", (const char *) glGetString(GL_RENDERER));
-}
-
-
-int
-main(int argc, char *argv[])
-{
- glutInit( &argc, argv );
- glutInitWindowPosition( 0, 0 );
- glutInitWindowSize( 600, 100 );
- glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
- glutCreateWindow(argv[0]);
- glutReshapeFunc( Reshape );
- glutKeyboardFunc( Key );
- glutSpecialFunc( SpecialKey );
- glutDisplayFunc( Display );
- Init();
- glutMainLoop();
- return 0;
-}
diff --git a/progs/tests/texobj.c b/progs/tests/texobj.c
deleted file mode 100644
index 40bce6e5695..00000000000
--- a/progs/tests/texobj.c
+++ /dev/null
@@ -1,284 +0,0 @@
-
-/*
- * Example of using the 1.1 texture object functions.
- * Also, this demo utilizes Mesa's fast texture map path.
- *
- * Brian Paul June 1996 This file is in the public domain.
- */
-
-#include <assert.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "GL/glut.h"
-
-static GLuint Window = 0;
-
-static GLuint TexObj[2];
-static GLfloat Angle = 0.0f;
-static GLboolean UseObj = GL_FALSE;
-
-
-#if defined(GL_VERSION_1_1) || defined(GL_VERSION_1_2)
-# define TEXTURE_OBJECT 1
-#elif defined(GL_EXT_texture_object)
-# define TEXTURE_OBJECT 1
-# define glBindTexture(A,B) glBindTextureEXT(A,B)
-# define glGenTextures(A,B) glGenTexturesEXT(A,B)
-# define glDeleteTextures(A,B) glDeleteTexturesEXT(A,B)
-#endif
-
-
-
-
-static void draw( void )
-{
- glClear( GL_COLOR_BUFFER_BIT );
-
- glColor3f( 1.0, 1.0, 1.0 );
-
- /* draw first polygon */
- glPushMatrix();
- glTranslatef( -1.0, 0.0, 0.0 );
- glRotatef( Angle, 0.0, 0.0, 1.0 );
- if (UseObj) {
-#ifdef TEXTURE_OBJECT
- glBindTexture( GL_TEXTURE_2D, TexObj[0] );
-#endif
- }
- else {
- glCallList( TexObj[0] );
- }
- glBegin( GL_POLYGON );
- glTexCoord2f( 0.0, 0.0 ); glVertex2f( -1.0, -1.0 );
- glTexCoord2f( 1.0, 0.0 ); glVertex2f( 1.0, -1.0 );
- glTexCoord2f( 1.0, 1.0 ); glVertex2f( 1.0, 1.0 );
- glTexCoord2f( 0.0, 1.0 ); glVertex2f( -1.0, 1.0 );
- glEnd();
- glPopMatrix();
-
- /* draw second polygon */
- glPushMatrix();
- glTranslatef( 1.0, 0.0, 0.0 );
- glRotatef( Angle-90.0, 0.0, 1.0, 0.0 );
- if (UseObj) {
-#ifdef TEXTURE_OBJECT
- glBindTexture( GL_TEXTURE_2D, TexObj[1] );
-#endif
- }
- else {
- glCallList( TexObj[1] );
- }
- glBegin( GL_POLYGON );
- glTexCoord2f( 0.0, 0.0 ); glVertex2f( -1.0, -1.0 );
- glTexCoord2f( 1.0, 0.0 ); glVertex2f( 1.0, -1.0 );
- glTexCoord2f( 1.0, 1.0 ); glVertex2f( 1.0, 1.0 );
- glTexCoord2f( 0.0, 1.0 ); glVertex2f( -1.0, 1.0 );
- glEnd();
- glPopMatrix();
-
- glutSwapBuffers();
-}
-
-
-
-static void idle( void )
-{
- static double t0 = -1.;
- double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
- if (t0 < 0.0)
- t0 = t;
- dt = t - t0;
- t0 = t;
- Angle += 120.0*dt;
- glutPostRedisplay();
-}
-
-
-
-/* change view Angle, exit upon ESC */
-static void key(unsigned char k, int x, int y)
-{
- (void) x;
- (void) y;
- switch (k) {
- case 27:
-#ifdef TEXTURE_OBJECT
- glDeleteTextures( 2, TexObj );
-#endif
- glutDestroyWindow(Window);
- exit(0);
- }
-}
-
-
-
-/* new window size or exposure */
-static void reshape( int width, int height )
-{
- glViewport(0, 0, (GLint)width, (GLint)height);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- /* glOrtho( -3.0, 3.0, -3.0, 3.0, -10.0, 10.0 );*/
- glFrustum( -2.0, 2.0, -2.0, 2.0, 6.0, 20.0 );
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glTranslatef( 0.0, 0.0, -8.0 );
-}
-
-
-static void init( void )
-{
- static int width=8, height=8;
- static GLubyte tex1[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 1, 0, 0, 0,
- 0, 0, 0, 1, 1, 0, 0, 0,
- 0, 0, 0, 0, 1, 0, 0, 0,
- 0, 0, 0, 0, 1, 0, 0, 0,
- 0, 0, 0, 0, 1, 0, 0, 0,
- 0, 0, 0, 1, 1, 1, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0 };
-
- static GLubyte tex2[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 2, 2, 0, 0, 0,
- 0, 0, 2, 0, 0, 2, 0, 0,
- 0, 0, 0, 0, 0, 2, 0, 0,
- 0, 0, 0, 0, 2, 0, 0, 0,
- 0, 0, 0, 2, 0, 0, 0, 0,
- 0, 0, 2, 2, 2, 2, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0 };
-
- GLubyte tex[64][3];
- GLint i, j;
-
-
- glDisable( GL_DITHER );
-
- /* Setup texturing */
- glEnable( GL_TEXTURE_2D );
- glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
- glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST );
-
-
- /* generate texture object IDs */
- if (UseObj) {
-#ifdef TEXTURE_OBJECT
- glGenTextures( 2, TexObj );
-#endif
- }
- else {
- TexObj[0] = glGenLists(2);
- TexObj[1] = TexObj[0]+1;
- }
-
- /* setup first texture object */
- if (UseObj) {
-#ifdef TEXTURE_OBJECT
- glBindTexture( GL_TEXTURE_2D, TexObj[0] );
- assert(glIsTexture(TexObj[0]));
-#endif
- }
- else {
- glNewList( TexObj[0], GL_COMPILE );
- }
- /* red on white */
- for (i=0;i<height;i++) {
- for (j=0;j<width;j++) {
- int p = i*width+j;
- if (tex1[(height-i-1)*width+j]) {
- tex[p][0] = 255; tex[p][1] = 0; tex[p][2] = 0;
- }
- else {
- tex[p][0] = 255; tex[p][1] = 255; tex[p][2] = 255;
- }
- }
- }
-
- glTexImage2D( GL_TEXTURE_2D, 0, 3, width, height, 0,
- GL_RGB, GL_UNSIGNED_BYTE, tex );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
- if (!UseObj) {
- glEndList();
- }
- /* end of texture object */
-
- /* setup second texture object */
- if (UseObj) {
-#ifdef TEXTURE_OBJECT
- glBindTexture( GL_TEXTURE_2D, TexObj[1] );
- assert(glIsTexture(TexObj[1]));
-#endif
- assert(!glIsTexture(TexObj[1] + 999));
- }
- else {
- glNewList( TexObj[1], GL_COMPILE );
- }
- /* green on blue */
- for (i=0;i<height;i++) {
- for (j=0;j<width;j++) {
- int p = i*width+j;
- if (tex2[(height-i-1)*width+j]) {
- tex[p][0] = 0; tex[p][1] = 255; tex[p][2] = 0;
- }
- else {
- tex[p][0] = 0; tex[p][1] = 0; tex[p][2] = 255;
- }
- }
- }
- glTexImage2D( GL_TEXTURE_2D, 0, 3, width, height, 0,
- GL_RGB, GL_UNSIGNED_BYTE, tex );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
- glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
- if (!UseObj) {
- glEndList();
- }
- /* end texture object */
-
-}
-
-
-
-int main( int argc, char *argv[] )
-{
- glutInit(&argc, argv);
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(300, 300);
- glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
-
- Window = glutCreateWindow("Texture Objects");
- if (!Window) {
- exit(1);
- }
-
- /* check that renderer has the GL_EXT_texture_object extension
- * or supports OpenGL 1.1
- */
-#ifdef TEXTURE_OBJECT
- {
- char *exten = (char *) glGetString( GL_EXTENSIONS );
- char *version = (char *) glGetString( GL_VERSION );
- if ( strstr( exten, "GL_EXT_texture_object" )
- || strncmp( version, "1.1", 3 )==0
- || strncmp( version, "1.2", 3 )==0 ) {
- UseObj = GL_TRUE;
- }
- }
-#endif
-
- init();
-
- glutReshapeFunc( reshape );
- glutKeyboardFunc( key );
- glutIdleFunc( idle );
- glutDisplayFunc( draw );
- glutMainLoop();
- return 0;
-}
diff --git a/progs/tests/zcomp.c b/progs/tests/zcomp.c
deleted file mode 100644
index 15e35f17b09..00000000000
--- a/progs/tests/zcomp.c
+++ /dev/null
@@ -1,224 +0,0 @@
-/**
- * Test Z compositing with glDrawPixels(GL_DEPTH_COMPONENT) and stencil test.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <GL/glew.h>
-#include <GL/glut.h>
-#include "../util/showbuffer.c"
-
-
-static int Win;
-static GLfloat Xrot = 0, Yrot = 0, Zpos = 6;
-static GLboolean Anim = GL_FALSE;
-
-static int Width = 400, Height = 200;
-static GLfloat *Zimg;
-static GLubyte *Cimg;
-static GLboolean showZ = 0;
-
-
-static void
-Idle(void)
-{
- Xrot += 3.0;
- Yrot += 4.0;
- glutPostRedisplay();
-}
-
-
-/**
- * Draw first object, save color+Z images
- */
-static void
-DrawFirst(void)
-{
- static const GLfloat red[4] = { 1.0, 0.0, 0.0, 0.0 };
-
- glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, red);
-
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- glPushMatrix();
- glTranslatef(-1, 0, 0);
- glRotatef(45 + Xrot, 1, 0, 0);
-
- glutSolidTorus(0.75, 2.0, 10, 20);
-
- glPopMatrix();
-
- glReadPixels(0, 0, Width, Height, GL_DEPTH_COMPONENT, GL_FLOAT, Zimg);
- glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, Cimg);
-}
-
-
-/**
- * Draw second object.
- */
-static void
-DrawSecond(void)
-{
- static const GLfloat blue[4] = { 0.0, 0.0, 1.0, 0.0 };
-
- glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, blue);
-
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
-
- glPushMatrix();
- glTranslatef(+1, 0, 0);
- glRotatef(-45 + Xrot, 1, 0, 0);
-
- glutSolidTorus(0.75, 2.0, 10, 20);
-
- glPopMatrix();
-}
-
-
-/**
- * Composite first/saved image over second rendering.
- */
-static void
-Composite(void)
-{
- glWindowPos2i(0, 0);
-
- /* Draw Z values, set stencil where Z test passes */
- glEnable(GL_STENCIL_TEST);
- glStencilFunc(GL_ALWAYS, 1, ~0);
- glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
- glColorMask(0,0,0,0);
- glDrawPixels(Width, Height, GL_DEPTH_COMPONENT, GL_FLOAT, Zimg);
- glColorMask(1,1,1,1);
-
- /* Draw color where stencil==1 */
- glStencilFunc(GL_EQUAL, 1, ~0);
- glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
- glDisable(GL_DEPTH_TEST);
- glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, Cimg);
- glEnable(GL_DEPTH_TEST);
-
- glDisable(GL_STENCIL_TEST);
-}
-
-
-static void
-Draw(void)
-{
- DrawFirst();
- DrawSecond();
- Composite();
- glutSwapBuffers();
-}
-
-
-static void
-Reshape(int width, int height)
-{
- GLfloat ar = (float) width / height;
- glViewport(0, 0, width, height);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glFrustum(-ar, ar, -1.0, 1.0, 5.0, 30.0);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glTranslatef(0.0, 0.0, -15.0);
-
- Width = width;
- Height = height;
-
- if (Zimg)
- free(Zimg);
- if (Cimg)
- free(Cimg);
- Zimg = (float *) malloc(width * height * 4);
- Cimg = (GLubyte *) malloc(width * height * 4);
-}
-
-
-static void
-Key(unsigned char key, int x, int y)
-{
- const GLfloat step = 1.0;
- (void) x;
- (void) y;
- switch (key) {
- case 'a':
- Anim = !Anim;
- if (Anim)
- glutIdleFunc(Idle);
- else
- glutIdleFunc(NULL);
- break;
- case 'd':
- showZ = !showZ;
- break;
- case 'z':
- Zpos -= step;
- break;
- case 'Z':
- Zpos += 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();
-}
-
-
-static void
-Init(void)
-{
- /* setup lighting, etc */
- glEnable(GL_DEPTH_TEST);
- glEnable(GL_LIGHTING);
- glEnable(GL_LIGHT0);
-}
-
-
-int
-main(int argc, char *argv[])
-{
- glutInit(&argc, argv);
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(Width, Height);
- glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL);
- Win = glutCreateWindow(argv[0]);
- glewInit();
- glutReshapeFunc(Reshape);
- glutKeyboardFunc(Key);
- glutSpecialFunc(SpecialKey);
- glutDisplayFunc(Draw);
- if (Anim)
- glutIdleFunc(Idle);
- Init();
- glutMainLoop();
- return 0;
-}
diff --git a/progs/tests/zdrawpix.c b/progs/tests/zdrawpix.c
deleted file mode 100644
index ba7da571ebf..00000000000
--- a/progs/tests/zdrawpix.c
+++ /dev/null
@@ -1,193 +0,0 @@
-/**
- * Test glDrawPixels(GL_DEPTH_COMPONENT)
- *
- * We load a window-sized buffer of Z values so that Z=1 at the top and
- * Z=0 at the bottom (and interpolate between).
- * We draw that image into the Z buffer, then draw an ordinary cube.
- * The bottom part of the cube should be "clipped" where the cube fails
- * the Z test.
- *
- * Press 'd' to view the Z buffer as a grayscale image.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <GL/glew.h>
-#include <GL/glut.h>
-#include "../util/showbuffer.c"
-
-
-static int Win;
-static GLfloat Xrot = 50, Yrot = 40, Zpos = 6;
-static GLboolean Anim = GL_FALSE;
-
-static int Width = 200, Height = 200;
-static GLfloat *z;
-static GLboolean showZ = 0;
-
-
-static void
-Idle(void)
-{
- Xrot += 3.0;
- Yrot += 4.0;
- glutPostRedisplay();
-}
-
-
-static void
-Draw(void)
-{
- glClearColor(0, 0, 0.5, 0);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-#if 1
- glColor3f(1, 0, 0);
- glWindowPos2i(0,0);
- glColorMask(0,0,0,0);
- glDrawPixels(Width, Height, GL_DEPTH_COMPONENT, GL_FLOAT, z);
-#elif 0
- glPushMatrix();
- glTranslatef(-0.75, 0, Zpos);
- glutSolidSphere(1.0, 20, 10);
- glPopMatrix();
-#endif
- glColorMask(1,1,1,1);
-
- /* draw cube */
- glPushMatrix();
- glTranslatef(0, 0, Zpos);
- glRotatef(Xrot, 1, 0, 0);
- glRotatef(Yrot, 0, 1, 0);
- glutSolidCube(2.0);
- glPopMatrix();
-
-#if 0
- /* drawpixels after cube */
- glColor3f(1, 0, 0);
- glWindowPos2i(0,0);
- //glColorMask(0,0,0,0);
- glDrawPixels(Width, Height, GL_DEPTH_COMPONENT, GL_FLOAT, z);
-#endif
-
- if (showZ) {
- ShowDepthBuffer(Width, Height, 0.0, 1.0);
- }
-
- glutSwapBuffers();
-}
-
-
-static void
-Reshape(int width, int height)
-{
- glViewport(0, 0, width, height);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 30.0);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glTranslatef(0.0, 0.0, -15.0);
-
- Width = width;
- Height = height;
-
- z = (float *) malloc(width * height * 4);
- {
- int i, j, k = 0;
- for (i = 0; i < height; i++) {
- float zval = (float) i / (height - 1);
- for (j = 0; j < width; j++) {
- z[k++] = zval;
- }
- }
- }
-}
-
-
-static void
-Key(unsigned char key, int x, int y)
-{
- const GLfloat step = 1.0;
- (void) x;
- (void) y;
- switch (key) {
- case 'a':
- Anim = !Anim;
- if (Anim)
- glutIdleFunc(Idle);
- else
- glutIdleFunc(NULL);
- break;
- case 'd':
- showZ = !showZ;
- break;
- case 'z':
- Zpos -= step;
- break;
- case 'Z':
- Zpos += 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();
-}
-
-
-static void
-Init(void)
-{
- /* setup lighting, etc */
- glEnable(GL_DEPTH_TEST);
- glEnable(GL_LIGHTING);
- glEnable(GL_LIGHT0);
-}
-
-
-int
-main(int argc, char *argv[])
-{
- glutInit(&argc, argv);
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(400, 400);
- glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
- Win = glutCreateWindow(argv[0]);
- glewInit();
- glutReshapeFunc(Reshape);
- glutKeyboardFunc(Key);
- glutSpecialFunc(SpecialKey);
- glutDisplayFunc(Draw);
- if (Anim)
- glutIdleFunc(Idle);
- Init();
- glutMainLoop();
- return 0;
-}
diff --git a/progs/util/extfuncs.h b/progs/util/extfuncs.h
index 070414e2943..0469e2f2c4c 100644
--- a/progs/util/extfuncs.h
+++ b/progs/util/extfuncs.h
@@ -86,6 +86,57 @@ static PFNGLISVERTEXARRAYAPPLEPROC glIsVertexArrayAPPLE_func = NULL;
/* GL_EXT_stencil_two_side */
static PFNGLACTIVESTENCILFACEEXTPROC glActiveStencilFaceEXT_func = NULL;
+/* GL_ARB_buffer_object */
+static PFNGLGENBUFFERSARBPROC glGenBuffersARB_func = NULL;
+static PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB_func = NULL;
+static PFNGLBINDBUFFERARBPROC glBindBufferARB_func = NULL;
+static PFNGLBUFFERDATAARBPROC glBufferDataARB_func = NULL;
+static PFNGLBUFFERSUBDATAARBPROC glBufferSubDataARB_func = NULL;
+static PFNGLMAPBUFFERARBPROC glMapBufferARB_func = NULL;
+static PFNGLUNMAPBUFFERARBPROC glUnmapBufferARB_func = NULL;
+
+/* GL_EXT_framebuffer_object */
+static PFNGLISRENDERBUFFEREXTPROC glIsRenderbufferEXT_func = NULL;
+static PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT_func = NULL;
+static PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT_func = NULL;
+static PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT_func = NULL;
+static PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT_func = NULL;
+static PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC glGetRenderbufferParameterivEXT_func = NULL;
+static PFNGLISFRAMEBUFFEREXTPROC glIsFramebufferEXT_func = NULL;
+static PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT_func = NULL;
+static PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT_func = NULL;
+static PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT_func = NULL;
+static PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT_func = NULL;
+static PFNGLFRAMEBUFFERTEXTURE1DEXTPROC glFramebufferTexture1DEXT_func = NULL;
+static PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT_func = NULL;
+static PFNGLFRAMEBUFFERTEXTURE3DEXTPROC glFramebufferTexture3DEXT_func = NULL;
+static PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT_func = NULL;
+static PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glGetFramebufferAttachmentParameterivEXT_func = NULL;
+static PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT_func = NULL;
+
+/* GL_ARB_framebuffer_object */
+static PFNGLISRENDERBUFFERPROC glIsRenderbuffer_func = NULL;
+static PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer_func = NULL;
+static PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers_func = NULL;
+static PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers_func = NULL;
+static PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage_func = NULL;
+static PFNGLGETRENDERBUFFERPARAMETERIVPROC glGetRenderbufferParameteriv_func = NULL;
+static PFNGLISFRAMEBUFFERPROC glIsFramebuffer_func = NULL;
+static PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer_func = NULL;
+static PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers_func = NULL;
+static PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers_func = NULL;
+static PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus_func = NULL;
+static PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D_func = NULL;
+static PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D_func = NULL;
+static PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D_func = NULL;
+static PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer_func = NULL;
+static PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glGetFramebufferAttachmentParameteriv_func = NULL;
+static PFNGLGENERATEMIPMAPPROC glGenerateMipmap_func = NULL;
+static PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer_func = NULL;
+static PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glRenderbufferStorageMultisample_func = NULL;
+static PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer_func = NULL;
+
+
static void
GetExtensionFuncs(void)
@@ -173,5 +224,55 @@ GetExtensionFuncs(void)
/* GL_EXT_stencil_two_side */
glActiveStencilFaceEXT_func = (PFNGLACTIVESTENCILFACEEXTPROC) glutGetProcAddress("glActiveStencilFaceEXT");
+
+ /* GL_ARB_vertex_buffer_object */
+ glGenBuffersARB_func = (PFNGLGENBUFFERSARBPROC) glutGetProcAddress("glGenBuffersARB");
+ glDeleteBuffersARB_func = (PFNGLDELETEBUFFERSARBPROC) glutGetProcAddress("glDeleteBuffersARB");
+ glBindBufferARB_func = (PFNGLBINDBUFFERARBPROC) glutGetProcAddress("glBindBufferARB");
+ glBufferDataARB_func = (PFNGLBUFFERDATAARBPROC) glutGetProcAddress("glBufferDataARB");
+ glBufferSubDataARB_func = (PFNGLBUFFERSUBDATAARBPROC) glutGetProcAddress("glBufferSubDataARB");
+ glMapBufferARB_func = (PFNGLMAPBUFFERARBPROC) glutGetProcAddress("glMapBufferARB");
+ glUnmapBufferARB_func = (PFNGLUNMAPBUFFERARBPROC) glutGetProcAddress("glUnmapBufferARB");
+
+ /* GL_EXT_framebuffer_object */
+ glIsRenderbufferEXT_func = (PFNGLISRENDERBUFFEREXTPROC) glutGetProcAddress("glIsRenderbufferEXT");
+ glBindRenderbufferEXT_func = (PFNGLBINDRENDERBUFFEREXTPROC) glutGetProcAddress("glBindRenderbufferEXT");
+ glDeleteRenderbuffersEXT_func = (PFNGLDELETERENDERBUFFERSEXTPROC) glutGetProcAddress("glDeleteRenderbuffersEXT");
+ glGenRenderbuffersEXT_func = (PFNGLGENRENDERBUFFERSEXTPROC) glutGetProcAddress("glGenRenderbuffersEXT");
+ glRenderbufferStorageEXT_func = (PFNGLRENDERBUFFERSTORAGEEXTPROC) glutGetProcAddress("glRenderbufferStorageEXT");
+ glGetRenderbufferParameterivEXT_func = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) glutGetProcAddress("glGetRenderbufferParameterivEXT");
+ glIsFramebufferEXT_func = (PFNGLISFRAMEBUFFEREXTPROC) glutGetProcAddress("glIsFramebufferEXT");
+ glBindFramebufferEXT_func = (PFNGLBINDFRAMEBUFFEREXTPROC) glutGetProcAddress("glBindFramebufferEXT");
+ glDeleteFramebuffersEXT_func = (PFNGLDELETEFRAMEBUFFERSEXTPROC) glutGetProcAddress("glDeleteFramebuffersEXT");
+ glGenFramebuffersEXT_func = (PFNGLGENFRAMEBUFFERSEXTPROC) glutGetProcAddress("glGenFramebuffersEXT");
+ glCheckFramebufferStatusEXT_func = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) glutGetProcAddress("glCheckFramebufferStatusEXT");
+ glFramebufferTexture1DEXT_func = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) glutGetProcAddress("glFramebufferTexture1DEXT");
+ glFramebufferTexture2DEXT_func = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) glutGetProcAddress("glFramebufferTexture2DEXT");
+ glFramebufferTexture3DEXT_func = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) glutGetProcAddress("glFramebufferTexture3DEXT");
+ glFramebufferRenderbufferEXT_func = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) glutGetProcAddress("glFramebufferRenderbufferEXT");
+ glGetFramebufferAttachmentParameterivEXT_func = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) glutGetProcAddress("glGetFramebufferAttachmentParameterivEXT");
+ glGenerateMipmapEXT_func = (PFNGLGENERATEMIPMAPEXTPROC) glutGetProcAddress("glGenerateMipmapEXT");
+
+ /* GL_ARB_framebuffer_object */
+ glIsRenderbuffer_func = (PFNGLISRENDERBUFFERPROC) glutGetProcAddress("glIsRenderbuffer");
+ glBindRenderbuffer_func = (PFNGLBINDRENDERBUFFERPROC) glutGetProcAddress("glBindRenderbuffer");
+ glDeleteRenderbuffers_func = (PFNGLDELETERENDERBUFFERSPROC) glutGetProcAddress("glDeleteRenderbuffers");
+ glGenRenderbuffers_func = (PFNGLGENRENDERBUFFERSPROC) glutGetProcAddress("glGenRenderbuffers");
+ glRenderbufferStorage_func = (PFNGLRENDERBUFFERSTORAGEPROC) glutGetProcAddress("glRenderbufferStorage");
+ glGetRenderbufferParameteriv_func = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) glutGetProcAddress("glGetRenderbufferParameteriv");
+ glIsFramebuffer_func = (PFNGLISFRAMEBUFFERPROC) glutGetProcAddress("glIsFramebuffer");
+ glBindFramebuffer_func = (PFNGLBINDFRAMEBUFFERPROC) glutGetProcAddress("glBindFramebuffer");
+ glDeleteFramebuffers_func = (PFNGLDELETEFRAMEBUFFERSPROC) glutGetProcAddress("glDeleteFramebuffers");
+ glGenFramebuffers_func = (PFNGLGENFRAMEBUFFERSPROC) glutGetProcAddress("glGenFramebuffers");
+ glCheckFramebufferStatus_func = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) glutGetProcAddress("glCheckFramebufferStatus");
+ glFramebufferTexture1D_func = (PFNGLFRAMEBUFFERTEXTURE1DPROC) glutGetProcAddress("glFramebufferTexture1D");
+ glFramebufferTexture2D_func = (PFNGLFRAMEBUFFERTEXTURE2DPROC) glutGetProcAddress("glFramebufferTexture2D");
+ glFramebufferTexture3D_func = (PFNGLFRAMEBUFFERTEXTURE3DPROC) glutGetProcAddress("glFramebufferTexture3D");
+ glFramebufferRenderbuffer_func = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) glutGetProcAddress("glFramebufferRenderbuffer");
+ glGetFramebufferAttachmentParameteriv_func = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) glutGetProcAddress("glGetFramebufferAttachmentParameteriv");
+ glGenerateMipmap_func = (PFNGLGENERATEMIPMAPPROC) glutGetProcAddress("glGenerateMipmap");
+ glBlitFramebuffer_func = (PFNGLBLITFRAMEBUFFERPROC) glutGetProcAddress("glBlitFramebuffer");
+ glRenderbufferStorageMultisample_func = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) glutGetProcAddress("glRenderbufferStorageMultisample");
+ glFramebufferTextureLayer_func = (PFNGLFRAMEBUFFERTEXTURELAYERPROC) glutGetProcAddress("glFramebufferTextureLayer");
}
diff --git a/progs/wgl/sharedtex_mt/sharedtex_mt.c b/progs/wgl/sharedtex_mt/sharedtex_mt.c
index 010eb873b85..779e15001db 100644
--- a/progs/wgl/sharedtex_mt/sharedtex_mt.c
+++ b/progs/wgl/sharedtex_mt/sharedtex_mt.c
@@ -50,6 +50,7 @@ struct window {
float Angle;
int Id;
HGLRC sharedContext;
+ HANDLE hEventInitialised;
};
@@ -414,6 +415,10 @@ threadRunner (void *arg)
Error("Couldn't obtain HDC");
}
+ /* Wait for the previous thread */
+ if(tia->id > 0)
+ WaitForSingleObject(Windows[tia->id - 1].hEventInitialised, INFINITE);
+
pfd.cColorBits = 24;
pfd.cDepthBits = 24;
pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
@@ -434,9 +439,16 @@ threadRunner (void *arg)
}
if (win->sharedContext) {
- wglShareLists(win->sharedContext, win->Context);
+ if(!wglShareLists(win->sharedContext, win->Context))
+ Error("Couldn't share WGL context lists");
}
+ SetEvent(win->hEventInitialised);
+
+ /* Wait for all threads to initialize otherwise wglShareLists will fail */
+ if(tia->id < NumWindows - 1)
+ WaitForSingleObject(Windows[NumWindows - 1].hEventInitialised, INFINITE);
+
SendMessage(win->Win, WM_SIZE, 0, 0);
while (1) {
@@ -511,20 +523,26 @@ main(int argc, char *argv[])
h[2] = AddWindow( 10, 350, gCtx);
h[3] = AddWindow(330, 350, gCtx);
- if (!wglMakeCurrent(gHDC, gCtx)) {
- Error("wglMakeCurrent failed for init thread.");
- return -1;
+ for (i = 0; i < NumWindows; i++) {
+ Windows[i].hEventInitialised = CreateEvent(NULL, TRUE, FALSE, NULL);
}
- InitGLstuff();
-
for (i = 0; i < NumWindows; i++) {
DWORD id;
tia[i].id = i;
threads[i] = CreateThread(NULL, 0, threadRunner, &tia[i], 0, &id);
+
+ WaitForSingleObject(Windows[i].hEventInitialised, INFINITE);
+ }
+
+ if (!wglMakeCurrent(gHDC, gCtx)) {
+ Error("wglMakeCurrent failed for init thread.");
+ return -1;
}
+ InitGLstuff();
+
while (1) {
MSG msg;
diff --git a/progs/wgl/wglthreads/wglthreads.c b/progs/wgl/wglthreads/wglthreads.c
index 9ca7f025dc3..27dca10f2a0 100644
--- a/progs/wgl/wglthreads/wglthreads.c
+++ b/progs/wgl/wglthreads/wglthreads.c
@@ -72,6 +72,7 @@ struct winthread {
int WinWidth, WinHeight;
GLboolean NewSize;
HANDLE hEventInitialised;
+ GLboolean Initialized;
GLboolean MakeNewTexture;
HANDLE hEventRedraw;
};
@@ -114,20 +115,20 @@ static void
MakeNewTexture(struct winthread *wt)
{
#define TEX_SIZE 128
- static float step = 0.0;
+ static float step = 0.0f;
GLfloat image[TEX_SIZE][TEX_SIZE][4];
GLint width;
int i, j;
for (j = 0; j < TEX_SIZE; j++) {
for (i = 0; i < TEX_SIZE; i++) {
- float dt = 5.0 * (j - 0.5 * TEX_SIZE) / TEX_SIZE;
- float ds = 5.0 * (i - 0.5 * TEX_SIZE) / TEX_SIZE;
+ float dt = 5.0f * (j - 0.5f * TEX_SIZE) / TEX_SIZE;
+ float ds = 5.0f * (i - 0.5f * TEX_SIZE) / TEX_SIZE;
float r = dt * dt + ds * ds + step;
image[j][i][0] =
image[j][i][1] =
- image[j][i][2] = 0.75 + 0.25 * cos(r);
- image[j][i][3] = 1.0;
+ image[j][i][2] = 0.75f + 0.25f * (float) cos(r);
+ image[j][i][3] = 1.0f;
}
}
@@ -159,7 +160,7 @@ static void
draw_object(void)
{
glPushMatrix();
- glScalef(0.75, 0.75, 0.75);
+ glScalef(0.75f, 0.75f, 0.75f);
glColor3f(1, 0, 0);
@@ -288,6 +289,15 @@ draw_loop(struct winthread *wt)
wglMakeCurrent(wt->hDC, wt->Context);
+ if (!wt->Initialized) {
+ printf("wglthreads: %d: GL_RENDERER = %s\n", wt->Index,
+ (char *) glGetString(GL_RENDERER));
+ if (Texture /*&& wt->Index == 0*/) {
+ MakeNewTexture(wt);
+ }
+ wt->Initialized = GL_TRUE;
+ }
+
if (Locking)
LeaveCriticalSection(&Mutex);
@@ -315,13 +325,15 @@ draw_loop(struct winthread *wt)
glPushMatrix();
glRotatef(wt->Angle, 0, 1, 0);
glRotatef(wt->Angle, 1, 0, 0);
- glScalef(0.7, 0.7, 0.7);
+ glScalef(0.7f, 0.7f, 0.7f);
draw_object();
glPopMatrix();
if (Locking)
EnterCriticalSection(&Mutex);
+
SwapBuffers(wt->hDC);
+
if (Locking)
LeaveCriticalSection(&Mutex);
@@ -433,7 +445,7 @@ create_window(struct winthread *wt, HGLRC shareCtx)
win = CreateWindowEx(0,
wc.lpszClassName,
"wglthreads",
- WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
+ WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TILEDWINDOW,
xpos,
ypos,
width,
@@ -471,7 +483,8 @@ create_window(struct winthread *wt, HGLRC shareCtx)
}
if (shareCtx) {
- wglShareLists(shareCtx, ctx);
+ if(!wglShareLists(shareCtx, ctx))
+ Error("Couldn't share WGL context lists");
}
/* save the info for this window/context */
@@ -482,14 +495,6 @@ create_window(struct winthread *wt, HGLRC shareCtx)
wt->WinWidth = width;
wt->WinHeight = height;
wt->NewSize = GL_TRUE;
-
- wglMakeCurrent(hdc, ctx);
- printf("wglthreads: %d: GL_RENDERER = %s\n", wt->Index, (char *) glGetString(GL_RENDERER));
- wglMakeCurrent(NULL, NULL);
-
- if (Texture/* && wt->Index == 0*/) {
- MakeNewTexture(wt);
- }
}
@@ -502,10 +507,22 @@ ThreadProc(void *p)
struct winthread *wt = (struct winthread *) p;
HGLRC share;
+ /* Wait for the previous thread */
+ if(Texture && wt->Index > 0) {
+ WaitForSingleObject(WinThreads[wt->Index - 1].hEventInitialised, INFINITE);
+ share = WinThreads[0].Context;
+ }
+ else
+ share = 0;
+
share = (Texture && wt->Index > 0) ? WinThreads[0].Context : 0;
create_window(wt, share);
SetEvent(wt->hEventInitialised);
+ /* Wait for all threads to initialize otherwise wglShareLists will fail */
+ if(wt->Index < NumWinThreads - 1)
+ WaitForSingleObject(WinThreads[NumWinThreads - 1].hEventInitialised, INFINITE);
+
draw_loop(wt);
return 0;
}
@@ -539,6 +556,7 @@ main(int argc, char *argv[])
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-h") == 0) {
usage();
+ exit(0);
}
else if (strcmp(argv[i], "-l") == 0) {
Locking = 1;
@@ -588,13 +606,17 @@ main(int argc, char *argv[])
printf("wglthreads: creating threads\n");
- /* Create the threads */
+ /* Create the events */
for (i = 0; i < NumWinThreads; i++) {
- DWORD id;
-
WinThreads[i].Index = i;
WinThreads[i].hEventInitialised = CreateEvent(NULL, TRUE, FALSE, NULL);
WinThreads[i].hEventRedraw = CreateEvent(NULL, FALSE, FALSE, NULL);
+ }
+
+ /* Create the threads */
+ for (i = 0; i < NumWinThreads; i++) {
+ DWORD id;
+
WinThreads[i].Thread = CreateThread(NULL,
0,
ThreadProc,
@@ -603,8 +625,6 @@ main(int argc, char *argv[])
&id);
printf("wglthreads: Created thread %p\n", (void *) WinThreads[i].Thread);
- WaitForSingleObject(WinThreads[i].hEventInitialised, INFINITE);
-
threads[i] = WinThreads[i].Thread;
}
diff --git a/progs/xdemos/glxcontexts.c b/progs/xdemos/glxcontexts.c
index a97b62a9081..481749be3d8 100644
--- a/progs/xdemos/glxcontexts.c
+++ b/progs/xdemos/glxcontexts.c
@@ -20,16 +20,17 @@
*/
/*
- * This is a port of the infamous "gears" demo to straight GLX (i.e. no GLUT)
- * Port by Brian Paul 23 March 2001
+ * Version of glxgears that creates/destroys the rendering context for each
+ * frame. Also periodically destroy/recreate the window.
+ * Good for finding memory leaks, etc.
*
* Command line options:
* -info print GL implementation information
- * -stereo use stereo enabled GLX visual
*
*/
+#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
@@ -92,13 +93,8 @@ 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 */
-static GLboolean stereo = GL_FALSE; /* Enable stereo. */
-static GLfloat eyesep = 5.0; /* Eye separation. */
-static GLfloat fix_point = 40.0; /* Fixation point distance. */
-static GLfloat left, right, asp; /* Stereo frustum params. */
-
- XVisualInfo *visinfo;
+static XVisualInfo *visinfo = NULL;
+static int WinWidth = 300, WinHeight = 300;
/*
@@ -272,22 +268,13 @@ do_draw(void)
}
-
/* new window size or exposure */
static void
reshape(int width, int height)
{
glViewport(0, 0, (GLint) width, (GLint) height);
- if (stereo) {
- GLfloat w;
-
- asp = (GLfloat) height / (GLfloat) width;
- w = fix_point * (1.0 / 5.0);
-
- left = -5.0 * ((w - 0.5 * eyesep) / fix_point);
- right = 5.0 * ((w + 0.5 * eyesep) / fix_point);
- } else {
+ {
GLfloat h = (GLfloat) height / (GLfloat) width;
glMatrixMode(GL_PROJECTION);
@@ -299,7 +286,6 @@ reshape(int width, int height)
glLoadIdentity();
glTranslatef(0.0, 0.0, -40.0);
}
-
static void
@@ -337,7 +323,7 @@ init(void)
glEnable(GL_NORMALIZE);
}
-
+
static void
draw( Display *dpy, Window win )
@@ -354,36 +340,9 @@ draw( Display *dpy, Window win )
init();
- if (stereo) {
- /* First left eye. */
- glDrawBuffer(GL_BACK_LEFT);
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glFrustum(left, right, -asp, asp, 5.0, 60.0);
+ reshape(WinWidth, WinHeight);
- glMatrixMode(GL_MODELVIEW);
-
- glPushMatrix();
- glTranslated(+0.5 * eyesep, 0.0, 0.0);
- do_draw();
- glPopMatrix();
-
- /* Then right eye. */
- glDrawBuffer(GL_BACK_RIGHT);
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glFrustum(-right, -left, -asp, asp, 5.0, 60.0);
-
- glMatrixMode(GL_MODELVIEW);
-
- glPushMatrix();
- glTranslated(-0.5 * eyesep, 0.0, 0.0);
- do_draw();
- glPopMatrix();
- } else
- do_draw();
+ do_draw();
glDeleteLists(gear1, 1);
glDeleteLists(gear2, 1);
@@ -410,14 +369,6 @@ make_window( Display *dpy, const char *name,
GLX_DOUBLEBUFFER,
GLX_DEPTH_SIZE, 1,
None };
- int stereoAttribs[] = { GLX_RGBA,
- GLX_RED_SIZE, 1,
- GLX_GREEN_SIZE, 1,
- GLX_BLUE_SIZE, 1,
- GLX_DOUBLEBUFFER,
- GLX_DEPTH_SIZE, 1,
- GLX_STEREO,
- None };
int scrnum;
XSetWindowAttributes attr;
unsigned long mask;
@@ -427,22 +378,9 @@ make_window( Display *dpy, const char *name,
scrnum = DefaultScreen( dpy );
root = RootWindow( dpy, scrnum );
- if (fullscreen) {
- x = 0; y = 0;
- width = DisplayWidth( dpy, scrnum );
- height = DisplayHeight( dpy, scrnum );
- }
-
- if (stereo)
- visinfo = glXChooseVisual( dpy, scrnum, stereoAttribs );
- else
- visinfo = glXChooseVisual( dpy, scrnum, attribs );
+ visinfo = glXChooseVisual( dpy, scrnum, attribs );
if (!visinfo) {
- if (stereo) {
- printf("Error: couldn't get an RGB, "
- "Double-buffered, Stereo visual\n");
- } else
- printf("Error: couldn't get an RGB, Double-buffered visual\n");
+ printf("Error: couldn't get an RGB, Double-buffered visual\n");
exit(1);
}
@@ -451,7 +389,7 @@ make_window( Display *dpy, const char *name,
attr.border_pixel = 0;
attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
- attr.override_redirect = fullscreen;
+ attr.override_redirect = 0;
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect;
win = XCreateWindow( dpy, root, x, y, width, height,
@@ -479,10 +417,9 @@ static void
event_loop(Display *dpy)
{
Window win;
- make_window(dpy, "glxgears", 0, 0, 300, 300, &win);
+ make_window(dpy, "glxgears", 0, 0, WinWidth, WinHeight, &win);
XMapWindow(dpy, win);
-
while (1) {
while (XPending(dpy) > 0) {
XEvent event;
@@ -492,34 +429,35 @@ event_loop(Display *dpy)
/* we'll redraw below */
break;
case ConfigureNotify:
- reshape(event.xconfigure.width, event.xconfigure.height);
+ WinWidth = event.xconfigure.width;
+ WinHeight = event.xconfigure.height;
break;
case KeyPress:
- {
- char buffer[10];
- int r, code;
- code = XLookupKeysym(&event.xkey, 0);
- if (code == XK_Left) {
- view_roty += 5.0;
- }
- else if (code == XK_Right) {
- view_roty -= 5.0;
- }
- else if (code == XK_Up) {
- view_rotx += 5.0;
- }
- else if (code == XK_Down) {
- view_rotx -= 5.0;
- }
- else {
- r = XLookupString(&event.xkey, buffer, sizeof(buffer),
- NULL, NULL);
- if (buffer[0] == 27) {
- /* escape */
- return;
- }
- }
- }
+ {
+ char buffer[10];
+ int r, code;
+ code = XLookupKeysym(&event.xkey, 0);
+ if (code == XK_Left) {
+ view_roty += 5.0;
+ }
+ else if (code == XK_Right) {
+ view_roty -= 5.0;
+ }
+ else if (code == XK_Up) {
+ view_rotx += 5.0;
+ }
+ else if (code == XK_Down) {
+ view_rotx -= 5.0;
+ }
+ else {
+ r = XLookupString(&event.xkey, buffer, sizeof(buffer),
+ NULL, NULL);
+ if (buffer[0] == 27) {
+ /* escape */
+ return;
+ }
+ }
+ }
}
}
@@ -550,9 +488,12 @@ event_loop(Display *dpy)
printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds,
fps);
tRate0 = t;
-
+
+ /* Destroy window and create new one */
XDestroyWindow(dpy, win);
- make_window(dpy, "glxgears", (int)(fps * 100) % 100, (int)(fps * 100) % 100, 300, 300, &win);
+ make_window(dpy, "glxgears",
+ (int)(fps * 100) % 100, (int)(fps * 100) % 100, /* x,y */
+ WinWidth, WinHeight, &win);
XMapWindow(dpy, win);
frames = 0;
@@ -562,7 +503,6 @@ event_loop(Display *dpy)
}
-
int
main(int argc, char *argv[])
{
@@ -579,12 +519,6 @@ main(int argc, char *argv[])
else if (strcmp(argv[i], "-info") == 0) {
printInfo = GL_TRUE;
}
- else if (strcmp(argv[i], "-stereo") == 0) {
- stereo = GL_TRUE;
- }
- else if (strcmp(argv[i], "-fullscreen") == 0) {
- fullscreen = GL_TRUE;
- }
else
printf("Warrning: unknown parameter: %s\n", argv[i]);
}
@@ -596,7 +530,6 @@ main(int argc, char *argv[])
return -1;
}
-
if (printInfo) {
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
@@ -604,7 +537,6 @@ main(int argc, char *argv[])
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
}
-
event_loop(dpy);
XCloseDisplay(dpy);
diff --git a/scons/crossmingw.py b/scons/crossmingw.py
index bf81f16fd64..3aed4843502 100644
--- a/scons/crossmingw.py
+++ b/scons/crossmingw.py
@@ -108,7 +108,7 @@ def shlib_emitter(target, source, env):
return (target, source)
-shlib_action = SCons.Action.Action(shlib_generator, generator=1)
+shlib_action = SCons.Action.Action(shlib_generator, '$SHLINKCOMSTR', generator=1)
res_action = SCons.Action.Action('$RCCOM', '$RCCOMSTR')
diff --git a/scons/dxsdk.py b/scons/dxsdk.py
new file mode 100644
index 00000000000..a369e1da10c
--- /dev/null
+++ b/scons/dxsdk.py
@@ -0,0 +1,66 @@
+"""dxsdk
+
+Tool-specific initialization for Microsoft DirectX SDK
+
+"""
+
+#
+# Copyright (c) 2009 VMware, Inc.
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+import os
+import os.path
+
+import SCons.Errors
+import SCons.Util
+
+
+def get_dxsdk_root(env):
+ try:
+ return os.environ['DXSDK_DIR']
+ except KeyError:
+ return None
+
+def get_dxsdk_paths(env):
+ dxsdk_root = get_dxsdk_root(env)
+ if dxsdk_root is None:
+ raise SCons.Errors.InternalError, "DirectX SDK not found"
+
+ if env['machine'] in ('generic', 'x86'):
+ target_cpu = 'x86'
+ elif env['machine'] == 'x86_64':
+ target_cpu = 'x64'
+ else:
+ raise SCons.Errors.InternalError, "Unsupported target machine"
+ include_dir = 'Include'
+
+ env.Append(CPPDEFINES = [('HAVE_DXSDK', '1')])
+ env.Prepend(CPPPATH = [os.path.join(dxsdk_root, 'Include')])
+ env.Prepend(LIBPATH = [os.path.join(dxsdk_root, 'Lib', target_cpu)])
+
+def generate(env):
+ get_dxsdk_paths(env)
+
+def exists(env):
+ return get_dxsdk_root(env) is not None
+
+# vim:set ts=4 sw=4 et:
diff --git a/scons/gallium.py b/scons/gallium.py
index 0d5843603e9..ee45af50c29 100644
--- a/scons/gallium.py
+++ b/scons/gallium.py
@@ -318,89 +318,78 @@ def generate(env):
env.Append(CPPDEFINES = cppdefines)
# C compiler options
- cflags = []
+ cflags = [] # C
+ cxxflags = [] # C++
+ ccflags = [] # C & C++
if gcc:
if debug:
- cflags += ['-O0', '-g3']
+ ccflags += ['-O0', '-g3']
elif env['toolchain'] == 'crossmingw':
- cflags += ['-O0', '-g3'] # mingw 4.2.1 optimizer is broken
+ ccflags += ['-O0', '-g3'] # mingw 4.2.1 optimizer is broken
else:
- cflags += ['-O3', '-g3']
+ ccflags += ['-O3', '-g3']
if env['profile']:
- cflags += ['-pg']
+ ccflags += ['-pg']
if env['machine'] == 'x86':
- cflags += [
+ ccflags += [
'-m32',
#'-march=pentium4',
'-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
#'-mfpmath=sse',
]
if env['machine'] == 'x86_64':
- cflags += ['-m64']
+ ccflags += ['-m64']
# See also:
# - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
- cflags += [
- '-Werror=declaration-after-statement',
+ ccflags += [
'-Wall',
- '-Wmissing-prototypes',
'-Wmissing-field-initializers',
'-Wpointer-arith',
'-Wno-long-long',
'-ffast-math',
- '-std=gnu99',
'-fmessage-length=0', # be nice to Eclipse
]
+ cflags += [
+ '-Werror=declaration-after-statement',
+ '-Wmissing-prototypes',
+ '-std=gnu99',
+ ]
if msvc:
# See also:
# - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx
# - cl /?
if debug:
- cflags += [
+ ccflags += [
'/Od', # disable optimizations
'/Oi', # enable intrinsic functions
'/Oy-', # disable frame pointer omission
'/GL-', # disable whole program optimization
]
else:
- if env['machine'] == 'x86_64':
- cflags += [
- # Same as /O2, but without global optimizations or auto-inlining
- # http://msdn.microsoft.com/en-us/library/8f8h5cxt.aspx
- '/Ob1', # enable inline expansion, disable auto-inlining
- '/Oi', # enable intrinsic functions
- '/Ot', # favors fast code
- '/Oy', # omit frame pointer
- '/Gs', # enable stack probes
- '/GF', # eliminate duplicate strings
- '/Gy', # enable function-level linking
- ]
- else:
- cflags += [
- '/O2', # optimize for speed
- ]
- cflags += [
+ ccflags += [
+ '/O2', # optimize for speed
#'/fp:fast', # fast floating point
]
if env['profile']:
- cflags += [
+ ccflags += [
'/Gh', # enable _penter hook function
'/GH', # enable _pexit hook function
]
- cflags += [
+ ccflags += [
'/W3', # warning level
#'/Wp64', # enable 64 bit porting warnings
]
if env['machine'] == 'x86':
- cflags += [
+ ccflags += [
#'/QIfist', # Suppress _ftol
#'/arch:SSE2', # use the SSE2 instructions
]
if platform == 'windows':
- cflags += [
+ ccflags += [
# TODO
]
if platform == 'winddk':
- cflags += [
+ ccflags += [
'/Zl', # omit default library name in .OBJ
'/Zp8', # 8bytes struct member alignment
'/Gy', # separate functions for linker
@@ -419,7 +408,7 @@ def generate(env):
]
if platform == 'wince':
# See also C:\WINCE600\public\common\oak\misc\makefile.def
- cflags += [
+ ccflags += [
'/Zl', # omit default library name in .OBJ
'/GF', # enable read-only string pooling
'/GR-', # disable C++ RTTI
@@ -436,8 +425,9 @@ def generate(env):
# See http://scons.tigris.org/issues/show_bug.cgi?id=1656
env.EnsureSConsVersion(0, 98, 0)
env['PDB'] = '${TARGET.base}.pdb'
+ env.Append(CCFLAGS = ccflags)
env.Append(CFLAGS = cflags)
- env.Append(CXXFLAGS = cflags)
+ env.Append(CXXFLAGS = cxxflags)
if env['platform'] == 'windows' and msvc:
# Choose the appropriate MSVC CRT
diff --git a/scons/generic.py b/scons/generic.py
index 29ddf76d6ff..a9c2244a74f 100644
--- a/scons/generic.py
+++ b/scons/generic.py
@@ -416,16 +416,18 @@ def generate(env):
# See also:
# - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
ccflags += [
- '-Werror=declaration-after-statement',
'-Wall',
- '-Wmissing-prototypes',
'-Wmissing-field-initializers',
'-Wpointer-arith',
'-Wno-long-long',
'-ffast-math',
- '-std=gnu99',
'-fmessage-length=0', # be nice to Eclipse
]
+ cflags += [
+ '-Werror=declaration-after-statement',
+ '-Wmissing-prototypes',
+ '-std=gnu99',
+ ]
if msvc:
# See also:
# - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx
diff --git a/src/gallium/auxiliary/draw/draw_pt_elts.c b/src/gallium/auxiliary/draw/draw_pt_elts.c
index b7780fb5073..88f4d9f495a 100644
--- a/src/gallium/auxiliary/draw/draw_pt_elts.c
+++ b/src/gallium/auxiliary/draw/draw_pt_elts.c
@@ -54,7 +54,8 @@ static unsigned elt_ubyte( const void *elts, unsigned idx )
static unsigned elt_vert( const void *elts, unsigned idx )
{
- return (const ubyte *)elts - (const ubyte *)NULL + idx;
+ /* unsigned index is packed in the pointer */
+ return (unsigned)(uintptr_t)elts + idx;
}
pt_elt_func draw_pt_elt_func( struct draw_context *draw )
diff --git a/src/gallium/auxiliary/indices/u_indices.c b/src/gallium/auxiliary/indices/u_indices.c
index 0cf7d88653c..03d7453f303 100644
--- a/src/gallium/auxiliary/indices/u_indices.c
+++ b/src/gallium/auxiliary/indices/u_indices.c
@@ -244,7 +244,7 @@ int u_index_generator( unsigned hw_mask,
default:
assert(0);
- *out_generate = generate[out_idx][in_pv][out_pv][prim];
+ *out_generate = generate[out_idx][in_pv][out_pv][PIPE_PRIM_POINTS];
*out_prim = PIPE_PRIM_POINTS;
*out_nr = nr;
return U_TRANSLATE_ERROR;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer.h b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
index 92b6fd00564..2590546cb4a 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
@@ -72,6 +72,12 @@ struct pb_desc
/**
+ * Size. Regular (32bit) unsigned for now.
+ */
+typedef unsigned pb_size;
+
+
+/**
* Base class for all pb_* buffers.
*/
struct pb_buffer
@@ -126,7 +132,7 @@ struct pb_vtbl
*/
void (*get_base_buffer)( struct pb_buffer *buf,
struct pb_buffer **base_buf,
- unsigned *offset );
+ pb_size *offset );
};
@@ -177,7 +183,7 @@ pb_unmap(struct pb_buffer *buf)
static INLINE void
pb_get_base_buffer( struct pb_buffer *buf,
struct pb_buffer **base_buf,
- unsigned *offset )
+ pb_size *offset )
{
assert(buf);
if(!buf) {
@@ -241,7 +247,7 @@ pb_reference(struct pb_buffer **dst,
* the requested or not.
*/
static INLINE boolean
-pb_check_alignment(size_t requested, size_t provided)
+pb_check_alignment(pb_size requested, pb_size provided)
{
if(!requested)
return TRUE;
@@ -269,7 +275,7 @@ pb_check_usage(unsigned requested, unsigned provided)
* hardware.
*/
struct pb_buffer *
-pb_malloc_buffer_create(size_t size,
+pb_malloc_buffer_create(pb_size size,
const struct pb_desc *desc);
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
index 4698efa69cf..109ac7c9d63 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
@@ -65,11 +65,11 @@ struct fenced_buffer_list
struct pb_fence_ops *ops;
- size_t numDelayed;
+ pb_size numDelayed;
struct list_head delayed;
#ifdef DEBUG
- size_t numUnfenced;
+ pb_size numUnfenced;
struct list_head unfenced;
#endif
};
@@ -433,7 +433,7 @@ fenced_buffer_fence(struct pb_buffer *buf,
static void
fenced_buffer_get_base_buffer(struct pb_buffer *buf,
struct pb_buffer **base_buf,
- unsigned *offset)
+ pb_size *offset)
{
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
pb_get_base_buffer(fenced_buf->buffer, base_buf, offset);
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c
index 689fd74771f..0760d607161 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c
@@ -102,7 +102,7 @@ malloc_buffer_fence(struct pb_buffer *buf,
static void
malloc_buffer_get_base_buffer(struct pb_buffer *buf,
struct pb_buffer **base_buf,
- unsigned *offset)
+ pb_size *offset)
{
*base_buf = buf;
*offset = 0;
@@ -121,7 +121,7 @@ malloc_buffer_vtbl = {
struct pb_buffer *
-pb_malloc_buffer_create(size_t size,
+pb_malloc_buffer_create(pb_size size,
const struct pb_desc *desc)
{
struct malloc_buffer *buf;
@@ -150,7 +150,7 @@ pb_malloc_buffer_create(size_t size,
static struct pb_buffer *
pb_malloc_bufmgr_create_buffer(struct pb_manager *mgr,
- size_t size,
+ pb_size size,
const struct pb_desc *desc)
{
return pb_malloc_buffer_create(size, desc);
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
index 74077f82774..39ab8e722c1 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
@@ -73,7 +73,7 @@ struct pb_manager
struct pb_buffer *
(*create_buffer)( struct pb_manager *mgr,
- size_t size,
+ pb_size size,
const struct pb_desc *desc);
/**
@@ -106,7 +106,7 @@ pb_malloc_bufmgr_create(void);
*/
struct pb_manager *
pool_bufmgr_create(struct pb_manager *provider,
- size_t n, size_t size,
+ pb_size n, pb_size size,
const struct pb_desc *desc);
@@ -119,7 +119,7 @@ pool_bufmgr_create(struct pb_manager *provider,
*/
struct pb_manager *
mm_bufmgr_create(struct pb_manager *provider,
- size_t size, size_t align2);
+ pb_size size, pb_size align2);
/**
* Same as mm_bufmgr_create.
@@ -128,7 +128,7 @@ mm_bufmgr_create(struct pb_manager *provider,
*/
struct pb_manager *
mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
- size_t size, size_t align2);
+ pb_size size, pb_size align2);
/**
@@ -136,8 +136,8 @@ mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
*/
struct pb_manager *
pb_slab_manager_create(struct pb_manager *provider,
- size_t bufSize,
- size_t slabSize,
+ pb_size bufSize,
+ pb_size slabSize,
const struct pb_desc *desc);
/**
@@ -146,9 +146,9 @@ pb_slab_manager_create(struct pb_manager *provider,
*/
struct pb_manager *
pb_slab_range_manager_create(struct pb_manager *provider,
- size_t minBufSize,
- size_t maxBufSize,
- size_t slabSize,
+ pb_size minBufSize,
+ pb_size maxBufSize,
+ pb_size slabSize,
const struct pb_desc *desc);
@@ -204,7 +204,7 @@ pb_ondemand_manager_create(struct pb_manager *provider);
*/
struct pb_manager *
pb_debug_manager_create(struct pb_manager *provider,
- size_t underflow_size, size_t overflow_size);
+ pb_size underflow_size, pb_size overflow_size);
#ifdef __cplusplus
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c
index db67d46c561..f60c836f18b 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c
@@ -60,7 +60,7 @@ pb_alt_manager(struct pb_manager *mgr)
static struct pb_buffer *
pb_alt_manager_create_buffer(struct pb_manager *_mgr,
- size_t size,
+ pb_size size,
const struct pb_desc *desc)
{
struct pb_alt_manager *mgr = pb_alt_manager(_mgr);
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
index 35358430b43..57d1ede45a4 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
@@ -81,7 +81,7 @@ struct pb_cache_manager
pipe_mutex mutex;
struct list_head delayed;
- size_t numDelayed;
+ pb_size numDelayed;
};
@@ -204,7 +204,7 @@ pb_cache_buffer_fence(struct pb_buffer *_buf,
static void
pb_cache_buffer_get_base_buffer(struct pb_buffer *_buf,
struct pb_buffer **base_buf,
- unsigned *offset)
+ pb_size *offset)
{
struct pb_cache_buffer *buf = pb_cache_buffer(_buf);
pb_get_base_buffer(buf->buffer, base_buf, offset);
@@ -224,7 +224,7 @@ pb_cache_buffer_vtbl = {
static INLINE boolean
pb_cache_is_buffer_compat(struct pb_cache_buffer *buf,
- size_t size,
+ pb_size size,
const struct pb_desc *desc)
{
if(buf->base.base.size < size)
@@ -246,7 +246,7 @@ pb_cache_is_buffer_compat(struct pb_cache_buffer *buf,
static struct pb_buffer *
pb_cache_manager_create_buffer(struct pb_manager *_mgr,
- size_t size,
+ pb_size size,
const struct pb_desc *desc)
{
struct pb_cache_manager *mgr = pb_cache_manager(_mgr);
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
index cedf745bdac..1b4df28c707 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
@@ -72,8 +72,8 @@ struct pb_debug_buffer
struct pb_buffer *buffer;
struct pb_debug_manager *mgr;
- size_t underflow_size;
- size_t overflow_size;
+ pb_size underflow_size;
+ pb_size overflow_size;
struct debug_stack_frame create_backtrace[PB_DEBUG_CREATE_BACKTRACE];
@@ -91,8 +91,8 @@ struct pb_debug_manager
struct pb_manager *provider;
- size_t underflow_size;
- size_t overflow_size;
+ pb_size underflow_size;
+ pb_size overflow_size;
pipe_mutex mutex;
struct list_head list;
@@ -124,9 +124,9 @@ static const uint8_t random_pattern[32] = {
static INLINE void
-fill_random_pattern(uint8_t *dst, size_t size)
+fill_random_pattern(uint8_t *dst, pb_size size)
{
- size_t i = 0;
+ pb_size i = 0;
while(size--) {
*dst++ = random_pattern[i++];
i &= sizeof(random_pattern) - 1;
@@ -135,11 +135,11 @@ fill_random_pattern(uint8_t *dst, size_t size)
static INLINE boolean
-check_random_pattern(const uint8_t *dst, size_t size,
- size_t *min_ofs, size_t *max_ofs)
+check_random_pattern(const uint8_t *dst, pb_size size,
+ pb_size *min_ofs, pb_size *max_ofs)
{
boolean result = TRUE;
- size_t i;
+ pb_size i;
*min_ofs = size;
*max_ofs = 0;
for(i = 0; i < size; ++i) {
@@ -183,7 +183,7 @@ pb_debug_buffer_check(struct pb_debug_buffer *buf)
assert(map);
if(map) {
boolean underflow, overflow;
- size_t min_ofs, max_ofs;
+ pb_size min_ofs, max_ofs;
underflow = !check_random_pattern(map, buf->underflow_size,
&min_ofs, &max_ofs);
@@ -287,7 +287,7 @@ pb_debug_buffer_unmap(struct pb_buffer *_buf)
static void
pb_debug_buffer_get_base_buffer(struct pb_buffer *_buf,
struct pb_buffer **base_buf,
- unsigned *offset)
+ pb_size *offset)
{
struct pb_debug_buffer *buf = pb_debug_buffer(_buf);
pb_get_base_buffer(buf->buffer, base_buf, offset);
@@ -363,13 +363,13 @@ pb_debug_manager_dump(struct pb_debug_manager *mgr)
static struct pb_buffer *
pb_debug_manager_create_buffer(struct pb_manager *_mgr,
- size_t size,
+ pb_size size,
const struct pb_desc *desc)
{
struct pb_debug_manager *mgr = pb_debug_manager(_mgr);
struct pb_debug_buffer *buf;
struct pb_desc real_desc;
- size_t real_size;
+ pb_size real_size;
buf = CALLOC_STRUCT(pb_debug_buffer);
if(!buf)
@@ -455,7 +455,7 @@ pb_debug_manager_destroy(struct pb_manager *_mgr)
struct pb_manager *
pb_debug_manager_create(struct pb_manager *provider,
- size_t underflow_size, size_t overflow_size)
+ pb_size underflow_size, pb_size overflow_size)
{
struct pb_debug_manager *mgr;
@@ -485,7 +485,7 @@ pb_debug_manager_create(struct pb_manager *provider,
struct pb_manager *
pb_debug_manager_create(struct pb_manager *provider,
- size_t underflow_size, size_t overflow_size)
+ pb_size underflow_size, pb_size overflow_size)
{
return provider;
}
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c
index 144db5669b6..97dd1427fda 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c
@@ -62,7 +62,7 @@ fenced_pb_manager(struct pb_manager *mgr)
static struct pb_buffer *
fenced_bufmgr_create_buffer(struct pb_manager *mgr,
- size_t size,
+ pb_size size,
const struct pb_desc *desc)
{
struct fenced_pb_manager *fenced_mgr = fenced_pb_manager(mgr);
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
index 5a342fbf3b1..6400fc5b0a3 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
@@ -55,10 +55,10 @@ struct mm_pb_manager
pipe_mutex mutex;
- size_t size;
+ pb_size size;
struct mem_block *heap;
- size_t align2;
+ pb_size align2;
struct pb_buffer *buffer;
void *map;
@@ -148,7 +148,7 @@ mm_buffer_fence(struct pb_buffer *buf,
static void
mm_buffer_get_base_buffer(struct pb_buffer *buf,
struct pb_buffer **base_buf,
- unsigned *offset)
+ pb_size *offset)
{
struct mm_buffer *mm_buf = mm_buffer(buf);
struct mm_pb_manager *mm = mm_buf->mgr;
@@ -170,15 +170,15 @@ mm_buffer_vtbl = {
static struct pb_buffer *
mm_bufmgr_create_buffer(struct pb_manager *mgr,
- size_t size,
+ pb_size size,
const struct pb_desc *desc)
{
struct mm_pb_manager *mm = mm_pb_manager(mgr);
struct mm_buffer *mm_buf;
/* We don't handle alignments larger then the one initially setup */
- assert(pb_check_alignment(desc->alignment, 1 << mm->align2));
- if(!pb_check_alignment(desc->alignment, 1 << mm->align2))
+ assert(pb_check_alignment(desc->alignment, (pb_size)1 << mm->align2));
+ if(!pb_check_alignment(desc->alignment, (pb_size)1 << mm->align2))
return NULL;
pipe_mutex_lock(mm->mutex);
@@ -198,10 +198,10 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr,
mm_buf->mgr = mm;
- mm_buf->block = u_mmAllocMem(mm->heap, size, mm->align2, 0);
+ mm_buf->block = u_mmAllocMem(mm->heap, (int)size, (int)mm->align2, 0);
if(!mm_buf->block) {
- debug_printf("warning: heap full\n");
#if 0
+ debug_printf("warning: heap full\n");
mmDumpMemInfo(mm->heap);
#endif
FREE(mm_buf);
@@ -210,8 +210,8 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr,
}
/* Some sanity checks */
- assert(0 <= (unsigned)mm_buf->block->ofs && (unsigned)mm_buf->block->ofs < mm->size);
- assert(size <= (unsigned)mm_buf->block->size && (unsigned)mm_buf->block->ofs + (unsigned)mm_buf->block->size <= mm->size);
+ assert(0 <= (pb_size)mm_buf->block->ofs && (pb_size)mm_buf->block->ofs < mm->size);
+ assert(size <= (pb_size)mm_buf->block->size && (pb_size)mm_buf->block->ofs + (pb_size)mm_buf->block->size <= mm->size);
pipe_mutex_unlock(mm->mutex);
return SUPER(mm_buf);
@@ -245,7 +245,7 @@ mm_bufmgr_destroy(struct pb_manager *mgr)
struct pb_manager *
mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
- size_t size, size_t align2)
+ pb_size size, pb_size align2)
{
struct mm_pb_manager *mm;
@@ -273,7 +273,7 @@ mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
if(!mm->map)
goto failure;
- mm->heap = u_mmInit(0, size);
+ mm->heap = u_mmInit(0, (int)size);
if (!mm->heap)
goto failure;
@@ -292,7 +292,7 @@ if(mm->heap)
struct pb_manager *
mm_bufmgr_create(struct pb_manager *provider,
- size_t size, size_t align2)
+ pb_size size, pb_size align2)
{
struct pb_buffer *buffer;
struct pb_manager *mgr;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c
index 4f7e6b1c4df..bc3093f620f 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c
@@ -55,7 +55,7 @@ struct pb_ondemand_buffer
/** Real buffer */
struct pb_buffer *buffer;
- size_t size;
+ pb_size size;
struct pb_desc desc;
};
@@ -204,7 +204,7 @@ pb_ondemand_buffer_fence(struct pb_buffer *_buf,
static void
pb_ondemand_buffer_get_base_buffer(struct pb_buffer *_buf,
struct pb_buffer **base_buf,
- unsigned *offset)
+ pb_size *offset)
{
struct pb_ondemand_buffer *buf = pb_ondemand_buffer(_buf);
@@ -232,7 +232,7 @@ pb_ondemand_buffer_vtbl = {
static struct pb_buffer *
pb_ondemand_manager_create_buffer(struct pb_manager *_mgr,
- size_t size,
+ pb_size size,
const struct pb_desc *desc)
{
struct pb_ondemand_manager *mgr = pb_ondemand_manager(_mgr);
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
index 07fd1a22d93..7fd65ed2261 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
@@ -58,11 +58,11 @@ struct pool_pb_manager
pipe_mutex mutex;
- size_t bufSize;
- size_t bufAlign;
+ pb_size bufSize;
+ pb_size bufAlign;
- size_t numFree;
- size_t numTot;
+ pb_size numFree;
+ pb_size numTot;
struct list_head free;
@@ -89,7 +89,7 @@ struct pool_buffer
struct list_head head;
- size_t start;
+ pb_size start;
};
@@ -162,7 +162,7 @@ pool_buffer_fence(struct pb_buffer *buf,
static void
pool_buffer_get_base_buffer(struct pb_buffer *buf,
struct pb_buffer **base_buf,
- unsigned *offset)
+ pb_size *offset)
{
struct pool_buffer *pool_buf = pool_buffer(buf);
struct pool_pb_manager *pool = pool_buf->mgr;
@@ -184,7 +184,7 @@ pool_buffer_vtbl = {
static struct pb_buffer *
pool_bufmgr_create_buffer(struct pb_manager *mgr,
- size_t size,
+ pb_size size,
const struct pb_desc *desc)
{
struct pool_pb_manager *pool = pool_pb_manager(mgr);
@@ -251,13 +251,13 @@ pool_bufmgr_destroy(struct pb_manager *mgr)
struct pb_manager *
pool_bufmgr_create(struct pb_manager *provider,
- size_t numBufs,
- size_t bufSize,
+ pb_size numBufs,
+ pb_size bufSize,
const struct pb_desc *desc)
{
struct pool_pb_manager *pool;
struct pool_buffer *pool_buf;
- size_t i;
+ pb_size i;
if(!provider)
return NULL;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
index 724aaadb436..e7352e90db9 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
@@ -68,7 +68,7 @@ struct pb_slab_buffer
unsigned mapCount;
/** Offset relative to the start of the slab buffer. */
- size_t start;
+ pb_size start;
/** Use when validating, to signal that all mappings are finished */
/* TODO: Actually validation does not reach this stage yet */
@@ -83,8 +83,8 @@ struct pb_slab
{
struct list_head head;
struct list_head freeBuffers;
- size_t numBuffers;
- size_t numFree;
+ pb_size numBuffers;
+ pb_size numFree;
struct pb_slab_buffer *buffers;
struct pb_slab_manager *mgr;
@@ -108,10 +108,10 @@ struct pb_slab_manager
struct pb_manager *provider;
/** Size of the buffers we hand on downstream */
- size_t bufSize;
+ pb_size bufSize;
/** Size of the buffers we request upstream */
- size_t slabSize;
+ pb_size slabSize;
/**
* Alignment, usage to be used to allocate the slab buffers.
@@ -150,14 +150,14 @@ struct pb_slab_range_manager
struct pb_manager *provider;
- size_t minBufSize;
- size_t maxBufSize;
+ pb_size minBufSize;
+ pb_size maxBufSize;
/** @sa pb_slab_manager::desc */
struct pb_desc desc;
unsigned numBuckets;
- size_t *bucketSizes;
+ pb_size *bucketSizes;
/** Array of pb_slab_manager, one for each bucket size */
struct pb_manager **buckets;
@@ -270,7 +270,7 @@ pb_slab_buffer_fence(struct pb_buffer *_buf,
static void
pb_slab_buffer_get_base_buffer(struct pb_buffer *_buf,
struct pb_buffer **base_buf,
- unsigned *offset)
+ pb_size *offset)
{
struct pb_slab_buffer *buf = pb_slab_buffer(_buf);
pb_get_base_buffer(buf->slab->bo, base_buf, offset);
@@ -369,7 +369,7 @@ out_err0:
static struct pb_buffer *
pb_slab_manager_create_buffer(struct pb_manager *_mgr,
- size_t size,
+ pb_size size,
const struct pb_desc *desc)
{
struct pb_slab_manager *mgr = pb_slab_manager(_mgr);
@@ -450,8 +450,8 @@ pb_slab_manager_destroy(struct pb_manager *_mgr)
struct pb_manager *
pb_slab_manager_create(struct pb_manager *provider,
- size_t bufSize,
- size_t slabSize,
+ pb_size bufSize,
+ pb_size slabSize,
const struct pb_desc *desc)
{
struct pb_slab_manager *mgr;
@@ -479,11 +479,11 @@ pb_slab_manager_create(struct pb_manager *provider,
static struct pb_buffer *
pb_slab_range_manager_create_buffer(struct pb_manager *_mgr,
- size_t size,
+ pb_size size,
const struct pb_desc *desc)
{
struct pb_slab_range_manager *mgr = pb_slab_range_manager(_mgr);
- size_t bufSize;
+ pb_size bufSize;
unsigned i;
bufSize = mgr->minBufSize;
@@ -527,13 +527,13 @@ pb_slab_range_manager_destroy(struct pb_manager *_mgr)
struct pb_manager *
pb_slab_range_manager_create(struct pb_manager *provider,
- size_t minBufSize,
- size_t maxBufSize,
- size_t slabSize,
+ pb_size minBufSize,
+ pb_size maxBufSize,
+ pb_size slabSize,
const struct pb_desc *desc)
{
struct pb_slab_range_manager *mgr;
- size_t bufSize;
+ pb_size bufSize;
unsigned i;
if(!provider)
diff --git a/src/gallium/auxiliary/rtasm/rtasm_ppc.c b/src/gallium/auxiliary/rtasm/rtasm_ppc.c
index e3586482db4..ef4b306cb67 100644
--- a/src/gallium/auxiliary/rtasm/rtasm_ppc.c
+++ b/src/gallium/auxiliary/rtasm/rtasm_ppc.c
@@ -168,7 +168,7 @@ ppc_allocate_register(struct ppc_function *p)
{
unsigned i;
for (i = 0; i < PPC_NUM_REGS; i++) {
- const uint64_t mask = 1 << i;
+ const uint32_t mask = 1 << i;
if ((p->reg_used & mask) == 0) {
p->reg_used |= mask;
return i;
@@ -200,7 +200,7 @@ ppc_allocate_fp_register(struct ppc_function *p)
{
unsigned i;
for (i = 0; i < PPC_NUM_FP_REGS; i++) {
- const uint64_t mask = 1 << i;
+ const uint32_t mask = 1 << i;
if ((p->fp_used & mask) == 0) {
p->fp_used |= mask;
return i;
@@ -232,7 +232,7 @@ ppc_allocate_vec_register(struct ppc_function *p)
{
unsigned i;
for (i = 0; i < PPC_NUM_VEC_REGS; i++) {
- const uint64_t mask = 1 << i;
+ const uint32_t mask = 1 << i;
if ((p->vec_used & mask) == 0) {
p->vec_used |= mask;
return i;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c
index a784b7cc3c1..76a09af18ee 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
@@ -27,6 +27,7 @@
#include "util/u_debug.h"
#include "util/u_string.h"
+#include "util/u_math.h"
#include "tgsi_dump.h"
#include "tgsi_info.h"
#include "tgsi_iterate.h"
@@ -516,7 +517,7 @@ struct str_dump_ctx
struct dump_ctx base;
char *str;
char *ptr;
- size_t left;
+ int left;
};
static void
@@ -525,13 +526,20 @@ str_dump_ctx_printf(struct dump_ctx *ctx, const char *format, ...)
struct str_dump_ctx *sctx = (struct str_dump_ctx *)ctx;
if(sctx->left > 1) {
- size_t written;
+ int written;
va_list ap;
va_start(ap, format);
written = util_vsnprintf(sctx->ptr, sctx->left, format, ap);
va_end(ap);
- sctx->ptr += written;
- sctx->left -= written;
+
+ /* Some complicated logic needed to handle the return value of
+ * vsnprintf:
+ */
+ if (written > 0) {
+ written = MIN2(sctx->left, written);
+ sctx->ptr += written;
+ sctx->left -= written;
+ }
}
}
@@ -556,7 +564,7 @@ tgsi_dump_str(
ctx.str = str;
ctx.str[0] = 0;
ctx.ptr = str;
- ctx.left = size;
+ ctx.left = (int)size;
tgsi_iterate_shader( tokens, &ctx.base.iter );
}
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c
index 6fa13a8ce11..ca797486a0e 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.c
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.c
@@ -1385,7 +1385,7 @@ set_vertex_data(struct gen_mipmap_state *ctx,
* Not +/-1 to avoid cube face selection ambiguity near the edges,
* though that can still sometimes happen with this scale factor...
*/
- const float scale = 0.9999;
+ const float scale = 0.9999f;
const float sc = (2.0f * st[i][0] - 1.0f) * scale;
const float tc = (2.0f * st[i][1] - 1.0f) * scale;
diff --git a/src/gallium/auxiliary/util/u_snprintf.c b/src/gallium/auxiliary/util/u_snprintf.c
index 0d54299b28a..65bdd0df2b7 100644
--- a/src/gallium/auxiliary/util/u_snprintf.c
+++ b/src/gallium/auxiliary/util/u_snprintf.c
@@ -829,7 +829,7 @@ util_vsnprintf(char *str, size_t size, const char *format, va_list args)
break;
default:
intptr = va_arg(args, int *);
- *intptr = len;
+ *intptr = (int)len;
break;
}
break;
diff --git a/src/gallium/drivers/cell/ppu/cell_screen.c b/src/gallium/drivers/cell/ppu/cell_screen.c
index 512d85d3525..bd48ce70050 100644
--- a/src/gallium/drivers/cell/ppu/cell_screen.c
+++ b/src/gallium/drivers/cell/ppu/cell_screen.c
@@ -86,6 +86,8 @@ cell_get_param(struct pipe_screen *screen, int param)
return 1; /* XXX not really true */
case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
return 0; /* XXX to do */
+ case PIPE_CAP_TGSI_CONT_SUPPORTED:
+ return 1;
default:
return 0;
}
diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c
index 62e8d99cfd0..86df320ea8a 100644
--- a/src/gallium/drivers/softpipe/sp_context.c
+++ b/src/gallium/drivers/softpipe/sp_context.c
@@ -126,6 +126,22 @@ softpipe_is_texture_referenced( struct pipe_context *pipe,
struct pipe_texture *texture,
unsigned face, unsigned level)
{
+ struct softpipe_context *softpipe = softpipe_context( pipe );
+ unsigned i;
+
+ if(softpipe->dirty_render_cache) {
+ for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++) {
+ if(softpipe->framebuffer.cbufs[i] &&
+ softpipe->framebuffer.cbufs[i]->texture == texture)
+ return PIPE_REFERENCED_FOR_WRITE;
+ }
+ if(softpipe->framebuffer.zsbuf &&
+ softpipe->framebuffer.zsbuf->texture == texture)
+ return PIPE_REFERENCED_FOR_WRITE;
+ }
+
+ /* FIXME: we also need to do the same for the texture cache */
+
return PIPE_UNREFERENCED;
}
diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h
index 59d6df8f2dd..dffc15a4f19 100644
--- a/src/gallium/drivers/softpipe/sp_context.h
+++ b/src/gallium/drivers/softpipe/sp_context.h
@@ -144,6 +144,8 @@ struct softpipe_context {
struct draw_stage *vbuf;
struct softpipe_vbuf_render *vbuf_render;
+ boolean dirty_render_cache;
+
struct softpipe_tile_cache *cbuf_cache[PIPE_MAX_COLOR_BUFS];
struct softpipe_tile_cache *zsbuf_cache;
diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c
index f117096bf73..ba2766ff139 100644
--- a/src/gallium/drivers/softpipe/sp_draw_arrays.c
+++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c
@@ -182,6 +182,8 @@ softpipe_draw_range_elements(struct pipe_context *pipe,
/* Note: leave drawing surfaces mapped */
softpipe_unmap_constant_buffers(sp);
+ sp->dirty_render_cache = TRUE;
+
return TRUE;
}
diff --git a/src/gallium/drivers/softpipe/sp_flush.c b/src/gallium/drivers/softpipe/sp_flush.c
index 035f4b963eb..4a14d49686e 100644
--- a/src/gallium/drivers/softpipe/sp_flush.c
+++ b/src/gallium/drivers/softpipe/sp_flush.c
@@ -71,6 +71,8 @@ softpipe_flush( struct pipe_context *pipe,
* to unmap surfaces when flushing.
*/
softpipe_unmap_transfers(softpipe);
+
+ softpipe->dirty_render_cache = FALSE;
}
/* Enable to dump BMPs of the color/depth buffers each frame */
diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
index a32fd3a1ba0..cc39d33ede6 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -87,6 +87,8 @@ softpipe_get_param(struct pipe_screen *screen, int param)
return 8; /* max 128x128x128 */
case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
return 12; /* max 2Kx2K */
+ case PIPE_CAP_TGSI_CONT_SUPPORTED:
+ return 1;
default:
return 0;
}
diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c
index accc692b66f..e5be65242d6 100644
--- a/src/gallium/drivers/softpipe/sp_setup.c
+++ b/src/gallium/drivers/softpipe/sp_setup.c
@@ -444,7 +444,8 @@ static void flush_spans( struct setup_context *setup )
mask |= MASK_TOP_RIGHT;
if (x+1 >= xleft1 && x+1 < xright1)
mask |= MASK_BOTTOM_RIGHT;
- EMIT_QUAD( setup, x, setup->span.y, mask );
+ if (mask)
+ EMIT_QUAD( setup, x, setup->span.y, mask );
}
break;
@@ -458,7 +459,8 @@ static void flush_spans( struct setup_context *setup )
mask |= MASK_TOP_LEFT;
if (x+1 >= xleft0 && x+1 < xright0)
mask |= MASK_TOP_RIGHT;
- EMIT_QUAD( setup, x, setup->span.y, mask );
+ if (mask)
+ EMIT_QUAD( setup, x, setup->span.y, mask );
}
break;
@@ -472,7 +474,8 @@ static void flush_spans( struct setup_context *setup )
mask |= MASK_BOTTOM_LEFT;
if (x+1 >= xleft1 && x+1 < xright1)
mask |= MASK_BOTTOM_RIGHT;
- EMIT_QUAD( setup, x, setup->span.y, mask );
+ if (mask)
+ EMIT_QUAD( setup, x, setup->span.y, mask );
}
break;
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
index adbd0cb7f0c..5de358dae93 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -744,7 +744,9 @@ shadow_compare(uint compare_func,
break;
}
+ /* XXX returning result for default GL_DEPTH_TEXTURE_MODE = GL_LUMINANCE */
rgba[0][j] = rgba[1][j] = rgba[2][j] = (float) k;
+ rgba[3][j] = 1.0F;
}
diff --git a/src/gallium/drivers/trace/tr_dump.c b/src/gallium/drivers/trace/tr_dump.c
index 3a1409e95a7..643587ab427 100644
--- a/src/gallium/drivers/trace/tr_dump.c
+++ b/src/gallium/drivers/trace/tr_dump.c
@@ -451,11 +451,11 @@ void trace_dump_float(double value)
}
void trace_dump_bytes(const void *data,
- long unsigned size)
+ size_t size)
{
static const char hex_table[16] = "0123456789ABCDEF";
const uint8_t *p = data;
- long unsigned i;
+ size_t i;
if (!dumping)
return;
diff --git a/src/gallium/drivers/trace/tr_dump.h b/src/gallium/drivers/trace/tr_dump.h
index 31ac70802f0..32592bab12f 100644
--- a/src/gallium/drivers/trace/tr_dump.h
+++ b/src/gallium/drivers/trace/tr_dump.h
@@ -91,7 +91,7 @@ void trace_dump_bool(int value);
void trace_dump_int(long long int value);
void trace_dump_uint(long long unsigned value);
void trace_dump_float(double value);
-void trace_dump_bytes(const void *data, long unsigned size);
+void trace_dump_bytes(const void *data, size_t size);
void trace_dump_string(const char *str);
void trace_dump_enum(const char *value);
void trace_dump_array_begin(void);
@@ -130,7 +130,7 @@ void trace_dump_transfer_ptr(struct pipe_transfer *_transfer);
#define trace_dump_array(_type, _obj, _size) \
do { \
- unsigned long idx; \
+ size_t idx; \
trace_dump_array_begin(); \
for(idx = 0; idx < (_size); ++idx) { \
trace_dump_elem_begin(); \
@@ -142,7 +142,7 @@ void trace_dump_transfer_ptr(struct pipe_transfer *_transfer);
#define trace_dump_struct_array(_type, _obj, _size) \
do { \
- unsigned long idx; \
+ size_t idx; \
trace_dump_array_begin(); \
for(idx = 0; idx < (_size); ++idx) { \
trace_dump_elem_begin(); \
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index 82e23c413c8..ab57ed73c4c 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -310,6 +310,7 @@ enum pipe_transfer_usage {
#define PIPE_CAP_TEXTURE_MIRROR_CLAMP 24
#define PIPE_CAP_TEXTURE_MIRROR_REPEAT 25
#define PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS 26
+#define PIPE_CAP_TGSI_CONT_SUPPORTED 27
/**
diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h
index a279eefef9e..c4469d4a9e9 100644
--- a/src/gallium/include/pipe/p_format.h
+++ b/src/gallium/include/pipe/p_format.h
@@ -536,14 +536,40 @@ pf_get_nblocks(const struct pipe_format_block *block, unsigned width, unsigned h
return pf_get_nblocksx(block, width)*pf_get_nblocksy(block, height);
}
+static INLINE size_t
+pf_get_stride(const struct pipe_format_block *block, unsigned width)
+{
+ return pf_get_nblocksx(block, width)*block->size;
+}
+
+static INLINE size_t
+pf_get_2d_size(const struct pipe_format_block *block, size_t stride, unsigned height)
+{
+ return pf_get_nblocksy(block, height)*stride;
+}
+
static INLINE boolean
-pf_is_depth_stencil( enum pipe_format format )
+pf_is_depth_or_stencil( enum pipe_format format )
{
return (pf_get_component_bits( format, PIPE_FORMAT_COMP_Z ) +
pf_get_component_bits( format, PIPE_FORMAT_COMP_S )) != 0;
}
static INLINE boolean
+pf_is_depth_and_stencil( enum pipe_format format )
+{
+ return (pf_get_component_bits( format, PIPE_FORMAT_COMP_Z ) != 0 &&
+ pf_get_component_bits( format, PIPE_FORMAT_COMP_S ) != 0);
+}
+
+/** DEPRECATED: For backwards compatibility */
+static INLINE boolean
+pf_is_depth_stencil( enum pipe_format format )
+{
+ return pf_is_depth_or_stencil( format );
+}
+
+static INLINE boolean
pf_is_compressed( enum pipe_format format )
{
return pf_layout(format) == PIPE_FORMAT_LAYOUT_DXT ? TRUE : FALSE;
diff --git a/src/gallium/include/pipe/p_refcnt.h b/src/gallium/include/pipe/p_refcnt.h
index 1f89453e09a..1f9088b3e9c 100644
--- a/src/gallium/include/pipe/p_refcnt.h
+++ b/src/gallium/include/pipe/p_refcnt.h
@@ -62,29 +62,29 @@ pipe_is_referenced(struct pipe_reference *reference)
* Set 'ptr' to point to 'reference' and update reference counting.
* The old thing pointed to, if any, will be unreferenced first.
* 'reference' may be NULL.
- *
- * XXX: thread safety issues!
*/
static INLINE bool
pipe_reference(struct pipe_reference **ptr, struct pipe_reference *reference)
{
bool destroy = FALSE;
- /* bump the reference.count first */
- if (reference) {
- assert(pipe_is_referenced(reference));
- p_atomic_inc(&reference->count);
- }
-
- if (*ptr) {
- assert(pipe_is_referenced(*ptr));
- if (p_atomic_dec_zero(&(*ptr)->count)) {
- destroy = TRUE;
+ if(*ptr != reference) {
+ /* bump the reference.count first */
+ if (reference) {
+ assert(pipe_is_referenced(reference));
+ p_atomic_inc(&reference->count);
}
+
+ if (*ptr) {
+ assert(pipe_is_referenced(*ptr));
+ if (p_atomic_dec_zero(&(*ptr)->count)) {
+ destroy = TRUE;
+ }
+ }
+
+ *ptr = reference;
}
- *ptr = reference;
-
return destroy;
}
diff --git a/src/gallium/include/pipe/p_thread.h b/src/gallium/include/pipe/p_thread.h
index de55e99ed49..ce8d79549ad 100644
--- a/src/gallium/include/pipe/p_thread.h
+++ b/src/gallium/include/pipe/p_thread.h
@@ -36,6 +36,7 @@
#include "pipe/p_compiler.h"
+#include "util/u_debug.h" /* for assert */
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS)
diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c
index 15a2088df51..5846390d02c 100644
--- a/src/gallium/state_trackers/dri/dri_drawable.c
+++ b/src/gallium/state_trackers/dri/dri_drawable.c
@@ -231,7 +231,6 @@ dri_create_buffer(__DRIscreenPrivate * sPriv,
if (visual->depthBits) {
if (pscreen->is_format_supported(pscreen, PIPE_FORMAT_Z24S8_UNORM,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_RENDER_TARGET |
PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0))
depthFormat = PIPE_FORMAT_Z24S8_UNORM;
else
@@ -242,7 +241,6 @@ dri_create_buffer(__DRIscreenPrivate * sPriv,
if (visual->stencilBits) {
if (pscreen->is_format_supported(pscreen, PIPE_FORMAT_Z24S8_UNORM,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_RENDER_TARGET |
PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0))
stencilFormat = PIPE_FORMAT_Z24S8_UNORM;
else
diff --git a/src/gallium/state_trackers/glx/xlib/fakeglx.c b/src/gallium/state_trackers/glx/xlib/fakeglx.c
index 65e7048188e..6df4c7d6936 100644
--- a/src/gallium/state_trackers/glx/xlib/fakeglx.c
+++ b/src/gallium/state_trackers/glx/xlib/fakeglx.c
@@ -1817,7 +1817,7 @@ Fake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap,
if (!dpy || !config || !pixmap)
return 0;
- for (attr = attribList; *attr; attr++) {
+ for (attr = attribList; attr && *attr; attr++) {
switch (*attr) {
case GLX_TEXTURE_FORMAT_EXT:
attr++;
diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py
index 5d4d04498b2..5885e162c28 100755
--- a/src/gallium/state_trackers/python/retrace/interpreter.py
+++ b/src/gallium/state_trackers/python/retrace/interpreter.py
@@ -43,19 +43,27 @@ except ImportError:
return struct.unpack(fmt, buf[offset:offset + size])
-def make_image(surface):
+def make_image(surface, x=None, y=None, w=None, h=None):
+ if x is None:
+ x = 0
+ if y is None:
+ y = 0
+ if w is None:
+ w = surface.width - x
+ if h is None:
+ h = surface.height - y
data = surface.get_tile_rgba8(0, 0, surface.width, surface.height)
import Image
outimage = Image.fromstring('RGBA', (surface.width, surface.height), data, "raw", 'RGBA', 0, 1)
return outimage
-def save_image(filename, surface):
- outimage = make_image(surface)
+def save_image(filename, surface, x=None, y=None, w=None, h=None):
+ outimage = make_image(surface, x, y, w, h)
outimage.save(filename, "PNG")
-def show_image(surface, title):
- outimage = make_image(surface)
+def show_image(surface, title, x=None, y=None, w=None, h=None):
+ outimage = make_image(surface, x, y, w, h)
import Tkinter as tk
from PIL import Image, ImageTk
@@ -305,7 +313,11 @@ class Screen(Object):
def get_tex_transfer(self, texture, face, level, zslice, usage, x, y, w, h):
if texture is None:
return None
- return Transfer(texture.get_surface(face, level, zslice), x, y, w, h)
+ transfer = Transfer(texture.get_surface(face, level, zslice), x, y, w, h)
+ if transfer and usage != gallium.PIPE_TRANSFER_WRITE:
+ if self.interpreter.options.all:
+ self.interpreter.present(transfer.surface, 'transf_read', x, y, w, h)
+ return transfer
def tex_transfer_destroy(self, transfer):
self.interpreter.unregister_object(transfer)
@@ -314,6 +326,8 @@ class Screen(Object):
if transfer is None:
return
transfer.surface.put_tile_raw(transfer.x, transfer.y, transfer.w, transfer.h, data, stride)
+ if self.interpreter.options.all:
+ self.interpreter.present(transfer.surface, 'transf_write', transfer.x, transfer.y, transfer.w, transfer.h)
def user_buffer_create(self, data, size):
# We don't really care to distinguish between user and regular buffers
@@ -577,6 +591,14 @@ class Context(Object):
self.real.draw_range_elements(indexBuffer, indexSize, minIndex, maxIndex, mode, start, count)
self._set_dirty()
+ def is_texture_referenced(self, texture, face, level):
+ #return self.real.is_texture_referenced(format, texture, face, level)
+ pass
+
+ def is_buffer_referenced(self, buf):
+ #return self.real.is_buffer_referenced(format, buf)
+ pass
+
def _set_dirty(self):
if self.interpreter.options.step:
self._present()
@@ -602,6 +624,9 @@ class Context(Object):
if self.cbufs and self.cbufs[0]:
self.interpreter.present(self.cbufs[0], "cbuf")
+ if self.zsbuf:
+ if self.interpreter.options.all:
+ self.interpreter.present(self.zsbuf, "zsbuf")
class Interpreter(parser.TraceDumper):
@@ -671,16 +696,16 @@ class Interpreter(parser.TraceDumper):
def verbosity(self, level):
return self.options.verbosity >= level
- def present(self, surface, description):
+ def present(self, surface, description, x=None, y=None, w=None, h=None):
if self.call_no < self.options.start:
return
if self.options.images:
- filename = '%s_%04u.png' % (description, self.call_no)
- save_image(filename, surface)
+ filename = '%04u_%s.png' % (self.call_no, description)
+ save_image(filename, surface, x, y, w, h)
else:
title = '%u. %s' % (self.call_no, description)
- show_image(surface, title)
+ show_image(surface, title, x, y, w, h)
class Main(parser.Main):
@@ -690,6 +715,7 @@ class Main(parser.Main):
optparser.add_option("-q", "--quiet", action="store_const", const=0, dest="verbosity", help="no messages")
optparser.add_option("-v", "--verbose", action="count", dest="verbosity", default=1, help="increase verbosity level")
optparser.add_option("-i", "--images", action="store_true", dest="images", default=False, help="save images instead of showing them")
+ optparser.add_option("-a", "--all", action="store_true", dest="all", default=False, help="show depth, stencil, and transfers")
optparser.add_option("-s", "--step", action="store_true", dest="step", default=False, help="step trhough every draw")
optparser.add_option("-f", "--from", action="store", type="int", dest="start", default=0, help="from call no")
optparser.add_option("-t", "--to", action="store", type="int", dest="stop", default=0, help="until call no")
diff --git a/src/gallium/state_trackers/python/tests/base.py b/src/gallium/state_trackers/python/tests/base.py
index 1fa7fe6f3b3..202ccfc3509 100755
--- a/src/gallium/state_trackers/python/tests/base.py
+++ b/src/gallium/state_trackers/python/tests/base.py
@@ -46,6 +46,14 @@ for name, value in globals().items():
if name.startswith("PIPE_FORMAT_") and isinstance(value, int):
formats[value] = name
+def is_depth_stencil_format(format):
+ # FIXME: make and use binding to pf_is_depth_stencil
+ return format in (
+ PIPE_FORMAT_Z32_UNORM,
+ PIPE_FORMAT_Z24S8_UNORM,
+ PIPE_FORMAT_Z24X8_UNORM,
+ PIPE_FORMAT_Z16_UNORM,
+ )
def make_image(width, height, rgba):
import Image
diff --git a/src/gallium/state_trackers/python/tests/texture_sample.py b/src/gallium/state_trackers/python/tests/texture_sample.py
index a382424667c..c7b78abbbec 100755
--- a/src/gallium/state_trackers/python/tests/texture_sample.py
+++ b/src/gallium/state_trackers/python/tests/texture_sample.py
@@ -99,7 +99,7 @@ def is_pot(n):
return n & (n - 1) == 0
-class TextureTest(TestCase):
+class TextureColorSampleTest(TestCase):
tags = (
'target',
@@ -286,6 +286,206 @@ class TextureTest(TestCase):
self.assert_rgba(cbuf, x, y, w, h, expected_rgba, 4.0/256, 0.85)
+class TextureDepthSampleTest(TestCase):
+
+ tags = (
+ 'target',
+ 'format',
+ 'width',
+ 'height',
+ 'depth',
+ 'last_level',
+ 'face',
+ 'level',
+ 'zslice',
+ )
+
+ def test(self):
+ dev = self.dev
+
+ target = self.target
+ format = self.format
+ width = self.width
+ height = self.height
+ depth = self.depth
+ last_level = self.last_level
+ face = self.face
+ level = self.level
+ zslice = self.zslice
+
+ tex_usage = PIPE_TEXTURE_USAGE_SAMPLER
+ geom_flags = 0
+ if width != height:
+ geom_flags |= PIPE_TEXTURE_GEOM_NON_SQUARE
+ if not is_pot(width) or not is_pot(height) or not is_pot(depth):
+ geom_flags |= PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO
+
+ if not dev.is_format_supported(format, target, tex_usage, geom_flags):
+ raise TestSkip
+
+ ctx = self.dev.context_create()
+
+ # disabled blending/masking
+ blend = Blend()
+ blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE
+ blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE
+ blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO
+ blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO
+ blend.colormask = PIPE_MASK_RGBA
+ ctx.set_blend(blend)
+
+ # depth/stencil/alpha
+ depth_stencil_alpha = DepthStencilAlpha()
+ depth_stencil_alpha.depth.enabled = 1
+ depth_stencil_alpha.depth.writemask = 1
+ depth_stencil_alpha.depth.func = PIPE_FUNC_LESS
+ ctx.set_depth_stencil_alpha(depth_stencil_alpha)
+
+ # rasterizer
+ rasterizer = Rasterizer()
+ rasterizer.front_winding = PIPE_WINDING_CW
+ rasterizer.cull_mode = PIPE_WINDING_NONE
+ rasterizer.bypass_vs_clip_and_viewport = 1
+ ctx.set_rasterizer(rasterizer)
+
+ # samplers
+ sampler = Sampler()
+ sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE
+ sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE
+ sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE
+ sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST
+ sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST
+ sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST
+ sampler.normalized_coords = 1
+ sampler.min_lod = 0
+ sampler.max_lod = PIPE_MAX_TEXTURE_LEVELS - 1
+ ctx.set_sampler(0, sampler)
+
+ # texture
+ texture = dev.texture_create(
+ target = target,
+ format = format,
+ width = width,
+ height = height,
+ depth = depth,
+ last_level = last_level,
+ tex_usage = tex_usage,
+ )
+
+ expected_rgba = FloatArray(height*width*4)
+ texture.get_surface(
+ face = face,
+ level = level,
+ zslice = zslice,
+ ).sample_rgba(expected_rgba)
+
+ ctx.set_sampler_texture(0, texture)
+
+ # framebuffer
+ cbuf_tex = dev.texture_create(
+ PIPE_FORMAT_A8R8G8B8_UNORM,
+ width,
+ height,
+ tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET,
+ )
+
+ zsbuf_tex = dev.texture_create(
+ PIPE_FORMAT_Z24X8_UNORM,
+ width,
+ height,
+ tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET,
+ )
+
+ cbuf = cbuf_tex.get_surface()
+ zsbuf = zsbuf_tex.get_surface()
+ fb = Framebuffer()
+ fb.width = width
+ fb.height = height
+ fb.nr_cbufs = 1
+ fb.set_cbuf(0, cbuf)
+ fb.set_zsbuf(zsbuf)
+ ctx.set_framebuffer(fb)
+ rgba = FloatArray(4);
+ rgba[0] = 0.5
+ rgba[1] = 0.5
+ rgba[2] = 0.5
+ rgba[3] = 0.5
+ ctx.clear(PIPE_CLEAR_DEPTHSTENCIL, rgba, 1.0, 0)
+ del fb
+
+ # vertex shader
+ vs = Shader('''
+ VERT1.1
+ DCL IN[0], POSITION, CONSTANT
+ DCL IN[1], GENERIC, CONSTANT
+ DCL OUT[0], POSITION, CONSTANT
+ DCL OUT[1], GENERIC, CONSTANT
+ 0:MOV OUT[0], IN[0]
+ 1:MOV OUT[1], IN[1]
+ 2:END
+ ''')
+ #vs.dump()
+ ctx.set_vertex_shader(vs)
+
+ # fragment shader
+ op = {
+ PIPE_TEXTURE_1D: "1D",
+ PIPE_TEXTURE_2D: "2D",
+ PIPE_TEXTURE_3D: "3D",
+ PIPE_TEXTURE_CUBE: "CUBE",
+ }[target]
+ fs = Shader('''
+ FRAG1.1
+ DCL IN[0], GENERIC[0], LINEAR
+ DCL SAMP[0], CONSTANT
+ DCL OUT[0].z, POSITION
+ 0:TEX OUT[0].z, IN[0], SAMP[0], %s
+ 1:END
+ ''' % op)
+ #fs.dump()
+ ctx.set_fragment_shader(fs)
+
+ nverts = 4
+ nattrs = 2
+ verts = FloatArray(nverts * nattrs * 4)
+
+ x = 0
+ y = 0
+ w, h = minify((width, height), level)
+
+ pos = [
+ [x, y],
+ [x+w, y],
+ [x+w, y+h],
+ [x, y+h],
+ ]
+
+ tex = tex_coords(texture, face, level, zslice)
+
+ for i in range(0, 4):
+ j = 8*i
+ verts[j + 0] = pos[i][0] # x
+ verts[j + 1] = pos[i][1] # y
+ verts[j + 2] = 0.0 # z
+ verts[j + 3] = 1.0 # w
+ verts[j + 4] = tex[i][0] # s
+ verts[j + 5] = tex[i][1] # r
+ verts[j + 6] = tex[i][2] # q
+ verts[j + 7] = 1.0
+
+ ctx.draw_vertices(PIPE_PRIM_TRIANGLE_FAN,
+ nverts,
+ nattrs,
+ verts)
+
+ ctx.flush()
+
+ zsbuf = zsbuf_tex.get_surface()
+
+ self.assert_rgba(zsbuf, x, y, w, h, expected_rgba, 4.0/256, 0.85)
+
+
+
def main():
dev = Device()
@@ -297,18 +497,13 @@ def main():
PIPE_TEXTURE_3D,
]
- formats = [
+ color_formats = [
PIPE_FORMAT_A8R8G8B8_UNORM,
PIPE_FORMAT_X8R8G8B8_UNORM,
#PIPE_FORMAT_A8R8G8B8_SRGB,
PIPE_FORMAT_R5G6B5_UNORM,
PIPE_FORMAT_A1R5G5B5_UNORM,
PIPE_FORMAT_A4R4G4B4_UNORM,
- #PIPE_FORMAT_Z32_UNORM,
- #PIPE_FORMAT_Z24S8_UNORM,
- #PIPE_FORMAT_Z24X8_UNORM,
- #PIPE_FORMAT_Z16_UNORM,
- #PIPE_FORMAT_S8_UNORM,
PIPE_FORMAT_A8_UNORM,
PIPE_FORMAT_L8_UNORM,
PIPE_FORMAT_YCBCR,
@@ -318,6 +513,13 @@ def main():
#PIPE_FORMAT_DXT5_RGBA,
]
+ depth_formats = [
+ PIPE_FORMAT_Z32_UNORM,
+ PIPE_FORMAT_Z24S8_UNORM,
+ PIPE_FORMAT_Z24X8_UNORM,
+ PIPE_FORMAT_Z16_UNORM,
+ ]
+
sizes = [64, 32, 16, 8, 4, 2, 1]
#sizes = [1020, 508, 252, 62, 30, 14, 6, 3]
#sizes = [64]
@@ -332,8 +534,8 @@ def main():
PIPE_TEX_FACE_NEG_Z,
]
- for target in targets:
- for format in formats:
+ for format in color_formats:
+ for target in targets:
for size in sizes:
if target == PIPE_TEXTURE_3D:
depth = size
@@ -347,7 +549,7 @@ def main():
for level in range(0, last_level + 1):
zslice = 0
while zslice < depth >> level:
- test = TextureTest(
+ test = TextureColorSampleTest(
dev = dev,
target = target,
format = format,
@@ -361,6 +563,27 @@ def main():
)
suite.add_test(test)
zslice = (zslice + 1)*2 - 1
+ for format in depth_formats:
+ target = PIPE_TEXTURE_2D
+ depth = 1
+ face = 0
+ last_level = 0
+ level = 0
+ zslice = 0
+ for size in sizes:
+ test = TextureDepthSampleTest(
+ dev = dev,
+ target = target,
+ format = format,
+ width = size,
+ height = size,
+ depth = depth,
+ last_level = last_level,
+ face = face,
+ level = level,
+ zslice = zslice,
+ )
+ suite.add_test(test)
suite.run()
diff --git a/src/gallium/state_trackers/wgl/shared/stw_context.c b/src/gallium/state_trackers/wgl/shared/stw_context.c
index 662b5fbcd2a..9df1ab76526 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_context.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_context.c
@@ -47,6 +47,23 @@
#include "stw_context.h"
#include "stw_tls.h"
+
+static INLINE struct stw_context *
+stw_context(GLcontext *glctx)
+{
+ if(!glctx)
+ return NULL;
+ assert(glctx->DriverCtx);
+ return (struct stw_context *)glctx->DriverCtx;
+}
+
+static INLINE struct stw_context *
+stw_current_context(void)
+{
+ GET_CURRENT_CONTEXT( glctx );
+ return stw_context(glctx);
+}
+
BOOL
stw_copy_context(
UINT_PTR hglrcSrc,
@@ -99,6 +116,18 @@ stw_share_lists(
return ret;
}
+static void
+stw_viewport(GLcontext * glctx, GLint x, GLint y,
+ GLsizei width, GLsizei height)
+{
+ struct stw_context *ctx = (struct stw_context *)glctx->DriverCtx;
+ struct stw_framebuffer *fb;
+
+ fb = stw_framebuffer_from_hdc( ctx->hdc );
+ if(fb)
+ stw_framebuffer_update(fb);
+}
+
UINT_PTR
stw_create_layer_context(
HDC hdc,
@@ -158,6 +187,7 @@ stw_create_layer_context(
goto no_st_ctx;
ctx->st->ctx->DriverCtx = ctx;
+ ctx->st->ctx->Driver.Viewport = stw_viewport;
pipe_mutex_lock( stw_dev->mutex );
ctx->hglrc = handle_table_add(stw_dev->ctx_table, ctx);
@@ -194,11 +224,10 @@ stw_delete_context(
pipe_mutex_unlock( stw_dev->mutex );
if (ctx) {
- GLcontext *glctx = ctx->st->ctx;
- GET_CURRENT_CONTEXT( glcurctx );
-
+ struct stw_context *curctx = stw_current_context();
+
/* Unbind current if deleting current context. */
- if (glcurctx == glctx)
+ if (curctx == ctx)
st_make_current( NULL, NULL, NULL );
st_destroy_context(ctx->st);
@@ -230,13 +259,8 @@ stw_release_context(
* current for this thread. We should check that and return False
* if not the case.
*/
- {
- GLcontext *glctx = ctx->st->ctx;
- GET_CURRENT_CONTEXT( glcurctx );
-
- if (glcurctx != glctx)
- return FALSE;
- }
+ if (ctx != stw_current_context())
+ return FALSE;
if (stw_make_current( NULL, 0 ) == FALSE)
return FALSE;
@@ -248,14 +272,9 @@ stw_release_context(
UINT_PTR
stw_get_current_context( void )
{
- GET_CURRENT_CONTEXT( glcurctx );
struct stw_context *ctx;
- if(!glcurctx)
- return 0;
-
- ctx = (struct stw_context *)glcurctx->DriverCtx;
- assert(ctx);
+ ctx = stw_current_context();
if(!ctx)
return 0;
@@ -265,14 +284,9 @@ stw_get_current_context( void )
HDC
stw_get_current_dc( void )
{
- GET_CURRENT_CONTEXT( glcurctx );
struct stw_context *ctx;
- if(!glcurctx)
- return NULL;
-
- ctx = (struct stw_context *)glcurctx->DriverCtx;
- assert(ctx);
+ ctx = stw_current_context();
if(!ctx)
return NULL;
@@ -284,23 +298,24 @@ stw_make_current(
HDC hdc,
UINT_PTR hglrc )
{
+ struct stw_context *curctx;
struct stw_context *ctx;
- GET_CURRENT_CONTEXT( glcurctx );
struct stw_framebuffer *fb;
if (!stw_dev)
goto fail;
- if (glcurctx != NULL) {
- struct stw_context *curctx;
- curctx = (struct stw_context *) glcurctx->DriverCtx;
-
+ curctx = stw_current_context();
+ if (curctx != NULL) {
if (curctx->hglrc != hglrc)
- st_flush(glcurctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+ st_flush(curctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
/* Return if already current. */
- if (curctx->hglrc == hglrc && curctx->hdc == hdc)
- return TRUE;
+ if (curctx->hglrc == hglrc && curctx->hdc == hdc) {
+ ctx = curctx;
+ fb = stw_framebuffer_from_hdc( hdc );
+ goto success;
+ }
}
if (hdc == NULL || hglrc == 0) {
@@ -344,7 +359,10 @@ stw_make_current(
if(!st_make_current( ctx->st, fb->stfb, fb->stfb ))
goto fail;
- stw_framebuffer_resize(fb);
+success:
+ assert(fb);
+ if(fb)
+ stw_framebuffer_update(fb);
return TRUE;
diff --git a/src/gallium/state_trackers/wgl/shared/stw_device.c b/src/gallium/state_trackers/wgl/shared/stw_device.c
index 1a6b29807d7..ce466241463 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_device.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_device.c
@@ -30,6 +30,7 @@
#include "glapi/glthread.h"
#include "util/u_debug.h"
#include "pipe/p_screen.h"
+#include "state_tracker/st_public.h"
#ifdef DEBUG
#include "trace/tr_screen.h"
@@ -63,15 +64,39 @@ stw_flush_frontbuffer(struct pipe_screen *screen,
{
const struct stw_winsys *stw_winsys = stw_dev->stw_winsys;
HDC hdc = (HDC)context_private;
+ struct stw_framebuffer *fb;
+ fb = stw_framebuffer_from_hdc( hdc );
+ /* fb can be NULL if window was destroyed already */
+ if (fb) {
+ pipe_mutex_lock( fb->mutex );
+
+#if DEBUG
+ {
+ struct pipe_surface *surface2;
+
+ if(!st_get_framebuffer_surface( fb->stfb, ST_SURFACE_FRONT_LEFT, &surface2 ))
+ assert(0);
+ else
+ assert(surface2 == surface);
+ }
+#endif
+
#ifdef DEBUG
- if(stw_dev->trace_running) {
- screen = trace_screen(screen)->screen;
- surface = trace_surface(surface)->surface;
- }
+ if(stw_dev->trace_running) {
+ screen = trace_screen(screen)->screen;
+ surface = trace_surface(surface)->surface;
+ }
#endif
+ }
stw_winsys->flush_frontbuffer(screen, surface, hdc);
+
+ if(fb) {
+ stw_framebuffer_update(fb);
+
+ pipe_mutex_unlock( fb->mutex );
+ }
}
@@ -133,20 +158,13 @@ error1:
boolean
stw_init_thread(void)
{
- if (!stw_tls_init_thread())
- return FALSE;
-
- if (!stw_framebuffer_init_thread())
- return FALSE;
-
- return TRUE;
+ return stw_tls_init_thread();
}
void
stw_cleanup_thread(void)
{
- stw_framebuffer_cleanup_thread();
stw_tls_cleanup_thread();
}
diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c
index de37d135dfe..7d0e8f46482 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c
@@ -45,7 +45,7 @@
#include "stw_tls.h"
-struct stw_framebuffer *
+static INLINE struct stw_framebuffer *
stw_framebuffer_from_hwnd_locked(
HWND hwnd )
{
@@ -84,7 +84,7 @@ stw_framebuffer_destroy_locked(
* @sa http://msdn.microsoft.com/en-us/library/ms644975(VS.85).aspx
* @sa http://msdn.microsoft.com/en-us/library/ms644960(VS.85).aspx
*/
-static LRESULT CALLBACK
+LRESULT CALLBACK
stw_call_window_proc(
int nCode,
WPARAM wParam,
@@ -111,14 +111,10 @@ stw_call_window_proc(
unsigned width = LOWORD( pParams->lParam );
unsigned height = HIWORD( pParams->lParam );
- /* FIXME: The mesa statetracker makes the assumptions that only
- * one context is using the framebuffer, and that that context is the
- * current one. However neither holds true, as WGL allows more than
- * one context to be bound to the same drawable, and this function can
- * be called from any thread.
- */
pipe_mutex_lock( fb->mutex );
- st_resize_framebuffer( fb->stfb, width, height );
+ fb->must_resize = TRUE;
+ fb->width = width;
+ fb->height = height;
pipe_mutex_unlock( fb->mutex );
}
}
@@ -139,6 +135,31 @@ stw_call_window_proc(
}
+static void
+stw_framebuffer_get_size( struct stw_framebuffer *fb )
+{
+ unsigned width, height;
+ RECT rect;
+
+ assert(fb->hWnd);
+
+ GetClientRect( fb->hWnd, &rect );
+ width = rect.right - rect.left;
+ height = rect.bottom - rect.top;
+
+ if(width < 1)
+ width = 1;
+ if(height < 1)
+ height = 1;
+
+ if(width != fb->width || height != fb->height) {
+ fb->must_resize = TRUE;
+ fb->width = width;
+ fb->height = height;
+ }
+}
+
+
/**
* Create a new framebuffer object which will correspond to the given HDC.
*/
@@ -168,6 +189,8 @@ stw_framebuffer_create_locked(
stw_pixelformat_visual(&fb->visual, pfi);
+ stw_framebuffer_get_size(fb);
+
pipe_mutex_init( fb->mutex );
fb->next = stw_dev->fb_head;
@@ -177,32 +200,6 @@ stw_framebuffer_create_locked(
}
-static void
-stw_framebuffer_get_size( struct stw_framebuffer *fb, GLuint *pwidth, GLuint *pheight )
-{
- GLuint width, height;
-
- if (fb->hWnd) {
- RECT rect;
- GetClientRect( fb->hWnd, &rect );
- width = rect.right - rect.left;
- height = rect.bottom - rect.top;
- }
- else {
- width = GetDeviceCaps( fb->hDC, HORZRES );
- height = GetDeviceCaps( fb->hDC, VERTRES );
- }
-
- if(width < 1)
- width = 1;
- if(height < 1)
- height = 1;
-
- *pwidth = width;
- *pheight = height;
-}
-
-
BOOL
stw_framebuffer_allocate(
struct stw_framebuffer *fb)
@@ -212,7 +209,6 @@ stw_framebuffer_allocate(
if(!fb->stfb) {
const struct stw_pixelformat_info *pfi = fb->pfi;
enum pipe_format colorFormat, depthFormat, stencilFormat;
- GLuint width, height;
colorFormat = pfi->color_format;
@@ -228,16 +224,21 @@ stw_framebuffer_allocate(
else
stencilFormat = PIPE_FORMAT_NONE;
- stw_framebuffer_get_size(fb, &width, &height);
-
+ assert(fb->must_resize);
+ assert(fb->width);
+ assert(fb->height);
+
fb->stfb = st_create_framebuffer(
&fb->visual,
colorFormat,
depthFormat,
stencilFormat,
- width,
- height,
+ fb->width,
+ fb->height,
(void *) fb );
+
+ // to notify the context
+ fb->must_resize = TRUE;
}
pipe_mutex_unlock( fb->mutex );
@@ -246,14 +247,29 @@ stw_framebuffer_allocate(
}
+/**
+ * Update the framebuffer's size if necessary.
+ */
void
-stw_framebuffer_resize(
+stw_framebuffer_update(
struct stw_framebuffer *fb)
{
- GLuint width, height;
assert(fb->stfb);
- stw_framebuffer_get_size(fb, &width, &height);
- st_resize_framebuffer(fb->stfb, width, height);
+ assert(fb->height);
+ assert(fb->width);
+
+ /* XXX: It would be nice to avoid checking the size again -- in theory
+ * stw_call_window_proc would have cought the resize and stored the right
+ * size already, but unfortunately threads created before the DllMain is
+ * called don't get a DLL_THREAD_ATTACH notification, and there is no way
+ * to know of their existing without using the not very portable PSAPI.
+ */
+ stw_framebuffer_get_size(fb);
+
+ if(fb->must_resize) {
+ st_resize_framebuffer(fb->stfb, fb->width, fb->height);
+ fb->must_resize = FALSE;
+ }
}
@@ -379,6 +395,9 @@ stw_swap_buffers(
if (fb == NULL)
return FALSE;
+ if (!(fb->pfi->pfd.dwFlags & PFD_DOUBLEBUFFER))
+ return TRUE;
+
pipe_mutex_lock( fb->mutex );
/* If we're swapping the buffer associated with the current context
@@ -403,6 +422,8 @@ stw_swap_buffers(
stw_dev->stw_winsys->flush_frontbuffer( screen, surface, hdc );
+ stw_framebuffer_update(fb);
+
pipe_mutex_unlock( fb->mutex );
return TRUE;
@@ -419,38 +440,3 @@ stw_swap_layer_buffers(
return FALSE;
}
-
-
-boolean
-stw_framebuffer_init_thread(void)
-{
- struct stw_tls_data *tls_data;
-
- tls_data = stw_tls_get_data();
- if(!tls_data)
- return FALSE;
-
- tls_data->hCallWndProcHook = SetWindowsHookEx(WH_CALLWNDPROC,
- stw_call_window_proc,
- NULL,
- GetCurrentThreadId());
- if(tls_data->hCallWndProcHook == NULL)
- return FALSE;
-
- return TRUE;
-}
-
-void
-stw_framebuffer_cleanup_thread(void)
-{
- struct stw_tls_data *tls_data;
-
- tls_data = stw_tls_get_data();
- if(!tls_data)
- return;
-
- if(tls_data->hCallWndProcHook) {
- UnhookWindowsHookEx(tls_data->hCallWndProcHook);
- tls_data->hCallWndProcHook = NULL;
- }
-}
diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h
index e7fa51c3a81..759e06b8914 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h
+++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.h
@@ -51,6 +51,11 @@ struct stw_framebuffer
pipe_mutex mutex;
struct st_framebuffer *stfb;
+ /* FIXME: Make this work for multiple contexts bound to the same framebuffer */
+ boolean must_resize;
+ unsigned width;
+ unsigned height;
+
/** This is protected by stw_device::mutex, not the mutex above */
struct stw_framebuffer *next;
};
@@ -65,7 +70,7 @@ stw_framebuffer_allocate(
struct stw_framebuffer *fb );
void
-stw_framebuffer_resize(
+stw_framebuffer_update(
struct stw_framebuffer *fb);
void
@@ -79,10 +84,4 @@ struct stw_framebuffer *
stw_framebuffer_from_hdc(
HDC hdc );
-boolean
-stw_framebuffer_init_thread(void);
-
-void
-stw_framebuffer_cleanup_thread(void);
-
#endif /* STW_FRAMEBUFFER_H */
diff --git a/src/gallium/state_trackers/wgl/shared/stw_tls.c b/src/gallium/state_trackers/wgl/shared/stw_tls.c
index 0c18a52352c..4bd6a9289c9 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_tls.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_tls.c
@@ -51,9 +51,23 @@ stw_tls_data_create()
data = CALLOC_STRUCT(stw_tls_data);
if (!data)
- return NULL;
+ goto no_data;
+
+ data->hCallWndProcHook = SetWindowsHookEx(WH_CALLWNDPROC,
+ stw_call_window_proc,
+ NULL,
+ GetCurrentThreadId());
+ if(data->hCallWndProcHook == NULL)
+ goto no_hook;
+
+ TlsSetValue(tlsIndex, data);
return data;
+
+no_hook:
+ FREE(data);
+no_data:
+ return NULL;
}
boolean
@@ -69,8 +83,6 @@ stw_tls_init_thread(void)
if(!data)
return FALSE;
- TlsSetValue(tlsIndex, data);
-
return TRUE;
}
@@ -84,8 +96,16 @@ stw_tls_cleanup_thread(void)
}
data = (struct stw_tls_data *) TlsGetValue(tlsIndex);
- TlsSetValue(tlsIndex, NULL);
- FREE(data);
+ if(data) {
+ TlsSetValue(tlsIndex, NULL);
+
+ if(data->hCallWndProcHook) {
+ UnhookWindowsHookEx(data->hCallWndProcHook);
+ data->hCallWndProcHook = NULL;
+ }
+
+ FREE(data);
+ }
}
void
@@ -110,12 +130,9 @@ stw_tls_get_data(void)
if(!data) {
/* DllMain is called with DLL_THREAD_ATTACH only by threads created after
* the DLL is loaded by the process */
-
data = stw_tls_data_create();
if(!data)
return NULL;
-
- TlsSetValue(tlsIndex, data);
}
return data;
diff --git a/src/gallium/state_trackers/wgl/shared/stw_tls.h b/src/gallium/state_trackers/wgl/shared/stw_tls.h
index 6af8be70c9f..fbf8b1cbee4 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_tls.h
+++ b/src/gallium/state_trackers/wgl/shared/stw_tls.h
@@ -50,4 +50,10 @@ stw_tls_cleanup(void);
struct stw_tls_data *
stw_tls_get_data(void);
+LRESULT CALLBACK
+stw_call_window_proc(
+ int nCode,
+ WPARAM wParam,
+ LPARAM lParam );
+
#endif /* STW_TLS_H */
diff --git a/src/glew/glew.c b/src/glew/glew.c
index 24c6a726c38..aa2278f6c03 100644
--- a/src/glew/glew.c
+++ b/src/glew/glew.c
@@ -547,7 +547,7 @@ PFNGLCHECKFRAMEBUFFERSTATUSPROC __glewCheckFramebufferStatus = NULL;
PFNGLDELETEFRAMEBUFFERSPROC __glewDeleteFramebuffers = NULL;
PFNGLDELETERENDERBUFFERSPROC __glewDeleteRenderbuffers = NULL;
PFNGLFRAMEBUFFERRENDERBUFFERPROC __glewFramebufferRenderbuffer = NULL;
-PFNGLFRAMEBUFFERTEXTURLAYERPROC __glewFramebufferTexturLayer = NULL;
+PFNGLFRAMEBUFFERTEXTURELAYERPROC __glewFramebufferTextureLayer = NULL;
PFNGLFRAMEBUFFERTEXTURE1DPROC __glewFramebufferTexture1D = NULL;
PFNGLFRAMEBUFFERTEXTURE2DPROC __glewFramebufferTexture2D = NULL;
PFNGLFRAMEBUFFERTEXTURE3DPROC __glewFramebufferTexture3D = NULL;
@@ -2739,7 +2739,7 @@ static GLboolean _glewInit_GL_ARB_framebuffer_object (GLEW_CONTEXT_ARG_DEF_INIT)
r = ((glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glDeleteFramebuffers")) == NULL) || r;
r = ((glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glDeleteRenderbuffers")) == NULL) || r;
r = ((glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)glewGetProcAddress((const GLubyte*)"glFramebufferRenderbuffer")) == NULL) || r;
- r = ((glFramebufferTexturLayer = (PFNGLFRAMEBUFFERTEXTURLAYERPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexturLayer")) == NULL) || r;
+ r = ((glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureLayer")) == NULL) || r;
r = ((glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture1D")) == NULL) || r;
r = ((glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture2D")) == NULL) || r;
r = ((glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture3D")) == NULL) || r;
diff --git a/src/glew/glewinfo.c b/src/glew/glewinfo.c
index 13c6d05bd1f..da2b241deab 100644
--- a/src/glew/glewinfo.c
+++ b/src/glew/glewinfo.c
@@ -708,7 +708,7 @@ static void _glewInfo_GL_ARB_framebuffer_object (void)
glewInfoFunc("glDeleteFramebuffers", glDeleteFramebuffers == NULL);
glewInfoFunc("glDeleteRenderbuffers", glDeleteRenderbuffers == NULL);
glewInfoFunc("glFramebufferRenderbuffer", glFramebufferRenderbuffer == NULL);
- glewInfoFunc("glFramebufferTexturLayer", glFramebufferTexturLayer == NULL);
+ glewInfoFunc("glFramebufferTextureLayer", glFramebufferTextureLayer == NULL);
glewInfoFunc("glFramebufferTexture1D", glFramebufferTexture1D == NULL);
glewInfoFunc("glFramebufferTexture2D", glFramebufferTexture2D == NULL);
glewInfoFunc("glFramebufferTexture3D", glFramebufferTexture3D == NULL);
diff --git a/src/glx/x11/dri_common.c b/src/glx/x11/dri_common.c
index 90c3d8c7d9d..6de41111134 100644
--- a/src/glx/x11/dri_common.c
+++ b/src/glx/x11/dri_common.c
@@ -345,7 +345,9 @@ driBindExtensions(__GLXscreenConfigs *psc, int dri2)
#endif
#ifdef __DRI_SWAP_CONTROL
- if (strcmp(extensions[i]->name, __DRI_SWAP_CONTROL) == 0) {
+ /* No DRI2 support for swap_control at the moment, since SwapBuffers
+ * is done by the X server */
+ if (strcmp(extensions[i]->name, __DRI_SWAP_CONTROL) == 0 && !dri2) {
psc->swapControl = (__DRIswapControlExtension *) extensions[i];
__glXEnableDirectExtension(psc, "GLX_SGI_swap_control");
__glXEnableDirectExtension(psc, "GLX_MESA_swap_control");
diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c
index ec3e69e4fe1..77471b8599c 100644
--- a/src/glx/x11/glxcmds.c
+++ b/src/glx/x11/glxcmds.c
@@ -869,6 +869,20 @@ PUBLIC void glXDestroyGLXPixmap(Display *dpy, GLXPixmap glxpixmap)
req->glxpixmap = glxpixmap;
UnlockDisplay(dpy);
SyncHandle();
+
+#ifdef GLX_DIRECT_RENDERING
+ {
+ int screen;
+ __GLXdisplayPrivate *const priv = __glXInitialize(dpy);
+ __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, glxpixmap, &screen);
+ __GLXscreenConfigs *psc = &priv->screenConfigs[screen];
+
+ if (pdraw != NULL) {
+ (*pdraw->destroyDrawable) (pdraw);
+ __glxHashDelete(psc->drawHash, glxpixmap);
+ }
+ }
+#endif
}
PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable)
diff --git a/src/glx/x11/glxcurrent.c b/src/glx/x11/glxcurrent.c
index 01f42332413..d44e0dd1fc8 100644
--- a/src/glx/x11/glxcurrent.c
+++ b/src/glx/x11/glxcurrent.c
@@ -457,7 +457,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw,
&dummy_reply);
}
#ifdef GLX_DIRECT_RENDERING
- else if (oldGC->driContext) {
+ else if (oldGC->driContext && oldGC != gc) {
oldGC->driContext->unbindContext(oldGC->driContext);
}
#endif
diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c
index 276da41f4e4..6a98c29a3d1 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -231,6 +231,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
driver->BeginQuery = _mesa_begin_query;
driver->EndQuery = _mesa_end_query;
driver->WaitQuery = _mesa_wait_query;
+ driver->CheckQuery = _mesa_check_query;
/* APPLE_vertex_array_object */
driver->NewArrayObject = _mesa_new_array_object;
diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
index e1127204718..576494940f3 100644
--- a/src/mesa/drivers/dri/common/dri_util.c
+++ b/src/mesa/drivers/dri/common/dri_util.c
@@ -119,6 +119,9 @@ static int driUnbindContext(__DRIcontext *pcp)
pdp = pcp->driDrawablePriv;
prp = pcp->driReadablePriv;
+ /* already unbound */
+ if (!pdp && !prp)
+ return GL_TRUE;
/* Let driver unbind drawable from context */
(*psp->DriverAPI.UnbindContext)(pcp);
@@ -143,9 +146,10 @@ static int driUnbindContext(__DRIcontext *pcp)
* window we can determine the last context bound to the window and
* use that context's lock. (BrianP, 2-Dec-2000)
*/
+ pcp->driDrawablePriv = pcp->driReadablePriv = NULL;
+
#if 0
/* Unbind the drawable */
- pcp->driDrawablePriv = NULL;
pdp->driContextPriv = &psp->dummyContextPriv;
#endif
diff --git a/src/mesa/drivers/dri/i915/i830_state.c b/src/mesa/drivers/dri/i915/i830_state.c
index d9cad0c4bf8..8ef6c9144f1 100644
--- a/src/mesa/drivers/dri/i915/i830_state.c
+++ b/src/mesa/drivers/dri/i915/i830_state.c
@@ -39,6 +39,7 @@
#include "intel_screen.h"
#include "intel_batchbuffer.h"
#include "intel_fbo.h"
+#include "intel_buffers.h"
#include "i830_context.h"
#include "i830_reg.h"
@@ -446,6 +447,24 @@ i830DepthMask(GLcontext * ctx, GLboolean flag)
i830->state.Ctx[I830_CTXREG_ENABLES_2] |= DISABLE_DEPTH_WRITE;
}
+/** Called from ctx->Driver.Viewport() */
+static void
+i830Viewport(GLcontext * ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ intelCalcViewport(ctx);
+
+ intel_viewport(ctx, x, y, width, height);
+}
+
+
+/** Called from ctx->Driver.DepthRange() */
+static void
+i830DepthRange(GLcontext * ctx, GLclampd nearval, GLclampd farval)
+{
+ intelCalcViewport(ctx);
+}
+
/* =============================================================
* Polygon stipple
*
@@ -1064,6 +1083,8 @@ i830InitStateFuncs(struct dd_function_table *functions)
functions->StencilFuncSeparate = i830StencilFuncSeparate;
functions->StencilMaskSeparate = i830StencilMaskSeparate;
functions->StencilOpSeparate = i830StencilOpSeparate;
+ functions->DepthRange = i830DepthRange;
+ functions->Viewport = i830Viewport;
}
void
diff --git a/src/mesa/drivers/dri/i915/i915_tex_layout.c b/src/mesa/drivers/dri/i915/i915_tex_layout.c
index d44a2f47b37..7cc1c096e4b 100644
--- a/src/mesa/drivers/dri/i915/i915_tex_layout.c
+++ b/src/mesa/drivers/dri/i915/i915_tex_layout.c
@@ -454,7 +454,10 @@ i945_miptree_layout(struct intel_context *intel, struct intel_mipmap_tree * mt)
{
switch (mt->target) {
case GL_TEXTURE_CUBE_MAP:
- i945_miptree_layout_cube(intel, mt);
+ if (mt->compressed)
+ i945_miptree_layout_cube(intel, mt);
+ else
+ i915_miptree_layout_cube(intel, mt);
break;
case GL_TEXTURE_3D:
i945_miptree_layout_3d(intel, mt);
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index aef2ff5f86f..577497bf6b0 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -616,9 +616,10 @@ struct brw_context
struct brw_wm_prog_data *prog_data;
struct brw_wm_compile *compile_data;
- /* Input sizes, calculated from active vertex program:
+ /** Input sizes, calculated from active vertex program.
+ * One bit per fragment program input attribute.
*/
- GLuint input_size_masks[4];
+ GLbitfield input_size_masks[4];
/** Array of surface default colors (texture border color) */
dri_bo *sdc_bo[BRW_MAX_TEX_UNIT];
diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c b/src/mesa/drivers/dri/i965/brw_sf_state.c
index 68fa9820b6f..c99918724b3 100644
--- a/src/mesa/drivers/dri/i965/brw_sf_state.c
+++ b/src/mesa/drivers/dri/i965/brw_sf_state.c
@@ -66,7 +66,9 @@ static void upload_sf_vp(struct brw_context *brw)
sfv.viewport.m31 = v[MAT_TY] * y_scale + y_bias;
sfv.viewport.m32 = v[MAT_TZ] * depth_scale;
- /* _NEW_SCISSOR */
+ /* _NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT
+ * for DrawBuffer->_[XY]{min,max}
+ */
/* The scissor only needs to handle the intersection of drawable and
* scissor rect. Clipping to the boundaries of static shared buffers
@@ -97,7 +99,8 @@ static void upload_sf_vp(struct brw_context *brw)
const struct brw_tracked_state brw_sf_vp = {
.dirty = {
.mesa = (_NEW_VIEWPORT |
- _NEW_SCISSOR),
+ _NEW_SCISSOR |
+ _NEW_BUFFERS),
.brw = 0,
.cache = 0
},
diff --git a/src/mesa/drivers/dri/i965/brw_vs_constval.c b/src/mesa/drivers/dri/i965/brw_vs_constval.c
index 2637344b482..249a800bf4b 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_constval.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_constval.c
@@ -39,8 +39,8 @@
*/
struct tracker {
GLboolean twoside;
- GLubyte active[PROGRAM_OUTPUT+1][128];
- GLuint size_masks[4];
+ GLubyte active[PROGRAM_OUTPUT+1][MAX_PROGRAM_TEMPS];
+ GLbitfield size_masks[4]; /**< one bit per fragment program input attrib */
};
@@ -53,8 +53,10 @@ static void set_active_component( struct tracker *t,
case PROGRAM_TEMPORARY:
case PROGRAM_INPUT:
case PROGRAM_OUTPUT:
+ assert(file < PROGRAM_OUTPUT + 1);
+ assert(index < Elements(t->active[0]));
t->active[file][index] |= active;
-
+ break;
default:
break;
}
@@ -108,10 +110,15 @@ static GLubyte get_active( struct tracker *t,
return active;
}
+/**
+ * Return the size (1,2,3 or 4) of the output/result for VERT_RESULT_idx.
+ */
static GLubyte get_output_size( struct tracker *t,
GLuint idx )
{
- GLubyte active = t->active[PROGRAM_OUTPUT][idx];
+ GLubyte active;
+ assert(idx < VERT_RESULT_MAX);
+ active = t->active[PROGRAM_OUTPUT][idx];
if (active & (1<<3)) return 4;
if (active & (1<<2)) return 3;
if (active & (1<<1)) return 2;
@@ -123,7 +130,7 @@ static GLubyte get_output_size( struct tracker *t,
*/
static void calc_sizes( struct tracker *t )
{
- GLuint i;
+ GLint vertRes;
if (t->twoside) {
t->active[PROGRAM_OUTPUT][VERT_RESULT_COL0] |=
@@ -133,12 +140,27 @@ static void calc_sizes( struct tracker *t )
t->active[PROGRAM_OUTPUT][VERT_RESULT_BFC1];
}
- for (i = 0; i < FRAG_ATTRIB_MAX; i++) {
- switch (get_output_size(t, i)) {
- case 4: t->size_masks[4-1] |= 1<<i;
- case 3: t->size_masks[3-1] |= 1<<i;
- case 2: t->size_masks[2-1] |= 1<<i;
- case 1: t->size_masks[1-1] |= 1<<i;
+ /* Examine vertex program output sizes to set the size_masks[] info
+ * which describes the fragment program input sizes.
+ */
+ for (vertRes = VERT_RESULT_TEX0; vertRes < VERT_RESULT_MAX; vertRes++) {
+ GLint fragAttrib;
+
+ /* map vertex program output index to fragment program input index */
+ if (vertRes <= VERT_RESULT_TEX7)
+ fragAttrib = FRAG_ATTRIB_TEX0 + vertRes - VERT_RESULT_TEX0;
+ else if (vertRes >= VERT_RESULT_VAR0)
+ fragAttrib = FRAG_ATTRIB_VAR0 + vertRes - VERT_RESULT_VAR0;
+ else
+ continue;
+ assert(fragAttrib >= FRAG_ATTRIB_TEX0);
+ assert(fragAttrib <= FRAG_ATTRIB_MAX);
+
+ switch (get_output_size(t, vertRes)) {
+ case 4: t->size_masks[4-1] |= 1 << fragAttrib;
+ case 3: t->size_masks[3-1] |= 1 << fragAttrib;
+ case 2: t->size_masks[2-1] |= 1 << fragAttrib;
+ case 1: t->size_masks[1-1] |= 1 << fragAttrib;
break;
}
}
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index 90d74c2885c..8a3b7df9c78 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -146,6 +146,13 @@ static void do_wm_prog( struct brw_context *brw,
if (c == NULL) {
brw->wm.compile_data = calloc(1, sizeof(*brw->wm.compile_data));
c = brw->wm.compile_data;
+ if (c == NULL) {
+ /* Ouch - big out of memory problem. Can't continue
+ * without triggering a segfault, no way to signal,
+ * so just return.
+ */
+ return;
+ }
} else {
memset(c, 0, sizeof(*brw->wm.compile_data));
}
@@ -260,7 +267,7 @@ static void brw_wm_populate_key( struct brw_context *brw,
/* BRW_NEW_WM_INPUT_DIMENSIONS */
- key->projtex_mask = brw->wm.input_size_masks[4-1] >> (FRAG_ATTRIB_TEX0 - FRAG_ATTRIB_WPOS);
+ key->proj_attrib_mask = brw->wm.input_size_masks[4-1];
/* _NEW_LIGHT */
key->flat_shade = (ctx->Light.ShadeModel == GL_FLAT);
@@ -312,6 +319,9 @@ static void brw_wm_populate_key( struct brw_context *brw,
key->drawable_height = brw->intel.driDrawable->h;
}
+ /* CACHE_NEW_VS_PROG */
+ key->vp_outputs_written = brw->vs.prog_data->outputs_written & DO_SETUP_BITS;
+
/* The unique fragment program ID */
key->program_string_id = fp->id;
}
@@ -350,7 +360,7 @@ const struct brw_tracked_state brw_wm_prog = {
.brw = (BRW_NEW_FRAGMENT_PROGRAM |
BRW_NEW_WM_INPUT_DIMENSIONS |
BRW_NEW_REDUCED_PRIMITIVE),
- .cache = 0
+ .cache = CACHE_NEW_VS_PROG,
},
.prepare = brw_prepare_wm_prog
};
diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h
index f0d31fc1ddc..295fed851bb 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.h
+++ b/src/mesa/drivers/dri/i965/brw_wm.h
@@ -65,7 +65,7 @@ struct brw_wm_prog_key {
GLuint flat_shade:1;
GLuint runtime_check_aads_emit:1;
- GLuint projtex_mask:16;
+ GLbitfield proj_attrib_mask; /**< one bit per fragment program attribute */
GLuint shadowtex_mask:16;
GLuint yuvtex_mask:16;
GLuint yuvtex_swap_mask:16; /* UV swaped */
@@ -75,6 +75,7 @@ struct brw_wm_prog_key {
GLuint program_string_id:32;
GLuint origin_x, origin_y;
GLuint drawable_height;
+ GLuint vp_outputs_written;
};
diff --git a/src/mesa/drivers/dri/i965/brw_wm_fp.c b/src/mesa/drivers/dri/i965/brw_wm_fp.c
index 1798d842c79..49aad281d7a 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_fp.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_fp.c
@@ -834,10 +834,16 @@ static void precalc_tex( struct brw_wm_compile *c,
}
+/**
+ * Check if the given TXP instruction really needs the divide-by-W step.
+ */
static GLboolean projtex( struct brw_wm_compile *c,
const struct prog_instruction *inst )
{
- struct prog_src_register src = inst->SrcReg[0];
+ const struct prog_src_register src = inst->SrcReg[0];
+ GLboolean retVal;
+
+ assert(inst->Opcode == OPCODE_TXP);
/* Only try to detect the simplest cases. Could detect (later)
* cases where we are trying to emit code like RCP {1.0}, MUL x,
@@ -847,16 +853,21 @@ static GLboolean projtex( struct brw_wm_compile *c,
* user-provided fragment programs anyway:
*/
if (inst->TexSrcTarget == TEXTURE_CUBE_INDEX)
- return 0; /* ut2004 gun rendering !?! */
+ retVal = GL_FALSE; /* ut2004 gun rendering !?! */
else if (src.File == PROGRAM_INPUT &&
GET_SWZ(src.Swizzle, W) == W &&
- (c->key.projtex_mask & (1<<(src.Index + FRAG_ATTRIB_WPOS - FRAG_ATTRIB_TEX0))) == 0)
- return 0;
+ (c->key.proj_attrib_mask & (1 << src.Index)) == 0)
+ retVal = GL_FALSE;
else
- return 1;
+ retVal = GL_TRUE;
+
+ return retVal;
}
+/**
+ * Emit code for TXP.
+ */
static void precalc_txp( struct brw_wm_compile *c,
const struct prog_instruction *inst )
{
diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c
index 117460842a3..094c1af2fef 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c
@@ -177,7 +177,7 @@ static void prealloc_reg(struct brw_wm_compile *c)
{
int i, j;
struct brw_reg reg;
- int nr_interp_regs = 0;
+ int urb_read_length = 0;
GLuint inputs = FRAG_BIT_WPOS | c->fp_interp_emitted | c->fp_deriv_emitted;
for (i = 0; i < 4; i++) {
@@ -231,18 +231,29 @@ static void prealloc_reg(struct brw_wm_compile *c)
}
/* fragment shader inputs */
- for (i = 0; i < FRAG_ATTRIB_MAX; i++) {
- if (inputs & (1<<i)) {
- nr_interp_regs++;
- reg = brw_vec8_grf(c->reg_index, 0);
- for (j = 0; j < 4; j++)
- set_reg(c, PROGRAM_PAYLOAD, i, j, reg);
- c->reg_index += 2;
- }
+ for (i = 0; i < VERT_RESULT_MAX; i++) {
+ int fp_input;
+
+ if (i >= VERT_RESULT_VAR0)
+ fp_input = i - VERT_RESULT_VAR0 + FRAG_ATTRIB_VAR0;
+ else if (i <= VERT_RESULT_TEX7)
+ fp_input = i;
+ else
+ fp_input = -1;
+
+ if (fp_input >= 0 && inputs & (1 << fp_input)) {
+ urb_read_length = c->reg_index;
+ reg = brw_vec8_grf(c->reg_index, 0);
+ for (j = 0; j < 4; j++)
+ set_reg(c, PROGRAM_PAYLOAD, fp_input, j, reg);
+ }
+ if (c->key.vp_outputs_written & (1 << i)) {
+ c->reg_index += 2;
+ }
}
c->prog_data.first_curbe_grf = c->key.nr_depth_regs * 2;
- c->prog_data.urb_read_length = nr_interp_regs * 2;
+ c->prog_data.urb_read_length = urb_read_length;
c->prog_data.curb_read_length = c->nr_creg;
c->emit_mask_reg = brw_uw1_reg(BRW_GENERAL_REGISTER_FILE, c->reg_index, 0);
c->reg_index++;
@@ -2670,6 +2681,7 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c)
emit_trunc(c, inst);
break;
case OPCODE_MOV:
+ case OPCODE_SWZ:
emit_mov(c, inst);
break;
case OPCODE_DP3:
diff --git a/src/mesa/drivers/dri/i965/brw_wm_pass2.c b/src/mesa/drivers/dri/i965/brw_wm_pass2.c
index 780edbc42e6..6faea018fbc 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_pass2.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_pass2.c
@@ -69,8 +69,6 @@ static void prealloc_reg(struct brw_wm_compile *c,
*/
static void init_registers( struct brw_wm_compile *c )
{
- struct brw_context *brw = c->func.brw;
- GLuint inputs = (brw->vs.prog_data->outputs_written & DO_SETUP_BITS);
GLuint nr_interp_regs = 0;
GLuint i = 0;
GLuint j;
@@ -85,16 +83,19 @@ static void init_registers( struct brw_wm_compile *c )
prealloc_reg(c, &c->creg[j], i++);
for (j = 0; j < FRAG_ATTRIB_MAX; j++) {
- if (inputs & (1<<j)) {
- /* index for vs output and ps input are not the same
- in shader varying */
- GLuint index;
- if (j > FRAG_ATTRIB_VAR0)
- index = j - (VERT_RESULT_VAR0 - FRAG_ATTRIB_VAR0);
+ if (c->key.vp_outputs_written & (1<<j)) {
+ int fp_index;
+
+ if (j >= VERT_RESULT_VAR0)
+ fp_index = j - (VERT_RESULT_VAR0 - FRAG_ATTRIB_VAR0);
+ else if (j <= VERT_RESULT_TEX7)
+ fp_index = j;
else
- index = j;
+ fp_index = -1;
+
nr_interp_regs++;
- prealloc_reg(c, &c->payload.input_interp[index], i++);
+ if (fp_index >= 0)
+ prealloc_reg(c, &c->payload.input_interp[fp_index], i++);
}
}
diff --git a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
index c604ef0162a..3fc18ff1f3a 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
@@ -178,6 +178,16 @@ static void brw_update_sampler_state(struct wm_sampler_entry *key,
sampler->ss1.s_wrap_mode = BRW_TEXCOORDMODE_CUBE;
sampler->ss1.t_wrap_mode = BRW_TEXCOORDMODE_CUBE;
}
+ else if (key->tex_target == GL_TEXTURE_1D) {
+ /* There's a bug in 1D texture sampling - it actually pays
+ * attention to the wrap_t value, though it should not.
+ * Override the wrap_t value here to GL_REPEAT to keep
+ * any nonexistent border pixels from floating in.
+ */
+ sampler->ss1.r_wrap_mode = translate_wrap_mode(key->wrap_r);
+ sampler->ss1.s_wrap_mode = translate_wrap_mode(key->wrap_s);
+ sampler->ss1.t_wrap_mode = BRW_TEXCOORDMODE_WRAP;
+ }
else {
sampler->ss1.r_wrap_mode = translate_wrap_mode(key->wrap_r);
sampler->ss1.s_wrap_mode = translate_wrap_mode(key->wrap_s);
diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.c b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
index c849e4869e5..c31fe91ad62 100644
--- a/src/mesa/drivers/dri/intel/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
@@ -102,6 +102,7 @@ intel_bufferobj_free(GLcontext * ctx, struct gl_buffer_object *obj)
assert(intel_obj);
assert(!obj->Pointer); /* Mesa should have unmapped it */
+ _mesa_free(intel_obj->sys_buffer);
if (intel_obj->region) {
intel_bufferobj_release_region(intel, intel_obj);
}
@@ -142,7 +143,23 @@ intel_bufferobj_data(GLcontext * ctx,
dri_bo_unreference(intel_obj->buffer);
intel_obj->buffer = NULL;
}
+ _mesa_free(intel_obj->sys_buffer);
+ intel_obj->sys_buffer = NULL;
+
if (size != 0) {
+#ifdef I915
+ /* On pre-965, stick VBOs in system memory, as we're always doing swtnl
+ * with their contents anyway.
+ */
+ if (target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER) {
+ intel_obj->sys_buffer = _mesa_malloc(size);
+ if (intel_obj->sys_buffer != NULL) {
+ if (data != NULL)
+ memcpy(intel_obj->sys_buffer, data, size);
+ return;
+ }
+ }
+#endif
intel_bufferobj_alloc_buffer(intel, intel_obj);
if (data != NULL)
@@ -172,7 +189,10 @@ intel_bufferobj_subdata(GLcontext * ctx,
if (intel_obj->region)
intel_bufferobj_cow(intel, intel_obj);
- dri_bo_subdata(intel_obj->buffer, offset, size, data);
+ if (intel_obj->sys_buffer)
+ memcpy((char *)intel_obj->sys_buffer + offset, data, size);
+ else
+ dri_bo_subdata(intel_obj->buffer, offset, size, data);
}
@@ -205,9 +225,15 @@ intel_bufferobj_map(GLcontext * ctx,
struct intel_context *intel = intel_context(ctx);
struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
GLboolean read_only = (access == GL_READ_ONLY_ARB);
+ GLboolean write_only = (access == GL_WRITE_ONLY_ARB);
assert(intel_obj);
+ if (intel_obj->sys_buffer) {
+ obj->Pointer = intel_obj->sys_buffer;
+ return obj->Pointer;
+ }
+
if (intel_obj->region)
intel_bufferobj_cow(intel, intel_obj);
@@ -216,7 +242,14 @@ intel_bufferobj_map(GLcontext * ctx,
return NULL;
}
- dri_bo_map(intel_obj->buffer, !read_only);
+ if (write_only && intel->intelScreen->kernel_exec_fencing) {
+ drm_intel_gem_bo_map_gtt(intel_obj->buffer);
+ intel_obj->mapped_gtt = GL_TRUE;
+ } else {
+ drm_intel_bo_map(intel_obj->buffer, !read_only);
+ intel_obj->mapped_gtt = GL_FALSE;
+ }
+
obj->Pointer = intel_obj->buffer->virtual;
return obj->Pointer;
}
@@ -234,7 +267,11 @@ intel_bufferobj_unmap(GLcontext * ctx,
assert(intel_obj);
if (intel_obj->buffer != NULL) {
assert(obj->Pointer);
- dri_bo_unmap(intel_obj->buffer);
+ if (intel_obj->mapped_gtt) {
+ drm_intel_gem_bo_unmap_gtt(intel_obj->buffer);
+ } else {
+ drm_intel_bo_unmap(intel_obj->buffer);
+ }
obj->Pointer = NULL;
}
return GL_TRUE;
@@ -253,6 +290,18 @@ intel_bufferobj_buffer(struct intel_context *intel,
}
}
+ if (intel_obj->buffer == NULL) {
+ intel_bufferobj_alloc_buffer(intel, intel_obj);
+ intel_bufferobj_subdata(&intel->ctx,
+ GL_ARRAY_BUFFER_ARB,
+ 0,
+ intel_obj->Base.Size,
+ intel_obj->sys_buffer,
+ &intel_obj->Base);
+ _mesa_free(intel_obj->sys_buffer);
+ intel_obj->sys_buffer = NULL;
+ }
+
return intel_obj->buffer;
}
diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.h b/src/mesa/drivers/dri/intel/intel_buffer_objects.h
index bf6dbd58f27..04310156319 100644
--- a/src/mesa/drivers/dri/intel/intel_buffer_objects.h
+++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.h
@@ -42,10 +42,13 @@ struct intel_buffer_object
{
struct gl_buffer_object Base;
dri_bo *buffer; /* the low-level buffer manager's buffer handle */
+ /** System memory buffer data, if not using a BO to store the data. */
+ void *sys_buffer;
struct intel_region *region; /* Is there a zero-copy texture
associated with this (pixel)
buffer object? */
+ GLboolean mapped_gtt;
};
diff --git a/src/mesa/drivers/dri/intel/intel_buffers.c b/src/mesa/drivers/dri/intel/intel_buffers.c
index b86cafea241..d2fad9e4ea1 100644
--- a/src/mesa/drivers/dri/intel/intel_buffers.c
+++ b/src/mesa/drivers/dri/intel/intel_buffers.c
@@ -276,7 +276,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)
ctx->Driver.Enable(ctx, GL_DEPTH_TEST,
(ctx->Depth.Test && fb->Visual.depthBits > 0));
ctx->Driver.Enable(ctx, GL_STENCIL_TEST,
- (ctx->Stencil._Enabled && fb->Visual.stencilBits > 0));
+ (ctx->Stencil.Enabled && fb->Visual.stencilBits > 0));
}
else {
/* Mesa's Stencil._Enabled field is updated when
diff --git a/src/mesa/drivers/dri/intel/intel_clear.c b/src/mesa/drivers/dri/intel/intel_clear.c
index eb0d890f477..19f47632ac0 100644
--- a/src/mesa/drivers/dri/intel/intel_clear.c
+++ b/src/mesa/drivers/dri/intel/intel_clear.c
@@ -255,14 +255,16 @@ intel_clear_tris(GLcontext *ctx, GLbitfield mask)
/* Control writing of the stencil clear value to stencil. */
if (this_mask & BUFFER_BIT_STENCIL) {
_mesa_Enable(GL_STENCIL_TEST);
- _mesa_StencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
- _mesa_StencilFuncSeparate(GL_FRONT, GL_ALWAYS, ctx->Stencil.Clear,
+ _mesa_StencilOpSeparate(GL_FRONT_AND_BACK,
+ GL_REPLACE, GL_REPLACE, GL_REPLACE);
+ _mesa_StencilFuncSeparate(GL_FRONT_AND_BACK, GL_ALWAYS,
+ ctx->Stencil.Clear,
ctx->Stencil.WriteMask[0]);
} else {
_mesa_Disable(GL_STENCIL_TEST);
}
- CALL_DrawArrays(ctx->Exec, (GL_TRIANGLE_FAN, 0, 4));
+ _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
mask &= ~this_mask;
}
diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c
index 5dc3df395d1..1222a9a8c6f 100644
--- a/src/mesa/drivers/dri/intel/intel_context.c
+++ b/src/mesa/drivers/dri/intel/intel_context.c
@@ -71,6 +71,8 @@ int INTEL_DEBUG = (0);
#define DRIVER_DATE_GEM "GEM " DRIVER_DATE
+static void intel_flush(GLcontext *ctx, GLboolean needs_mi_flush);
+
static const GLubyte *
intelGetString(GLcontext * ctx, GLenum name)
{
@@ -394,7 +396,16 @@ intel_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
if (!driContext->driScreenPriv->dri2.enabled)
return;
- if (!intel->internal_viewport_call) {
+ if (!intel->internal_viewport_call && ctx->DrawBuffer->Name == 0) {
+ /* If we're rendering to the fake front buffer, make sure all the pending
+ * drawing has landed on the real front buffer. Otherwise when we
+ * eventually get to DRI2GetBuffersWithFormat the stale real front
+ * buffer contents will get copied to the new fake front buffer.
+ */
+ if (intel->is_front_buffer_rendering) {
+ intel_flush(ctx, GL_FALSE);
+ }
+
intel_update_renderbuffers(driContext, driContext->driDrawablePriv);
if (driContext->driDrawablePriv != driContext->driReadablePriv)
intel_update_renderbuffers(driContext, driContext->driReadablePriv);
diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h
index f45e24ca3a1..b5cf7e6648e 100644
--- a/src/mesa/drivers/dri/intel/intel_context.h
+++ b/src/mesa/drivers/dri/intel/intel_context.h
@@ -559,4 +559,10 @@ intel_context(GLcontext * ctx)
return (struct intel_context *) ctx;
}
+static INLINE GLboolean
+is_power_of_two(uint32_t value)
+{
+ return (value & (value - 1)) == 0;
+}
+
#endif
diff --git a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
index 1db7f5594e9..a2ccae1b7d6 100644
--- a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
+++ b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
@@ -401,6 +401,14 @@ intel_texture_bitmap(GLcontext * ctx,
return GL_FALSE;
}
+ if (!ctx->Extensions.ARB_texture_non_power_of_two &&
+ (!is_power_of_two(width) || !is_power_of_two(height))) {
+ if (INTEL_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr,
+ "glBitmap() fallback: NPOT texture\n");
+ return GL_FALSE;
+ }
+
/* Check that we can load in a texture this big. */
if (width > (1 << (ctx->Const.MaxTextureLevels - 1)) ||
height > (1 << (ctx->Const.MaxTextureLevels - 1))) {
@@ -499,7 +507,7 @@ intel_texture_bitmap(GLcontext * ctx,
_mesa_TexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), &texcoords);
_mesa_Enable(GL_VERTEX_ARRAY);
_mesa_Enable(GL_TEXTURE_COORD_ARRAY);
- CALL_DrawArrays(ctx->Exec, (GL_TRIANGLE_FAN, 0, 4));
+ _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
intel_meta_restore_transform(intel);
intel_meta_restore_fragment_program(intel);
diff --git a/src/mesa/drivers/dri/intel/intel_pixel_draw.c b/src/mesa/drivers/dri/intel/intel_pixel_draw.c
index e8d5ac8569d..d80069dd586 100644
--- a/src/mesa/drivers/dri/intel/intel_pixel_draw.c
+++ b/src/mesa/drivers/dri/intel/intel_pixel_draw.c
@@ -97,7 +97,7 @@ intel_texture_drawpixels(GLcontext * ctx,
/* We don't have a way to generate fragments with stencil values which
* will set the resulting stencil value.
*/
- if (format == GL_STENCIL_INDEX)
+ if (format == GL_STENCIL_INDEX || format == GL_DEPTH_STENCIL)
return GL_FALSE;
/* Check that we can load in a texture this big. */
@@ -120,6 +120,14 @@ intel_texture_drawpixels(GLcontext * ctx,
return GL_FALSE;
}
+ if (!ctx->Extensions.ARB_texture_non_power_of_two &&
+ (!is_power_of_two(width) || !is_power_of_two(height))) {
+ if (INTEL_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr,
+ "glDrawPixels() fallback: NPOT texture\n");
+ return GL_FALSE;
+ }
+
_mesa_PushAttrib(GL_ENABLE_BIT | GL_TEXTURE_BIT |
GL_CURRENT_BIT);
_mesa_PushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
@@ -183,7 +191,7 @@ intel_texture_drawpixels(GLcontext * ctx,
_mesa_TexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), &texcoords);
_mesa_Enable(GL_VERTEX_ARRAY);
_mesa_Enable(GL_TEXTURE_COORD_ARRAY);
- CALL_DrawArrays(ctx->Exec, (GL_TRIANGLE_FAN, 0, 4));
+ _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
intel_meta_restore_transform(intel);
@@ -273,6 +281,14 @@ intel_stencil_drawpixels(GLcontext * ctx,
return GL_FALSE;
}
+ if (!ctx->Extensions.ARB_texture_non_power_of_two &&
+ (!is_power_of_two(width) || !is_power_of_two(height))) {
+ if (INTEL_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr,
+ "glDrawPixels(GL_STENCIL_INDEX) fallback: NPOT texture\n");
+ return GL_FALSE;
+ }
+
_mesa_PushAttrib(GL_ENABLE_BIT | GL_TEXTURE_BIT |
GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
_mesa_PushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
@@ -367,7 +383,7 @@ intel_stencil_drawpixels(GLcontext * ctx,
_mesa_TexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), &texcoords);
_mesa_Enable(GL_VERTEX_ARRAY);
_mesa_Enable(GL_TEXTURE_COORD_ARRAY);
- CALL_DrawArrays(ctx->Exec, (GL_TRIANGLE_FAN, 0, 4));
+ _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
intel_meta_restore_transform(intel);
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
index 65e62947ef6..0f278b3acdd 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -236,7 +236,7 @@ intel_get_param(__DRIscreenPrivate *psp, int param, int *value)
ret = drmCommandWriteRead(psp->fd, DRM_I915_GETPARAM, &gp, sizeof(gp));
if (ret) {
- fprintf(stderr, "drm_i915_getparam: %d\n", ret);
+ _mesa_warning(NULL, "drm_i915_getparam: %d", ret);
return GL_FALSE;
}
@@ -395,6 +395,30 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
static void
intelDestroyBuffer(__DRIdrawablePrivate * driDrawPriv)
{
+ struct intel_framebuffer *intel_fb = driDrawPriv->driverPrivate;
+ struct intel_renderbuffer *depth_rb;
+ struct intel_renderbuffer *stencil_rb;
+
+ if (intel_fb) {
+ if (intel_fb->color_rb[0]) {
+ intel_renderbuffer_set_region(intel_fb->color_rb[0], NULL);
+ }
+
+ if (intel_fb->color_rb[1]) {
+ intel_renderbuffer_set_region(intel_fb->color_rb[1], NULL);
+ }
+
+ depth_rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
+ if (depth_rb) {
+ intel_renderbuffer_set_region(depth_rb, NULL);
+ }
+
+ stencil_rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
+ if (stencil_rb) {
+ intel_renderbuffer_set_region(stencil_rb, NULL);
+ }
+ }
+
_mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
}
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index 1f192dafbe1..5e61e9e95ec 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -208,7 +208,7 @@ try_pbo_upload(struct intel_context *intel,
if (!pbo ||
intel->ctx._ImageTransferState ||
unpack->SkipPixels || unpack->SkipRows) {
- _mesa_printf("%s: failure 1\n", __FUNCTION__);
+ DBG("%s: failure 1\n", __FUNCTION__);
return GL_FALSE;
}
@@ -264,7 +264,7 @@ try_pbo_zcopy(struct intel_context *intel,
if (!pbo ||
intel->ctx._ImageTransferState ||
unpack->SkipPixels || unpack->SkipRows) {
- _mesa_printf("%s: failure 1\n", __FUNCTION__);
+ DBG("%s: failure 1\n", __FUNCTION__);
return GL_FALSE;
}
@@ -283,7 +283,7 @@ try_pbo_zcopy(struct intel_context *intel,
dst_stride = intelImage->mt->pitch;
if (src_stride != dst_stride || dst_offset != 0 || src_offset != 0) {
- _mesa_printf("%s: failure 2\n", __FUNCTION__);
+ DBG("%s: failure 2\n", __FUNCTION__);
return GL_FALSE;
}
@@ -637,6 +637,12 @@ intel_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
struct intel_context *intel = intel_context(ctx);
struct intel_texture_image *intelImage = intel_texture_image(texImage);
+ /* If we're reading from a texture that has been rendered to, need to
+ * make sure rendering is complete.
+ * We could probably predicate this on texObj->_RenderToTexture
+ */
+ intelFlush(ctx);
+
/* Map */
if (intelImage->mt) {
/* Image is stored in hardware format in a buffer managed by the
diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c
index c06751516eb..058296eab23 100644
--- a/src/mesa/drivers/dri/r200/r200_context.c
+++ b/src/mesa/drivers/dri/r200/r200_context.c
@@ -405,6 +405,8 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
ctx->Const.MaxDrawBuffers = 1;
+ _mesa_set_mvp_with_dp4( ctx, GL_TRUE );
+
/* Initialize the software rasterizer and helper modules.
*/
_swrast_CreateContext( ctx );
diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c
index 8f0effd83e2..7d6705058fe 100644
--- a/src/mesa/drivers/dri/r300/r300_context.c
+++ b/src/mesa/drivers/dri/r300/r300_context.c
@@ -327,6 +327,8 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual,
ctx->Const.MaxDrawBuffers = 1;
+ _mesa_set_mvp_with_dp4( ctx, GL_TRUE );
+
/* Initialize the software rasterizer and helper modules.
*/
_swrast_CreateContext(ctx);
diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c
index ea81a3250b7..b67bda7d06a 100644
--- a/src/mesa/drivers/dri/radeon/radeon_context.c
+++ b/src/mesa/drivers/dri/radeon/radeon_context.c
@@ -355,6 +355,8 @@ radeonCreateContext( const __GLcontextModes *glVisual,
ctx->Const.MaxDrawBuffers = 1;
+ _mesa_set_mvp_with_dp4( ctx, GL_TRUE );
+
/* Initialize the software rasterizer and helper modules.
*/
_swrast_CreateContext( ctx );
diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c
index 3b004a3ee25..34e0b8bc8d7 100644
--- a/src/mesa/drivers/x11/fakeglx.c
+++ b/src/mesa/drivers/x11/fakeglx.c
@@ -2218,7 +2218,7 @@ Fake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap,
if (!dpy || !config || !pixmap)
return 0;
- for (attr = attribList; *attr; attr++) {
+ for (attr = attribList; attr && *attr; attr++) {
switch (*attr) {
case GLX_TEXTURE_FORMAT_EXT:
attr++;
diff --git a/src/mesa/main/api_noop.c b/src/mesa/main/api_noop.c
index a1cc3a2a4b8..66f9c4e6bdb 100644
--- a/src/mesa/main/api_noop.c
+++ b/src/mesa/main/api_noop.c
@@ -477,7 +477,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib4fvNV( GLuint index, const GLfloat
static void GLAPIENTRY _mesa_noop_VertexAttrib1fARB( GLuint index, GLfloat x )
{
GET_CURRENT_CONTEXT(ctx);
- if (index < MAX_VERTEX_ATTRIBS) {
+ if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, 0, 0, 1);
}
else
@@ -487,7 +487,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib1fARB( GLuint index, GLfloat x )
static void GLAPIENTRY _mesa_noop_VertexAttrib1fvARB( GLuint index, const GLfloat *v )
{
GET_CURRENT_CONTEXT(ctx);
- if (index < MAX_VERTEX_ATTRIBS) {
+ if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], 0, 0, 1);
}
else
@@ -497,7 +497,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib1fvARB( GLuint index, const GLfloa
static void GLAPIENTRY _mesa_noop_VertexAttrib2fARB( GLuint index, GLfloat x, GLfloat y )
{
GET_CURRENT_CONTEXT(ctx);
- if (index < MAX_VERTEX_ATTRIBS) {
+ if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, 0, 1);
}
else
@@ -507,7 +507,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib2fARB( GLuint index, GLfloat x, GL
static void GLAPIENTRY _mesa_noop_VertexAttrib2fvARB( GLuint index, const GLfloat *v )
{
GET_CURRENT_CONTEXT(ctx);
- if (index < MAX_VERTEX_ATTRIBS) {
+ if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], 0, 1);
}
else
@@ -518,7 +518,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib3fARB( GLuint index, GLfloat x,
GLfloat y, GLfloat z )
{
GET_CURRENT_CONTEXT(ctx);
- if (index < MAX_VERTEX_ATTRIBS) {
+ if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, z, 1);
}
else
@@ -528,7 +528,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib3fARB( GLuint index, GLfloat x,
static void GLAPIENTRY _mesa_noop_VertexAttrib3fvARB( GLuint index, const GLfloat *v )
{
GET_CURRENT_CONTEXT(ctx);
- if (index < MAX_VERTEX_ATTRIBS) {
+ if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], v[2], 1);
}
else
@@ -539,7 +539,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib4fARB( GLuint index, GLfloat x,
GLfloat y, GLfloat z, GLfloat w )
{
GET_CURRENT_CONTEXT(ctx);
- if (index < MAX_VERTEX_ATTRIBS) {
+ if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, z, w);
}
else
@@ -549,7 +549,7 @@ static void GLAPIENTRY _mesa_noop_VertexAttrib4fARB( GLuint index, GLfloat x,
static void GLAPIENTRY _mesa_noop_VertexAttrib4fvARB( GLuint index, const GLfloat *v )
{
GET_CURRENT_CONTEXT(ctx);
- if (index < MAX_VERTEX_ATTRIBS) {
+ if (index < MAX_VERTEX_GENERIC_ATTRIBS) {
ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], v[2], v[3]);
}
else
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 42d1e579e08..2c6f370df94 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -40,7 +40,7 @@ max_buffer_index(GLcontext *ctx, GLuint count, GLenum type,
{
const GLubyte *map = NULL;
GLuint max = 0;
- GLint i;
+ GLuint i;
if (elementBuf->Name) {
/* elements are in a user-defined buffer object. need to map it */
@@ -224,7 +224,7 @@ _mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode,
/* Vertex buffer object tests */
if (ctx->Array.ElementArrayBufferObj->Name) {
/* use indices in the buffer object */
- GLuint indexBytes;
+ GLsizei indexBytes;
if (type == GL_UNSIGNED_INT) {
indexBytes = count * sizeof(GLuint);
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index e43fa96dd31..a609199504e 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 7.3
+ * Version: 7.6
*
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
@@ -541,6 +541,7 @@ end:
static void
pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable)
{
+ const GLuint curTexUnitSave = ctx->Texture.CurrentUnit;
GLuint i;
#define TEST_AND_UPDATE(VALUE, NEWVALUE, ENUM) \
@@ -685,59 +686,51 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable)
/* texture unit enables */
for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
- if (ctx->Texture.Unit[i].Enabled != enable->Texture[i]) {
- ctx->Texture.Unit[i].Enabled = enable->Texture[i];
- if (ctx->Driver.Enable) {
- if (ctx->Driver.ActiveTexture) {
- (*ctx->Driver.ActiveTexture)(ctx, i);
- }
- (*ctx->Driver.Enable)( ctx, GL_TEXTURE_1D,
- (GLboolean) (enable->Texture[i] & TEXTURE_1D_BIT) );
- (*ctx->Driver.Enable)( ctx, GL_TEXTURE_2D,
- (GLboolean) (enable->Texture[i] & TEXTURE_2D_BIT) );
- (*ctx->Driver.Enable)( ctx, GL_TEXTURE_3D,
- (GLboolean) (enable->Texture[i] & TEXTURE_3D_BIT) );
- if (ctx->Extensions.ARB_texture_cube_map)
- (*ctx->Driver.Enable)( ctx, GL_TEXTURE_CUBE_MAP_ARB,
- (GLboolean) (enable->Texture[i] & TEXTURE_CUBE_BIT) );
- if (ctx->Extensions.NV_texture_rectangle)
- (*ctx->Driver.Enable)( ctx, GL_TEXTURE_RECTANGLE_NV,
- (GLboolean) (enable->Texture[i] & TEXTURE_RECT_BIT) );
+ const GLbitfield enabled = enable->Texture[i];
+ const GLbitfield genEnabled = enable->TexGen[i];
+
+ if (ctx->Texture.Unit[i].Enabled != enabled) {
+ _mesa_ActiveTextureARB(GL_TEXTURE0 + i);
+
+ _mesa_set_enable(ctx, GL_TEXTURE_1D,
+ (enabled & TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE);
+ _mesa_set_enable(ctx, GL_TEXTURE_2D,
+ (enabled & TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE);
+ _mesa_set_enable(ctx, GL_TEXTURE_3D,
+ (enabled & TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE);
+ if (ctx->Extensions.NV_texture_rectangle) {
+ _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE_ARB,
+ (enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE);
+ }
+ if (ctx->Extensions.ARB_texture_cube_map) {
+ _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP,
+ (enabled & TEXTURE_CUBE_BIT) ? GL_TRUE : GL_FALSE);
+ }
+ if (ctx->Extensions.MESA_texture_array) {
+ _mesa_set_enable(ctx, GL_TEXTURE_1D_ARRAY_EXT,
+ (enabled & TEXTURE_1D_ARRAY_BIT) ? GL_TRUE : GL_FALSE);
+ _mesa_set_enable(ctx, GL_TEXTURE_2D_ARRAY_EXT,
+ (enabled & TEXTURE_2D_ARRAY_BIT) ? GL_TRUE : GL_FALSE);
}
}
- if (ctx->Texture.Unit[i].TexGenEnabled != enable->TexGen[i]) {
- ctx->Texture.Unit[i].TexGenEnabled = enable->TexGen[i];
- if (ctx->Driver.Enable) {
- if (ctx->Driver.ActiveTexture) {
- (*ctx->Driver.ActiveTexture)(ctx, i);
- }
- if (enable->TexGen[i] & S_BIT)
- (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_S, GL_TRUE);
- else
- (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_S, GL_FALSE);
- if (enable->TexGen[i] & T_BIT)
- (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_T, GL_TRUE);
- else
- (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_T, GL_FALSE);
- if (enable->TexGen[i] & R_BIT)
- (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_R, GL_TRUE);
- else
- (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_R, GL_FALSE);
- if (enable->TexGen[i] & Q_BIT)
- (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_Q, GL_TRUE);
- else
- (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_Q, GL_FALSE);
- }
+ if (ctx->Texture.Unit[i].TexGenEnabled != genEnabled) {
+ _mesa_ActiveTextureARB(GL_TEXTURE0 + i);
+ _mesa_set_enable(ctx, GL_TEXTURE_GEN_S,
+ (genEnabled & S_BIT) ? GL_TRUE : GL_FALSE);
+ _mesa_set_enable(ctx, GL_TEXTURE_GEN_T,
+ (genEnabled & T_BIT) ? GL_TRUE : GL_FALSE);
+ _mesa_set_enable(ctx, GL_TEXTURE_GEN_R,
+ (genEnabled & R_BIT) ? GL_TRUE : GL_FALSE);
+ _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q,
+ (genEnabled & Q_BIT) ? GL_TRUE : GL_FALSE);
}
/* GL_SGI_texture_color_table */
ctx->Texture.Unit[i].ColorTableEnabled = enable->TextureColorTable[i];
}
- if (ctx->Driver.ActiveTexture) {
- (*ctx->Driver.ActiveTexture)(ctx, ctx->Texture.CurrentUnit);
- }
+ _mesa_ActiveTextureARB(GL_TEXTURE0 + curTexUnitSave);
}
@@ -770,6 +763,13 @@ pop_texture_group(GLcontext *ctx, struct texture_state *texstate)
_mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE_NV,
(unit->Enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE);
}
+ if (ctx->Extensions.MESA_texture_array) {
+ _mesa_set_enable(ctx, GL_TEXTURE_1D_ARRAY_EXT,
+ (unit->Enabled & TEXTURE_1D_ARRAY_BIT) ? GL_TRUE : GL_FALSE);
+ _mesa_set_enable(ctx, GL_TEXTURE_2D_ARRAY_EXT,
+ (unit->Enabled & TEXTURE_2D_ARRAY_BIT) ? GL_TRUE : GL_FALSE);
+ }
+
if (ctx->Extensions.SGI_texture_color_table) {
_mesa_set_enable(ctx, GL_TEXTURE_COLOR_TABLE_SGI,
unit->ColorTableEnabled);
diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h
index 93103fe878d..e79bbc2ac5f 100644
--- a/src/mesa/main/compiler.h
+++ b/src/mesa/main/compiler.h
@@ -468,9 +468,9 @@ do { \
#endif
-
+#ifndef Elements
#define Elements(x) (sizeof(x)/sizeof(*(x)))
-
+#endif
diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h
index 2a9fdf9ca05..f7acd2f08e0 100644
--- a/src/mesa/main/config.h
+++ b/src/mesa/main/config.h
@@ -180,14 +180,14 @@
/*@{*/
#define MAX_PROGRAM_INSTRUCTIONS (16 * 1024)
#define MAX_PROGRAM_LOCAL_PARAMS 256 /**< per-program constants (power of two) */
-#define MAX_PROGRAM_ENV_PARAMS 128
+#define MAX_PROGRAM_ENV_PARAMS 256 /**< per-context constants (power of two) */
#define MAX_PROGRAM_MATRICES 8
#define MAX_PROGRAM_MATRIX_STACK_DEPTH 4
#define MAX_PROGRAM_CALL_DEPTH 8
#define MAX_PROGRAM_TEMPS 256
#define MAX_PROGRAM_ADDRESS_REGS 2
#define MAX_UNIFORMS 1024 /**< number of vec4 uniforms */
-#define MAX_VARYING 8 /**< number of float[4] vectors */
+#define MAX_VARYING 16 /**< number of float[4] vectors */
#define MAX_SAMPLERS MAX_TEXTURE_IMAGE_UNITS
#define MAX_PROGRAM_INPUTS 32
#define MAX_PROGRAM_OUTPUTS 32
@@ -197,7 +197,7 @@
/*@{*/
#define MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS 128
#define MAX_NV_VERTEX_PROGRAM_TEMPS 12
-#define MAX_NV_VERTEX_PROGRAM_PARAMS MAX_PROGRAM_ENV_PARAMS
+#define MAX_NV_VERTEX_PROGRAM_PARAMS 96
#define MAX_NV_VERTEX_PROGRAM_INPUTS 16
#define MAX_NV_VERTEX_PROGRAM_OUTPUTS 15
/*@}*/
@@ -215,7 +215,7 @@
/** For GL_ARB_vertex_shader */
/*@{*/
-#define MAX_VERTEX_ATTRIBS 16
+#define MAX_VERTEX_GENERIC_ATTRIBS 16
#define MAX_VERTEX_TEXTURE_IMAGE_UNITS MAX_TEXTURE_IMAGE_UNITS
#define MAX_COMBINED_TEXTURE_IMAGE_UNITS MAX_TEXTURE_IMAGE_UNITS
/*@}*/
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index a947f69632f..0a4c9acdfe9 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1256,6 +1256,24 @@ initialize_framebuffer_size(GLcontext *ctx, GLframebuffer *fb)
/**
+ * Check if the viewport/scissor size has not yet been initialized.
+ * Initialize the size if the given width and height are non-zero.
+ */
+void
+_mesa_check_init_viewport(GLcontext *ctx, GLuint width, GLuint height)
+{
+ if (!ctx->ViewportInitialized && width > 0 && height > 0) {
+ /* Note: set flag here, before calling _mesa_set_viewport(), to prevent
+ * potential infinite recursion.
+ */
+ ctx->ViewportInitialized = GL_TRUE;
+ _mesa_set_viewport(ctx, 0, 0, width, height);
+ _mesa_set_scissor(ctx, 0, 0, width, height);
+ }
+}
+
+
+/**
* Bind the given context to the given drawBuffer and readBuffer and
* make it the current context for the calling thread.
* We'll render into the drawBuffer and read pixels from the
@@ -1372,25 +1390,24 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
ASSERT(drawBuffer->Height > 0);
#endif
- if (newCtx->FirstTimeCurrent) {
- /* set initial viewport and scissor size now */
- _mesa_set_viewport(newCtx, 0, 0,
- drawBuffer->Width, drawBuffer->Height);
- _mesa_set_scissor(newCtx, 0, 0,
- drawBuffer->Width, drawBuffer->Height );
- check_context_limits(newCtx);
+ if (drawBuffer) {
+ _mesa_check_init_viewport(newCtx,
+ drawBuffer->Width, drawBuffer->Height);
}
}
- /* We can use this to help debug user's problems. Tell them to set
- * the MESA_INFO env variable before running their app. Then the
- * first time each context is made current we'll print some useful
- * information.
- */
if (newCtx->FirstTimeCurrent) {
+ check_context_limits(newCtx);
+
+ /* We can use this to help debug user's problems. Tell them to set
+ * the MESA_INFO env variable before running their app. Then the
+ * first time each context is made current we'll print some useful
+ * information.
+ */
if (_mesa_getenv("MESA_INFO")) {
_mesa_print_info();
}
+
newCtx->FirstTimeCurrent = GL_FALSE;
}
}
diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index 6b3e1b2b973..0531ae8ee86 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -130,6 +130,9 @@ extern void
_mesa_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask);
+extern void
+_mesa_check_init_viewport(GLcontext *ctx, GLuint width, GLuint height);
+
extern GLboolean
_mesa_make_current( GLcontext *ctx, GLframebuffer *drawBuffer,
GLframebuffer *readBuffer );
diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c
index 2eabcdaf493..b54e47919dd 100644
--- a/src/mesa/main/debug.c
+++ b/src/mesa/main/debug.c
@@ -282,7 +282,7 @@ write_texture_image(struct gl_texture_object *texObj)
case MESA_FORMAT_RGB565:
{
GLubyte *buf2 = (GLubyte *) _mesa_malloc(img->Width * img->Height * 3);
- GLint i;
+ GLuint i;
for (i = 0; i < img->Width * img->Height; i++) {
GLint r, g, b;
GLushort s = ((GLushort *) img->Data)[i];
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 537ff5881f3..782f847904e 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -4974,7 +4974,7 @@ save_Attr1fARB(GLenum attr, GLfloat x)
n[2].f = x;
}
- ASSERT(attr < MAX_VERTEX_ATTRIBS);
+ ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
ctx->ListState.ActiveAttribSize[attr] = 1;
ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1);
@@ -4996,7 +4996,7 @@ save_Attr2fARB(GLenum attr, GLfloat x, GLfloat y)
n[3].f = y;
}
- ASSERT(attr < MAX_VERTEX_ATTRIBS);
+ ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
ctx->ListState.ActiveAttribSize[attr] = 2;
ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1);
@@ -5019,7 +5019,7 @@ save_Attr3fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z)
n[4].f = z;
}
- ASSERT(attr < MAX_VERTEX_ATTRIBS);
+ ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
ctx->ListState.ActiveAttribSize[attr] = 3;
ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1);
@@ -5043,7 +5043,7 @@ save_Attr4fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
n[5].f = w;
}
- ASSERT(attr < MAX_VERTEX_ATTRIBS);
+ ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
ctx->ListState.ActiveAttribSize[attr] = 4;
ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w);
@@ -5506,7 +5506,7 @@ index_error(void)
static void GLAPIENTRY
save_VertexAttrib1fNV(GLuint index, GLfloat x)
{
- if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
+ if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
save_Attr1fNV(index, x);
else
index_error();
@@ -5515,7 +5515,7 @@ save_VertexAttrib1fNV(GLuint index, GLfloat x)
static void GLAPIENTRY
save_VertexAttrib1fvNV(GLuint index, const GLfloat * v)
{
- if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
+ if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
save_Attr1fNV(index, v[0]);
else
index_error();
@@ -5524,7 +5524,7 @@ save_VertexAttrib1fvNV(GLuint index, const GLfloat * v)
static void GLAPIENTRY
save_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y)
{
- if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
+ if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
save_Attr2fNV(index, x, y);
else
index_error();
@@ -5533,7 +5533,7 @@ save_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y)
static void GLAPIENTRY
save_VertexAttrib2fvNV(GLuint index, const GLfloat * v)
{
- if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
+ if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
save_Attr2fNV(index, v[0], v[1]);
else
index_error();
@@ -5542,7 +5542,7 @@ save_VertexAttrib2fvNV(GLuint index, const GLfloat * v)
static void GLAPIENTRY
save_VertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z)
{
- if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
+ if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
save_Attr3fNV(index, x, y, z);
else
index_error();
@@ -5551,7 +5551,7 @@ save_VertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z)
static void GLAPIENTRY
save_VertexAttrib3fvNV(GLuint index, const GLfloat * v)
{
- if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
+ if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
save_Attr3fNV(index, v[0], v[1], v[2]);
else
index_error();
@@ -5561,7 +5561,7 @@ static void GLAPIENTRY
save_VertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y,
GLfloat z, GLfloat w)
{
- if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
+ if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
save_Attr4fNV(index, x, y, z, w);
else
index_error();
@@ -5570,7 +5570,7 @@ save_VertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y,
static void GLAPIENTRY
save_VertexAttrib4fvNV(GLuint index, const GLfloat * v)
{
- if (index < MAX_VERTEX_PROGRAM_ATTRIBS)
+ if (index < MAX_NV_VERTEX_PROGRAM_INPUTS)
save_Attr4fNV(index, v[0], v[1], v[2], v[3]);
else
index_error();
@@ -5582,7 +5582,7 @@ save_VertexAttrib4fvNV(GLuint index, const GLfloat * v)
static void GLAPIENTRY
save_VertexAttrib1fARB(GLuint index, GLfloat x)
{
- if (index < MAX_VERTEX_ATTRIBS)
+ if (index < MAX_VERTEX_GENERIC_ATTRIBS)
save_Attr1fARB(index, x);
else
index_error();
@@ -5591,7 +5591,7 @@ save_VertexAttrib1fARB(GLuint index, GLfloat x)
static void GLAPIENTRY
save_VertexAttrib1fvARB(GLuint index, const GLfloat * v)
{
- if (index < MAX_VERTEX_ATTRIBS)
+ if (index < MAX_VERTEX_GENERIC_ATTRIBS)
save_Attr1fARB(index, v[0]);
else
index_error();
@@ -5600,7 +5600,7 @@ save_VertexAttrib1fvARB(GLuint index, const GLfloat * v)
static void GLAPIENTRY
save_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y)
{
- if (index < MAX_VERTEX_ATTRIBS)
+ if (index < MAX_VERTEX_GENERIC_ATTRIBS)
save_Attr2fARB(index, x, y);
else
index_error();
@@ -5609,7 +5609,7 @@ save_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y)
static void GLAPIENTRY
save_VertexAttrib2fvARB(GLuint index, const GLfloat * v)
{
- if (index < MAX_VERTEX_ATTRIBS)
+ if (index < MAX_VERTEX_GENERIC_ATTRIBS)
save_Attr2fARB(index, v[0], v[1]);
else
index_error();
@@ -5618,7 +5618,7 @@ save_VertexAttrib2fvARB(GLuint index, const GLfloat * v)
static void GLAPIENTRY
save_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z)
{
- if (index < MAX_VERTEX_ATTRIBS)
+ if (index < MAX_VERTEX_GENERIC_ATTRIBS)
save_Attr3fARB(index, x, y, z);
else
index_error();
@@ -5627,7 +5627,7 @@ save_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z)
static void GLAPIENTRY
save_VertexAttrib3fvARB(GLuint index, const GLfloat * v)
{
- if (index < MAX_VERTEX_ATTRIBS)
+ if (index < MAX_VERTEX_GENERIC_ATTRIBS)
save_Attr3fARB(index, v[0], v[1], v[2]);
else
index_error();
@@ -5637,7 +5637,7 @@ static void GLAPIENTRY
save_VertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z,
GLfloat w)
{
- if (index < MAX_VERTEX_ATTRIBS)
+ if (index < MAX_VERTEX_GENERIC_ATTRIBS)
save_Attr4fARB(index, x, y, z, w);
else
index_error();
@@ -5646,7 +5646,7 @@ save_VertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z,
static void GLAPIENTRY
save_VertexAttrib4fvARB(GLuint index, const GLfloat * v)
{
- if (index < MAX_VERTEX_ATTRIBS)
+ if (index < MAX_VERTEX_GENERIC_ATTRIBS)
save_Attr4fARB(index, v[0], v[1], v[2], v[3]);
else
index_error();
diff --git a/src/mesa/main/enums.c b/src/mesa/main/enums.c
index c077bc0a89a..cf893fdac51 100644
--- a/src/mesa/main/enums.c
+++ b/src/mesa/main/enums.c
@@ -948,8 +948,8 @@ LONGSTRING static const char enum_string_table[] =
"GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV\0"
"GL_MAX_VARYING_FLOATS\0"
"GL_MAX_VARYING_FLOATS_ARB\0"
- "GL_MAX_VERTEX_ATTRIBS\0"
- "GL_MAX_VERTEX_ATTRIBS_ARB\0"
+ "GL_MAX_VERTEX_GENERIC_ATTRIBS\0"
+ "GL_MAX_VERTEX_GENERIC_ATTRIBS_ARB\0"
"GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS\0"
"GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB\0"
"GL_MAX_VERTEX_UNIFORM_COMPONENTS\0"
@@ -2772,8 +2772,8 @@ static const enum_elt all_enums[1820] =
{ 19417, 0x0000862E }, /* GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */
{ 19452, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS */
{ 19474, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS_ARB */
- { 19500, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS */
- { 19522, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS_ARB */
+ { 19500, 0x00008869 }, /* GL_MAX_VERTEX_GENERIC_ATTRIBS */
+ { 19522, 0x00008869 }, /* GL_MAX_VERTEX_GENERIC_ATTRIBS_ARB */
{ 19548, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS */
{ 19582, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */
{ 19620, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS */
@@ -4733,7 +4733,7 @@ static const unsigned reduced_enums[1319] =
317, /* GL_CURRENT_QUERY */
1259, /* GL_QUERY_RESULT */
1261, /* GL_QUERY_RESULT_AVAILABLE */
- 912, /* GL_MAX_VERTEX_ATTRIBS */
+ 912, /* GL_MAX_VERTEX_GENERIC_ATTRIBS */
1778, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED */
368, /* GL_DEPTH_STENCIL_TO_RGBA_NV */
367, /* GL_DEPTH_STENCIL_TO_BGRA_NV */
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index e8e8c2bf30e..83301f1e621 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -368,6 +368,11 @@ test_attachment_completeness(const GLcontext *ctx, GLenum format,
att->Complete = GL_FALSE;
return;
}
+ if (texImage->TexFormat->TexelBytes == 0) {
+ att_incomplete("compressed internalformat");
+ att->Complete = GL_FALSE;
+ return;
+ }
}
else if (format == GL_DEPTH) {
if (texImage->TexFormat->BaseFormat == GL_DEPTH_COMPONENT) {
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index 332febf91f9..01fbe40a03b 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -2872,7 +2872,7 @@ extract_uint_indexes(GLuint n, GLuint indexes[],
}
else {
for (i = 0; i < n; i++)
- indexes[i] = s[i] & 0xfff; /* lower 8 bits */
+ indexes[i] = s[i] & 0xff; /* lower 8 bits */
}
}
break;
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index 01d59dd42da..59def651a39 100644
--- a/src/mesa/main/macros.h
+++ b/src/mesa/main/macros.h
@@ -55,7 +55,7 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256];
/** Convert GLbyte in [-128,127] to GLfloat in [-1.0,1.0], texture/fb data */
-#define BYTE_TO_FLOAT_TEX(B) ((B) == -128 ? -1.0 : (B) * (1.0F/127.0F))
+#define BYTE_TO_FLOAT_TEX(B) ((B) == -128 ? -1.0F : (B) * (1.0F/127.0F))
/** Convert GLfloat in [-1.0,1.0] to GLbyte in [-128,127], texture/fb data */
#define FLOAT_TO_BYTE_TEX(X) ( (GLint) (127.0F * (X)) )
@@ -65,7 +65,7 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256];
#define USHORT_TO_FLOAT(S) ((GLfloat) (S) * (1.0F / 65535.0F))
/** Convert GLfloat in [0.0,1.0] to GLushort in [0, 65535] */
-#define FLOAT_TO_USHORT(X) ((GLuint) ((X) * 65535.0))
+#define FLOAT_TO_USHORT(X) ((GLuint) ((X) * 65535.0F))
/** Convert GLshort in [-32768,32767] to GLfloat in [-1.0,1.0] */
@@ -76,7 +76,7 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256];
/** Convert GLshort in [-32768,32767] to GLfloat in [-1.0,1.0], texture/fb data */
-#define SHORT_TO_FLOAT_TEX(S) ((S) == -32768 ? -1.0 : (S) * (1.0F/32767.0F))
+#define SHORT_TO_FLOAT_TEX(S) ((S) == -32768 ? -1.0F : (S) * (1.0F/32767.0F))
/** Convert GLfloat in [-1.0,1.0] to GLshort in [-32768,32767], texture/fb data */
#define FLOAT_TO_SHORT_TEX(X) ( (GLint) (32767.0F * (X)) )
@@ -86,7 +86,7 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256];
#define UINT_TO_FLOAT(U) ((GLfloat) (U) * (1.0F / 4294967295.0F))
/** Convert GLfloat in [0.0,1.0] to GLuint in [0,4294967295] */
-#define FLOAT_TO_UINT(X) ((GLuint) ((X) * 4294967295.0))
+#define FLOAT_TO_UINT(X) ((GLuint) ((X) * 4294967295.0F))
/** Convert GLint in [-2147483648,2147483647] to GLfloat in [-1.0,1.0] */
@@ -97,11 +97,11 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256];
#define FLOAT_TO_INT(X) ( (((GLint) (4294967294.0F * (X))) - 1) / 2 )
*/
/* a close approximation: */
-#define FLOAT_TO_INT(X) ( (GLint) (2147483647.0 * (X)) )
+#define FLOAT_TO_INT(X) ( (GLint) (2147483647.0F * (X)) )
/** Convert GLint in [-2147483648,2147483647] to GLfloat in [-1.0,1.0], texture/fb data */
-#define INT_TO_FLOAT_TEX(I) ((I) == -2147483648 ? -1.0 : (I) * (1.0F/2147483647.0))
+#define INT_TO_FLOAT_TEX(I) ((I) == -2147483648 ? -1.0F : (I) * (1.0F/2147483647.0F))
/** Convert GLfloat in [-1.0,1.0] to GLint in [-2147483648,2147483647], texture/fb data */
#define FLOAT_TO_INT_TEX(X) ( (GLint) (2147483647.0F * (X)) )
@@ -120,7 +120,7 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256];
#define INT_TO_USHORT(i) ((i) < 0 ? 0 : ((GLushort) ((i) >> 15)))
#define UINT_TO_USHORT(i) ((i) < 0 ? 0 : ((GLushort) ((i) >> 16)))
#define UNCLAMPED_FLOAT_TO_USHORT(us, f) \
- us = ( (GLushort) IROUND( CLAMP((f), 0.0, 1.0) * 65535.0F) )
+ us = ( (GLushort) IROUND( CLAMP((f), 0.0F, 1.0F) * 65535.0F) )
#define CLAMPED_FLOAT_TO_USHORT(us, f) \
us = ( (GLushort) IROUND( (f) * 65535.0F) )
diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c
index 39b4967a58e..ebc3cbd59c3 100644
--- a/src/mesa/main/matrix.c
+++ b/src/mesa/main/matrix.c
@@ -160,11 +160,21 @@ _mesa_MatrixMode( GLenum mode )
ctx->CurrentStack = &ctx->ProjectionMatrixStack;
break;
case GL_TEXTURE:
+ /* This error check is disabled because if we're called from
+ * glPopAttrib() when the active texture unit is >= MaxTextureCoordUnits
+ * we'll generate an unexpected error.
+ * From the GL_ARB_vertex_shader spec it sounds like we should instead
+ * do error checking in other places when we actually try to access
+ * texture matrices beyond MaxTextureCoordUnits.
+ */
+#if 0
if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glMatrixMode(invalid tex unit %d)",
ctx->Texture.CurrentUnit);
return;
}
+#endif
+ ASSERT(ctx->Texture.CurrentUnit < Elements(ctx->TextureMatrixStack));
ctx->CurrentStack = &ctx->TextureMatrixStack[ctx->Texture.CurrentUnit];
break;
case GL_COLOR:
diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
index 7a719745fcc..b3067004842 100644
--- a/src/mesa/main/mipmap.c
+++ b/src/mesa/main/mipmap.c
@@ -1598,9 +1598,6 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
return;
}
- if (dstImage->ImageOffsets)
- _mesa_free(dstImage->ImageOffsets);
-
/* Free old image data */
if (dstImage->Data)
ctx->Driver.FreeTexImageData(ctx, dstImage);
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 50dc2def87f..84a082b253e 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2032,6 +2032,7 @@ struct gl_shader_state
struct gl_shader_program *CurrentProgram; /**< The user-bound program */
/** Driver-selectable options: */
GLboolean EmitHighLevelInstructions; /**< IF/ELSE/ENDIF vs. BRA, etc. */
+ GLboolean EmitContReturn; /**< Emit CONT/RET opcodes? */
GLboolean EmitCondCodes; /**< Use condition codes? */
GLboolean EmitComments; /**< Annotated instructions */
void *MemPool;
@@ -2053,6 +2054,9 @@ struct gl_shared_state
/** Default texture objects (shared by all texture units) */
struct gl_texture_object *DefaultTex[NUM_TEXTURE_TARGETS];
+ /** Fallback texture used when a bound texture is incomplete */
+ struct gl_texture_object *FallbackTex;
+
/**
* \name Thread safety and statechange notification for texture
* objects.
@@ -2947,6 +2951,8 @@ struct __GLcontextRec
GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
GLbitfield NewState; /**< bitwise-or of _NEW_* flags */
+ GLboolean ViewportInitialized; /**< has viewport size been initialized? */
+
GLbitfield varying_vp_inputs; /**< mask of VERT_BIT_* flags */
/** \name Derived state */
diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c
index 554e0b0d181..c25b31af023 100644
--- a/src/mesa/main/queryobj.c
+++ b/src/mesa/main/queryobj.c
@@ -83,13 +83,27 @@ void
_mesa_wait_query(GLcontext *ctx, struct gl_query_object *q)
{
/* For software drivers, _mesa_end_query() should have completed the query.
- * For real hardware, implement a proper WaitQuery() driver function.
+ * For real hardware, implement a proper WaitQuery() driver function,
+ * which may require issuing a flush.
*/
assert(q->Ready);
}
/**
+ * Check if a query results are ready. Software driver fallback.
+ * Called via ctx->Driver.CheckQuery().
+ */
+void
+_mesa_check_query(GLcontext *ctx, struct gl_query_object *q)
+{
+ /* No-op for sw rendering.
+ * HW drivers may need to flush at this time.
+ */
+}
+
+
+/**
* Delete a query object. Called via ctx->Driver.DeleteQuery().
* Not removed from hash table here.
*/
diff --git a/src/mesa/main/queryobj.h b/src/mesa/main/queryobj.h
index 9a9774641bb..bc02b65b54c 100644
--- a/src/mesa/main/queryobj.h
+++ b/src/mesa/main/queryobj.h
@@ -48,6 +48,9 @@ _mesa_end_query(GLcontext *ctx, struct gl_query_object *q);
extern void
_mesa_wait_query(GLcontext *ctx, struct gl_query_object *q);
+extern void
+_mesa_check_query(GLcontext *ctx, struct gl_query_object *q);
+
extern void GLAPIENTRY
_mesa_GenQueriesARB(GLsizei n, GLuint *ids);
diff --git a/src/mesa/main/texenv.c b/src/mesa/main/texenv.c
index 4d511f2f7ed..4c04a7ed375 100644
--- a/src/mesa/main/texenv.c
+++ b/src/mesa/main/texenv.c
@@ -959,7 +959,7 @@ void GLAPIENTRY
_mesa_GetTexBumpParameterivATI( GLenum pname, GLint *param )
{
const struct gl_texture_unit *texUnit;
- GLint i;
+ GLuint i;
GLint temp = 0;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -1006,7 +1006,7 @@ void GLAPIENTRY
_mesa_GetTexBumpParameterfvATI( GLenum pname, GLfloat *param )
{
const struct gl_texture_unit *texUnit;
- GLint i;
+ GLuint i;
GLint temp = 0;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c
index a70d069bd9c..b92ba2542d2 100644
--- a/src/mesa/main/texenvprogram.c
+++ b/src/mesa/main/texenvprogram.c
@@ -877,6 +877,7 @@ static struct ureg get_source( struct texenv_fragment_program *p,
default:
assert(0);
+ return undef;
}
}
diff --git a/src/mesa/main/texformat_tmp.h b/src/mesa/main/texformat_tmp.h
index f3b2fb9c9c4..eb160deff93 100644
--- a/src/mesa/main/texformat_tmp.h
+++ b/src/mesa/main/texformat_tmp.h
@@ -1347,13 +1347,13 @@ static void FETCH(f_ycbcr)( const struct gl_texture_image *texImage,
const GLubyte cb = *src0 & 0xff; /* chroma U */
const GLubyte y1 = (*src1 >> 8) & 0xff; /* luminance */
const GLubyte cr = *src1 & 0xff; /* chroma V */
- const GLfloat y = (i & 1) ? y1 : y0; /* choose even/odd luminance */
- GLfloat r = 1.164 * (y - 16) + 1.596 * (cr - 128);
- GLfloat g = 1.164 * (y - 16) - 0.813 * (cr - 128) - 0.391 * (cb - 128);
- GLfloat b = 1.164 * (y - 16) + 2.018 * (cb - 128);
- r *= (1.0 / 255.0F);
- g *= (1.0 / 255.0F);
- b *= (1.0 / 255.0F);
+ const GLubyte y = (i & 1) ? y1 : y0; /* choose even/odd luminance */
+ GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128);
+ GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128);
+ GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128);
+ r *= (1.0F / 255.0F);
+ g *= (1.0F / 255.0F);
+ b *= (1.0F / 255.0F);
texel[RCOMP] = CLAMP(r, 0.0F, 1.0F);
texel[GCOMP] = CLAMP(g, 0.0F, 1.0F);
texel[BCOMP] = CLAMP(b, 0.0F, 1.0F);
@@ -1388,13 +1388,13 @@ static void FETCH(f_ycbcr_rev)( const struct gl_texture_image *texImage,
const GLubyte cr = (*src0 >> 8) & 0xff; /* chroma V */
const GLubyte y1 = *src1 & 0xff; /* luminance */
const GLubyte cb = (*src1 >> 8) & 0xff; /* chroma U */
- const GLfloat y = (i & 1) ? y1 : y0; /* choose even/odd luminance */
- GLfloat r = 1.164 * (y - 16) + 1.596 * (cr - 128);
- GLfloat g = 1.164 * (y - 16) - 0.813 * (cr - 128) - 0.391 * (cb - 128);
- GLfloat b = 1.164 * (y - 16) + 2.018 * (cb - 128);
- r *= (1.0 / 255.0F);
- g *= (1.0 / 255.0F);
- b *= (1.0 / 255.0F);
+ const GLubyte y = (i & 1) ? y1 : y0; /* choose even/odd luminance */
+ GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128);
+ GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128);
+ GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128);
+ r *= (1.0F / 255.0F);
+ g *= (1.0F / 255.0F);
+ b *= (1.0F / 255.0F);
texel[RCOMP] = CLAMP(r, 0.0F, 1.0F);
texel[GCOMP] = CLAMP(g, 0.0F, 1.0F);
texel[BCOMP] = CLAMP(b, 0.0F, 1.0F);
diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
index 70a25080cb0..02409d80098 100644
--- a/src/mesa/main/texgetimage.c
+++ b/src/mesa/main/texgetimage.c
@@ -73,11 +73,11 @@ linear_to_nonlinear(GLfloat cl)
{
/* can't have values outside [0, 1] */
GLfloat cs;
- if (cl < 0.0031308) {
- cs = 12.92 * cl;
+ if (cl < 0.0031308f) {
+ cs = 12.92f * cl;
}
else {
- cs = 1.055 * _mesa_pow(cl, 0.41666) - 0.055;
+ cs = (GLfloat)(1.055 * _mesa_pow(cl, 0.41666) - 0.055);
}
return cs;
}
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 76b46d700b5..6e21066537b 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1250,6 +1250,8 @@ _mesa_init_teximage_fields(GLcontext *ctx, GLenum target,
* We allocate the array for 1D/2D textures too in order to avoid special-
* case code in the texstore routines.
*/
+ if (img->ImageOffsets)
+ _mesa_free(img->ImageOffsets);
img->ImageOffsets = (GLuint *) _mesa_malloc(depth * sizeof(GLuint));
for (i = 0; i < depth; i++) {
img->ImageOffsets[i] = i * width * height;
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index b63f747fe8d..89ee69770e4 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -662,6 +662,59 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
}
}
+
+/**
+ * Return pointer to a default/fallback texture.
+ * The texture is a 2D 8x8 RGBA texture with all texels = (0,0,0,1).
+ * That's the value a sampler should get when sampling from an
+ * incomplete texture.
+ */
+struct gl_texture_object *
+_mesa_get_fallback_texture(GLcontext *ctx)
+{
+ if (!ctx->Shared->FallbackTex) {
+ /* create fallback texture now */
+ static GLubyte texels[8 * 8][4];
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ GLuint i;
+
+ for (i = 0; i < 8 * 8; i++) {
+ texels[i][0] =
+ texels[i][1] =
+ texels[i][2] = 0x0;
+ texels[i][3] = 0xff;
+ }
+
+ /* create texture object */
+ texObj = ctx->Driver.NewTextureObject(ctx, 0, GL_TEXTURE_2D);
+ assert(texObj->RefCount == 1);
+ texObj->MinFilter = GL_NEAREST;
+ texObj->MagFilter = GL_NEAREST;
+
+ /* create level[0] texture image */
+ texImage = _mesa_get_tex_image(ctx, texObj, GL_TEXTURE_2D, 0);
+
+ /* init the image fields */
+ _mesa_init_teximage_fields(ctx, GL_TEXTURE_2D, texImage,
+ 8, 8, 1, 0, GL_RGBA);
+
+ /* set image data */
+ ctx->Driver.TexImage2D(ctx, GL_TEXTURE_2D, 0, GL_RGBA,
+ 8, 8, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, texels,
+ &ctx->DefaultPacking, texObj, texImage);
+
+ _mesa_test_texobj_completeness(ctx, texObj);
+ assert(texObj->_Complete);
+
+ ctx->Shared->FallbackTex = texObj;
+ }
+ return ctx->Shared->FallbackTex;
+}
+
+
+
/*@}*/
@@ -891,6 +944,7 @@ _mesa_BindTexture( GLenum target, GLuint texName )
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
struct gl_texture_object *newTexObj = NULL, *defaultTexObj = NULL;
GLint targetIndex;
+ GLboolean early_out = GL_FALSE;
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
@@ -944,6 +998,17 @@ _mesa_BindTexture( GLenum target, GLuint texName )
assert(valid_texture_object(newTexObj));
+ _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
+ if ((ctx->Shared->RefCount == 1)
+ && (newTexObj == texUnit->CurrentTex[targetIndex])) {
+ early_out = GL_TRUE;
+ }
+ _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
+
+ if (early_out) {
+ return;
+ }
+
/* flush before changing binding */
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
index d5374c5d6c4..2599c0816a9 100644
--- a/src/mesa/main/texobj.h
+++ b/src/mesa/main/texobj.h
@@ -65,6 +65,9 @@ extern void
_mesa_test_texobj_completeness( const GLcontext *ctx,
struct gl_texture_object *obj );
+extern struct gl_texture_object *
+_mesa_get_fallback_texture(GLcontext *ctx);
+
extern void
_mesa_unlock_context_textures( GLcontext *ctx );
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index cef58d7a496..89da4335a2e 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -561,8 +561,13 @@ update_texture_state( GLcontext *ctx )
}
if (!texUnit->_ReallyEnabled) {
- _mesa_reference_texobj(&texUnit->_Current, NULL);
- continue;
+ /* If we get here it means the shader (or fixed-function state)
+ * is expecting a texture object, but there isn't one (or it's
+ * incomplete). Use the fallback texture.
+ */
+ struct gl_texture_object *texObj = _mesa_get_fallback_texture(ctx);
+ texUnit->_ReallyEnabled = 1 << TEXTURE_2D_INDEX;
+ _mesa_reference_texobj(&texUnit->_Current, texObj);
}
/* if we get here, we know this texture unit is enabled */
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index f3739f950b0..bfced1b3f4f 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -2689,12 +2689,45 @@ GLboolean
_mesa_texstore_z24_s8(TEXSTORE_PARAMS)
{
const GLfloat depthScale = (GLfloat) 0xffffff;
+ const GLint srcRowStride
+ = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType)
+ / sizeof(GLuint);
+ GLint img, row;
ASSERT(dstFormat == &_mesa_texformat_z24_s8);
- ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT);
- ASSERT(srcType == GL_UNSIGNED_INT_24_8_EXT);
+ ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT || srcFormat == GL_DEPTH_COMPONENT);
+ ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT || srcType == GL_UNSIGNED_INT_24_8_EXT);
- if (ctx->Pixel.DepthScale == 1.0f &&
+ /* In case we only upload depth we need to preserve the stencil */
+ if (srcFormat == GL_DEPTH_COMPONENT) {
+ for (img = 0; img < srcDepth; img++) {
+ GLuint *dstRow = (GLuint *) dstAddr
+ + dstImageOffsets[dstZoffset + img]
+ + dstYoffset * dstRowStride / sizeof(GLuint)
+ + dstXoffset;
+ const GLuint *src
+ = (const GLuint *) _mesa_image_address(dims, srcPacking, srcAddr,
+ srcWidth, srcHeight,
+ srcFormat, srcType,
+ img, 0, 0);
+ for (row = 0; row < srcHeight; row++) {
+ GLuint depth[MAX_WIDTH];
+ GLint i;
+ _mesa_unpack_depth_span(ctx, srcWidth,
+ GL_UNSIGNED_INT, /* dst type */
+ depth, /* dst addr */
+ depthScale,
+ srcType, src, srcPacking);
+
+ for (i = 0; i < srcWidth; i++)
+ dstRow[i] = depth[i] << 8 | (dstRow[i] & 0x000000FF);
+
+ src += srcRowStride;
+ dstRow += dstRowStride / sizeof(GLuint);
+ }
+ }
+ }
+ else if (ctx->Pixel.DepthScale == 1.0f &&
ctx->Pixel.DepthBias == 0.0f &&
!srcPacking->SwapBytes) {
/* simple path */
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 72b3e834b3a..8f6621ee45f 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -534,10 +534,11 @@ _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
{
GLboolean normalized = GL_FALSE;
GLsizei elementSize;
+ GLenum format;
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
- if (index >= MAX_VERTEX_PROGRAM_ATTRIBS) {
+ if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) {
_mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(index)");
return;
}
@@ -557,6 +558,21 @@ _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
return;
}
+ if (size == GL_BGRA) {
+ if (type != GL_UNSIGNED_BYTE) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glVertexAttribPointerNV(GL_BGRA/type)");
+ return;
+ }
+
+ format = GL_BGRA;
+ size = 4;
+ normalized = GL_TRUE;
+ }
+ else {
+ format = GL_RGBA;
+ }
+
/* check for valid 'type' and compute StrideB right away */
switch (type) {
case GL_UNSIGNED_BYTE:
@@ -579,7 +595,7 @@ _mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
_NEW_ARRAY_ATTRIB(index),
- elementSize, size, type, GL_RGBA, stride, normalized, ptr);
+ elementSize, size, type, format, stride, normalized, ptr);
if (ctx->Driver.VertexAttribPointer)
ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr );
@@ -621,9 +637,14 @@ _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
"glVertexAttribPointerARB(GL_BGRA/type)");
return;
}
+ if (normalized != GL_TRUE) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glVertexAttribPointerARB(GL_BGRA/normalized)");
+ return;
+ }
+
format = GL_BGRA;
size = 4;
- normalized = GL_TRUE;
}
else {
format = GL_RGBA;
@@ -668,7 +689,7 @@ _mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
update_array(ctx, &ctx->Array.ArrayObj->VertexAttrib[index],
_NEW_ARRAY_ATTRIB(index),
- elementSize, size, type, GL_RGBA, stride, normalized, ptr);
+ elementSize, size, type, format, stride, normalized, ptr);
if (ctx->Driver.VertexAttribPointer)
ctx->Driver.VertexAttribPointer(ctx, index, size, type, stride, ptr);
diff --git a/src/mesa/main/version.h b/src/mesa/main/version.h
index 015ac71a178..52ee324d172 100644
--- a/src/mesa/main/version.h
+++ b/src/mesa/main/version.h
@@ -31,7 +31,7 @@
#define MESA_MAJOR 7
#define MESA_MINOR 5
#define MESA_PATCH 0
-#define MESA_VERSION_STRING "7.5-rc3"
+#define MESA_VERSION_STRING "7.5-rc4"
/* To make version comparison easy */
#define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c
index ead856d32c3..50e0402d278 100644
--- a/src/mesa/main/viewport.c
+++ b/src/mesa/main/viewport.c
@@ -73,8 +73,8 @@ _mesa_set_viewport(GLcontext *ctx, GLint x, GLint y,
}
/* clamp width and height to the implementation dependent range */
- width = CLAMP(width, 1, (GLsizei) ctx->Const.MaxViewportWidth);
- height = CLAMP(height, 1, (GLsizei) ctx->Const.MaxViewportHeight);
+ width = MIN2(width, (GLsizei) ctx->Const.MaxViewportWidth);
+ height = MIN2(height, (GLsizei) ctx->Const.MaxViewportHeight);
ctx->Viewport.X = x;
ctx->Viewport.Width = width;
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c
index c7a031067ef..bb4c5b38d41 100644
--- a/src/mesa/shader/arbprogparse.c
+++ b/src/mesa/shader/arbprogparse.c
@@ -1014,7 +1014,10 @@ parse_teximage_num (GLcontext * ctx, const GLubyte ** inst,
GLint i = parse_integer (inst, Program);
if ((i < 0) || (i >= (int)ctx->Const.MaxTextureImageUnits)) {
- program_error(ctx, Program->Position, "Invalid texture image index");
+ char s[100];
+ _mesa_snprintf(s, sizeof(s), "Invalid texture image index %d (%u is max)",
+ i, ctx->Const.MaxTextureImageUnits);
+ program_error(ctx, Program->Position, s);
return 1;
}
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index 644cd39185c..cf9f8b92224 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -402,6 +402,7 @@ _mesa_init_shader_state(GLcontext * ctx)
* are generated by the GLSL compiler.
*/
ctx->Shader.EmitHighLevelInstructions = GL_TRUE;
+ ctx->Shader.EmitContReturn = GL_TRUE;
ctx->Shader.EmitCondCodes = GL_FALSE;
ctx->Shader.EmitComments = GL_FALSE;
ctx->Shader.Flags = get_shader_flags();
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index 6d693c9027a..24e99523869 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -75,6 +75,11 @@ const GLuint MAX_FOR_LOOP_UNROLL_COMPLEXITY = 256;
static slang_ir_node *
_slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper);
+static void
+slang_substitute(slang_assemble_ctx *A, slang_operation *oper,
+ GLuint substCount, slang_variable **substOld,
+ slang_operation **substNew, GLboolean isLHS);
+
/**
* Retrieves type information about an operation.
@@ -326,6 +331,17 @@ sampler_to_texture_index(const slang_type_specifier_type type)
}
+/** helper to build a SLANG_OPER_IDENTIFIER node */
+static void
+slang_operation_identifier(slang_operation *oper,
+ slang_assemble_ctx *A,
+ const char *name)
+{
+ oper->type = SLANG_OPER_IDENTIFIER;
+ oper->a_id = slang_atom_pool_atom(A->atoms, name);
+}
+
+
#define SWIZZLE_ZWWW MAKE_SWIZZLE4(SWIZZLE_Z, SWIZZLE_W, SWIZZLE_W, SWIZZLE_W)
/**
@@ -429,6 +445,56 @@ _slang_output_index(const char *name, GLenum target)
}
+/**
+ * Called when we begin code/IR generation for a new while/do/for loop.
+ */
+static void
+push_loop(slang_assemble_ctx *A, slang_operation *loopOper, slang_ir_node *loopIR)
+{
+ A->LoopOperStack[A->LoopDepth] = loopOper;
+ A->LoopIRStack[A->LoopDepth] = loopIR;
+ A->LoopDepth++;
+}
+
+
+/**
+ * Called when we end code/IR generation for a new while/do/for loop.
+ */
+static void
+pop_loop(slang_assemble_ctx *A)
+{
+ assert(A->LoopDepth > 0);
+ A->LoopDepth--;
+}
+
+
+/**
+ * Return pointer to slang_operation for the loop we're currently inside,
+ * or NULL if not in a loop.
+ */
+static const slang_operation *
+current_loop_oper(const slang_assemble_ctx *A)
+{
+ if (A->LoopDepth > 0)
+ return A->LoopOperStack[A->LoopDepth - 1];
+ else
+ return NULL;
+}
+
+
+/**
+ * Return pointer to slang_ir_node for the loop we're currently inside,
+ * or NULL if not in a loop.
+ */
+static slang_ir_node *
+current_loop_ir(const slang_assemble_ctx *A)
+{
+ if (A->LoopDepth > 0)
+ return A->LoopIRStack[A->LoopDepth - 1];
+ else
+ return NULL;
+}
+
/**********************************************************************/
@@ -636,7 +702,7 @@ new_break(slang_ir_node *loopNode)
assert(loopNode);
assert(loopNode->Opcode == IR_LOOP);
if (n) {
- /* insert this node at head of linked list */
+ /* insert this node at head of linked list of cont/break instructions */
n->List = loopNode->List;
loopNode->List = n;
}
@@ -648,14 +714,15 @@ new_break(slang_ir_node *loopNode)
* Make new IR_BREAK_IF_TRUE.
*/
static slang_ir_node *
-new_break_if_true(slang_ir_node *loopNode, slang_ir_node *cond)
+new_break_if_true(slang_assemble_ctx *A, slang_ir_node *cond)
{
+ slang_ir_node *loopNode = current_loop_ir(A);
slang_ir_node *n;
assert(loopNode);
assert(loopNode->Opcode == IR_LOOP);
n = new_node1(IR_BREAK_IF_TRUE, cond);
if (n) {
- /* insert this node at head of linked list */
+ /* insert this node at head of linked list of cont/break instructions */
n->List = loopNode->List;
loopNode->List = n;
}
@@ -667,14 +734,16 @@ new_break_if_true(slang_ir_node *loopNode, slang_ir_node *cond)
* Make new IR_CONT_IF_TRUE node.
*/
static slang_ir_node *
-new_cont_if_true(slang_ir_node *loopNode, slang_ir_node *cond)
+new_cont_if_true(slang_assemble_ctx *A, slang_ir_node *cond)
{
+ slang_ir_node *loopNode = current_loop_ir(A);
slang_ir_node *n;
assert(loopNode);
assert(loopNode->Opcode == IR_LOOP);
n = new_node1(IR_CONT_IF_TRUE, cond);
if (n) {
- /* insert this node at head of linked list */
+ n->Parent = loopNode; /* pointer to containing loop */
+ /* insert this node at head of linked list of cont/break instructions */
n->List = loopNode->List;
loopNode->List = n;
}
@@ -749,6 +818,7 @@ _slang_is_noop(const slang_operation *oper)
/**
* Recursively search tree for a node of the given type.
*/
+#if 0
static slang_operation *
_slang_find_node_type(slang_operation *oper, slang_operation_type type)
{
@@ -762,13 +832,14 @@ _slang_find_node_type(slang_operation *oper, slang_operation_type type)
}
return NULL;
}
+#endif
/**
* Count the number of operations of the given time rooted at 'oper'.
*/
static GLuint
-_slang_count_node_type(slang_operation *oper, slang_operation_type type)
+_slang_count_node_type(const slang_operation *oper, slang_operation_type type)
{
GLuint i, count = 0;
if (oper->type == type) {
@@ -822,6 +893,37 @@ _slang_is_tail_return(const slang_operation *oper)
}
+/**
+ * Generate a variable declaration opeartion.
+ * I.e.: generate AST code for "bool flag = false;"
+ */
+static void
+slang_generate_declaration(slang_assemble_ctx *A,
+ slang_variable_scope *scope,
+ slang_operation *decl,
+ slang_type_specifier_type type,
+ const char *name,
+ GLint initValue)
+{
+ slang_variable *var;
+
+ assert(type == SLANG_SPEC_BOOL ||
+ type == SLANG_SPEC_INT);
+
+ decl->type = SLANG_OPER_VARIABLE_DECL;
+
+ var = slang_variable_scope_grow(scope);
+
+ slang_fully_specified_type_construct(&var->type);
+
+ var->type.specifier.type = type;
+ var->a_name = slang_atom_pool_atom(A->atoms, name);
+ decl->a_id = var->a_name;
+ var->initializer = slang_operation_new(1);
+ slang_operation_literal_bool(var->initializer, initValue);
+}
+
+
static void
slang_resolve_variable(slang_operation *oper)
{
@@ -832,6 +934,159 @@ slang_resolve_variable(slang_operation *oper)
/**
+ * Rewrite AST code for "return expression;".
+ *
+ * We return values from functions by assinging the returned value to
+ * the hidden __retVal variable which is an extra 'out' parameter we add
+ * to the function signature.
+ * This code basically converts "return expr;" into "__retVal = expr; return;"
+ *
+ * \return the new AST code.
+ */
+static slang_operation *
+gen_return_with_expression(slang_assemble_ctx *A, slang_operation *oper)
+{
+ slang_operation *blockOper, *assignOper;
+
+ assert(oper->type == SLANG_OPER_RETURN);
+
+ if (A->CurFunction->header.type.specifier.type == SLANG_SPEC_VOID) {
+ slang_info_log_error(A->log, "illegal return expression");
+ return NULL;
+ }
+
+ blockOper = slang_operation_new(1);
+ blockOper->type = SLANG_OPER_BLOCK_NO_NEW_SCOPE;
+ blockOper->locals->outer_scope = oper->locals->outer_scope;
+ slang_operation_add_children(blockOper, 2);
+
+ if (A->UseReturnFlag) {
+ /* Emit:
+ * {
+ * if (__notRetFlag)
+ * __retVal = expr;
+ * __notRetFlag = 0;
+ * }
+ */
+ {
+ slang_operation *ifOper = slang_oper_child(blockOper, 0);
+ ifOper->type = SLANG_OPER_IF;
+ slang_operation_add_children(ifOper, 3);
+ {
+ slang_operation *cond = slang_oper_child(ifOper, 0);
+ cond->type = SLANG_OPER_IDENTIFIER;
+ cond->a_id = slang_atom_pool_atom(A->atoms, "__notRetFlag");
+ }
+ {
+ slang_operation *elseOper = slang_oper_child(ifOper, 2);
+ elseOper->type = SLANG_OPER_VOID;
+ }
+ assignOper = slang_oper_child(ifOper, 1);
+ }
+ {
+ slang_operation *setOper = slang_oper_child(blockOper, 1);
+ setOper->type = SLANG_OPER_ASSIGN;
+ slang_operation_add_children(setOper, 2);
+ {
+ slang_operation *lhs = slang_oper_child(setOper, 0);
+ lhs->type = SLANG_OPER_IDENTIFIER;
+ lhs->a_id = slang_atom_pool_atom(A->atoms, "__notRetFlag");
+ }
+ {
+ slang_operation *rhs = slang_oper_child(setOper, 1);
+ slang_operation_literal_bool(rhs, GL_FALSE);
+ }
+ }
+ }
+ else {
+ /* Emit:
+ * {
+ * __retVal = expr;
+ * return_inlined;
+ * }
+ */
+ assignOper = slang_oper_child(blockOper, 0);
+ {
+ slang_operation *returnOper = slang_oper_child(blockOper, 1);
+ returnOper->type = SLANG_OPER_RETURN_INLINED;
+ assert(returnOper->num_children == 0);
+ }
+ }
+
+ /* __retVal = expression; */
+ assignOper->type = SLANG_OPER_ASSIGN;
+ slang_operation_add_children(assignOper, 2);
+ {
+ slang_operation *lhs = slang_oper_child(assignOper, 0);
+ lhs->type = SLANG_OPER_IDENTIFIER;
+ lhs->a_id = slang_atom_pool_atom(A->atoms, "__retVal");
+ }
+ {
+ slang_operation *rhs = slang_oper_child(assignOper, 1);
+ slang_operation_copy(rhs, &oper->children[0]);
+ }
+
+ ///blockOper->locals->outer_scope = oper->locals->outer_scope;
+
+ /*slang_print_tree(blockOper, 0);*/
+
+ return blockOper;
+}
+
+
+/**
+ * Rewrite AST code for "return;" (no expression).
+ */
+static slang_operation *
+gen_return_without_expression(slang_assemble_ctx *A, slang_operation *oper)
+{
+ slang_operation *newRet;
+
+ assert(oper->type == SLANG_OPER_RETURN);
+
+ if (A->CurFunction->header.type.specifier.type != SLANG_SPEC_VOID) {
+ slang_info_log_error(A->log, "return statement requires an expression");
+ return NULL;
+ }
+
+ if (A->UseReturnFlag) {
+ /* Emit:
+ * __notRetFlag = 0;
+ */
+ {
+ newRet = slang_operation_new(1);
+ newRet->locals->outer_scope = oper->locals->outer_scope;
+ newRet->type = SLANG_OPER_ASSIGN;
+ slang_operation_add_children(newRet, 2);
+ {
+ slang_operation *lhs = slang_oper_child(newRet, 0);
+ lhs->type = SLANG_OPER_IDENTIFIER;
+ lhs->a_id = slang_atom_pool_atom(A->atoms, "__notRetFlag");
+ }
+ {
+ slang_operation *rhs = slang_oper_child(newRet, 1);
+ slang_operation_literal_bool(rhs, GL_FALSE);
+ }
+ }
+ }
+ else {
+ /* Emit:
+ * return_inlined;
+ */
+ newRet = slang_operation_new(1);
+ newRet->locals->outer_scope = oper->locals->outer_scope;
+ newRet->type = SLANG_OPER_RETURN_INLINED;
+ }
+
+ /*slang_print_tree(newRet, 0);*/
+
+ return newRet;
+}
+
+
+
+
+/**
* Replace particular variables (SLANG_OPER_IDENTIFIER) with new expressions.
*/
static void
@@ -866,7 +1121,8 @@ slang_substitute(slang_assemble_ctx *A, slang_operation *oper,
GLuint i;
v = _slang_variable_locate(oper->locals, id, GL_TRUE);
if (!v) {
- _mesa_problem(NULL, "var %s not found!\n", (char *) oper->a_id);
+ if (_mesa_strcmp((char *) oper->a_id, "__notRetFlag"))
+ _mesa_problem(NULL, "var %s not found!\n", (char *) oper->a_id);
return;
}
@@ -896,62 +1152,24 @@ slang_substitute(slang_assemble_ctx *A, slang_operation *oper,
break;
case SLANG_OPER_RETURN:
- /* do return replacement here too */
- assert(oper->num_children == 0 || oper->num_children == 1);
- if (oper->num_children == 1 && !_slang_is_noop(&oper->children[0])) {
- /* replace:
- * return expr;
- * with:
- * __retVal = expr;
- * return;
- * then do substitutions on the assignment.
- */
- slang_operation *blockOper, *assignOper, *returnOper;
+ {
+ slang_operation *newReturn;
+ /* generate new 'return' code' */
+ if (slang_oper_child(oper, 0)->type == SLANG_OPER_VOID)
+ newReturn = gen_return_without_expression(A, oper);
+ else
+ newReturn = gen_return_with_expression(A, oper);
- /* check if function actually has a return type */
- assert(A->CurFunction);
- if (A->CurFunction->header.type.specifier.type == SLANG_SPEC_VOID) {
- slang_info_log_error(A->log, "illegal return expression");
+ if (!newReturn)
return;
- }
-
- blockOper = slang_operation_new(1);
- blockOper->type = SLANG_OPER_BLOCK_NO_NEW_SCOPE;
- blockOper->num_children = 2;
- blockOper->locals->outer_scope = oper->locals->outer_scope;
- blockOper->children = slang_operation_new(2);
- assignOper = blockOper->children + 0;
- returnOper = blockOper->children + 1;
-
- assignOper->type = SLANG_OPER_ASSIGN;
- assignOper->num_children = 2;
- assignOper->locals->outer_scope = blockOper->locals;
- assignOper->children = slang_operation_new(2);
- assignOper->children[0].type = SLANG_OPER_IDENTIFIER;
- assignOper->children[0].a_id = slang_atom_pool_atom(A->atoms, "__retVal");
- assignOper->children[0].locals->outer_scope = assignOper->locals;
-
- slang_operation_copy(&assignOper->children[1],
- &oper->children[0]);
-
- returnOper->type = SLANG_OPER_RETURN; /* return w/ no value */
- assert(returnOper->num_children == 0);
- /* do substitutions on the "__retVal = expr" sub-tree */
- slang_substitute(A, assignOper,
+ /* do substitutions on the new 'return' code */
+ slang_substitute(A, newReturn,
substCount, substOld, substNew, GL_FALSE);
- /* install new code */
- slang_operation_copy(oper, blockOper);
- slang_operation_destruct(blockOper);
- }
- else {
- /* check if return value was expected */
- assert(A->CurFunction);
- if (A->CurFunction->header.type.specifier.type != SLANG_SPEC_VOID) {
- slang_info_log_error(A->log, "return statement requires an expression");
- return;
- }
+ /* install new 'return' code */
+ slang_operation_copy(oper, newReturn);
+ slang_operation_destruct(newReturn);
}
break;
@@ -1346,12 +1564,74 @@ slang_inline_function_call(slang_assemble_ctx * A, slang_function *fun,
}
+/**
+ * Insert declaration for "bool __notRetFlag" in given block operation.
+ * This is used when we can't emit "early" return statements in subroutines.
+ */
+static void
+declare_return_flag(slang_assemble_ctx *A, slang_operation *oper)
+{
+ slang_operation *decl;
+
+ assert(oper->type == SLANG_OPER_BLOCK_NEW_SCOPE ||
+ oper->type == SLANG_OPER_SEQUENCE);
+
+ decl = slang_operation_insert_child(oper, 1);
+
+ slang_generate_declaration(A, oper->locals, decl,
+ SLANG_SPEC_BOOL, "__notRetFlag", GL_TRUE);
+
+ /*slang_print_tree(oper, 0);*/
+}
+
+
+/**
+ * Recursively replace instances of the old node type with the new type.
+ */
+static void
+replace_node_type(slang_operation *oper, slang_operation_type oldType,
+ slang_operation_type newType)
+{
+ GLuint i;
+
+ if (oper->type == oldType)
+ oper->type = newType;
+
+ for (i = 0; i < slang_oper_num_children(oper); i++) {
+ replace_node_type(slang_oper_child(oper, i), oldType, newType);
+ }
+}
+
+
+
+/**
+ * Test if the given function body has an "early return". That is, there's
+ * a 'return' statement that's not the very last instruction in the body.
+ */
+static GLboolean
+has_early_return(const slang_operation *funcBody)
+{
+ GLuint retCount = _slang_count_node_type(funcBody, SLANG_OPER_RETURN);
+ if (retCount == 0)
+ return GL_FALSE;
+ else if (retCount == 1 && _slang_is_tail_return(funcBody))
+ return GL_FALSE;
+ else
+ return GL_TRUE;
+}
+
+
+/**
+ * Emit IR code for a function call. This does one of two things:
+ * 1. Inline the function's code
+ * 2. Create an IR for the function's body and create a real call to it.
+ */
static slang_ir_node *
_slang_gen_function_call(slang_assemble_ctx *A, slang_function *fun,
slang_operation *oper, slang_operation *dest)
{
slang_ir_node *n;
- slang_operation *inlined;
+ slang_operation *instance;
slang_label *prevFuncEndLabel;
char name[200];
@@ -1360,9 +1640,14 @@ _slang_gen_function_call(slang_assemble_ctx *A, slang_function *fun,
A->curFuncEndLabel = _slang_label_new(name);
assert(A->curFuncEndLabel);
+ /*
+ * 'instance' is basically a copy of the function's body with various
+ * transformations.
+ */
+
if (slang_is_asm_function(fun) && !dest) {
/* assemble assembly function - tree style */
- inlined = slang_inline_asm_function(A, fun, oper);
+ instance = slang_inline_asm_function(A, fun, oper);
}
else {
/* non-assembly function */
@@ -1371,65 +1656,82 @@ _slang_gen_function_call(slang_assemble_ctx *A, slang_function *fun,
* 1. insert the inline code
* 2. Generate a call to the "inline" code as a subroutine
*/
+ const GLboolean earlyReturn = has_early_return(fun->body);
+ if (earlyReturn && !A->EmitContReturn) {
+ A->UseReturnFlag = GL_TRUE;
+ }
- slang_operation *ret = NULL;
-
- inlined = slang_inline_function_call(A, fun, oper, dest);
- if (!inlined)
+ instance = slang_inline_function_call(A, fun, oper, dest);
+ if (!instance)
return NULL;
- ret = _slang_find_node_type(inlined, SLANG_OPER_RETURN);
- if (ret) {
- /* check if this is a "tail" return */
- if (_slang_count_node_type(inlined, SLANG_OPER_RETURN) == 1 &&
- _slang_is_tail_return(inlined)) {
- /* The only RETURN is the last stmt in the function, no-op it
- * and inline the function body.
+ if (earlyReturn) {
+ /* The function we're calling has one or more 'return' statements
+ * that prevent us from inlining the function's code.
+ *
+ * In this case, change the function's body type from
+ * SLANG_OPER_BLOCK_NEW_SCOPE to SLANG_OPER_NON_INLINED_CALL.
+ * During code emit this will result in a true subroutine call.
+ *
+ * Also, convert SLANG_OPER_RETURN_INLINED nodes to SLANG_OPER_RETURN.
+ */
+ slang_operation *callOper;
+
+ assert(instance->type == SLANG_OPER_BLOCK_NEW_SCOPE ||
+ instance->type == SLANG_OPER_SEQUENCE);
+
+ if (_slang_function_has_return_value(fun) && !dest) {
+ assert(instance->children[0].type == SLANG_OPER_VARIABLE_DECL);
+ assert(instance->children[2].type == SLANG_OPER_IDENTIFIER);
+ callOper = &instance->children[1];
+ }
+ else {
+ callOper = instance;
+ }
+
+ if (A->UseReturnFlag) {
+ /* Early returns not supported. Create a _returnFlag variable
+ * that's set upon 'return' and tested elsewhere to no-op any
+ * remaining instructions in the subroutine.
*/
- ret->type = SLANG_OPER_NONE;
+ assert(callOper->type == SLANG_OPER_BLOCK_NEW_SCOPE ||
+ callOper->type == SLANG_OPER_SEQUENCE);
+ declare_return_flag(A, callOper);
}
else {
- slang_operation *callOper;
- /* The function we're calling has one or more 'return' statements.
- * So, we can't truly inline this function because we need to
- * implement 'return' with RET (and CAL).
- * Nevertheless, we performed "inlining" to make a new instance
- * of the function body to deal with static register allocation.
- *
- * XXX check if there's one 'return' and if it's the very last
- * statement in the function - we can optimize that case.
+ /* We can emit real 'return' statements. If we generated any
+ * 'inline return' statements during function instantiation,
+ * change them back to regular 'return' statements.
*/
- assert(inlined->type == SLANG_OPER_BLOCK_NEW_SCOPE ||
- inlined->type == SLANG_OPER_SEQUENCE);
-
- if (_slang_function_has_return_value(fun) && !dest) {
- assert(inlined->children[0].type == SLANG_OPER_VARIABLE_DECL);
- assert(inlined->children[2].type == SLANG_OPER_IDENTIFIER);
- callOper = &inlined->children[1];
- }
- else {
- callOper = inlined;
- }
- callOper->type = SLANG_OPER_NON_INLINED_CALL;
- callOper->fun = fun;
- callOper->label = _slang_label_new_unique((char*) fun->header.a_name);
+ replace_node_type(instance, SLANG_OPER_RETURN_INLINED,
+ SLANG_OPER_RETURN);
}
+
+ callOper->type = SLANG_OPER_NON_INLINED_CALL;
+ callOper->fun = fun;
+ callOper->label = _slang_label_new_unique((char*) fun->header.a_name);
+ }
+ else {
+ /* If there are any 'return' statements remaining, they're at the
+ * very end of the function and can effectively become no-ops.
+ */
+ replace_node_type(instance, SLANG_OPER_RETURN_INLINED,
+ SLANG_OPER_VOID);
}
}
- if (!inlined)
+ if (!instance)
return NULL;
- /* Replace the function call with the inlined block (or new CALL stmt) */
+ /* Replace the function call with the instance block (or new CALL stmt) */
slang_operation_destruct(oper);
- *oper = *inlined;
- _slang_free(inlined);
+ *oper = *instance;
+ _slang_free(instance);
#if 0
- assert(inlined->locals);
- printf("*** Inlined code for call to %s:\n",
- (char*) fun->header.a_name);
+ assert(instance->locals);
+ printf("*** Inlined code for call to %s:\n", (char*) fun->header.a_name);
slang_print_tree(oper, 10);
printf("\n");
#endif
@@ -1445,6 +1747,8 @@ _slang_gen_function_call(slang_assemble_ctx *A, slang_function *fun,
n->Comment = _slang_strdup(s);
}
+ A->UseReturnFlag = GL_FALSE;
+
return n;
}
@@ -2337,19 +2641,252 @@ _slang_is_boolean(slang_assemble_ctx *A, slang_operation *oper)
/**
+ * Check if a loop contains a 'continue' statement.
+ * Stop looking if we find a nested loop.
+ */
+static GLboolean
+_slang_loop_contains_continue(const slang_operation *oper)
+{
+ switch (oper->type) {
+ case SLANG_OPER_CONTINUE:
+ return GL_TRUE;
+ case SLANG_OPER_FOR:
+ case SLANG_OPER_DO:
+ case SLANG_OPER_WHILE:
+ /* stop upon finding a nested loop */
+ return GL_FALSE;
+ default:
+ /* recurse */
+ {
+ GLuint i;
+ for (i = 0; i < oper->num_children; i++) {
+ const slang_operation *child = slang_oper_child_const(oper, i);
+ if (_slang_loop_contains_continue(child))
+ return GL_TRUE;
+ }
+ }
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Check if a loop contains a 'continue' or 'break' statement.
+ * Stop looking if we find a nested loop.
+ */
+static GLboolean
+_slang_loop_contains_continue_or_break(const slang_operation *oper)
+{
+ switch (oper->type) {
+ case SLANG_OPER_CONTINUE:
+ case SLANG_OPER_BREAK:
+ return GL_TRUE;
+ case SLANG_OPER_FOR:
+ case SLANG_OPER_DO:
+ case SLANG_OPER_WHILE:
+ /* stop upon finding a nested loop */
+ return GL_FALSE;
+ default:
+ /* recurse */
+ {
+ GLuint i;
+ for (i = 0; i < oper->num_children; i++) {
+ const slang_operation *child = slang_oper_child_const(oper, i);
+ if (_slang_loop_contains_continue_or_break(child))
+ return GL_TRUE;
+ }
+ }
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Replace 'break' and 'continue' statements inside a do and while loops.
+ * This is a recursive helper function used by
+ * _slang_gen_do/while_without_continue().
+ */
+static void
+replace_break_and_cont(slang_assemble_ctx *A, slang_operation *oper)
+{
+ switch (oper->type) {
+ case SLANG_OPER_BREAK:
+ /* replace 'break' with "_notBreakFlag = false; break" */
+ {
+ slang_operation *block = oper;
+ block->type = SLANG_OPER_BLOCK_NEW_SCOPE;
+ slang_operation_add_children(block, 2);
+ {
+ slang_operation *assign = slang_oper_child(block, 0);
+ assign->type = SLANG_OPER_ASSIGN;
+ slang_operation_add_children(assign, 2);
+ {
+ slang_operation *lhs = slang_oper_child(assign, 0);
+ slang_operation_identifier(lhs, A, "_notBreakFlag");
+ }
+ {
+ slang_operation *rhs = slang_oper_child(assign, 1);
+ slang_operation_literal_bool(rhs, GL_FALSE);
+ }
+ }
+ {
+ slang_operation *brk = slang_oper_child(block, 1);
+ brk->type = SLANG_OPER_BREAK;
+ assert(!brk->children);
+ }
+ }
+ break;
+ case SLANG_OPER_CONTINUE:
+ /* convert continue into a break */
+ oper->type = SLANG_OPER_BREAK;
+ break;
+ case SLANG_OPER_FOR:
+ case SLANG_OPER_DO:
+ case SLANG_OPER_WHILE:
+ /* stop upon finding a nested loop */
+ break;
+ default:
+ /* recurse */
+ {
+ GLuint i;
+ for (i = 0; i < oper->num_children; i++) {
+ replace_break_and_cont(A, slang_oper_child(oper, i));
+ }
+ }
+ }
+}
+
+
+/**
+ * Transform a while-loop so that continue statements are converted to breaks.
+ * Then do normal IR code generation.
+ *
+ * Before:
+ *
+ * while (LOOPCOND) {
+ * A;
+ * if (IFCOND)
+ * continue;
+ * B;
+ * break;
+ * C;
+ * }
+ *
+ * After:
+ *
+ * {
+ * bool _notBreakFlag = 1;
+ * while (_notBreakFlag && LOOPCOND) {
+ * do {
+ * A;
+ * if (IFCOND) {
+ * break; // was continue
+ * }
+ * B;
+ * _notBreakFlag = 0; // was
+ * break; // break
+ * C;
+ * } while (0)
+ * }
+ * }
+ */
+static slang_ir_node *
+_slang_gen_while_without_continue(slang_assemble_ctx *A, slang_operation *oper)
+{
+ slang_operation *top;
+ slang_operation *innerBody;
+
+ assert(oper->type == SLANG_OPER_WHILE);
+
+ top = slang_operation_new(1);
+ top->type = SLANG_OPER_BLOCK_NEW_SCOPE;
+ top->locals->outer_scope = oper->locals->outer_scope;
+ slang_operation_add_children(top, 2);
+
+ /* declare: bool _notBreakFlag = true */
+ {
+ slang_operation *condDecl = slang_oper_child(top, 0);
+ slang_generate_declaration(A, top->locals, condDecl,
+ SLANG_SPEC_BOOL, "_notBreakFlag", GL_TRUE);
+ }
+
+ /* build outer while-loop: while (_notBreakFlag && LOOPCOND) { ... } */
+ {
+ slang_operation *outerWhile = slang_oper_child(top, 1);
+ outerWhile->type = SLANG_OPER_WHILE;
+ slang_operation_add_children(outerWhile, 2);
+
+ /* _notBreakFlag && LOOPCOND */
+ {
+ slang_operation *cond = slang_oper_child(outerWhile, 0);
+ cond->type = SLANG_OPER_LOGICALAND;
+ slang_operation_add_children(cond, 2);
+ {
+ slang_operation *notBreak = slang_oper_child(cond, 0);
+ slang_operation_identifier(notBreak, A, "_notBreakFlag");
+ }
+ {
+ slang_operation *origCond = slang_oper_child(cond, 1);
+ slang_operation_copy(origCond, slang_oper_child(oper, 0));
+ }
+ }
+
+ /* inner loop */
+ {
+ slang_operation *innerDo = slang_oper_child(outerWhile, 1);
+ innerDo->type = SLANG_OPER_DO;
+ slang_operation_add_children(innerDo, 2);
+
+ /* copy original do-loop body into inner do-loop's body */
+ innerBody = slang_oper_child(innerDo, 0);
+ slang_operation_copy(innerBody, slang_oper_child(oper, 1));
+ innerBody->locals->outer_scope = innerDo->locals;
+
+ /* inner do-loop's condition is constant/false */
+ {
+ slang_operation *constFalse = slang_oper_child(innerDo, 1);
+ slang_operation_literal_bool(constFalse, GL_FALSE);
+ }
+ }
+ }
+
+ /* Finally, in innerBody,
+ * replace "break" with "_notBreakFlag = 0; break"
+ * replace "continue" with "break"
+ */
+ replace_break_and_cont(A, innerBody);
+
+ /*slang_print_tree(top, 0);*/
+
+ return _slang_gen_operation(A, top);
+
+ return NULL;
+}
+
+
+/**
* Generate loop code using high-level IR_LOOP instruction
*/
static slang_ir_node *
-_slang_gen_while(slang_assemble_ctx * A, const slang_operation *oper)
+_slang_gen_while(slang_assemble_ctx * A, slang_operation *oper)
{
/*
* LOOP:
* BREAK if !expr (child[0])
* body code (child[1])
*/
- slang_ir_node *prevLoop, *loop, *breakIf, *body;
+ slang_ir_node *loop, *breakIf, *body;
GLboolean isConst, constTrue;
+ if (!A->EmitContReturn) {
+ /* We don't want to emit CONT instructions. If this while-loop has
+ * a continue, translate it away.
+ */
+ if (_slang_loop_contains_continue(slang_oper_child(oper, 1))) {
+ return _slang_gen_while_without_continue(A, oper);
+ }
+ }
+
/* type-check expression */
if (!_slang_is_boolean(A, &oper->children[0])) {
slang_info_log_error(A->log, "scalar/boolean expression expected for 'while'");
@@ -2364,11 +2901,11 @@ _slang_gen_while(slang_assemble_ctx * A, const slang_operation *oper)
return new_node0(IR_NOP);
}
+ /* Begin new loop */
loop = new_loop(NULL);
- /* save old, push new loop */
- prevLoop = A->CurLoop;
- A->CurLoop = loop;
+ /* save loop state */
+ push_loop(A, oper, loop);
if (isConst && constTrue) {
/* while(nonzero constant), no conditional break */
@@ -2377,7 +2914,7 @@ _slang_gen_while(slang_assemble_ctx * A, const slang_operation *oper)
else {
slang_ir_node *cond
= new_cond(new_not(_slang_gen_operation(A, &oper->children[0])));
- breakIf = new_break_if_true(A->CurLoop, cond);
+ breakIf = new_break_if_true(A, cond);
}
body = _slang_gen_operation(A, &oper->children[1]);
loop->Children[0] = new_seq(breakIf, body);
@@ -2386,23 +2923,128 @@ _slang_gen_while(slang_assemble_ctx * A, const slang_operation *oper)
/* loop->List is head of linked list of break/continue nodes */
if (!loop->List && isConst && constTrue) {
/* infinite loop detected */
- A->CurLoop = prevLoop; /* clean-up */
+ pop_loop(A);
slang_info_log_error(A->log, "Infinite loop detected!");
return NULL;
}
- /* pop loop, restore prev */
- A->CurLoop = prevLoop;
+ /* restore loop state */
+ pop_loop(A);
return loop;
}
/**
+ * Transform a do-while-loop so that continue statements are converted to breaks.
+ * Then do normal IR code generation.
+ *
+ * Before:
+ *
+ * do {
+ * A;
+ * if (IFCOND)
+ * continue;
+ * B;
+ * break;
+ * C;
+ * } while (LOOPCOND);
+ *
+ * After:
+ *
+ * {
+ * bool _notBreakFlag = 1;
+ * do {
+ * do {
+ * A;
+ * if (IFCOND) {
+ * break; // was continue
+ * }
+ * B;
+ * _notBreakFlag = 0; // was
+ * break; // break
+ * C;
+ * } while (0)
+ * } while (_notBreakFlag && LOOPCOND);
+ * }
+ */
+static slang_ir_node *
+_slang_gen_do_without_continue(slang_assemble_ctx *A, slang_operation *oper)
+{
+ slang_operation *top;
+ slang_operation *innerBody;
+
+ assert(oper->type == SLANG_OPER_DO);
+
+ top = slang_operation_new(1);
+ top->type = SLANG_OPER_BLOCK_NEW_SCOPE;
+ top->locals->outer_scope = oper->locals->outer_scope;
+ slang_operation_add_children(top, 2);
+
+ /* declare: bool _notBreakFlag = true */
+ {
+ slang_operation *condDecl = slang_oper_child(top, 0);
+ slang_generate_declaration(A, top->locals, condDecl,
+ SLANG_SPEC_BOOL, "_notBreakFlag", GL_TRUE);
+ }
+
+ /* build outer do-loop: do { ... } while (_notBreakFlag && LOOPCOND) */
+ {
+ slang_operation *outerDo = slang_oper_child(top, 1);
+ outerDo->type = SLANG_OPER_DO;
+ slang_operation_add_children(outerDo, 2);
+
+ /* inner do-loop */
+ {
+ slang_operation *innerDo = slang_oper_child(outerDo, 0);
+ innerDo->type = SLANG_OPER_DO;
+ slang_operation_add_children(innerDo, 2);
+
+ /* copy original do-loop body into inner do-loop's body */
+ innerBody = slang_oper_child(innerDo, 0);
+ slang_operation_copy(innerBody, slang_oper_child(oper, 0));
+ innerBody->locals->outer_scope = innerDo->locals;
+
+ /* inner do-loop's condition is constant/false */
+ {
+ slang_operation *constFalse = slang_oper_child(innerDo, 1);
+ slang_operation_literal_bool(constFalse, GL_FALSE);
+ }
+ }
+
+ /* _notBreakFlag && LOOPCOND */
+ {
+ slang_operation *cond = slang_oper_child(outerDo, 1);
+ cond->type = SLANG_OPER_LOGICALAND;
+ slang_operation_add_children(cond, 2);
+ {
+ slang_operation *notBreak = slang_oper_child(cond, 0);
+ slang_operation_identifier(notBreak, A, "_notBreakFlag");
+ }
+ {
+ slang_operation *origCond = slang_oper_child(cond, 1);
+ slang_operation_copy(origCond, slang_oper_child(oper, 1));
+ }
+ }
+ }
+
+ /* Finally, in innerBody,
+ * replace "break" with "_notBreakFlag = 0; break"
+ * replace "continue" with "break"
+ */
+ replace_break_and_cont(A, innerBody);
+
+ /*slang_print_tree(top, 0);*/
+
+ return _slang_gen_operation(A, top);
+}
+
+
+/**
* Generate IR tree for a do-while loop using high-level LOOP, IF instructions.
*/
static slang_ir_node *
-_slang_gen_do(slang_assemble_ctx * A, const slang_operation *oper)
+_slang_gen_do(slang_assemble_ctx * A, slang_operation *oper)
{
/*
* LOOP:
@@ -2410,9 +3052,18 @@ _slang_gen_do(slang_assemble_ctx * A, const slang_operation *oper)
* tail code:
* BREAK if !expr (child[1])
*/
- slang_ir_node *prevLoop, *loop;
+ slang_ir_node *loop;
GLboolean isConst, constTrue;
+ if (!A->EmitContReturn) {
+ /* We don't want to emit CONT instructions. If this do-loop has
+ * a continue, translate it away.
+ */
+ if (_slang_loop_contains_continue(slang_oper_child(oper, 0))) {
+ return _slang_gen_do_without_continue(A, oper);
+ }
+ }
+
/* type-check expression */
if (!_slang_is_boolean(A, &oper->children[1])) {
slang_info_log_error(A->log, "scalar/boolean expression expected for 'do/while'");
@@ -2421,9 +3072,8 @@ _slang_gen_do(slang_assemble_ctx * A, const slang_operation *oper)
loop = new_loop(NULL);
- /* save old, push new loop */
- prevLoop = A->CurLoop;
- A->CurLoop = loop;
+ /* save loop state */
+ push_loop(A, oper, loop);
/* loop body: */
loop->Children[0] = _slang_gen_operation(A, &oper->children[0]);
@@ -2437,13 +3087,13 @@ _slang_gen_do(slang_assemble_ctx * A, const slang_operation *oper)
else {
slang_ir_node *cond
= new_cond(new_not(_slang_gen_operation(A, &oper->children[1])));
- loop->Children[1] = new_break_if_true(A->CurLoop, cond);
+ loop->Children[1] = new_break_if_true(A, cond);
}
/* XXX we should do infinite loop detection, as above */
- /* pop loop, restore prev */
- A->CurLoop = prevLoop;
+ /* restore loop state */
+ pop_loop(A);
return loop;
}
@@ -2485,9 +3135,14 @@ _slang_can_unroll_for_loop(slang_assemble_ctx * A, const slang_operation *oper)
const char *varName;
slang_atom varId;
- assert(oper->type == SLANG_OPER_FOR);
+ if (oper->type != SLANG_OPER_FOR)
+ return GL_FALSE;
+
assert(oper->num_children == 4);
+ if (_slang_loop_contains_continue_or_break(slang_oper_child_const(oper, 3)))
+ return GL_FALSE;
+
/* children[0] must be either "int i=constant" or "i=constant" */
if (oper->children[0].type == SLANG_OPER_BLOCK_NO_NEW_SCOPE) {
slang_variable *var;
@@ -2582,20 +3237,6 @@ _slang_can_unroll_for_loop(slang_assemble_ctx * A, const slang_operation *oper)
}
-static void
-_unroll_loop_inc(slang_assemble_ctx * A)
-{
- A->UnrollLoop++;
-}
-
-
-static void
-_unroll_loop_dec(slang_assemble_ctx * A)
-{
- A->UnrollLoop--;
-}
-
-
/**
* Unroll a for-loop.
* First we determine the number of iterations to unroll.
@@ -2612,9 +3253,6 @@ _slang_unroll_for_loop(slang_assemble_ctx * A, const slang_operation *oper)
slang_ir_node *n, *root = NULL;
slang_atom varId;
- /* Set flag so code generator knows we're unrolling loops */
- _unroll_loop_inc( A );
-
if (oper->children[0].type == SLANG_OPER_BLOCK_NO_NEW_SCOPE) {
/* for (int i=0; ... */
slang_variable *var;
@@ -2637,15 +3275,11 @@ _slang_unroll_for_loop(slang_assemble_ctx * A, const slang_operation *oper)
/* make a copy of the loop body */
body = slang_operation_new(1);
- if (!body) {
- _unroll_loop_dec( A );
+ if (!body)
return NULL;
- }
- if (!slang_operation_copy(body, &oper->children[3])) {
- _unroll_loop_dec( A );
+ if (!slang_operation_copy(body, &oper->children[3]))
return NULL;
- }
/* in body, replace instances of 'varId' with literal 'iter' */
{
@@ -2656,7 +3290,6 @@ _slang_unroll_for_loop(slang_assemble_ctx * A, const slang_operation *oper)
if (!oldVar) {
/* undeclared loop variable */
slang_operation_delete(body);
- _unroll_loop_dec( A );
return NULL;
}
@@ -2671,36 +3304,195 @@ _slang_unroll_for_loop(slang_assemble_ctx * A, const slang_operation *oper)
/* do IR codegen for body */
n = _slang_gen_operation(A, body);
- if (!n) {
- _unroll_loop_dec( A );
+ if (!n)
return NULL;
- }
root = new_seq(root, n);
slang_operation_delete(body);
}
- _unroll_loop_dec( A );
-
return root;
}
/**
+ * Replace 'continue' statement with 'break' inside a for-loop.
+ * This is a recursive helper function used by _slang_gen_for_without_continue().
+ */
+static void
+replace_continue_with_break(slang_assemble_ctx *A, slang_operation *oper)
+{
+ switch (oper->type) {
+ case SLANG_OPER_CONTINUE:
+ oper->type = SLANG_OPER_BREAK;
+ break;
+ case SLANG_OPER_FOR:
+ case SLANG_OPER_DO:
+ case SLANG_OPER_WHILE:
+ /* stop upon finding a nested loop */
+ break;
+ default:
+ /* recurse */
+ {
+ GLuint i;
+ for (i = 0; i < oper->num_children; i++) {
+ replace_continue_with_break(A, slang_oper_child(oper, i));
+ }
+ }
+ }
+}
+
+
+/**
+ * Transform a for-loop so that continue statements are converted to breaks.
+ * Then do normal IR code generation.
+ *
+ * Before:
+ *
+ * for (INIT; LOOPCOND; INCR) {
+ * A;
+ * if (IFCOND) {
+ * continue;
+ * }
+ * B;
+ * }
+ *
+ * After:
+ *
+ * {
+ * bool _condFlag = 1;
+ * for (INIT; _condFlag; ) {
+ * for ( ; _condFlag = LOOPCOND; INCR) {
+ * A;
+ * if (IFCOND) {
+ * break;
+ * }
+ * B;
+ * }
+ * if (_condFlag)
+ * INCR;
+ * }
+ * }
+ */
+static slang_ir_node *
+_slang_gen_for_without_continue(slang_assemble_ctx *A, slang_operation *oper)
+{
+ slang_operation *top;
+ slang_operation *outerFor, *innerFor, *init, *cond, *incr;
+ slang_operation *lhs, *rhs;
+
+ assert(oper->type == SLANG_OPER_FOR);
+
+ top = slang_operation_new(1);
+ top->type = SLANG_OPER_BLOCK_NEW_SCOPE;
+ top->locals->outer_scope = oper->locals->outer_scope;
+ slang_operation_add_children(top, 2);
+
+ /* declare: bool _condFlag = true */
+ {
+ slang_operation *condDecl = slang_oper_child(top, 0);
+ slang_generate_declaration(A, top->locals, condDecl,
+ SLANG_SPEC_BOOL, "_condFlag", GL_TRUE);
+ }
+
+ /* build outer loop: for (INIT; _condFlag; ) { */
+ outerFor = slang_oper_child(top, 1);
+ outerFor->type = SLANG_OPER_FOR;
+ slang_operation_add_children(outerFor, 4);
+
+ init = slang_oper_child(outerFor, 0);
+ slang_operation_copy(init, slang_oper_child(oper, 0));
+
+ cond = slang_oper_child(outerFor, 1);
+ cond->type = SLANG_OPER_IDENTIFIER;
+ cond->a_id = slang_atom_pool_atom(A->atoms, "_condFlag");
+
+ incr = slang_oper_child(outerFor, 2);
+ incr->type = SLANG_OPER_VOID;
+
+ /* body of the outer loop */
+ {
+ slang_operation *block = slang_oper_child(outerFor, 3);
+
+ slang_operation_add_children(block, 2);
+ block->type = SLANG_OPER_BLOCK_NO_NEW_SCOPE;
+
+ /* build inner loop: for ( ; _condFlag = LOOPCOND; INCR) { */
+ {
+ innerFor = slang_oper_child(block, 0);
+
+ /* make copy of orig loop */
+ slang_operation_copy(innerFor, oper);
+ assert(innerFor->type == SLANG_OPER_FOR);
+ innerFor->locals->outer_scope = block->locals;
+
+ init = slang_oper_child(innerFor, 0);
+ init->type = SLANG_OPER_VOID; /* leak? */
+
+ cond = slang_oper_child(innerFor, 1);
+ slang_operation_destruct(cond);
+ cond->type = SLANG_OPER_ASSIGN;
+ cond->locals = _slang_variable_scope_new(innerFor->locals);
+ slang_operation_add_children(cond, 2);
+
+ lhs = slang_oper_child(cond, 0);
+ lhs->type = SLANG_OPER_IDENTIFIER;
+ lhs->a_id = slang_atom_pool_atom(A->atoms, "_condFlag");
+
+ rhs = slang_oper_child(cond, 1);
+ slang_operation_copy(rhs, slang_oper_child(oper, 1));
+ }
+
+ /* if (_condFlag) INCR; */
+ {
+ slang_operation *ifop = slang_oper_child(block, 1);
+ ifop->type = SLANG_OPER_IF;
+ slang_operation_add_children(ifop, 2);
+
+ /* re-use cond node build above */
+ slang_operation_copy(slang_oper_child(ifop, 0), cond);
+
+ /* incr node from original for-loop operation */
+ slang_operation_copy(slang_oper_child(ifop, 1),
+ slang_oper_child(oper, 2));
+ }
+
+ /* finally, replace "continue" with "break" in the inner for-loop */
+ replace_continue_with_break(A, slang_oper_child(innerFor, 3));
+ }
+
+ return _slang_gen_operation(A, top);
+}
+
+
+
+/**
* Generate IR for a for-loop. Unrolling will be done when possible.
*/
static slang_ir_node *
-_slang_gen_for(slang_assemble_ctx * A, const slang_operation *oper)
+_slang_gen_for(slang_assemble_ctx * A, slang_operation *oper)
{
- GLboolean unroll = _slang_can_unroll_for_loop(A, oper);
+ GLboolean unroll;
+
+ if (!A->EmitContReturn) {
+ /* We don't want to emit CONT instructions. If this for-loop has
+ * a continue, translate it away.
+ */
+ if (_slang_loop_contains_continue(slang_oper_child(oper, 3))) {
+ return _slang_gen_for_without_continue(A, oper);
+ }
+ }
+ unroll = _slang_can_unroll_for_loop(A, oper);
if (unroll) {
slang_ir_node *code = _slang_unroll_for_loop(A, oper);
if (code)
return code;
}
+ assert(oper->type == SLANG_OPER_FOR);
+
/* conventional for-loop code generation */
{
/*
@@ -2711,24 +3503,23 @@ _slang_gen_for(slang_assemble_ctx * A, const slang_operation *oper)
* tail code:
* incr code (child[2]) // XXX continue here
*/
- slang_ir_node *prevLoop, *loop, *cond, *breakIf, *body, *init, *incr;
+ slang_ir_node *loop, *cond, *breakIf, *body, *init, *incr;
init = _slang_gen_operation(A, &oper->children[0]);
loop = new_loop(NULL);
- /* save old, push new loop */
- prevLoop = A->CurLoop;
- A->CurLoop = loop;
+ /* save loop state */
+ push_loop(A, oper, loop);
cond = new_cond(new_not(_slang_gen_operation(A, &oper->children[1])));
- breakIf = new_break_if_true(A->CurLoop, cond);
+ breakIf = new_break_if_true(A, cond);
body = _slang_gen_operation(A, &oper->children[3]);
incr = _slang_gen_operation(A, &oper->children[2]);
loop->Children[0] = new_seq(breakIf, body);
loop->Children[1] = incr; /* tail code */
- /* pop loop, restore prev */
- A->CurLoop = prevLoop;
+ /* restore loop state */
+ pop_loop(A);
return new_seq(init, loop);
}
@@ -2738,18 +3529,22 @@ _slang_gen_for(slang_assemble_ctx * A, const slang_operation *oper)
static slang_ir_node *
_slang_gen_continue(slang_assemble_ctx * A, const slang_operation *oper)
{
- slang_ir_node *n, *loopNode;
+ slang_ir_node *n, *cont, *incr = NULL, *loopNode;
+
assert(oper->type == SLANG_OPER_CONTINUE);
- loopNode = A->CurLoop;
+ loopNode = current_loop_ir(A);
assert(loopNode);
assert(loopNode->Opcode == IR_LOOP);
- n = new_node0(IR_CONT);
- if (n) {
- n->Parent = loopNode;
- /* insert this node at head of linked list */
- n->List = loopNode->List;
- loopNode->List = n;
+
+ cont = new_node0(IR_CONT);
+ if (cont) {
+ cont->Parent = loopNode;
+ /* insert this node at head of linked list of cont/break instructions */
+ cont->List = loopNode->List;
+ loopNode->List = cont;
}
+
+ n = new_seq(incr, cont);
return n;
}
@@ -2819,24 +3614,20 @@ _slang_gen_if(slang_assemble_ctx * A, const slang_operation *oper)
if (is_operation_type(&oper->children[1], SLANG_OPER_BREAK)
&& !haveElseClause) {
/* Special case: generate a conditional break */
- if (!A->CurLoop && A->UnrollLoop) /* trying to unroll */
- return NULL;
- ifBody = new_break_if_true(A->CurLoop, cond);
+ ifBody = new_break_if_true(A, cond);
return ifBody;
}
else if (is_operation_type(&oper->children[1], SLANG_OPER_CONTINUE)
- && !haveElseClause) {
+ && !haveElseClause
+ && current_loop_oper(A)
+ && current_loop_oper(A)->type != SLANG_OPER_FOR) {
/* Special case: generate a conditional continue */
- if (!A->CurLoop && A->UnrollLoop) /* trying to unroll */
- return NULL;
- ifBody = new_cont_if_true(A->CurLoop, cond);
+ ifBody = new_cont_if_true(A, cond);
return ifBody;
}
else {
/* general case */
ifBody = _slang_gen_operation(A, &oper->children[1]);
- if (!ifBody)
- return NULL;
if (haveElseClause)
elseBody = _slang_gen_operation(A, &oper->children[2]);
else
@@ -3242,14 +4033,11 @@ _slang_gen_logical_and(slang_assemble_ctx *A, slang_operation *oper)
select = slang_operation_new(1);
select->type = SLANG_OPER_SELECT;
- select->num_children = 3;
- select->children = slang_operation_new(3);
+ slang_operation_add_children(select, 3);
- slang_operation_copy(&select->children[0], &oper->children[0]);
- slang_operation_copy(&select->children[1], &oper->children[1]);
- select->children[2].type = SLANG_OPER_LITERAL_BOOL;
- ASSIGN_4V(select->children[2].literal, 0, 0, 0, 0); /* false */
- select->children[2].literal_size = 1;
+ slang_operation_copy(slang_oper_child(select, 0), &oper->children[0]);
+ slang_operation_copy(slang_oper_child(select, 1), &oper->children[1]);
+ slang_operation_literal_bool(slang_oper_child(select, 2), GL_FALSE);
n = _slang_gen_select(A, select);
return n;
@@ -3268,14 +4056,11 @@ _slang_gen_logical_or(slang_assemble_ctx *A, slang_operation *oper)
select = slang_operation_new(1);
select->type = SLANG_OPER_SELECT;
- select->num_children = 3;
- select->children = slang_operation_new(3);
+ slang_operation_add_children(select, 3);
- slang_operation_copy(&select->children[0], &oper->children[0]);
- select->children[1].type = SLANG_OPER_LITERAL_BOOL;
- ASSIGN_4V(select->children[1].literal, 1, 1, 1, 1); /* true */
- select->children[1].literal_size = 1;
- slang_operation_copy(&select->children[2], &oper->children[1]);
+ slang_operation_copy(slang_oper_child(select, 0), &oper->children[0]);
+ slang_operation_literal_bool(slang_oper_child(select, 1), GL_TRUE);
+ slang_operation_copy(slang_oper_child(select, 2), &oper->children[1]);
n = _slang_gen_select(A, select);
return n;
@@ -3288,70 +4073,8 @@ _slang_gen_logical_or(slang_assemble_ctx *A, slang_operation *oper)
static slang_ir_node *
_slang_gen_return(slang_assemble_ctx * A, slang_operation *oper)
{
- const GLboolean haveReturnValue
- = (oper->num_children == 1 && oper->children[0].type != SLANG_OPER_VOID);
-
- /* error checking */
- assert(A->CurFunction);
- if (haveReturnValue &&
- A->CurFunction->header.type.specifier.type == SLANG_SPEC_VOID) {
- slang_info_log_error(A->log, "illegal return expression");
- return NULL;
- }
- else if (!haveReturnValue &&
- A->CurFunction->header.type.specifier.type != SLANG_SPEC_VOID) {
- slang_info_log_error(A->log, "return statement requires an expression");
- return NULL;
- }
-
- if (!haveReturnValue) {
- return new_return(A->curFuncEndLabel);
- }
- else {
- /*
- * Convert from:
- * return expr;
- * To:
- * __retVal = expr;
- * return; // goto __endOfFunction
- */
- slang_operation *assign;
- slang_atom a_retVal;
- slang_ir_node *n;
-
- a_retVal = slang_atom_pool_atom(A->atoms, "__retVal");
- assert(a_retVal);
-
-#if 1 /* DEBUG */
- {
- slang_variable *v =
- _slang_variable_locate(oper->locals, a_retVal, GL_TRUE);
- if (!v) {
- /* trying to return a value in a void-valued function */
- return NULL;
- }
- }
-#endif
-
- assign = slang_operation_new(1);
- assign->type = SLANG_OPER_ASSIGN;
- assign->num_children = 2;
- assign->children = slang_operation_new(2);
- /* lhs (__retVal) */
- assign->children[0].type = SLANG_OPER_IDENTIFIER;
- assign->children[0].a_id = a_retVal;
- assign->children[0].locals->outer_scope = assign->locals;
- /* rhs (expr) */
- /* XXX we might be able to avoid this copy someday */
- slang_operation_copy(&assign->children[1], &oper->children[0]);
-
- /* assemble the new code */
- n = new_seq(_slang_gen_operation(A, assign),
- new_return(A->curFuncEndLabel));
-
- slang_operation_delete(assign);
- return n;
- }
+ assert(oper->type == SLANG_OPER_RETURN);
+ return new_return(A->curFuncEndLabel);
}
@@ -3457,6 +4180,7 @@ _slang_gen_declaration(slang_assemble_ctx *A, slang_operation *oper)
assert(oper->type == SLANG_OPER_VARIABLE_DECL);
assert(oper->num_children <= 1);
+
/* lookup the variable by name */
var = _slang_variable_locate(oper->locals, oper->a_id, GL_TRUE);
if (!var)
@@ -3612,6 +4336,9 @@ root_swizzle(const slang_ir_storage *st)
static slang_ir_node *
_slang_gen_assignment(slang_assemble_ctx * A, slang_operation *oper)
{
+ slang_operation *pred = NULL;
+ slang_ir_node *n = NULL;
+
if (oper->children[0].type == SLANG_OPER_IDENTIFIER) {
/* Check that var is writeable */
slang_variable *var
@@ -3632,6 +4359,17 @@ _slang_gen_assignment(slang_assemble_ctx * A, slang_operation *oper)
(char *) oper->children[0].a_id);
return NULL;
}
+
+ /* check if we need to predicate this assignment based on __notRetFlag */
+ if ((var->is_global ||
+ var->type.qualifier == SLANG_QUAL_OUT ||
+ var->type.qualifier == SLANG_QUAL_INOUT) && A->UseReturnFlag) {
+ /* create predicate, used below */
+ pred = slang_operation_new(1);
+ pred->type = SLANG_OPER_IDENTIFIER;
+ pred->a_id = slang_atom_pool_atom(A->atoms, "__notRetFlag");
+ pred->locals->outer_scope = oper->locals->outer_scope;
+ }
}
if (oper->children[0].type == SLANG_OPER_IDENTIFIER &&
@@ -3643,14 +4381,12 @@ _slang_gen_assignment(slang_assemble_ctx * A, slang_operation *oper)
* cases such as "v.x = f();" - would help with typical vertex
* transformation.
*/
- slang_ir_node *n;
n = _slang_gen_function_call_name(A,
(const char *) oper->children[1].a_id,
&oper->children[1], &oper->children[0]);
- return n;
}
else {
- slang_ir_node *n, *lhs, *rhs;
+ slang_ir_node *lhs, *rhs;
/* lhs and rhs type checking */
if (!_slang_assignment_compatible(A,
@@ -3690,12 +4426,21 @@ _slang_gen_assignment(slang_assemble_ctx * A, slang_operation *oper)
rhs = _slang_gen_swizzle(rhs, newSwizzle);
}
n = new_node2(IR_COPY, lhs, rhs);
- return n;
}
else {
return NULL;
}
}
+
+ if (n && pred) {
+ /* predicate the assignment code on __notRetFlag */
+ slang_ir_node *top, *cond;
+
+ cond = _slang_gen_operation(A, pred);
+ top = new_if(cond, n, NULL);
+ return top;
+ }
+ return n;
}
@@ -4048,16 +4793,14 @@ _slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper)
case SLANG_OPER_WHILE:
return _slang_gen_while(A, oper);
case SLANG_OPER_BREAK:
- if (!A->CurLoop) {
- if (!A->UnrollLoop)
- slang_info_log_error(A->log, "'break' not in loop");
+ if (!current_loop_oper(A)) {
+ slang_info_log_error(A->log, "'break' not in loop");
return NULL;
}
- return new_break(A->CurLoop);
+ return new_break(current_loop_ir(A));
case SLANG_OPER_CONTINUE:
- if (!A->CurLoop) {
- if (!A->UnrollLoop)
- slang_info_log_error(A->log, "'continue' not in loop");
+ if (!current_loop_oper(A)) {
+ slang_info_log_error(A->log, "'continue' not in loop");
return NULL;
}
return _slang_gen_continue(A, oper);
@@ -4182,6 +4925,8 @@ _slang_gen_operation(slang_assemble_ctx * A, slang_operation *oper)
return _slang_gen_method_call(A, oper);
case SLANG_OPER_RETURN:
return _slang_gen_return(A, oper);
+ case SLANG_OPER_RETURN_INLINED:
+ return _slang_gen_return(A, oper);
case SLANG_OPER_LABEL:
return new_label(oper->label);
case SLANG_OPER_IDENTIFIER:
@@ -4303,6 +5048,8 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
const GLint totalSize = _slang_array_size(size, arrayLen);
GLint texIndex = sampler_to_texture_index(var->type.specifier.type);
+ var->is_global = GL_TRUE;
+
/* check for sampler2D arrays */
if (texIndex == -1 && var->type.specifier._array)
texIndex = sampler_to_texture_index(var->type.specifier._array->type);
@@ -4601,7 +5348,9 @@ _slang_codegen_function(slang_assemble_ctx * A, slang_function * fun)
assert(A->program->Parameters );
assert(A->program->Varying);
assert(A->vartable);
- A->CurLoop = NULL;
+
+ A->LoopDepth = 0;
+ A->UseReturnFlag = GL_FALSE;
A->CurFunction = fun;
/* fold constant expressions, etc. */
diff --git a/src/mesa/shader/slang/slang_codegen.h b/src/mesa/shader/slang/slang_codegen.h
index d80013ad341..ee3be55a459 100644
--- a/src/mesa/shader/slang/slang_codegen.h
+++ b/src/mesa/shader/slang/slang_codegen.h
@@ -31,6 +31,9 @@
#include "slang_compile.h"
+#define MAX_LOOP_DEPTH 30
+
+
typedef struct slang_assemble_ctx_
{
slang_atom_pool *atoms;
@@ -39,11 +42,19 @@ typedef struct slang_assemble_ctx_
struct gl_sl_pragmas *pragmas;
slang_var_table *vartable;
slang_info_log *log;
- struct slang_label_ *curFuncEndLabel;
- struct slang_ir_node_ *CurLoop;
+
+ /* current loop stack */
+ const slang_operation *LoopOperStack[MAX_LOOP_DEPTH];
+ struct slang_ir_node_ *LoopIRStack[MAX_LOOP_DEPTH];
+ GLuint LoopDepth;
+
+ /* current function */
struct slang_function_ *CurFunction;
- GLuint UnrollLoop;
+ struct slang_label_ *curFuncEndLabel;
+ GLboolean UseReturnFlag;
+
GLboolean UnresolvedRefs;
+ GLboolean EmitContReturn;
} slang_assemble_ctx;
diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c
index d7ad879e97a..c1b97c7cb70 100644
--- a/src/mesa/shader/slang/slang_compile.c
+++ b/src/mesa/shader/slang/slang_compile.c
@@ -1953,6 +1953,7 @@ static int
parse_init_declarator(slang_parse_ctx * C, slang_output_ctx * O,
const slang_fully_specified_type * type)
{
+ GET_CURRENT_CONTEXT(ctx); /* a hack */
slang_variable *var;
slang_atom a_name;
@@ -2066,6 +2067,7 @@ parse_init_declarator(slang_parse_ctx * C, slang_output_ctx * O,
A.vartable = O->vartable;
A.log = C->L;
A.curFuncEndLabel = NULL;
+ A.EmitContReturn = ctx->Shader.EmitContReturn;
if (!_slang_codegen_global_variable(&A, var, C->type))
RETURN0;
}
@@ -2430,6 +2432,7 @@ parse_code_unit(slang_parse_ctx * C, slang_code_unit * unit,
A.program = o.program;
A.pragmas = &shader->Pragmas;
A.vartable = o.vartable;
+ A.EmitContReturn = ctx->Shader.EmitContReturn;
A.log = C->L;
/* main() takes no parameters */
diff --git a/src/mesa/shader/slang/slang_compile_operation.c b/src/mesa/shader/slang/slang_compile_operation.c
index e6506168808..3e2bdbc91ff 100644
--- a/src/mesa/shader/slang/slang_compile_operation.c
+++ b/src/mesa/shader/slang/slang_compile_operation.c
@@ -119,11 +119,13 @@ slang_operation_copy(slang_operation * x, const slang_operation * y)
if (!slang_operation_construct(&z))
return GL_FALSE;
z.type = y->type;
- z.children = (slang_operation *)
- _slang_alloc(y->num_children * sizeof(slang_operation));
- if (z.children == NULL) {
- slang_operation_destruct(&z);
- return GL_FALSE;
+ if (y->num_children > 0) {
+ z.children = (slang_operation *)
+ _slang_alloc(y->num_children * sizeof(slang_operation));
+ if (z.children == NULL) {
+ slang_operation_destruct(&z);
+ return GL_FALSE;
+ }
}
for (z.num_children = 0; z.num_children < y->num_children;
z.num_children++) {
@@ -152,6 +154,15 @@ slang_operation_copy(slang_operation * x, const slang_operation * y)
return GL_FALSE;
}
}
+
+ /* update scoping for children */
+ for (i = 0; i < y->num_children; i++) {
+ if (y->children[i].locals &&
+ y->children[i].locals->outer_scope == y->locals) {
+ z.children[i].locals->outer_scope = z.locals;
+ }
+ }
+
#if 0
z.var = y->var;
z.fun = y->fun;
@@ -198,6 +209,20 @@ slang_operation_delete(slang_operation *oper)
}
+void
+slang_operation_free_children(slang_operation *oper)
+{
+ GLuint i;
+ for (i = 0; i < slang_oper_num_children(oper); i++) {
+ slang_operation *child = slang_oper_child(oper, i);
+ slang_operation_destruct(child);
+ }
+ _slang_free(oper->children);
+ oper->children = NULL;
+ oper->num_children = 0;
+}
+
+
slang_operation *
slang_operation_grow(GLuint *numChildren, slang_operation **children)
{
@@ -263,6 +288,26 @@ slang_operation_insert(GLuint *numElements, slang_operation **array,
}
+/**
+ * Add/insert new child into given node at given position.
+ * \return pointer to the new child node
+ */
+slang_operation *
+slang_operation_insert_child(slang_operation *oper, GLuint pos)
+{
+ slang_operation *newOp;
+
+ newOp = slang_operation_insert(&oper->num_children,
+ &oper->children,
+ pos);
+ if (newOp) {
+ newOp->locals->outer_scope = oper->locals;
+ }
+
+ return newOp;
+}
+
+
void
_slang_operation_swap(slang_operation *oper0, slang_operation *oper1)
{
@@ -272,3 +317,16 @@ _slang_operation_swap(slang_operation *oper0, slang_operation *oper1)
}
+void
+slang_operation_add_children(slang_operation *oper, GLuint num_children)
+{
+ GLuint i;
+ assert(oper->num_children == 0);
+ assert(oper->children == NULL);
+ oper->num_children = num_children;
+ oper->children = slang_operation_new(num_children);
+ for (i = 0; i < num_children; i++) {
+ oper->children[i].locals = _slang_variable_scope_new(oper->locals);
+ }
+}
+
diff --git a/src/mesa/shader/slang/slang_compile_operation.h b/src/mesa/shader/slang/slang_compile_operation.h
index 37af5d617c9..58f1edeed85 100644
--- a/src/mesa/shader/slang/slang_compile_operation.h
+++ b/src/mesa/shader/slang/slang_compile_operation.h
@@ -42,6 +42,7 @@ typedef enum slang_operation_type_
SLANG_OPER_CONTINUE, /* "continue" statement */
SLANG_OPER_DISCARD, /* "discard" (kill fragment) statement */
SLANG_OPER_RETURN, /* "return" [expr] */
+ SLANG_OPER_RETURN_INLINED, /* "return" [expr] from inlined function */
SLANG_OPER_LABEL, /* a jump target */
SLANG_OPER_EXPRESSION, /* [expr] */
SLANG_OPER_IF, /* "if" [0] then [1] else [2] */
@@ -150,6 +151,9 @@ slang_operation_new(GLuint count);
extern void
slang_operation_delete(slang_operation *oper);
+extern void
+slang_operation_free_children(slang_operation *oper);
+
extern slang_operation *
slang_operation_grow(GLuint *numChildren, slang_operation **children);
@@ -157,8 +161,66 @@ extern slang_operation *
slang_operation_insert(GLuint *numChildren, slang_operation **children,
GLuint pos);
+extern slang_operation *
+slang_operation_insert_child(slang_operation *oper, GLuint pos);
+
extern void
_slang_operation_swap(slang_operation *oper0, slang_operation *oper1);
+extern void
+slang_operation_add_children(slang_operation *oper, GLuint num_children);
+
+
+/** Return number of children of given node */
+static INLINE GLuint
+slang_oper_num_children(const slang_operation *oper)
+{
+ return oper->num_children;
+}
+
+/** Return child of given operation node */
+static INLINE slang_operation *
+slang_oper_child(slang_operation *oper, GLuint child)
+{
+ assert(child < oper->num_children);
+ return &oper->children[child];
+}
+
+
+/** Return child of given operation node, const version */
+static INLINE const slang_operation *
+slang_oper_child_const(const slang_operation *oper, GLuint child)
+{
+ assert(child < oper->num_children);
+ return &oper->children[child];
+}
+
+
+/** Init oper to a boolean literal. */
+static INLINE void
+slang_operation_literal_bool(slang_operation *oper, GLboolean value)
+{
+ oper->type = SLANG_OPER_LITERAL_BOOL;
+ oper->literal[0] =
+ oper->literal[1] =
+ oper->literal[2] =
+ oper->literal[3] = (float) value;
+ oper->literal_size = 1;
+}
+
+
+/** Init oper to an int literal. */
+static INLINE void
+slang_operation_literal_int(slang_operation *oper, GLint value)
+{
+ oper->type = SLANG_OPER_LITERAL_INT;
+ oper->literal[0] =
+ oper->literal[1] =
+ oper->literal[2] =
+ oper->literal[3] = (float) value;
+ oper->literal_size = 1;
+}
+
+
#endif /* SLANG_COMPILE_OPERATION_H */
diff --git a/src/mesa/shader/slang/slang_compile_variable.h b/src/mesa/shader/slang/slang_compile_variable.h
index a667d91b471..b4585599f24 100644
--- a/src/mesa/shader/slang/slang_compile_variable.h
+++ b/src/mesa/shader/slang/slang_compile_variable.h
@@ -39,6 +39,7 @@ typedef struct slang_variable_
GLuint array_len; /**< only if type == SLANG_SPEC_ARRAy */
struct slang_operation_ *initializer; /**< Optional initializer code */
GLuint size; /**< Variable's size in bytes */
+ GLboolean is_global;
GLboolean isTemp; /**< a named temporary (__resultTmp) */
GLboolean declared; /**< for debug */
struct slang_ir_storage_ *store; /**< Storage for this var */
diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c
index 1fdf4db054c..387659ff300 100644
--- a/src/mesa/shader/slang/slang_link.c
+++ b/src/mesa/shader/slang/slang_link.c
@@ -97,7 +97,8 @@ bits_agree(GLbitfield flags1, GLbitfield flags2, GLbitfield bit)
* which inputs are centroid-sampled, invariant, etc.
*/
static GLboolean
-link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog)
+link_varying_vars(GLcontext *ctx,
+ struct gl_shader_program *shProg, struct gl_program *prog)
{
GLuint *map, i, firstVarying, newFile;
GLbitfield *inOutFlags;
@@ -156,8 +157,12 @@ link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog)
var->Flags);
}
+ if (shProg->Varying->NumParameters > ctx->Const.MaxVarying) {
+ link_error(shProg, "Too many varying variables");
+ return GL_FALSE;
+ }
+
/* Map varying[i] to varying[j].
- * Plus, set prog->Input/OutputFlags[] as described above.
* Note: the loop here takes care of arrays or large (sz>4) vars.
*/
{
@@ -319,7 +324,7 @@ _slang_resolve_attributes(struct gl_shader_program *shProg,
const struct gl_program *origProg,
struct gl_program *linkedProg)
{
- GLint attribMap[MAX_VERTEX_ATTRIBS];
+ GLint attribMap[MAX_VERTEX_GENERIC_ATTRIBS];
GLuint i, j;
GLbitfield usedAttributes; /* generics only, not legacy attributes */
@@ -355,7 +360,7 @@ _slang_resolve_attributes(struct gl_shader_program *shProg,
}
/* initialize the generic attribute map entries to -1 */
- for (i = 0; i < MAX_VERTEX_ATTRIBS; i++) {
+ for (i = 0; i < MAX_VERTEX_GENERIC_ATTRIBS; i++) {
attribMap[i] = -1;
}
@@ -396,11 +401,11 @@ _slang_resolve_attributes(struct gl_shader_program *shProg,
* Start at 1 since generic attribute 0 always aliases
* glVertex/position.
*/
- for (attr = 0; attr < MAX_VERTEX_ATTRIBS; attr++) {
+ for (attr = 0; attr < MAX_VERTEX_GENERIC_ATTRIBS; attr++) {
if (((1 << attr) & usedAttributes) == 0)
break;
}
- if (attr == MAX_VERTEX_ATTRIBS) {
+ if (attr == MAX_VERTEX_GENERIC_ATTRIBS) {
link_error(shProg, "Too many vertex attributes");
return GL_FALSE;
}
@@ -725,11 +730,11 @@ _slang_link(GLcontext *ctx,
/* link varying vars */
if (shProg->VertexProgram) {
- if (!link_varying_vars(shProg, &shProg->VertexProgram->Base))
+ if (!link_varying_vars(ctx, shProg, &shProg->VertexProgram->Base))
return;
}
if (shProg->FragmentProgram) {
- if (!link_varying_vars(shProg, &shProg->FragmentProgram->Base))
+ if (!link_varying_vars(ctx, shProg, &shProg->FragmentProgram->Base))
return;
}
diff --git a/src/mesa/shader/slang/slang_preprocess.c b/src/mesa/shader/slang/slang_preprocess.c
index ff913ad8838..e9a24cc009a 100644
--- a/src/mesa/shader/slang/slang_preprocess.c
+++ b/src/mesa/shader/slang/slang_preprocess.c
@@ -1035,11 +1035,11 @@ preprocess_source (slang_string *output, const char *source,
/* Parse optional macro parameters. */
while (prod[i++] != PARAM_END) {
- if (state.cond.top->effective) {
- pp_symbol *param;
+ pp_symbol *param;
- id = (const char *) (&prod[i]);
- idlen = _mesa_strlen (id);
+ id = (const char *) (&prod[i]);
+ idlen = _mesa_strlen (id);
+ if (state.cond.top->effective) {
pp_annotate (output, "%s, ", id);
param = pp_symbols_push (&symbol->parameters);
if (param == NULL)
@@ -1053,8 +1053,23 @@ preprocess_source (slang_string *output, const char *source,
id = (const char *) (&prod[i]);
idlen = _mesa_strlen (id);
if (state.cond.top->effective) {
+ slang_string replacement;
+ expand_state es;
+
pp_annotate (output, ") %s", id);
- slang_string_pushs (&symbol->replacement, id, idlen);
+
+ slang_string_init(&replacement);
+ slang_string_pushs(&replacement, id, idlen);
+
+ /* Expand macro replacement. */
+ es.output = &symbol->replacement;
+ es.input = slang_string_cstr(&replacement);
+ es.state = &state;
+ if (!expand(&es, &state.symbols)) {
+ slang_string_free(&replacement);
+ goto error;
+ }
+ slang_string_free(&replacement);
}
i += idlen + 1;
}
@@ -1286,6 +1301,45 @@ error:
/**
+ * Remove the continuation characters from the input string.
+ * This is the very first step in preprocessing and is effective
+ * even inside comment blocks.
+ * If there is a whitespace between a backslash and a newline,
+ * this is not considered as a line continuation.
+ * \return GL_TRUE for success, GL_FALSE otherwise.
+ */
+static GLboolean
+_slang_preprocess_backslashes(slang_string *output,
+ const char *input)
+{
+ while (*input) {
+ if (input[0] == '\\') {
+ /* If a newline follows, eat the backslash and the newline. */
+ if (input[1] == '\r') {
+ if (input[2] == '\n') {
+ input += 3;
+ } else {
+ input += 2;
+ }
+ } else if (input[1] == '\n') {
+ if (input[2] == '\r') {
+ input += 3;
+ } else {
+ input += 2;
+ }
+ } else {
+ /* Leave the backslash alone. */
+ slang_string_pushc(output, *input++);
+ }
+ } else {
+ slang_string_pushc(output, *input++);
+ }
+ }
+ return GL_TRUE;
+}
+
+
+/**
* Run preprocessor on source code.
* \param extensions indicates which GL extensions are enabled
* \param output the post-process results
@@ -1304,6 +1358,7 @@ _slang_preprocess_directives(slang_string *output,
{
grammar pid, eid;
GLboolean success;
+ slang_string without_backslashes;
pid = grammar_load_from_text ((const byte *) (slang_pp_directives_syn));
if (pid == 0) {
@@ -1316,9 +1371,36 @@ _slang_preprocess_directives(slang_string *output,
grammar_destroy (pid);
return GL_FALSE;
}
- success = preprocess_source (output, input, pid, eid, elog, extensions, pragmas);
+
+ slang_string_init(&without_backslashes);
+ success = _slang_preprocess_backslashes(&without_backslashes, input);
+
+ if (0) {
+ _mesa_printf("Pre-processed shader:\n");
+ _mesa_printf("%s", slang_string_cstr(&without_backslashes));
+ _mesa_printf("----------------------\n");
+ }
+
+ if (success) {
+ success = preprocess_source(output,
+ slang_string_cstr(&without_backslashes),
+ pid,
+ eid,
+ elog,
+ extensions,
+ pragmas);
+ }
+
+ slang_string_free(&without_backslashes);
grammar_destroy (eid);
grammar_destroy (pid);
+
+ if (0) {
+ _mesa_printf("Post-processed shader:\n");
+ _mesa_printf("%s", slang_string_cstr(output));
+ _mesa_printf("----------------------\n");
+ }
+
return success;
}
diff --git a/src/mesa/shader/slang/slang_print.c b/src/mesa/shader/slang/slang_print.c
index bf1475f91d9..98c7877534f 100644
--- a/src/mesa/shader/slang/slang_print.c
+++ b/src/mesa/shader/slang/slang_print.c
@@ -261,6 +261,7 @@ slang_print_tree(const slang_operation *op, int indent)
break;
case SLANG_OPER_BLOCK_NEW_SCOPE:
+ case SLANG_OPER_NON_INLINED_CALL:
spaces(indent);
printf("{{ // new scope locals=%p outer=%p: ",
(void *) op->locals,
@@ -348,6 +349,13 @@ slang_print_tree(const slang_operation *op, int indent)
slang_print_tree(&op->children[0], indent + 3);
break;
+ case SLANG_OPER_RETURN_INLINED:
+ spaces(indent);
+ printf("RETURN_INLINED\n");
+ if (op->num_children > 0)
+ slang_print_tree(&op->children[0], indent + 3);
+ break;
+
case SLANG_OPER_LABEL:
spaces(indent);
printf("LABEL %s\n", (char *) op->a_id);
@@ -478,7 +486,7 @@ slang_print_tree(const slang_operation *op, int indent)
(void *) scope,
(void *) op->locals,
(void *) op->locals->outer_scope);
- assert(scope);
+ /*assert(scope);*/
}
}
break;
diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c
index fc1ff5be04a..ee649be885e 100644
--- a/src/mesa/state_tracker/st_atom_shader.c
+++ b/src/mesa/state_tracker/st_atom_shader.c
@@ -175,11 +175,12 @@ find_translated_vp(struct st_context *st,
/* See if we need to translate vertex program to TGSI form */
if (xvp->serialNo != stvp->serialNo) {
- GLuint outAttr, dummySlot;
+ GLuint outAttr;
const GLbitfield outputsWritten = stvp->Base.Base.OutputsWritten;
GLuint numVpOuts = 0;
GLboolean emitPntSize = GL_FALSE, emitBFC0 = GL_FALSE, emitBFC1 = GL_FALSE;
- GLint maxGeneric;
+ GLbitfield usedGenerics = 0x0;
+ GLbitfield usedOutputSlots = 0x0;
/* Compute mapping of vertex program outputs to slots, which depends
* on the fragment program's input->slot mapping.
@@ -192,10 +193,12 @@ find_translated_vp(struct st_context *st,
if (outAttr == VERT_RESULT_HPOS) {
/* always put xformed position into slot zero */
- xvp->output_to_slot[VERT_RESULT_HPOS] = 0;
+ GLuint slot = 0;
+ xvp->output_to_slot[VERT_RESULT_HPOS] = slot;
xvp->output_to_semantic_name[outAttr] = TGSI_SEMANTIC_POSITION;
xvp->output_to_semantic_index[outAttr] = 0;
numVpOuts++;
+ usedOutputSlots |= (1 << slot);
}
else if (outputsWritten & (1 << outAttr)) {
/* see if the frag prog wants this vert output */
@@ -209,6 +212,12 @@ find_translated_vp(struct st_context *st,
xvp->output_to_semantic_name[outAttr] = stfp->input_semantic_name[fpInSlot];
xvp->output_to_semantic_index[outAttr] = stfp->input_semantic_index[fpInSlot];
numVpOuts++;
+ usedOutputSlots |= (1 << vpOutSlot);
+ }
+ else {
+#if 0 /*debug*/
+ printf("VP output %d not used by FP\n", outAttr);
+#endif
}
}
else if (outAttr == VERT_RESULT_PSIZ)
@@ -226,45 +235,49 @@ find_translated_vp(struct st_context *st,
/* must do these last */
if (emitPntSize) {
- xvp->output_to_slot[VERT_RESULT_PSIZ] = numVpOuts++;
+ GLuint slot = numVpOuts++;
+ xvp->output_to_slot[VERT_RESULT_PSIZ] = slot;
xvp->output_to_semantic_name[VERT_RESULT_PSIZ] = TGSI_SEMANTIC_PSIZE;
xvp->output_to_semantic_index[VERT_RESULT_PSIZ] = 0;
+ usedOutputSlots |= (1 << slot);
}
if (emitBFC0) {
- xvp->output_to_slot[VERT_RESULT_BFC0] = numVpOuts++;
+ GLuint slot = numVpOuts++;
+ xvp->output_to_slot[VERT_RESULT_BFC0] = slot;
xvp->output_to_semantic_name[VERT_RESULT_BFC0] = TGSI_SEMANTIC_COLOR;
xvp->output_to_semantic_index[VERT_RESULT_BFC0] = 0;
+ usedOutputSlots |= (1 << slot);
}
if (emitBFC1) {
- xvp->output_to_slot[VERT_RESULT_BFC1] = numVpOuts++;
- xvp->output_to_semantic_name[VERT_RESULT_BFC0] = TGSI_SEMANTIC_COLOR;
- xvp->output_to_semantic_index[VERT_RESULT_BFC0] = 1;
+ GLuint slot = numVpOuts++;
+ xvp->output_to_slot[VERT_RESULT_BFC1] = slot;
+ xvp->output_to_semantic_name[VERT_RESULT_BFC1] = TGSI_SEMANTIC_COLOR;
+ xvp->output_to_semantic_index[VERT_RESULT_BFC1] = 1;
+ usedOutputSlots |= (1 << slot);
}
- /* Unneeded vertex program outputs will go to this slot.
- * We could use this info to do dead code elimination in the
- * vertex program.
- */
- dummySlot = numVpOuts;
-
- /* find max GENERIC slot index */
- maxGeneric = -1;
+ /* build usedGenerics mask */
+ usedGenerics = 0x0;
for (outAttr = 0; outAttr < VERT_RESULT_MAX; outAttr++) {
if (xvp->output_to_semantic_name[outAttr] == TGSI_SEMANTIC_GENERIC) {
- maxGeneric = MAX2(maxGeneric,
- xvp->output_to_semantic_index[outAttr]);
+ usedGenerics |= (1 << xvp->output_to_semantic_index[outAttr]);
}
}
- /* Map vert program outputs that aren't used to the dummy slot
- * (and an unused generic attribute slot).
+ /* For each vertex program output that doesn't match up to a fragment
+ * program input, map the vertex program output to a free slot and
+ * free generic attribute.
*/
for (outAttr = 0; outAttr < VERT_RESULT_MAX; outAttr++) {
if (outputsWritten & (1 << outAttr)) {
if (xvp->output_to_slot[outAttr] == UNUSED) {
- xvp->output_to_slot[outAttr] = dummySlot;
+ GLint freeGeneric = _mesa_ffs(~usedGenerics) - 1;
+ GLint freeSlot = _mesa_ffs(~usedOutputSlots) - 1;
+ usedGenerics |= (1 << freeGeneric);
+ usedOutputSlots |= (1 << freeSlot);
+ xvp->output_to_slot[outAttr] = freeSlot;
xvp->output_to_semantic_name[outAttr] = TGSI_SEMANTIC_GENERIC;
- xvp->output_to_semantic_index[outAttr] = maxGeneric + 1;
+ xvp->output_to_semantic_index[outAttr] = freeGeneric;
}
}
diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c
index 7f793cf08db..95181578f63 100644
--- a/src/mesa/state_tracker/st_cb_accum.c
+++ b/src/mesa/state_tracker/st_cb_accum.c
@@ -48,10 +48,6 @@
#include "util/u_tile.h"
-#define UNCLAMPED_FLOAT_TO_SHORT(us, f) \
- us = ( (short) ( CLAMP((f), -1.0, 1.0) * 32767.0F) )
-
-
/**
* For hardware that supports deep color buffers, we could accelerate
* most/all the accum operations with blending/texturing.
@@ -59,74 +55,20 @@
*/
-/**
- * Wrapper for pipe_get_tile_rgba(). Do format/cpp override to make the
- * tile util function think the surface is 16bit/channel, even if it's not.
- * See also: st_renderbuffer_alloc_storage()
- */
-static void
-acc_get_tile_rgba(struct pipe_context *pipe, struct pipe_transfer *acc_pt,
- uint x, uint y, uint w, uint h, float *p)
-{
- const enum pipe_format f = acc_pt->format;
- const struct pipe_format_block b = acc_pt->block;
-
- acc_pt->format = DEFAULT_ACCUM_PIPE_FORMAT;
- acc_pt->block.size = 8;
- acc_pt->block.width = 1;
- acc_pt->block.height = 1;
-
- pipe_get_tile_rgba(acc_pt, x, y, w, h, p);
-
- acc_pt->format = f;
- acc_pt->block = b;
-}
-
-
-/**
- * Wrapper for pipe_put_tile_rgba(). Do format/cpp override to make the
- * tile util function think the surface is 16bit/channel, even if it's not.
- * See also: st_renderbuffer_alloc_storage()
- */
-static void
-acc_put_tile_rgba(struct pipe_context *pipe, struct pipe_transfer *acc_pt,
- uint x, uint y, uint w, uint h, const float *p)
-{
- enum pipe_format f = acc_pt->format;
- const struct pipe_format_block b = acc_pt->block;
-
- acc_pt->format = DEFAULT_ACCUM_PIPE_FORMAT;
- acc_pt->block.size = 8;
- acc_pt->block.width = 1;
- acc_pt->block.height = 1;
-
- pipe_put_tile_rgba(acc_pt, x, y, w, h, p);
-
- acc_pt->format = f;
- acc_pt->block = b;
-}
-
-
-
void
st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
{
struct st_renderbuffer *acc_strb = st_renderbuffer(rb);
- struct pipe_transfer *acc_pt;
- struct pipe_screen *screen = ctx->st->pipe->screen;
const GLint xpos = ctx->DrawBuffer->_Xmin;
const GLint ypos = ctx->DrawBuffer->_Ymin;
const GLint width = ctx->DrawBuffer->_Xmax - xpos;
const GLint height = ctx->DrawBuffer->_Ymax - ypos;
- GLubyte *map;
-
- acc_pt = st_cond_flush_get_tex_transfer(st_context(ctx), acc_strb->texture,
- 0, 0, 0,
- PIPE_TRANSFER_WRITE, xpos, ypos,
- width, height);
- map = screen->transfer_map(screen, acc_pt);
+ size_t stride = acc_strb->stride;
+ GLubyte *data = acc_strb->data;
- /* note acc_strb->format might not equal acc_pt->format */
+ if(!data)
+ return;
+
switch (acc_strb->format) {
case PIPE_FORMAT_R16G16B16A16_SNORM:
{
@@ -136,7 +78,7 @@ st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
GLshort a = FLOAT_TO_SHORT(ctx->Accum.ClearColor[3]);
int i, j;
for (i = 0; i < height; i++) {
- GLshort *dst = (GLshort *) (map + i * acc_pt->stride + xpos * 8);
+ GLshort *dst = (GLshort *) (data + (ypos + i) * stride + xpos * 8);
for (j = 0; j < width; j++) {
dst[0] = r;
dst[1] = g;
@@ -150,9 +92,6 @@ st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
default:
_mesa_problem(ctx, "unexpected format in st_clear_accum_buffer()");
}
-
- screen->transfer_unmap(screen, acc_pt);
- screen->tex_transfer_destroy(acc_pt);
}
@@ -162,27 +101,18 @@ accum_mad(GLcontext *ctx, GLfloat scale, GLfloat bias,
GLint xpos, GLint ypos, GLint width, GLint height,
struct st_renderbuffer *acc_strb)
{
- struct pipe_screen *screen = ctx->st->pipe->screen;
- struct pipe_transfer *acc_pt;
- GLubyte *map;
-
- acc_pt = st_cond_flush_get_tex_transfer(st_context(ctx), acc_strb->texture,
- 0, 0, 0,
- PIPE_TRANSFER_READ_WRITE,
- xpos, ypos,
- width, height);
- map = screen->transfer_map(screen, acc_pt);
-
- /* note acc_strb->format might not equal acc_pt->format */
+ size_t stride = acc_strb->stride;
+ GLubyte *data = acc_strb->data;
+
switch (acc_strb->format) {
case PIPE_FORMAT_R16G16B16A16_SNORM:
{
int i, j;
for (i = 0; i < height; i++) {
- GLshort *acc = (GLshort *) (map + (ypos + i) * acc_pt->stride + xpos * 8);
+ GLshort *acc = (GLshort *) (data + (ypos + i) * stride + xpos * 8);
for (j = 0; j < width * 4; j++) {
- float val = SHORT_TO_FLOAT(acc[j]) * scale + bias;
- acc[j] = FLOAT_TO_SHORT(val);
+ float val = SHORT_TO_FLOAT(*acc) * scale + bias;
+ *acc++ = FLOAT_TO_SHORT(val);
}
}
}
@@ -190,9 +120,6 @@ accum_mad(GLcontext *ctx, GLfloat scale, GLfloat bias,
default:
_mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()");
}
-
- screen->transfer_unmap(screen, acc_pt);
- screen->tex_transfer_destroy(acc_pt);
}
@@ -204,39 +131,39 @@ accum_accum(struct st_context *st, GLfloat value,
{
struct pipe_context *pipe = st->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_transfer *acc_trans, *color_trans;
- GLfloat *colorBuf, *accBuf;
- GLint i;
-
- acc_trans = st_cond_flush_get_tex_transfer(st, acc_strb->texture, 0, 0, 0,
- PIPE_TRANSFER_READ, xpos, ypos,
- width, height);
+ struct pipe_transfer *color_trans;
+ size_t stride = acc_strb->stride;
+ GLubyte *data = acc_strb->data;
+ GLfloat *buf;
color_trans = st_cond_flush_get_tex_transfer(st, color_strb->texture,
0, 0, 0,
PIPE_TRANSFER_READ, xpos, ypos,
width, height);
- colorBuf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
- accBuf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
+ buf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
- pipe_get_tile_rgba(color_trans, 0, 0, width, height, colorBuf);
- acc_get_tile_rgba(pipe, acc_trans, 0, 0, width, height, accBuf);
+ pipe_get_tile_rgba(color_trans, 0, 0, width, height, buf);
- for (i = 0; i < 4 * width * height; i++) {
- accBuf[i] = accBuf[i] + colorBuf[i] * value;
+ switch (acc_strb->format) {
+ case PIPE_FORMAT_R16G16B16A16_SNORM:
+ {
+ const GLfloat *color = buf;
+ int i, j;
+ for (i = 0; i < height; i++) {
+ GLshort *acc = (GLshort *) (data + (ypos + i) * stride + xpos * 8);
+ for (j = 0; j < width * 4; j++) {
+ float val = *color++ * value;
+ *acc++ += FLOAT_TO_SHORT(val);
+ }
+ }
+ }
+ break;
+ default:
+ _mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()");
}
- screen->tex_transfer_destroy(acc_trans);
- acc_trans = st_no_flush_get_tex_transfer(st, acc_strb->texture, 0, 0, 0,
- PIPE_TRANSFER_WRITE, xpos, ypos,
- width, height);
-
- acc_put_tile_rgba(pipe, acc_trans, 0, 0, width, height, accBuf);
-
- _mesa_free(colorBuf);
- _mesa_free(accBuf);
- screen->tex_transfer_destroy(acc_trans);
+ _mesa_free(buf);
screen->tex_transfer_destroy(color_trans);
}
@@ -249,13 +176,10 @@ accum_load(struct st_context *st, GLfloat value,
{
struct pipe_context *pipe = st->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_transfer *acc_trans, *color_trans;
+ struct pipe_transfer *color_trans;
+ size_t stride = acc_strb->stride;
+ GLubyte *data = acc_strb->data;
GLfloat *buf;
- GLint i;
-
- acc_trans = st_cond_flush_get_tex_transfer(st, acc_strb->texture, 0, 0, 0,
- PIPE_TRANSFER_WRITE, xpos, ypos,
- width, height);
color_trans = st_cond_flush_get_tex_transfer(st, color_strb->texture,
0, 0, 0,
@@ -266,14 +190,25 @@ accum_load(struct st_context *st, GLfloat value,
pipe_get_tile_rgba(color_trans, 0, 0, width, height, buf);
- for (i = 0; i < 4 * width * height; i++) {
- buf[i] = buf[i] * value;
+ switch (acc_strb->format) {
+ case PIPE_FORMAT_R16G16B16A16_SNORM:
+ {
+ const GLfloat *color = buf;
+ int i, j;
+ for (i = 0; i < height; i++) {
+ GLshort *acc = (GLshort *) (data + (ypos + i) * stride + xpos * 8);
+ for (j = 0; j < width * 4; j++) {
+ float val = *color++ * value;
+ *acc++ = FLOAT_TO_SHORT(val);
+ }
+ }
+ }
+ break;
+ default:
+ _mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()");
}
- acc_put_tile_rgba(pipe, acc_trans, 0, 0, width, height, buf);
-
_mesa_free(buf);
- screen->tex_transfer_destroy(acc_trans);
screen->tex_transfer_destroy(color_trans);
}
@@ -287,48 +222,58 @@ accum_return(GLcontext *ctx, GLfloat value,
struct pipe_context *pipe = ctx->st->pipe;
struct pipe_screen *screen = pipe->screen;
const GLubyte *colormask = ctx->Color.ColorMask;
- struct pipe_transfer *acc_trans, *color_trans;
- GLfloat *abuf, *cbuf = NULL;
- GLint i, ch;
-
- abuf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
+ enum pipe_transfer_usage usage;
+ struct pipe_transfer *color_trans;
+ size_t stride = acc_strb->stride;
+ const GLubyte *data = acc_strb->data;
+ GLfloat *buf;
- acc_trans = st_cond_flush_get_tex_transfer(st_context(ctx),
- acc_strb->texture, 0, 0, 0,
- PIPE_TRANSFER_READ, xpos, ypos,
- width, height);
+ buf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
+ if (!colormask[0] || !colormask[1] || !colormask[2] || !colormask[3])
+ usage = PIPE_TRANSFER_READ_WRITE;
+ else
+ usage = PIPE_TRANSFER_WRITE;
+
color_trans = st_cond_flush_get_tex_transfer(st_context(ctx),
color_strb->texture, 0, 0, 0,
- PIPE_TRANSFER_READ_WRITE,
+ usage,
xpos, ypos,
width, height);
- acc_get_tile_rgba(pipe, acc_trans, 0, 0, width, height, abuf);
-
- if (!colormask[0] || !colormask[1] || !colormask[2] || !colormask[3]) {
- cbuf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
- pipe_get_tile_rgba(color_trans, 0, 0, width, height, cbuf);
- }
+ if (usage != PIPE_TRANSFER_WRITE)
+ pipe_get_tile_rgba(color_trans, 0, 0, width, height, buf);
- for (i = 0; i < width * height; i++) {
- for (ch = 0; ch < 4; ch++) {
- if (colormask[ch]) {
- GLfloat val = abuf[i * 4 + ch] * value;
- abuf[i * 4 + ch] = CLAMP(val, 0.0f, 1.0f);
- }
- else {
- abuf[i * 4 + ch] = cbuf[i * 4 + ch];
+ switch (acc_strb->format) {
+ case PIPE_FORMAT_R16G16B16A16_SNORM:
+ {
+ GLfloat *color = buf;
+ int i, j, ch;
+ for (i = 0; i < height; i++) {
+ const GLshort *acc = (const GLshort *) (data + (ypos + i) * stride + xpos * 8);
+ for (j = 0; j < width; j++) {
+ for (ch = 0; ch < 4; ch++) {
+ if (colormask[ch]) {
+ GLfloat val = SHORT_TO_FLOAT(*acc * value);
+ *color = CLAMP(val, 0.0f, 1.0f);
+ }
+ else {
+ /* No change */
+ }
+ ++acc;
+ ++color;
+ }
+ }
}
}
+ break;
+ default:
+ _mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()");
}
- pipe_put_tile_rgba(color_trans, 0, 0, width, height, abuf);
+ pipe_put_tile_rgba(color_trans, 0, 0, width, height, buf);
- _mesa_free(abuf);
- if (cbuf)
- _mesa_free(cbuf);
- screen->tex_transfer_destroy(acc_trans);
+ _mesa_free(buf);
screen->tex_transfer_destroy(color_trans);
}
@@ -347,6 +292,9 @@ st_Accum(GLcontext *ctx, GLenum op, GLfloat value)
const GLint width = ctx->DrawBuffer->_Xmax - xpos;
const GLint height = ctx->DrawBuffer->_Ymax - ypos;
+ if(!acc_strb->data)
+ return;
+
/* make sure color bufs aren't cached */
st_flush( st, PIPE_FLUSH_RENDER_CACHE, NULL );
diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c
index a94e11fff12..19a0e673623 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -250,8 +250,8 @@ st_bufferobj_map_range(GLcontext *ctx, GLenum target,
map = obj->Pointer = pipe_buffer_map_range(pipe->screen, st_obj->buffer, offset, length, flags);
if(obj->Pointer) {
- obj->Offset = 0;
- obj->Length = obj->Size;
+ obj->Offset = offset;
+ obj->Length = length;
map += offset;
}
@@ -270,7 +270,6 @@ st_bufferobj_flush_mapped_range(GLcontext *ctx, GLenum target,
/* Subrange is relative to mapped range */
assert(offset >= 0);
assert(length >= 0);
- assert(offset < obj->Length);
assert(offset + length <= obj->Length);
pipe_buffer_flush_mapped_range(pipe->screen, st_obj->buffer,
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 880e83108c1..668acbccb88 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -103,20 +103,6 @@ st_destroy_clear(struct st_context *st)
}
-static GLboolean
-is_depth_stencil_format(enum pipe_format pipeFormat)
-{
- switch (pipeFormat) {
- case PIPE_FORMAT_S8Z24_UNORM:
- case PIPE_FORMAT_Z24S8_UNORM:
- return GL_TRUE;
- default:
- return GL_FALSE;
- }
-}
-
-
-
/**
* Draw a screen-aligned quadrilateral.
* Coords are window coords with y=0=bottom. These will be passed
@@ -331,7 +317,7 @@ static INLINE GLboolean
check_clear_depth_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
{
const struct st_renderbuffer *strb = st_renderbuffer(rb);
- const GLboolean isDS = is_depth_stencil_format(strb->surface->format);
+ const GLboolean isDS = pf_is_depth_and_stencil(strb->surface->format);
if (ctx->Scissor.Enabled)
return TRUE;
@@ -351,7 +337,7 @@ static INLINE GLboolean
check_clear_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
{
const struct st_renderbuffer *strb = st_renderbuffer(rb);
- const GLboolean isDS = is_depth_stencil_format(strb->surface->format);
+ const GLboolean isDS = pf_is_depth_and_stencil(strb->surface->format);
const GLuint stencilMax = (1 << rb->StencilBits) - 1;
const GLboolean maskStencil
= (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax;
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 89725cfe8dc..2027b713ce0 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -630,6 +630,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
struct pipe_context *pipe = st->pipe;
struct pipe_screen *screen = pipe->screen;
struct st_renderbuffer *strb;
+ enum pipe_transfer_usage usage;
struct pipe_transfer *pt;
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0 || ctx->Pixel.ZoomY != 1.0;
GLint skipPixels;
@@ -642,8 +643,14 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
y = ctx->DrawBuffer->Height - y - height;
}
+ if(format != GL_DEPTH_STENCIL &&
+ pf_get_component_bits( strb->format, PIPE_FORMAT_COMP_Z ) != 0)
+ usage = PIPE_TRANSFER_READ_WRITE;
+ else
+ usage = PIPE_TRANSFER_WRITE;
+
pt = st_cond_flush_get_tex_transfer(st_context(ctx), strb->texture, 0, 0, 0,
- PIPE_TRANSFER_WRITE, x, y,
+ usage, x, y,
width, height);
stmap = screen->transfer_map(screen, pt);
@@ -694,6 +701,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
case PIPE_FORMAT_S8_UNORM:
{
ubyte *dest = stmap + spanY * pt->stride + spanX;
+ assert(usage == PIPE_TRANSFER_WRITE);
memcpy(dest, sValues, spanWidth);
}
break;
@@ -701,6 +709,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
if (format == GL_DEPTH_STENCIL) {
uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4);
GLint k;
+ assert(usage == PIPE_TRANSFER_WRITE);
for (k = 0; k < spanWidth; k++) {
dest[k] = zValues[k] | (sValues[k] << 24);
}
@@ -708,6 +717,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
else {
uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4);
GLint k;
+ assert(usage == PIPE_TRANSFER_READ_WRITE);
for (k = 0; k < spanWidth; k++) {
dest[k] = (dest[k] & 0xffffff) | (sValues[k] << 24);
}
@@ -717,13 +727,15 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
if (format == GL_DEPTH_STENCIL) {
uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4);
GLint k;
+ assert(usage == PIPE_TRANSFER_WRITE);
for (k = 0; k < spanWidth; k++) {
- dest[k] = zValues[k] | (sValues[k] << 24);
+ dest[k] = (zValues[k] << 8) | (sValues[k] & 0xff);
}
}
else {
uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4);
GLint k;
+ assert(usage == PIPE_TRANSFER_READ_WRITE);
for (k = 0; k < spanWidth; k++) {
dest[k] = (dest[k] & 0xffffff00) | (sValues[k] & 0xff);
}
@@ -757,7 +769,6 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
struct st_vertex_program *stvp;
struct st_context *st = ctx->st;
struct pipe_surface *ps;
- GLuint bufferFormat;
const GLfloat *color;
if (format == GL_STENCIL_INDEX ||
@@ -785,8 +796,6 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
color = NULL;
}
- bufferFormat = ps->format;
-
/* draw with textured quad */
{
struct pipe_texture *pt
@@ -811,6 +820,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
{
struct st_renderbuffer *rbDraw = st_renderbuffer(ctx->DrawBuffer->_StencilBuffer);
struct pipe_screen *screen = ctx->st->pipe->screen;
+ enum pipe_transfer_usage usage;
struct pipe_transfer *ptDraw;
ubyte *drawMap;
ubyte *buffer;
@@ -827,9 +837,14 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
GL_STENCIL_INDEX, GL_UNSIGNED_BYTE,
&ctx->DefaultPacking, buffer);
+ if(pf_get_component_bits( rbDraw->format, PIPE_FORMAT_COMP_Z ) != 0)
+ usage = PIPE_TRANSFER_READ_WRITE;
+ else
+ usage = PIPE_TRANSFER_WRITE;
+
ptDraw = st_cond_flush_get_tex_transfer(st_context(ctx),
rbDraw->texture, 0, 0, 0,
- PIPE_TRANSFER_WRITE, dstx, dsty,
+ usage, dstx, dsty,
width, height);
assert(ptDraw->block.width == 1);
@@ -859,6 +874,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
{
uint *dst4 = (uint *) dst;
int j;
+ assert(usage == PIPE_TRANSFER_READ_WRITE);
for (j = 0; j < width; j++) {
*dst4 = (*dst4 & 0xffffff) | (src[j] << 24);
dst4++;
@@ -869,6 +885,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
{
uint *dst4 = (uint *) dst;
int j;
+ assert(usage == PIPE_TRANSFER_READ_WRITE);
for (j = 0; j < width; j++) {
*dst4 = (*dst4 & 0xffffff00) | (src[j] & 0xff);
dst4++;
@@ -876,6 +893,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
}
break;
case PIPE_FORMAT_S8_UNORM:
+ assert(usage == PIPE_TRANSFER_WRITE);
memcpy(dst, src, width);
break;
default:
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index e003b6db5cf..21ddf2fc7a2 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -88,91 +88,90 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
{
struct pipe_context *pipe = ctx->st->pipe;
struct st_renderbuffer *strb = st_renderbuffer(rb);
- struct pipe_texture template;
- unsigned surface_usage;
-
- /* Free the old surface and texture
- */
- pipe_surface_reference( &strb->surface, NULL );
- pipe_texture_reference( &strb->texture, NULL );
-
- /* Setup new texture template.
- */
- memset(&template, 0, sizeof(template));
- template.target = PIPE_TEXTURE_2D;
- if (strb->format != PIPE_FORMAT_NONE) {
- template.format = strb->format;
- }
- else {
- template.format = st_choose_renderbuffer_format(pipe, internalFormat);
- }
- pf_get_block(template.format, &template.block);
- template.width[0] = width;
- template.height[0] = height;
- template.depth[0] = 1;
- template.last_level = 0;
- template.nr_samples = rb->NumSamples;
- if (pf_is_depth_stencil(template.format)) {
- template.tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
- }
- else {
- template.tex_usage = (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
- PIPE_TEXTURE_USAGE_RENDER_TARGET);
- }
+ enum pipe_format format;
+ if (strb->format != PIPE_FORMAT_NONE)
+ format = strb->format;
+ else
+ format = st_choose_renderbuffer_format(pipe, internalFormat);
+
/* init renderbuffer fields */
strb->Base.Width = width;
strb->Base.Height = height;
- init_renderbuffer_bits(strb, template.format);
-
- /* Probably need dedicated flags for surface usage too:
- */
- surface_usage = (PIPE_BUFFER_USAGE_GPU_READ |
- PIPE_BUFFER_USAGE_GPU_WRITE);
-#if 0
- PIPE_BUFFER_USAGE_CPU_READ |
- PIPE_BUFFER_USAGE_CPU_WRITE);
-#endif
-
- strb->texture = pipe->screen->texture_create( pipe->screen,
- &template );
+ init_renderbuffer_bits(strb, format);
+
+ if(strb->software) {
+ struct pipe_format_block block;
+ size_t size;
+
+ _mesa_free(strb->data);
+
+ assert(strb->format != PIPE_FORMAT_NONE);
+ pf_get_block(strb->format, &block);
+
+ strb->stride = pf_get_stride(&block, width);
+ size = pf_get_2d_size(&block, strb->stride, height);
+
+ strb->data = _mesa_malloc(size);
+
+ return strb->data != NULL;
+ }
+ else {
+ struct pipe_texture template;
+ unsigned surface_usage;
+
+ /* Free the old surface and texture
+ */
+ pipe_surface_reference( &strb->surface, NULL );
+ pipe_texture_reference( &strb->texture, NULL );
- /* Special path for accum buffers.
- *
- * Try a different surface format. Since accum buffers are s/w
- * only for now, the surface pixel format doesn't really matter,
- * only that the buffer is large enough.
- */
- if (!strb->texture && template.format == DEFAULT_ACCUM_PIPE_FORMAT)
- {
- /* Actually, just setting this usage value should be sufficient
- * to tell the driver to go ahead and allocate the buffer, even
- * if HW doesn't support the format.
+ /* Setup new texture template.
+ */
+ memset(&template, 0, sizeof(template));
+ template.target = PIPE_TEXTURE_2D;
+ template.format = format;
+ pf_get_block(format, &template.block);
+ template.width[0] = width;
+ template.height[0] = height;
+ template.depth[0] = 1;
+ template.last_level = 0;
+ template.nr_samples = rb->NumSamples;
+ if (pf_is_depth_stencil(format)) {
+ template.tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
+ }
+ else {
+ template.tex_usage = (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
+ PIPE_TEXTURE_USAGE_RENDER_TARGET);
+ }
+
+ /* Probably need dedicated flags for surface usage too:
*/
- template.tex_usage = 0;
- surface_usage = (PIPE_BUFFER_USAGE_CPU_READ |
+ surface_usage = (PIPE_BUFFER_USAGE_GPU_READ |
+ PIPE_BUFFER_USAGE_GPU_WRITE);
+#if 0
+ PIPE_BUFFER_USAGE_CPU_READ |
PIPE_BUFFER_USAGE_CPU_WRITE);
+#endif
strb->texture = pipe->screen->texture_create( pipe->screen,
&template );
- }
-
- if (!strb->texture)
- return FALSE;
+ if (!strb->texture)
+ return FALSE;
- strb->surface = pipe->screen->get_tex_surface( pipe->screen,
- strb->texture,
- 0, 0, 0,
- surface_usage );
+ strb->surface = pipe->screen->get_tex_surface( pipe->screen,
+ strb->texture,
+ 0, 0, 0,
+ surface_usage );
- assert(strb->surface->texture);
- assert(strb->surface->format);
- assert(strb->surface->width == width);
- assert(strb->surface->height == height);
+ assert(strb->surface->texture);
+ assert(strb->surface->format);
+ assert(strb->surface->width == width);
+ assert(strb->surface->height == height);
- return strb->surface != NULL;
+ return strb->surface != NULL;
+ }
}
@@ -186,6 +185,7 @@ st_renderbuffer_delete(struct gl_renderbuffer *rb)
ASSERT(strb);
pipe_surface_reference(&strb->surface, NULL);
pipe_texture_reference(&strb->texture, NULL);
+ _mesa_free(strb->data);
_mesa_free(strb);
}
@@ -242,7 +242,7 @@ st_new_renderbuffer(GLcontext *ctx, GLuint name)
* renderbuffer). The window system code determines the format.
*/
struct gl_renderbuffer *
-st_new_renderbuffer_fb(enum pipe_format format, int samples)
+st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw)
{
struct st_renderbuffer *strb;
@@ -256,7 +256,8 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples)
strb->Base.ClassID = 0x4242; /* just a unique value */
strb->Base.NumSamples = samples;
strb->format = format;
-
+ strb->software = sw;
+
switch (format) {
case PIPE_FORMAT_A8R8G8B8_UNORM:
case PIPE_FORMAT_B8G8R8A8_UNORM:
@@ -287,7 +288,7 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples)
strb->Base.InternalFormat = GL_STENCIL_INDEX8_EXT;
strb->Base._BaseFormat = GL_STENCIL_INDEX;
break;
- case DEFAULT_ACCUM_PIPE_FORMAT: /*PIPE_FORMAT_R16G16B16A16_SNORM*/
+ case PIPE_FORMAT_R16G16B16A16_SNORM:
strb->Base.InternalFormat = GL_RGBA16;
strb->Base._BaseFormat = GL_RGBA;
break;
diff --git a/src/mesa/state_tracker/st_cb_fbo.h b/src/mesa/state_tracker/st_cb_fbo.h
index 44fa9fe9a4f..9a199550d9f 100644
--- a/src/mesa/state_tracker/st_cb_fbo.h
+++ b/src/mesa/state_tracker/st_cb_fbo.h
@@ -30,10 +30,6 @@
#define ST_CB_FBO_H
-#define DEFAULT_ACCUM_PIPE_FORMAT PIPE_FORMAT_R16G16B16A16_SNORM
-
-
-
/**
* Derived renderbuffer class. Just need to add a pointer to the
* pipe surface.
@@ -45,6 +41,13 @@ struct st_renderbuffer
struct pipe_surface *surface; /* temporary view into texture */
enum pipe_format format; /** preferred format, or PIPE_FORMAT_NONE */
+ /**
+ * Used only when hardware accumulation buffers are not supported.
+ */
+ boolean software;
+ size_t stride;
+ void *data;
+
struct st_texture_object *rtt; /**< GL render to texture's texture */
int rtt_level, rtt_face, rtt_slice;
@@ -62,7 +65,7 @@ st_renderbuffer(struct gl_renderbuffer *rb)
extern struct gl_renderbuffer *
-st_new_renderbuffer_fb(enum pipe_format format, int samples);
+st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw);
extern void
st_init_fbo_functions(struct dd_function_table *functions);
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index 7a4bbf5ce3a..ccf1a0b5634 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -112,7 +112,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
case PIPE_FORMAT_S8Z24_UNORM:
if (format == GL_DEPTH_STENCIL) {
const uint *src = (uint *) (stmap + srcY * pt->stride);
- const GLfloat scale = 1.0 / (0xffffff);
+ const GLfloat scale = 1.0f / (0xffffff);
GLint k;
for (k = 0; k < width; k++) {
sValues[k] = src[k] >> 24;
@@ -130,7 +130,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
case PIPE_FORMAT_Z24S8_UNORM:
if (format == GL_DEPTH_STENCIL) {
const uint *src = (uint *) (stmap + srcY * pt->stride);
- const GLfloat scale = 1.0 / (0xffffff);
+ const GLfloat scale = 1.0f / (0xffffff);
GLint k;
for (k = 0; k < width; k++) {
sValues[k] = src[k] & 0xff;
@@ -445,11 +445,16 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
}
}
else {
- /* untested, but simple: */
+ /* XXX: unreachable code -- should be before st_read_stencil_pixels */
assert(format == GL_DEPTH_STENCIL_EXT);
for (i = 0; i < height; i++) {
+ GLuint *zshort = (GLuint *)dst;
pipe_get_tile_raw(trans, 0, y, width, 1, dst, 0);
y += yStep;
+ /* Reverse into 24/8 */
+ for (j = 0; j < width; j++) {
+ zshort[j] = (zshort[j] << 8) | (zshort[j] >> 24);
+ }
dst += dstStride;
}
}
@@ -472,7 +477,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
}
}
else {
- /* untested, but simple: */
+ /* XXX: unreachable code -- should be before st_read_stencil_pixels */
assert(format == GL_DEPTH_STENCIL_EXT);
for (i = 0; i < height; i++) {
pipe_get_tile_raw(trans, 0, y, width, 1, dst, 0);
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 92ddffc0148..8514b6b3756 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -274,20 +274,11 @@ st_make_current(struct st_context *st,
_glapi_check_multithread();
if (st) {
- GLboolean firstTime = st->ctx->FirstTimeCurrent;
- if(!_mesa_make_current(st->ctx, &draw->Base, &read->Base))
+ if (!_mesa_make_current(st->ctx, &draw->Base, &read->Base))
return GL_FALSE;
- /* Need to initialize viewport here since draw->Base->Width/Height
- * will still be zero at this point.
- * This could be improved, but would require rather extensive work
- * elsewhere (allocate rb surface storage sooner)
- */
- if (firstTime) {
- GLuint w = draw->InitWidth, h = draw->InitHeight;
- _mesa_set_viewport(st->ctx, 0, 0, w, h);
- _mesa_set_scissor(st->ctx, 0, 0, w, h);
- }
+ _mesa_check_init_viewport(st->ctx, draw->InitWidth, draw->InitHeight);
+
return GL_TRUE;
}
else {
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 8f6be507742..e6728ae8955 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -120,6 +120,11 @@ void st_init_limits(struct st_context *st)
c->MaxDrawBuffers
= CLAMP(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS),
1, MAX_DRAW_BUFFERS);
+
+ /* Is TGSI_OPCODE_CONT supported? */
+ /* XXX separate query for early function return? */
+ st->ctx->Shader.EmitContReturn =
+ screen->get_param(screen, PIPE_CAP_TGSI_CONT_SUPPORTED);
}
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index d507e3e58dd..b243c249e37 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -392,7 +392,7 @@ default_depth_format(struct pipe_screen *screen,
* or PIPE_TEXTURE_USAGE_SAMPLER
*/
enum pipe_format
-st_choose_format(struct pipe_context *pipe, GLint internalFormat,
+st_choose_format(struct pipe_context *pipe, GLenum internalFormat,
enum pipe_texture_target target, unsigned tex_usage)
{
struct pipe_screen *screen = pipe->screen;
@@ -594,9 +594,13 @@ st_choose_format(struct pipe_context *pipe, GLint internalFormat,
static GLboolean
-is_stencil_format(GLenum format)
+is_depth_or_stencil_format(GLenum internalFormat)
{
- switch (format) {
+ switch (internalFormat) {
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_COMPONENT16:
+ case GL_DEPTH_COMPONENT24:
+ case GL_DEPTH_COMPONENT32:
case GL_STENCIL_INDEX:
case GL_STENCIL_INDEX1_EXT:
case GL_STENCIL_INDEX4_EXT:
@@ -614,10 +618,10 @@ is_stencil_format(GLenum format)
* Called by FBO code to choose a PIPE_FORMAT_ for drawing surfaces.
*/
enum pipe_format
-st_choose_renderbuffer_format(struct pipe_context *pipe, GLint internalFormat)
+st_choose_renderbuffer_format(struct pipe_context *pipe, GLenum internalFormat)
{
uint usage;
- if (is_stencil_format(internalFormat))
+ if (is_depth_or_stencil_format(internalFormat))
usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
else
usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h
index 7bbbe2d5704..9d9e02fe9b6 100644
--- a/src/mesa/state_tracker/st_format.h
+++ b/src/mesa/state_tracker/st_format.h
@@ -64,11 +64,11 @@ st_mesa_format_to_pipe_format(GLuint mesaFormat);
extern enum pipe_format
-st_choose_format(struct pipe_context *pipe, GLint internalFormat,
+st_choose_format(struct pipe_context *pipe, GLenum internalFormat,
enum pipe_texture_target target, unsigned tex_usage);
extern enum pipe_format
-st_choose_renderbuffer_format(struct pipe_context *pipe, GLint internalFormat);
+st_choose_renderbuffer_format(struct pipe_context *pipe, GLenum internalFormat);
extern const struct gl_texture_format *
diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c
index daaad65ccaf..33a90ea7db6 100644
--- a/src/mesa/state_tracker/st_framebuffer.c
+++ b/src/mesa/state_tracker/st_framebuffer.c
@@ -63,20 +63,20 @@ st_create_framebuffer( const __GLcontextModes *visual,
/* XXX allocation should only happen in the unusual case
it's actually needed */
struct gl_renderbuffer *rb
- = st_new_renderbuffer_fb(colorFormat, samples);
+ = st_new_renderbuffer_fb(colorFormat, samples, FALSE);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_FRONT_LEFT, rb);
}
if (visual->doubleBufferMode) {
struct gl_renderbuffer *rb
- = st_new_renderbuffer_fb(colorFormat, samples);
+ = st_new_renderbuffer_fb(colorFormat, samples, FALSE);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_BACK_LEFT, rb);
}
if (depthFormat == stencilFormat && depthFormat != PIPE_FORMAT_NONE) {
/* combined depth/stencil buffer */
struct gl_renderbuffer *depthStencilRb
- = st_new_renderbuffer_fb(depthFormat, samples);
+ = st_new_renderbuffer_fb(depthFormat, samples, FALSE);
/* note: bind RB to two attachment points */
_mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthStencilRb);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL, depthStencilRb);
@@ -87,34 +87,35 @@ st_create_framebuffer( const __GLcontextModes *visual,
if (visual->depthBits == 32) {
/* 32-bit depth buffer */
struct gl_renderbuffer *depthRb
- = st_new_renderbuffer_fb(depthFormat, samples);
+ = st_new_renderbuffer_fb(depthFormat, samples, FALSE);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthRb);
}
else if (visual->depthBits == 24) {
/* 24-bit depth buffer, ignore stencil bits */
struct gl_renderbuffer *depthRb
- = st_new_renderbuffer_fb(depthFormat, samples);
+ = st_new_renderbuffer_fb(depthFormat, samples, FALSE);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthRb);
}
else if (visual->depthBits > 0) {
/* 16-bit depth buffer */
struct gl_renderbuffer *depthRb
- = st_new_renderbuffer_fb(depthFormat, samples);
+ = st_new_renderbuffer_fb(depthFormat, samples, FALSE);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthRb);
}
if (visual->stencilBits > 0) {
/* 8-bit stencil */
struct gl_renderbuffer *stencilRb
- = st_new_renderbuffer_fb(stencilFormat, samples);
+ = st_new_renderbuffer_fb(stencilFormat, samples, FALSE);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL, stencilRb);
}
}
if (visual->accumRedBits > 0) {
/* 16-bit/channel accum */
+ /* TODO: query the pipe screen for accumulation buffer format support */
struct gl_renderbuffer *accumRb
- = st_new_renderbuffer_fb(DEFAULT_ACCUM_PIPE_FORMAT, 0); /* XXX accum isn't multisampled right? */
+ = st_new_renderbuffer_fb(PIPE_FORMAT_R16G16B16A16_SNORM, 0, TRUE);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_ACCUM, accumRb);
}
@@ -133,16 +134,7 @@ void st_resize_framebuffer( struct st_framebuffer *stfb,
if (stfb->Base.Width != width || stfb->Base.Height != height) {
GET_CURRENT_CONTEXT(ctx);
if (ctx) {
- if (stfb->InitWidth == 0 && stfb->InitHeight == 0) {
- /* didn't have a valid size until now */
- stfb->InitWidth = width;
- stfb->InitHeight = height;
- if (ctx->Viewport.Width <= 1) {
- /* set context's initial viewport/scissor size */
- _mesa_set_viewport(ctx, 0, 0, width, height);
- _mesa_set_scissor(ctx, 0, 0, width, height);
- }
- }
+ _mesa_check_init_viewport(ctx, width, height);
_mesa_resize_framebuffer(ctx, &stfb->Base, width, height);
diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c
index dc6d77825f5..58f69336523 100644
--- a/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/src/mesa/state_tracker/st_gen_mipmap.c
@@ -198,9 +198,6 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
return;
}
- if (dstImage->ImageOffsets)
- _mesa_free(dstImage->ImageOffsets);
-
/* Free old image data */
if (dstImage->Data)
ctx->Driver.FreeTexImageData(ctx, dstImage);
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 34926101ed0..72ca8524582 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -55,20 +55,6 @@
#define TGSI_DEBUG 0
-/** XXX we should use the version of this from u_memory.h but including
- * that header causes symbol collisions.
- */
-static INLINE void *
-mem_dup(const void *src, uint size)
-{
- void *dup = _mesa_malloc(size);
- if (dup)
- _mesa_memcpy(dup, src, size);
- return dup;
-}
-
-
-
/**
* Translate a Mesa vertex shader into a TGSI shader.
* \param outputMapping to map vertex program output registers (VERT_RESULT_x)
@@ -84,7 +70,7 @@ st_translate_vertex_program(struct st_context *st,
const ubyte *outputSemanticIndex)
{
struct pipe_context *pipe = st->pipe;
- struct tgsi_token tokens[ST_MAX_SHADER_TOKENS];
+ struct tgsi_token *tokens;
GLuint defaultOutputMapping[VERT_RESULT_MAX];
struct pipe_shader_state vs;
GLuint attr, i;
@@ -102,6 +88,13 @@ st_translate_vertex_program(struct st_context *st,
GLbitfield input_flags[MAX_PROGRAM_INPUTS];
GLbitfield output_flags[MAX_PROGRAM_OUTPUTS];
+ tokens = (struct tgsi_token *)MALLOC(ST_MAX_SHADER_TOKENS * sizeof *tokens);
+ if(!tokens) {
+ /* FIXME: propagate error to the caller */
+ assert(0);
+ return;
+ }
+
memset(&vs, 0, sizeof(vs));
memset(input_flags, 0, sizeof(input_flags));
memset(output_flags, 0, sizeof(output_flags));
@@ -297,9 +290,6 @@ st_translate_vertex_program(struct st_context *st,
}
}
- assert(vs_output_semantic_name[0] == TGSI_SEMANTIC_POSITION);
-
-
if (outputMapping) {
/* find max output slot referenced to compute vs_num_outputs */
GLuint maxSlot = 0;
@@ -347,7 +337,9 @@ st_translate_vertex_program(struct st_context *st,
assert(num_tokens < ST_MAX_SHADER_TOKENS);
vs.tokens = (struct tgsi_token *)
- mem_dup(tokens, num_tokens * sizeof(tokens[0]));
+ _mesa_realloc(tokens,
+ ST_MAX_SHADER_TOKENS * sizeof *tokens,
+ num_tokens * sizeof *tokens);
stvp->num_inputs = vs_num_inputs;
stvp->state = vs; /* struct copy */
@@ -375,7 +367,7 @@ st_translate_fragment_program(struct st_context *st,
const GLuint inputMapping[])
{
struct pipe_context *pipe = st->pipe;
- struct tgsi_token tokens[ST_MAX_SHADER_TOKENS];
+ struct tgsi_token *tokens;
GLuint outputMapping[FRAG_RESULT_MAX];
GLuint defaultInputMapping[FRAG_ATTRIB_MAX];
struct pipe_shader_state fs;
@@ -395,6 +387,13 @@ st_translate_fragment_program(struct st_context *st,
GLbitfield input_flags[MAX_PROGRAM_INPUTS];
GLbitfield output_flags[MAX_PROGRAM_OUTPUTS];
+ tokens = (struct tgsi_token *)MALLOC(ST_MAX_SHADER_TOKENS * sizeof *tokens);
+ if(!tokens) {
+ /* FIXME: propagate error to the caller */
+ assert(0);
+ return;
+ }
+
memset(&fs, 0, sizeof(fs));
memset(input_flags, 0, sizeof(input_flags));
memset(output_flags, 0, sizeof(output_flags));
@@ -536,7 +535,9 @@ st_translate_fragment_program(struct st_context *st,
assert(num_tokens < ST_MAX_SHADER_TOKENS);
fs.tokens = (struct tgsi_token *)
- mem_dup(tokens, num_tokens * sizeof(tokens[0]));
+ _mesa_realloc(tokens,
+ ST_MAX_SHADER_TOKENS * sizeof *tokens,
+ num_tokens * sizeof *tokens);
stfp->state = fs; /* struct copy */
stfp->driver_shader = pipe->create_fs_state(pipe, &fs);
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index f24f4fc59b2..e7c2ace32c7 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -289,6 +289,7 @@ _swrast_update_specular_vertex_add(GLcontext *ctx)
#define _SWRAST_NEW_DERIVED (_SWRAST_NEW_RASTERMASK | \
+ _NEW_PROGRAM_CONSTANTS | \
_NEW_TEXTURE | \
_NEW_HINT | \
_NEW_POLYGON )
diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c
index 31bfb5c9520..dd59314cd96 100644
--- a/src/mesa/swrast/s_texfilter.c
+++ b/src/mesa/swrast/s_texfilter.c
@@ -138,7 +138,7 @@ lerp_rgba_3d(GLfloat result[4], GLfloat a, GLfloat b, GLfloat c,
* If A is a signed integer, A % B doesn't give the right value for A < 0
* (in terms of texture repeat). Just casting to unsigned fixes that.
*/
-#define REMAINDER(A, B) ((unsigned) (A) % (unsigned) (B))
+#define REMAINDER(A, B) (((A) + (B) * 1024) % (B))
/**
diff --git a/src/mesa/vbo/vbo_attrib_tmp.h b/src/mesa/vbo/vbo_attrib_tmp.h
index ff11c7d59a7..7a889b8e2f8 100644
--- a/src/mesa/vbo/vbo_attrib_tmp.h
+++ b/src/mesa/vbo/vbo_attrib_tmp.h
@@ -265,7 +265,7 @@ static void GLAPIENTRY TAG(VertexAttrib1fARB)( GLuint index, GLfloat x )
GET_CURRENT_CONTEXT( ctx );
if (index == 0)
ATTR1F(0, x);
- else if (index < MAX_VERTEX_ATTRIBS)
+ else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR1F(VBO_ATTRIB_GENERIC0 + index, x);
else
ERROR();
@@ -277,7 +277,7 @@ static void GLAPIENTRY TAG(VertexAttrib1fvARB)( GLuint index,
GET_CURRENT_CONTEXT( ctx );
if (index == 0)
ATTR1FV(0, v);
- else if (index < MAX_VERTEX_ATTRIBS)
+ else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR1FV(VBO_ATTRIB_GENERIC0 + index, v);
else
ERROR();
@@ -289,7 +289,7 @@ static void GLAPIENTRY TAG(VertexAttrib2fARB)( GLuint index, GLfloat x,
GET_CURRENT_CONTEXT( ctx );
if (index == 0)
ATTR2F(0, x, y);
- else if (index < MAX_VERTEX_ATTRIBS)
+ else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR2F(VBO_ATTRIB_GENERIC0 + index, x, y);
else
ERROR();
@@ -301,7 +301,7 @@ static void GLAPIENTRY TAG(VertexAttrib2fvARB)( GLuint index,
GET_CURRENT_CONTEXT( ctx );
if (index == 0)
ATTR2FV(0, v);
- else if (index < MAX_VERTEX_ATTRIBS)
+ else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR2FV(VBO_ATTRIB_GENERIC0 + index, v);
else
ERROR();
@@ -313,7 +313,7 @@ static void GLAPIENTRY TAG(VertexAttrib3fARB)( GLuint index, GLfloat x,
GET_CURRENT_CONTEXT( ctx );
if (index == 0)
ATTR3F(0, x, y, z);
- else if (index < MAX_VERTEX_ATTRIBS)
+ else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR3F(VBO_ATTRIB_GENERIC0 + index, x, y, z);
else
ERROR();
@@ -325,7 +325,7 @@ static void GLAPIENTRY TAG(VertexAttrib3fvARB)( GLuint index,
GET_CURRENT_CONTEXT( ctx );
if (index == 0)
ATTR3FV(0, v);
- else if (index < MAX_VERTEX_ATTRIBS)
+ else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR3FV(VBO_ATTRIB_GENERIC0 + index, v);
else
ERROR();
@@ -338,7 +338,7 @@ static void GLAPIENTRY TAG(VertexAttrib4fARB)( GLuint index, GLfloat x,
GET_CURRENT_CONTEXT( ctx );
if (index == 0)
ATTR4F(0, x, y, z, w);
- else if (index < MAX_VERTEX_ATTRIBS)
+ else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR4F(VBO_ATTRIB_GENERIC0 + index, x, y, z, w);
else
ERROR();
@@ -350,7 +350,7 @@ static void GLAPIENTRY TAG(VertexAttrib4fvARB)( GLuint index,
GET_CURRENT_CONTEXT( ctx );
if (index == 0)
ATTR4FV(0, v);
- else if (index < MAX_VERTEX_ATTRIBS)
+ else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
ATTR4FV(VBO_ATTRIB_GENERIC0 + index, v);
else
ERROR();
diff --git a/src/mesa/vbo/vbo_context.h b/src/mesa/vbo/vbo_context.h
index bf405eb6933..5c85161caa5 100644
--- a/src/mesa/vbo/vbo_context.h
+++ b/src/mesa/vbo/vbo_context.h
@@ -102,6 +102,8 @@ static INLINE GLuint get_program_mode( GLcontext *ctx )
{
if (!ctx->VertexProgram._Current)
return VP_NONE;
+ else if (ctx->VertexProgram._Current == ctx->VertexProgram._TnlProgram)
+ return VP_NONE;
else if (ctx->VertexProgram._Current->IsNVProgram)
return VP_NV;
else
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index 5d35ec9c111..34e849aaab7 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -51,6 +51,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#endif
+/** ID/name for immediate-mode VBO */
+#define IMM_BUFFER_NAME 0xaabbccdd
+
+
static void reset_attrfv( struct vbo_exec_context *exec );
@@ -665,7 +669,7 @@ void vbo_use_buffer_objects(GLcontext *ctx)
/* Any buffer name but 0 can be used here since this bufferobj won't
* go into the bufferobj hashtable.
*/
- GLuint bufName = 0xaabbccdd;
+ GLuint bufName = IMM_BUFFER_NAME;
GLenum target = GL_ARRAY_BUFFER_ARB;
GLenum usage = GL_STREAM_DRAW_ARB;
GLsizei size = VBO_VERT_BUFFER_SIZE;
@@ -727,19 +731,33 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec )
void vbo_exec_vtx_destroy( struct vbo_exec_context *exec )
{
- if (exec->vtx.bufferobj->Name) {
- /* using a real VBO for vertex data */
- GLcontext *ctx = exec->ctx;
- _mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, NULL);
- }
- else {
- /* just using malloc'd space for vertex data */
- if (exec->vtx.buffer_map) {
+ /* using a real VBO for vertex data */
+ GLcontext *ctx = exec->ctx;
+ unsigned i;
+
+ /* True VBOs should already be unmapped
+ */
+ if (exec->vtx.buffer_map) {
+ ASSERT(exec->vtx.bufferobj->Name == 0 ||
+ exec->vtx.bufferobj->Name == IMM_BUFFER_NAME);
+ if (exec->vtx.bufferobj->Name == 0) {
ALIGN_FREE(exec->vtx.buffer_map);
exec->vtx.buffer_map = NULL;
exec->vtx.buffer_ptr = NULL;
}
}
+
+ /* Drop any outstanding reference to the vertex buffer
+ */
+ for (i = 0; i < Elements(exec->vtx.arrays); i++) {
+ _mesa_reference_buffer_object(ctx,
+ &exec->vtx.arrays[i].BufferObj,
+ NULL);
+ }
+
+ /* Free the vertex buffer:
+ */
+ _mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, NULL);
}
void vbo_exec_BeginVertices( GLcontext *ctx )
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 65fe197a4d7..de66cdd92fd 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -118,7 +118,7 @@ static void bind_array_obj( GLcontext *ctx )
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++)
exec->array.legacy_array[VERT_ATTRIB_TEX0 + i] = &arrayObj->TexCoord[i];
- for (i = 0; i < MAX_VERTEX_ATTRIBS; i++) {
+ for (i = 0; i < MAX_VERTEX_GENERIC_ATTRIBS; i++) {
assert(i < Elements(arrayObj->VertexAttrib));
assert(i < Elements(exec->array.generic_array));
exec->array.generic_array[i] = &arrayObj->VertexAttrib[i];
@@ -219,7 +219,7 @@ static void recalculate_input_bindings( GLcontext *ctx )
}
}
- for (i = 0; i < MAX_VERTEX_ATTRIBS; i++) {
+ for (i = 0; i < MAX_VERTEX_GENERIC_ATTRIBS; i++) {
if (exec->array.generic_array[i]->Enabled)
inputs[VERT_ATTRIB_GENERIC0 + i] = exec->array.generic_array[i];
else {