Search
lxdream.org :: lxdream :: r653:3202ff01d48e
lxdream 0.9.1
released Jun 29
Download Now
changeset653:3202ff01d48e
parent644:ccae4bfa5f82
child654:d40b3b68fbdf
authornkeynes
dateFri Mar 28 12:32:25 2008 +0000 (16 years ago)
Merge lxdream-render branch (643:670) to trunk
Makefile.in
config.h.in
configure
configure.in
src/Makefile.am
src/Makefile.in
src/drivers/fragment.glsl
src/drivers/gl_common.c
src/drivers/gl_common.h
src/drivers/gl_fbo.c
src/drivers/gl_sl.c
src/drivers/gl_slsrc.c
src/drivers/vertex.glsl
src/drivers/video_gdk.c
src/drivers/video_gl.c
src/drivers/video_gl.h
src/drivers/video_glx.c
src/drivers/video_gtk.c
src/gtkui/main_win.c
src/pvr2/fragment.glsl
src/pvr2/gl_sl.c
src/pvr2/gl_slsrc.c
src/pvr2/glrender.c
src/pvr2/glutil.c
src/pvr2/glutil.h
src/pvr2/pvr2.c
src/pvr2/pvr2.h
src/pvr2/pvr2mem.c
src/pvr2/pvr2mmio.h
src/pvr2/rendbkg.c
src/pvr2/rendcore.c
src/pvr2/render.c
src/pvr2/rendsort.c
src/pvr2/scene.c
src/pvr2/scene.h
src/pvr2/tacore.c
src/pvr2/texcache.c
src/pvr2/vertex.glsl
1.1 --- a/Makefile.in Sun Mar 02 11:38:08 2008 +0000
1.2 +++ b/Makefile.in Fri Mar 28 12:32:25 2008 +0000
1.3 @@ -37,12 +37,16 @@
1.4 POST_UNINSTALL = :
1.5 host_triplet = @host@
1.6 ACLOCAL = @ACLOCAL@
1.7 +ALSA_CFLAGS = @ALSA_CFLAGS@
1.8 +ALSA_LIBS = @ALSA_LIBS@
1.9 AMDEP_FALSE = @AMDEP_FALSE@
1.10 AMDEP_TRUE = @AMDEP_TRUE@
1.11 AMTAR = @AMTAR@
1.12 ARMCC = @ARMCC@
1.13 ARMLD = @ARMLD@
1.14 ARMOBJCOPY = @ARMOBJCOPY@
1.15 +AUDIO_ALSA_FALSE = @AUDIO_ALSA_FALSE@
1.16 +AUDIO_ALSA_TRUE = @AUDIO_ALSA_TRUE@
1.17 AUDIO_ESOUND_FALSE = @AUDIO_ESOUND_FALSE@
1.18 AUDIO_ESOUND_TRUE = @AUDIO_ESOUND_TRUE@
1.19 AUTOCONF = @AUTOCONF@
1.20 @@ -111,6 +115,8 @@
1.21 MSGFMT = @MSGFMT@
1.22 MSGFMT_OPTS = @MSGFMT_OPTS@
1.23 OBJEXT = @OBJEXT@
1.24 +OSMESA_DRIVER_FALSE = @OSMESA_DRIVER_FALSE@
1.25 +OSMESA_DRIVER_TRUE = @OSMESA_DRIVER_TRUE@
1.26 PACKAGE = @PACKAGE@
1.27 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
1.28 PACKAGE_NAME = @PACKAGE_NAME@
2.1 --- a/config.h.in Sun Mar 02 11:38:08 2008 +0000
2.2 +++ b/config.h.in Fri Mar 28 12:32:25 2008 +0000
2.3 @@ -52,6 +52,9 @@
2.4 /* Define to 1 if you have the `GL' library (-lGL). */
2.5 #undef HAVE_LIBGL
2.6
2.7 +/* Define to 1 if you have the `OSMesa' library (-lOSMesa). */
2.8 +#undef HAVE_LIBOSMESA
2.9 +
2.10 /* Define to 1 if you have the `z' library (-lz). */
2.11 #undef HAVE_LIBZ
2.12
3.1 --- a/configure Sun Mar 02 11:38:08 2008 +0000
3.2 +++ b/configure Fri Mar 28 12:32:25 2008 +0000
3.3 @@ -700,6 +700,8 @@
3.4 host_cpu
3.5 host_vendor
3.6 host_os
3.7 +OSMESA_DRIVER_TRUE
3.8 +OSMESA_DRIVER_FALSE
3.9 PKG_CONFIG
3.10 LIBPNG_CFLAGS
3.11 LIBPNG_LIBS
3.12 @@ -1359,6 +1361,12 @@
3.13 --enable-watch Enable watchpoints in the debugger (warning: hurts
3.14 performance)
3.15
3.16 +Optional Packages:
3.17 + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
3.18 + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
3.19 + --with-osmesa Build with the osmesa GL library (software
3.20 + rendering)
3.21 +
3.22 Some influential environment variables:
3.23 CC C compiler command
3.24 CFLAGS C compiler flags
3.25 @@ -4991,6 +4999,15 @@
3.26 fi
3.27 fi
3.28
3.29 +
3.30 +# Check whether --with-osmesa was given.
3.31 +if test "${with_osmesa+set}" = set; then
3.32 + withval=$with_osmesa;
3.33 +else
3.34 + with_osmesa=no
3.35 +fi
3.36 +
3.37 +
3.38 # On IRIX 5.3, sys/types and inttypes.h are conflicting.
3.39
3.40
3.41 @@ -5060,6 +5077,235 @@
3.42 done
3.43
3.44
3.45 +if test "x$with_osmesa" != xno; then
3.46 +
3.47 +
3.48 +{ echo "$as_me:$LINENO: checking for OSMesaCreateContext in -lOSMesa" >&5
3.49 +echo $ECHO_N "checking for OSMesaCreateContext in -lOSMesa... $ECHO_C" >&6; }
3.50 +if test "${ac_cv_lib_OSMesa_OSMesaCreateContext+set}" = set; then
3.51 + echo $ECHO_N "(cached) $ECHO_C" >&6
3.52 +else
3.53 + ac_check_lib_save_LIBS=$LIBS
3.54 +LIBS="-lOSMesa $LIBS"
3.55 +cat >conftest.$ac_ext <<_ACEOF
3.56 +/* confdefs.h. */
3.57 +_ACEOF
3.58 +cat confdefs.h >>conftest.$ac_ext
3.59 +cat >>conftest.$ac_ext <<_ACEOF
3.60 +/* end confdefs.h. */
3.61 +
3.62 +/* Override any GCC internal prototype to avoid an error.
3.63 + Use char because int might match the return type of a GCC
3.64 + builtin and then its argument prototype would still apply. */
3.65 +#ifdef __cplusplus
3.66 +extern "C"
3.67 +#endif
3.68 +char OSMesaCreateContext ();
3.69 +int
3.70 +main ()
3.71 +{
3.72 +return OSMesaCreateContext ();
3.73 + ;
3.74 + return 0;
3.75 +}
3.76 +_ACEOF
3.77 +rm -f conftest.$ac_objext conftest$ac_exeext
3.78 +if { (ac_try="$ac_link"
3.79 +case "(($ac_try" in
3.80 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3.81 + *) ac_try_echo=$ac_try;;
3.82 +esac
3.83 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3.84 + (eval "$ac_link") 2>conftest.er1
3.85 + ac_status=$?
3.86 + grep -v '^ *+' conftest.er1 >conftest.err
3.87 + rm -f conftest.er1
3.88 + cat conftest.err >&5
3.89 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
3.90 + (exit $ac_status); } && {
3.91 + test -z "$ac_c_werror_flag" ||
3.92 + test ! -s conftest.err
3.93 + } && test -s conftest$ac_exeext &&
3.94 + $as_test_x conftest$ac_exeext; then
3.95 + ac_cv_lib_OSMesa_OSMesaCreateContext=yes
3.96 +else
3.97 + echo "$as_me: failed program was:" >&5
3.98 +sed 's/^/| /' conftest.$ac_ext >&5
3.99 +
3.100 + ac_cv_lib_OSMesa_OSMesaCreateContext=no
3.101 +fi
3.102 +
3.103 +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
3.104 + conftest$ac_exeext conftest.$ac_ext
3.105 +LIBS=$ac_check_lib_save_LIBS
3.106 +fi
3.107 +{ echo "$as_me:$LINENO: result: $ac_cv_lib_OSMesa_OSMesaCreateContext" >&5
3.108 +echo "${ECHO_T}$ac_cv_lib_OSMesa_OSMesaCreateContext" >&6; }
3.109 +if test $ac_cv_lib_OSMesa_OSMesaCreateContext = yes; then
3.110 + cat >>confdefs.h <<_ACEOF
3.111 +#define HAVE_LIBOSMESA 1
3.112 +_ACEOF
3.113 +
3.114 + LIBS="-lOSMesa $LIBS"
3.115 +
3.116 +else
3.117 + { { echo "$as_me:$LINENO: error: --with-osmesa was given, but OSMesa library could not be found
3.118 +See \`config.log' for more details." >&5
3.119 +echo "$as_me: error: --with-osmesa was given, but OSMesa library could not be found
3.120 +See \`config.log' for more details." >&2;}
3.121 + { (exit 1); exit 1; }; }
3.122 +fi
3.123 +
3.124 + if test "${ac_cv_header_GL_osmesa_h+set}" = set; then
3.125 + { echo "$as_me:$LINENO: checking for GL/osmesa.h" >&5
3.126 +echo $ECHO_N "checking for GL/osmesa.h... $ECHO_C" >&6; }
3.127 +if test "${ac_cv_header_GL_osmesa_h+set}" = set; then
3.128 + echo $ECHO_N "(cached) $ECHO_C" >&6
3.129 +fi
3.130 +{ echo "$as_me:$LINENO: result: $ac_cv_header_GL_osmesa_h" >&5
3.131 +echo "${ECHO_T}$ac_cv_header_GL_osmesa_h" >&6; }
3.132 +else
3.133 + # Is the header compilable?
3.134 +{ echo "$as_me:$LINENO: checking GL/osmesa.h usability" >&5
3.135 +echo $ECHO_N "checking GL/osmesa.h usability... $ECHO_C" >&6; }
3.136 +cat >conftest.$ac_ext <<_ACEOF
3.137 +/* confdefs.h. */
3.138 +_ACEOF
3.139 +cat confdefs.h >>conftest.$ac_ext
3.140 +cat >>conftest.$ac_ext <<_ACEOF
3.141 +/* end confdefs.h. */
3.142 +$ac_includes_default
3.143 +#include <GL/osmesa.h>
3.144 +_ACEOF
3.145 +rm -f conftest.$ac_objext
3.146 +if { (ac_try="$ac_compile"
3.147 +case "(($ac_try" in
3.148 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3.149 + *) ac_try_echo=$ac_try;;
3.150 +esac
3.151 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3.152 + (eval "$ac_compile") 2>conftest.er1
3.153 + ac_status=$?
3.154 + grep -v '^ *+' conftest.er1 >conftest.err
3.155 + rm -f conftest.er1
3.156 + cat conftest.err >&5
3.157 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
3.158 + (exit $ac_status); } && {
3.159 + test -z "$ac_c_werror_flag" ||
3.160 + test ! -s conftest.err
3.161 + } && test -s conftest.$ac_objext; then
3.162 + ac_header_compiler=yes
3.163 +else
3.164 + echo "$as_me: failed program was:" >&5
3.165 +sed 's/^/| /' conftest.$ac_ext >&5
3.166 +
3.167 + ac_header_compiler=no
3.168 +fi
3.169 +
3.170 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3.171 +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
3.172 +echo "${ECHO_T}$ac_header_compiler" >&6; }
3.173 +
3.174 +# Is the header present?
3.175 +{ echo "$as_me:$LINENO: checking GL/osmesa.h presence" >&5
3.176 +echo $ECHO_N "checking GL/osmesa.h presence... $ECHO_C" >&6; }
3.177 +cat >conftest.$ac_ext <<_ACEOF
3.178 +/* confdefs.h. */
3.179 +_ACEOF
3.180 +cat confdefs.h >>conftest.$ac_ext
3.181 +cat >>conftest.$ac_ext <<_ACEOF
3.182 +/* end confdefs.h. */
3.183 +#include <GL/osmesa.h>
3.184 +_ACEOF
3.185 +if { (ac_try="$ac_cpp conftest.$ac_ext"
3.186 +case "(($ac_try" in
3.187 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3.188 + *) ac_try_echo=$ac_try;;
3.189 +esac
3.190 +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3.191 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
3.192 + ac_status=$?
3.193 + grep -v '^ *+' conftest.er1 >conftest.err
3.194 + rm -f conftest.er1
3.195 + cat conftest.err >&5
3.196 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
3.197 + (exit $ac_status); } >/dev/null && {
3.198 + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
3.199 + test ! -s conftest.err
3.200 + }; then
3.201 + ac_header_preproc=yes
3.202 +else
3.203 + echo "$as_me: failed program was:" >&5
3.204 +sed 's/^/| /' conftest.$ac_ext >&5
3.205 +
3.206 + ac_header_preproc=no
3.207 +fi
3.208 +
3.209 +rm -f conftest.err conftest.$ac_ext
3.210 +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
3.211 +echo "${ECHO_T}$ac_header_preproc" >&6; }
3.212 +
3.213 +# So? What about this header?
3.214 +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
3.215 + yes:no: )
3.216 + { echo "$as_me:$LINENO: WARNING: GL/osmesa.h: accepted by the compiler, rejected by the preprocessor!" >&5
3.217 +echo "$as_me: WARNING: GL/osmesa.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
3.218 + { echo "$as_me:$LINENO: WARNING: GL/osmesa.h: proceeding with the compiler's result" >&5
3.219 +echo "$as_me: WARNING: GL/osmesa.h: proceeding with the compiler's result" >&2;}
3.220 + ac_header_preproc=yes
3.221 + ;;
3.222 + no:yes:* )
3.223 + { echo "$as_me:$LINENO: WARNING: GL/osmesa.h: present but cannot be compiled" >&5
3.224 +echo "$as_me: WARNING: GL/osmesa.h: present but cannot be compiled" >&2;}
3.225 + { echo "$as_me:$LINENO: WARNING: GL/osmesa.h: check for missing prerequisite headers?" >&5
3.226 +echo "$as_me: WARNING: GL/osmesa.h: check for missing prerequisite headers?" >&2;}
3.227 + { echo "$as_me:$LINENO: WARNING: GL/osmesa.h: see the Autoconf documentation" >&5
3.228 +echo "$as_me: WARNING: GL/osmesa.h: see the Autoconf documentation" >&2;}
3.229 + { echo "$as_me:$LINENO: WARNING: GL/osmesa.h: section \"Present But Cannot Be Compiled\"" >&5
3.230 +echo "$as_me: WARNING: GL/osmesa.h: section \"Present But Cannot Be Compiled\"" >&2;}
3.231 + { echo "$as_me:$LINENO: WARNING: GL/osmesa.h: proceeding with the preprocessor's result" >&5
3.232 +echo "$as_me: WARNING: GL/osmesa.h: proceeding with the preprocessor's result" >&2;}
3.233 + { echo "$as_me:$LINENO: WARNING: GL/osmesa.h: in the future, the compiler will take precedence" >&5
3.234 +echo "$as_me: WARNING: GL/osmesa.h: in the future, the compiler will take precedence" >&2;}
3.235 +
3.236 + ;;
3.237 +esac
3.238 +{ echo "$as_me:$LINENO: checking for GL/osmesa.h" >&5
3.239 +echo $ECHO_N "checking for GL/osmesa.h... $ECHO_C" >&6; }
3.240 +if test "${ac_cv_header_GL_osmesa_h+set}" = set; then
3.241 + echo $ECHO_N "(cached) $ECHO_C" >&6
3.242 +else
3.243 + ac_cv_header_GL_osmesa_h=$ac_header_preproc
3.244 +fi
3.245 +{ echo "$as_me:$LINENO: result: $ac_cv_header_GL_osmesa_h" >&5
3.246 +echo "${ECHO_T}$ac_cv_header_GL_osmesa_h" >&6; }
3.247 +
3.248 +fi
3.249 +if test $ac_cv_header_GL_osmesa_h = yes; then
3.250 + :
3.251 +else
3.252 + { { echo "$as_me:$LINENO: error: --with-osmesa was given, but osmesa.h could not be found
3.253 +See \`config.log' for more details." >&5
3.254 +echo "$as_me: error: --with-osmesa was given, but osmesa.h could not be found
3.255 +See \`config.log' for more details." >&2;}
3.256 + { (exit 1); exit 1; }; }
3.257 +fi
3.258 +
3.259 +
3.260 +
3.261 +fi
3.262 +
3.263 +
3.264 +
3.265 +if test "x$with_osmesa" != xno; then
3.266 + OSMESA_DRIVER_TRUE=
3.267 + OSMESA_DRIVER_FALSE='#'
3.268 +else
3.269 + OSMESA_DRIVER_TRUE='#'
3.270 + OSMESA_DRIVER_FALSE=
3.271 +fi
3.272 +
3.273 +
3.274 if test "${ac_cv_header_Carbon_Carbon_h+set}" = set; then
3.275 { echo "$as_me:$LINENO: checking for Carbon/Carbon.h" >&5
3.276 echo $ECHO_N "checking for Carbon/Carbon.h... $ECHO_C" >&6; }
3.277 @@ -5514,6 +5760,7 @@
3.278
3.279
3.280 if test "$APPLE_BUILD" != 'yes'; then
3.281 +if test "x$with_osmesa" == "xno"; then
3.282
3.283 { echo "$as_me:$LINENO: checking for glXQueryVersion in -lGL" >&5
3.284 echo $ECHO_N "checking for glXQueryVersion in -lGL... $ECHO_C" >&6; }
3.285 @@ -5724,6 +5971,7 @@
3.286
3.287
3.288 fi
3.289 +fi
3.290
3.291
3.292 pkg_failed=no
3.293 @@ -8300,6 +8548,13 @@
3.294 Usually this means the macro was only invoked conditionally." >&2;}
3.295 { (exit 1); exit 1; }; }
3.296 fi
3.297 +if test -z "${OSMESA_DRIVER_TRUE}" && test -z "${OSMESA_DRIVER_FALSE}"; then
3.298 + { { echo "$as_me:$LINENO: error: conditional \"OSMESA_DRIVER\" was never defined.
3.299 +Usually this means the macro was only invoked conditionally." >&5
3.300 +echo "$as_me: error: conditional \"OSMESA_DRIVER\" was never defined.
3.301 +Usually this means the macro was only invoked conditionally." >&2;}
3.302 + { (exit 1); exit 1; }; }
3.303 +fi
3.304 if test -z "${GUI_CARBON_TRUE}" && test -z "${GUI_CARBON_FALSE}"; then
3.305 { { echo "$as_me:$LINENO: error: conditional \"GUI_CARBON\" was never defined.
3.306 Usually this means the macro was only invoked conditionally." >&5
3.307 @@ -8993,6 +9248,8 @@
3.308 host_cpu!$host_cpu$ac_delim
3.309 host_vendor!$host_vendor$ac_delim
3.310 host_os!$host_os$ac_delim
3.311 +OSMESA_DRIVER_TRUE!$OSMESA_DRIVER_TRUE$ac_delim
3.312 +OSMESA_DRIVER_FALSE!$OSMESA_DRIVER_FALSE$ac_delim
3.313 PKG_CONFIG!$PKG_CONFIG$ac_delim
3.314 LIBPNG_CFLAGS!$LIBPNG_CFLAGS$ac_delim
3.315 LIBPNG_LIBS!$LIBPNG_LIBS$ac_delim
3.316 @@ -9001,8 +9258,6 @@
3.317 GUI_CARBON_TRUE!$GUI_CARBON_TRUE$ac_delim
3.318 GUI_CARBON_FALSE!$GUI_CARBON_FALSE$ac_delim
3.319 GUI_GTK_TRUE!$GUI_GTK_TRUE$ac_delim
3.320 -GUI_GTK_FALSE!$GUI_GTK_FALSE$ac_delim
3.321 -BUILD_SH4X86_TRUE!$BUILD_SH4X86_TRUE$ac_delim
3.322 _ACEOF
3.323
3.324 if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
3.325 @@ -9044,6 +9299,8 @@
3.326 ac_delim='%!_!# '
3.327 for ac_last_try in false false false false false :; do
3.328 cat >conf$$subs.sed <<_ACEOF
3.329 +GUI_GTK_FALSE!$GUI_GTK_FALSE$ac_delim
3.330 +BUILD_SH4X86_TRUE!$BUILD_SH4X86_TRUE$ac_delim
3.331 BUILD_SH4X86_FALSE!$BUILD_SH4X86_FALSE$ac_delim
3.332 BUILD_X86_64_TRUE!$BUILD_X86_64_TRUE$ac_delim
3.333 BUILD_X86_64_FALSE!$BUILD_X86_64_FALSE$ac_delim
3.334 @@ -9090,7 +9347,7 @@
3.335 LTLIBOBJS!$LTLIBOBJS$ac_delim
3.336 _ACEOF
3.337
3.338 - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 44; then
3.339 + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 46; then
3.340 break
3.341 elif $ac_last_try; then
3.342 { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
4.1 --- a/configure.in Sun Mar 02 11:38:08 2008 +0000
4.2 +++ b/configure.in Fri Mar 28 12:32:25 2008 +0000
4.3 @@ -22,6 +22,18 @@
4.4 [if test "$enableval" == "yes"; then
4.5 AC_DEFINE(ENABLE_WATCH, 1, [Enable watchpoints])
4.6 fi] )
4.7 +AC_ARG_WITH( osmesa,
4.8 + AS_HELP_STRING( [--with-osmesa], [Build with the osmesa GL library (software rendering)]),
4.9 + [], [with_osmesa=no])
4.10 +
4.11 +AS_IF([test "x$with_osmesa" != xno], [
4.12 + AC_CHECK_LIB([OSMesa], [OSMesaCreateContext], [],
4.13 + [AC_MSG_FAILURE( [--with-osmesa was given, but OSMesa library could not be found])])
4.14 + AC_CHECK_HEADER([GL/osmesa.h], [],
4.15 + [AC_MSG_FAILURE( [--with-osmesa was given, but osmesa.h could not be found])])
4.16 + ])
4.17 +AM_CONDITIONAL(OSMESA_DRIVER, [test "x$with_osmesa" != xno])
4.18 +
4.19 dnl ----------- Check for mandatory dependencies --------------
4.20 dnl Building on MAC?
4.21 AC_CHECK_HEADER([Carbon/Carbon.h], [
4.22 @@ -41,6 +53,7 @@
4.23 exit 1])
4.24
4.25 if test "$APPLE_BUILD" != 'yes'; then
4.26 +if test "x$with_osmesa" == "xno"; then
4.27 AC_CHECK_LIB(GL, glXQueryVersion, [], [
4.28 echo "The OpenGL library (libGL.so) could not be found, but is required."
4.29 exit 1])
4.30 @@ -48,6 +61,7 @@
4.31 echo "The OpenGL header files (eg GL/gl.h) could not be found, but are required."
4.32 exit 1])
4.33 fi
4.34 +fi
4.35
4.36 dnl Check for GTK (required for unix systems)
4.37 PKG_CHECK_MODULES(GTK, gtk+-2.0, [
5.1 --- a/src/Makefile.am Sun Mar 02 11:38:08 2008 +0000
5.2 +++ b/src/Makefile.am Fri Mar 28 12:32:25 2008 +0000
5.3 @@ -13,7 +13,7 @@
5.4
5.5 AM_CFLAGS = -D_ISOC99_SOURCE -D_BSD_SOURCE
5.6 TESTS = test/testxlt
5.7 -BUILT_SOURCES = sh4/sh4core.c sh4/sh4dasm.c sh4/sh4x86.c drivers/gl_slsrc.c
5.8 +BUILT_SOURCES = sh4/sh4core.c sh4/sh4dasm.c sh4/sh4x86.c pvr2/gl_slsrc.c
5.9
5.10 gendec_SOURCES = tools/gendec.c tools/gendec.h tools/insparse.c tools/actparse.c
5.11 genglsl_SOURCES = tools/genglsl.c
5.12 @@ -35,15 +35,15 @@
5.13 aica/armcore.c aica/armcore.h aica/armdasm.c aica/armmem.c \
5.14 aica/aica.c aica/aica.h aica/audio.c aica/audio.h \
5.15 pvr2/pvr2.c pvr2/pvr2.h pvr2/pvr2mem.c \
5.16 - pvr2/tacore.c pvr2/render.c pvr2/rendcore.c pvr2/rendbkg.c pvr2/rendsort.c \
5.17 - pvr2/texcache.c pvr2/yuv.c pvr2/rendsave.c \
5.18 + pvr2/tacore.c pvr2/rendbkg.c pvr2/rendsort.c \
5.19 + pvr2/texcache.c pvr2/yuv.c pvr2/rendsave.c pvr2/scene.c pvr2/scene.h \
5.20 + pvr2/gl_sl.c pvr2/gl_slsrc.c pvr2/glutil.c pvr2/glutil.h pvr2/glrender.c \
5.21 maple/maple.c maple/maple.h \
5.22 maple/controller.c maple/controller.h maple/kbd.c maple/mouse.c \
5.23 loader.c bootstrap.c util.c \
5.24 display.c display.h dckeysyms.h \
5.25 drivers/audio_null.c drivers/video_null.c \
5.26 - drivers/gl_common.c drivers/gl_common.h drivers/gl_fbo.c \
5.27 - drivers/gl_sl.c drivers/gl_slsrc.c
5.28 + drivers/video_gl.c drivers/video_gl.h drivers/gl_fbo.c
5.29
5.30 if BUILD_SH4X86
5.31 lxdream_SOURCES += sh4/sh4x86.c sh4/x86op.h \
5.32 @@ -63,12 +63,21 @@
5.33 endif
5.34
5.35 if GUI_GTK
5.36 +if OSMESA_DRIVER
5.37 lxdream_SOURCES += gtkui/gtkui.c gtkui/gtkui.h \
5.38 gtkui/main_win.c gtkui/gtkcb.c \
5.39 gtkui/mmio_win.c gtkui/debug_win.c gtkui/dump_win.c \
5.40 gtkui/ctrl_dlg.c gtkui/path_dlg.c gtkui/gdrom_menu.c \
5.41 drivers/video_gtk.c drivers/video_gtk.h \
5.42 - drivers/video_glx.c drivers/video_glx.h
5.43 + drivers/video_gdk.c drivers/video_gdk.h
5.44 +else
5.45 +lxdream_SOURCES += gtkui/gtkui.c gtkui/gtkui.h \
5.46 + gtkui/main_win.c gtkui/gtkcb.c \
5.47 + gtkui/mmio_win.c gtkui/debug_win.c gtkui/dump_win.c \
5.48 + gtkui/ctrl_dlg.c gtkui/path_dlg.c gtkui/gdrom_menu.c \
5.49 + drivers/video_gtk.c drivers/video_gtk.h \
5.50 + drivers/video_glx.c drivers/video_glx.h
5.51 +endif
5.52 endif
5.53
5.54 if CDROM_LINUX
5.55 @@ -105,5 +114,5 @@
5.56 ./gendec sh4/sh4.def sh4/sh4x86.in -o sh4/sh4x86.c
5.57 sh4/sh4stat.c: gendec sh4/sh4.def sh4/sh4stat.in
5.58 ./gendec sh4/sh4.def sh4/sh4stat.in -o sh4/sh4stat.c
5.59 -drivers/gl_slsrc.c: genglsl drivers/vertex.glsl drivers/fragment.glsl
5.60 - ./genglsl drivers/vertex.glsl drivers/fragment.glsl drivers/gl_slsrc.c
5.61 +pvr2/gl_slsrc.c: genglsl pvr2/vertex.glsl pvr2/fragment.glsl
5.62 + ./genglsl pvr2/vertex.glsl pvr2/fragment.glsl pvr2/gl_slsrc.c
6.1 --- a/src/Makefile.in Sun Mar 02 11:38:08 2008 +0000
6.2 +++ b/src/Makefile.in Fri Mar 28 12:32:25 2008 +0000
6.3 @@ -43,18 +43,25 @@
6.4 @BUILD_SH4X86_TRUE@ x86dasm/i386-dis.c x86dasm/dis-init.c x86dasm/dis-buf.c
6.5
6.6 @BUILD_SH4X86_TRUE@am__append_2 = test/testsh4x86
6.7 -@GUI_GTK_TRUE@am__append_3 = gtkui/gtkui.c gtkui/gtkui.h \
6.8 -@GUI_GTK_TRUE@ gtkui/main_win.c gtkui/gtkcb.c \
6.9 -@GUI_GTK_TRUE@ gtkui/mmio_win.c gtkui/debug_win.c gtkui/dump_win.c \
6.10 -@GUI_GTK_TRUE@ gtkui/ctrl_dlg.c gtkui/path_dlg.c gtkui/gdrom_menu.c \
6.11 -@GUI_GTK_TRUE@ drivers/video_gtk.c drivers/video_gtk.h \
6.12 -@GUI_GTK_TRUE@ drivers/video_glx.c drivers/video_glx.h
6.13 +@GUI_GTK_TRUE@@OSMESA_DRIVER_TRUE@am__append_3 = gtkui/gtkui.c gtkui/gtkui.h \
6.14 +@GUI_GTK_TRUE@@OSMESA_DRIVER_TRUE@ gtkui/main_win.c gtkui/gtkcb.c \
6.15 +@GUI_GTK_TRUE@@OSMESA_DRIVER_TRUE@ gtkui/mmio_win.c gtkui/debug_win.c gtkui/dump_win.c \
6.16 +@GUI_GTK_TRUE@@OSMESA_DRIVER_TRUE@ gtkui/ctrl_dlg.c gtkui/path_dlg.c gtkui/gdrom_menu.c \
6.17 +@GUI_GTK_TRUE@@OSMESA_DRIVER_TRUE@ drivers/video_gtk.c drivers/video_gtk.h \
6.18 +@GUI_GTK_TRUE@@OSMESA_DRIVER_TRUE@ drivers/video_gdk.c drivers/video_gdk.h
6.19
6.20 -@CDROM_LINUX_TRUE@am__append_4 = drivers/cd_linux.c
6.21 -@CDROM_LINUX_FALSE@am__append_5 = drivers/cd_none.c
6.22 -@JOY_LINUX_TRUE@am__append_6 = drivers/joy_linux.c
6.23 -@AUDIO_ESOUND_TRUE@am__append_7 = drivers/audio_esd.c
6.24 -@AUDIO_ALSA_TRUE@am__append_8 = drivers/audio_alsa.c
6.25 +@GUI_GTK_TRUE@@OSMESA_DRIVER_FALSE@am__append_4 = gtkui/gtkui.c gtkui/gtkui.h \
6.26 +@GUI_GTK_TRUE@@OSMESA_DRIVER_FALSE@ gtkui/main_win.c gtkui/gtkcb.c \
6.27 +@GUI_GTK_TRUE@@OSMESA_DRIVER_FALSE@ gtkui/mmio_win.c gtkui/debug_win.c gtkui/dump_win.c \
6.28 +@GUI_GTK_TRUE@@OSMESA_DRIVER_FALSE@ gtkui/ctrl_dlg.c gtkui/path_dlg.c gtkui/gdrom_menu.c \
6.29 +@GUI_GTK_TRUE@@OSMESA_DRIVER_FALSE@ drivers/video_gtk.c drivers/video_gtk.h \
6.30 +@GUI_GTK_TRUE@@OSMESA_DRIVER_FALSE@ drivers/video_glx.c drivers/video_glx.h
6.31 +
6.32 +@CDROM_LINUX_TRUE@am__append_5 = drivers/cd_linux.c
6.33 +@CDROM_LINUX_FALSE@am__append_6 = drivers/cd_none.c
6.34 +@JOY_LINUX_TRUE@am__append_7 = drivers/joy_linux.c
6.35 +@AUDIO_ESOUND_TRUE@am__append_8 = drivers/audio_esd.c
6.36 +@AUDIO_ALSA_TRUE@am__append_9 = drivers/audio_alsa.c
6.37 ACLOCAL = @ACLOCAL@
6.38 ALSA_CFLAGS = @ALSA_CFLAGS@
6.39 ALSA_LIBS = @ALSA_LIBS@
6.40 @@ -134,6 +141,8 @@
6.41 MSGFMT = @MSGFMT@
6.42 MSGFMT_OPTS = @MSGFMT_OPTS@
6.43 OBJEXT = @OBJEXT@
6.44 +OSMESA_DRIVER_FALSE = @OSMESA_DRIVER_FALSE@
6.45 +OSMESA_DRIVER_TRUE = @OSMESA_DRIVER_TRUE@
6.46 PACKAGE = @PACKAGE@
6.47 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
6.48 PACKAGE_NAME = @PACKAGE_NAME@
6.49 @@ -210,7 +219,7 @@
6.50
6.51 AM_CFLAGS = -D_ISOC99_SOURCE -D_BSD_SOURCE
6.52 TESTS = test/testxlt
6.53 -BUILT_SOURCES = sh4/sh4core.c sh4/sh4dasm.c sh4/sh4x86.c drivers/gl_slsrc.c
6.54 +BUILT_SOURCES = sh4/sh4core.c sh4/sh4dasm.c sh4/sh4x86.c pvr2/gl_slsrc.c
6.55
6.56 gendec_SOURCES = tools/gendec.c tools/gendec.h tools/insparse.c tools/actparse.c
6.57 genglsl_SOURCES = tools/genglsl.c
6.58 @@ -232,16 +241,16 @@
6.59 aica/armcore.c aica/armcore.h aica/armdasm.c aica/armmem.c \
6.60 aica/aica.c aica/aica.h aica/audio.c aica/audio.h \
6.61 pvr2/pvr2.c pvr2/pvr2.h pvr2/pvr2mem.c \
6.62 - pvr2/tacore.c pvr2/render.c pvr2/rendcore.c pvr2/rendbkg.c pvr2/rendsort.c \
6.63 - pvr2/texcache.c pvr2/yuv.c pvr2/rendsave.c \
6.64 + pvr2/tacore.c pvr2/rendbkg.c pvr2/rendsort.c \
6.65 + pvr2/texcache.c pvr2/yuv.c pvr2/rendsave.c pvr2/scene.c pvr2/scene.h \
6.66 + pvr2/gl_sl.c pvr2/gl_slsrc.c pvr2/glutil.c pvr2/glutil.h pvr2/glrender.c \
6.67 maple/maple.c maple/maple.h \
6.68 maple/controller.c maple/controller.h maple/kbd.c maple/mouse.c \
6.69 loader.c bootstrap.c util.c \
6.70 display.c display.h dckeysyms.h \
6.71 drivers/audio_null.c drivers/video_null.c \
6.72 - drivers/gl_common.c drivers/gl_common.h drivers/gl_fbo.c \
6.73 - drivers/gl_sl.c drivers/gl_slsrc.c\
6.74 -$(am__append_1) $(am__append_3) $(am__append_4) $(am__append_5) $(am__append_6) $(am__append_7) $(am__append_8)
6.75 + drivers/video_gl.c drivers/video_gl.h drivers/gl_fbo.c\
6.76 +$(am__append_1) $(am__append_3) $(am__append_4) $(am__append_5) $(am__append_6) $(am__append_7) $(am__append_8) $(am__append_9)
6.77
6.78 @BUILD_SH4X86_TRUE@test_testsh4x86_LDADD = @GTK_LIBS@
6.79 @BUILD_SH4X86_TRUE@test_testsh4x86_SOURCES = test/testsh4x86.c x86dasm/x86dasm.c \
6.80 @@ -291,37 +300,54 @@
6.81 sh4/sh4stat.h sh4/xltcache.c sh4/xltcache.h sh4/sh4.h \
6.82 aica/armcore.c aica/armcore.h aica/armdasm.c aica/armmem.c \
6.83 aica/aica.c aica/aica.h aica/audio.c aica/audio.h pvr2/pvr2.c \
6.84 - pvr2/pvr2.h pvr2/pvr2mem.c pvr2/tacore.c pvr2/render.c \
6.85 - pvr2/rendcore.c pvr2/rendbkg.c pvr2/rendsort.c pvr2/texcache.c \
6.86 - pvr2/yuv.c pvr2/rendsave.c maple/maple.c maple/maple.h \
6.87 - maple/controller.c maple/controller.h maple/kbd.c maple/mouse.c \
6.88 - loader.c bootstrap.c util.c display.c display.h dckeysyms.h \
6.89 - drivers/audio_null.c drivers/video_null.c drivers/gl_common.c \
6.90 - drivers/gl_common.h drivers/gl_fbo.c drivers/gl_sl.c \
6.91 - drivers/gl_slsrc.c sh4/sh4x86.c sh4/x86op.h sh4/ia32abi.h \
6.92 - sh4/ia32mac.h sh4/ia64abi.h sh4/sh4trans.c sh4/sh4trans.h \
6.93 - x86dasm/x86dasm.c x86dasm/x86dasm.h x86dasm/i386-dis.c \
6.94 - x86dasm/dis-init.c x86dasm/dis-buf.c gtkui/gtkui.c \
6.95 - gtkui/gtkui.h gtkui/main_win.c gtkui/gtkcb.c gtkui/mmio_win.c \
6.96 - gtkui/debug_win.c gtkui/dump_win.c gtkui/ctrl_dlg.c \
6.97 - gtkui/path_dlg.c gtkui/gdrom_menu.c drivers/video_gtk.c \
6.98 - drivers/video_gtk.h drivers/video_glx.c drivers/video_glx.h \
6.99 - drivers/cd_linux.c drivers/cd_none.c drivers/joy_linux.c \
6.100 - drivers/audio_esd.c drivers/audio_alsa.c
6.101 + pvr2/pvr2.h pvr2/pvr2mem.c pvr2/tacore.c pvr2/rendbkg.c \
6.102 + pvr2/rendsort.c pvr2/texcache.c pvr2/yuv.c pvr2/rendsave.c \
6.103 + pvr2/scene.c pvr2/scene.h pvr2/gl_sl.c pvr2/gl_slsrc.c \
6.104 + pvr2/glutil.c pvr2/glutil.h pvr2/glrender.c maple/maple.c \
6.105 + maple/maple.h maple/controller.c maple/controller.h maple/kbd.c \
6.106 + maple/mouse.c loader.c bootstrap.c util.c display.c display.h \
6.107 + dckeysyms.h drivers/audio_null.c drivers/video_null.c \
6.108 + drivers/video_gl.c drivers/video_gl.h drivers/gl_fbo.c \
6.109 + sh4/sh4x86.c sh4/x86op.h sh4/ia32abi.h sh4/ia32mac.h \
6.110 + sh4/ia64abi.h sh4/sh4trans.c sh4/sh4trans.h x86dasm/x86dasm.c \
6.111 + x86dasm/x86dasm.h x86dasm/i386-dis.c x86dasm/dis-init.c \
6.112 + x86dasm/dis-buf.c gtkui/gtkui.c gtkui/gtkui.h gtkui/main_win.c \
6.113 + gtkui/gtkcb.c gtkui/mmio_win.c gtkui/debug_win.c \
6.114 + gtkui/dump_win.c gtkui/ctrl_dlg.c gtkui/path_dlg.c \
6.115 + gtkui/gdrom_menu.c drivers/video_gtk.c drivers/video_gtk.h \
6.116 + drivers/video_gdk.c drivers/video_gdk.h drivers/video_glx.c \
6.117 + drivers/video_glx.h drivers/cd_linux.c drivers/cd_none.c \
6.118 + drivers/joy_linux.c drivers/audio_esd.c drivers/audio_alsa.c
6.119 @BUILD_SH4X86_TRUE@am__objects_1 = sh4x86.$(OBJEXT) sh4trans.$(OBJEXT) \
6.120 @BUILD_SH4X86_TRUE@ x86dasm.$(OBJEXT) i386-dis.$(OBJEXT) \
6.121 @BUILD_SH4X86_TRUE@ dis-init.$(OBJEXT) dis-buf.$(OBJEXT)
6.122 -@GUI_GTK_TRUE@am__objects_2 = gtkui.$(OBJEXT) main_win.$(OBJEXT) \
6.123 -@GUI_GTK_TRUE@ gtkcb.$(OBJEXT) mmio_win.$(OBJEXT) \
6.124 -@GUI_GTK_TRUE@ debug_win.$(OBJEXT) dump_win.$(OBJEXT) \
6.125 -@GUI_GTK_TRUE@ ctrl_dlg.$(OBJEXT) path_dlg.$(OBJEXT) \
6.126 -@GUI_GTK_TRUE@ gdrom_menu.$(OBJEXT) video_gtk.$(OBJEXT) \
6.127 -@GUI_GTK_TRUE@ video_glx.$(OBJEXT)
6.128 -@CDROM_LINUX_TRUE@am__objects_3 = cd_linux.$(OBJEXT)
6.129 -@CDROM_LINUX_FALSE@am__objects_4 = cd_none.$(OBJEXT)
6.130 -@JOY_LINUX_TRUE@am__objects_5 = joy_linux.$(OBJEXT)
6.131 -@AUDIO_ESOUND_TRUE@am__objects_6 = audio_esd.$(OBJEXT)
6.132 -@AUDIO_ALSA_TRUE@am__objects_7 = audio_alsa.$(OBJEXT)
6.133 +@GUI_GTK_TRUE@@OSMESA_DRIVER_TRUE@am__objects_2 = gtkui.$(OBJEXT) \
6.134 +@GUI_GTK_TRUE@@OSMESA_DRIVER_TRUE@ main_win.$(OBJEXT) \
6.135 +@GUI_GTK_TRUE@@OSMESA_DRIVER_TRUE@ gtkcb.$(OBJEXT) \
6.136 +@GUI_GTK_TRUE@@OSMESA_DRIVER_TRUE@ mmio_win.$(OBJEXT) \
6.137 +@GUI_GTK_TRUE@@OSMESA_DRIVER_TRUE@ debug_win.$(OBJEXT) \
6.138 +@GUI_GTK_TRUE@@OSMESA_DRIVER_TRUE@ dump_win.$(OBJEXT) \
6.139 +@GUI_GTK_TRUE@@OSMESA_DRIVER_TRUE@ ctrl_dlg.$(OBJEXT) \
6.140 +@GUI_GTK_TRUE@@OSMESA_DRIVER_TRUE@ path_dlg.$(OBJEXT) \
6.141 +@GUI_GTK_TRUE@@OSMESA_DRIVER_TRUE@ gdrom_menu.$(OBJEXT) \
6.142 +@GUI_GTK_TRUE@@OSMESA_DRIVER_TRUE@ video_gtk.$(OBJEXT) \
6.143 +@GUI_GTK_TRUE@@OSMESA_DRIVER_TRUE@ video_gdk.$(OBJEXT)
6.144 +@GUI_GTK_TRUE@@OSMESA_DRIVER_FALSE@am__objects_3 = gtkui.$(OBJEXT) \
6.145 +@GUI_GTK_TRUE@@OSMESA_DRIVER_FALSE@ main_win.$(OBJEXT) \
6.146 +@GUI_GTK_TRUE@@OSMESA_DRIVER_FALSE@ gtkcb.$(OBJEXT) \
6.147 +@GUI_GTK_TRUE@@OSMESA_DRIVER_FALSE@ mmio_win.$(OBJEXT) \
6.148 +@GUI_GTK_TRUE@@OSMESA_DRIVER_FALSE@ debug_win.$(OBJEXT) \
6.149 +@GUI_GTK_TRUE@@OSMESA_DRIVER_FALSE@ dump_win.$(OBJEXT) \
6.150 +@GUI_GTK_TRUE@@OSMESA_DRIVER_FALSE@ ctrl_dlg.$(OBJEXT) \
6.151 +@GUI_GTK_TRUE@@OSMESA_DRIVER_FALSE@ path_dlg.$(OBJEXT) \
6.152 +@GUI_GTK_TRUE@@OSMESA_DRIVER_FALSE@ gdrom_menu.$(OBJEXT) \
6.153 +@GUI_GTK_TRUE@@OSMESA_DRIVER_FALSE@ video_gtk.$(OBJEXT) \
6.154 +@GUI_GTK_TRUE@@OSMESA_DRIVER_FALSE@ video_glx.$(OBJEXT)
6.155 +@CDROM_LINUX_TRUE@am__objects_4 = cd_linux.$(OBJEXT)
6.156 +@CDROM_LINUX_FALSE@am__objects_5 = cd_none.$(OBJEXT)
6.157 +@JOY_LINUX_TRUE@am__objects_6 = joy_linux.$(OBJEXT)
6.158 +@AUDIO_ESOUND_TRUE@am__objects_7 = audio_esd.$(OBJEXT)
6.159 +@AUDIO_ALSA_TRUE@am__objects_8 = audio_alsa.$(OBJEXT)
6.160 am_lxdream_OBJECTS = main.$(OBJEXT) config.$(OBJEXT) mem.$(OBJEXT) \
6.161 watch.$(OBJEXT) asic.$(OBJEXT) syscall.$(OBJEXT) bios.$(OBJEXT) \
6.162 dcload.$(OBJEXT) ide.$(OBJEXT) gdimage.$(OBJEXT) \
6.163 @@ -333,16 +359,17 @@
6.164 sh4stat.$(OBJEXT) xltcache.$(OBJEXT) armcore.$(OBJEXT) \
6.165 armdasm.$(OBJEXT) armmem.$(OBJEXT) aica.$(OBJEXT) \
6.166 audio.$(OBJEXT) pvr2.$(OBJEXT) pvr2mem.$(OBJEXT) \
6.167 - tacore.$(OBJEXT) render.$(OBJEXT) rendcore.$(OBJEXT) \
6.168 - rendbkg.$(OBJEXT) rendsort.$(OBJEXT) texcache.$(OBJEXT) \
6.169 - yuv.$(OBJEXT) rendsave.$(OBJEXT) maple.$(OBJEXT) \
6.170 + tacore.$(OBJEXT) rendbkg.$(OBJEXT) rendsort.$(OBJEXT) \
6.171 + texcache.$(OBJEXT) yuv.$(OBJEXT) rendsave.$(OBJEXT) \
6.172 + scene.$(OBJEXT) gl_sl.$(OBJEXT) gl_slsrc.$(OBJEXT) \
6.173 + glutil.$(OBJEXT) glrender.$(OBJEXT) maple.$(OBJEXT) \
6.174 controller.$(OBJEXT) kbd.$(OBJEXT) mouse.$(OBJEXT) \
6.175 loader.$(OBJEXT) bootstrap.$(OBJEXT) util.$(OBJEXT) \
6.176 display.$(OBJEXT) audio_null.$(OBJEXT) video_null.$(OBJEXT) \
6.177 - gl_common.$(OBJEXT) gl_fbo.$(OBJEXT) gl_sl.$(OBJEXT) \
6.178 - gl_slsrc.$(OBJEXT) $(am__objects_1) $(am__objects_2) \
6.179 - $(am__objects_3) $(am__objects_4) $(am__objects_5) \
6.180 - $(am__objects_6) $(am__objects_7)
6.181 + video_gl.$(OBJEXT) gl_fbo.$(OBJEXT) $(am__objects_1) \
6.182 + $(am__objects_2) $(am__objects_3) $(am__objects_4) \
6.183 + $(am__objects_5) $(am__objects_6) $(am__objects_7) \
6.184 + $(am__objects_8)
6.185 lxdream_OBJECTS = $(am_lxdream_OBJECTS)
6.186 lxdream_DEPENDENCIES =
6.187 lxdream_LDFLAGS =
6.188 @@ -387,21 +414,21 @@
6.189 @AMDEP_TRUE@ ./$(DEPDIR)/gdi.Po ./$(DEPDIR)/gdimage.Po \
6.190 @AMDEP_TRUE@ ./$(DEPDIR)/gdrom.Po ./$(DEPDIR)/gdrom_menu.Po \
6.191 @AMDEP_TRUE@ ./$(DEPDIR)/gendec.Po ./$(DEPDIR)/genglsl.Po \
6.192 -@AMDEP_TRUE@ ./$(DEPDIR)/gl_common.Po ./$(DEPDIR)/gl_fbo.Po \
6.193 -@AMDEP_TRUE@ ./$(DEPDIR)/gl_sl.Po ./$(DEPDIR)/gl_slsrc.Po \
6.194 -@AMDEP_TRUE@ ./$(DEPDIR)/gtkcb.Po ./$(DEPDIR)/gtkui.Po \
6.195 -@AMDEP_TRUE@ ./$(DEPDIR)/i386-dis.Po ./$(DEPDIR)/ide.Po \
6.196 -@AMDEP_TRUE@ ./$(DEPDIR)/insparse.Po ./$(DEPDIR)/intc.Po \
6.197 -@AMDEP_TRUE@ ./$(DEPDIR)/joy_linux.Po ./$(DEPDIR)/kbd.Po \
6.198 -@AMDEP_TRUE@ ./$(DEPDIR)/loader.Po ./$(DEPDIR)/main.Po \
6.199 -@AMDEP_TRUE@ ./$(DEPDIR)/main_win.Po ./$(DEPDIR)/maple.Po \
6.200 -@AMDEP_TRUE@ ./$(DEPDIR)/mem.Po ./$(DEPDIR)/mmio_win.Po \
6.201 -@AMDEP_TRUE@ ./$(DEPDIR)/mmu.Po ./$(DEPDIR)/mouse.Po \
6.202 -@AMDEP_TRUE@ ./$(DEPDIR)/nrg.Po ./$(DEPDIR)/path_dlg.Po \
6.203 -@AMDEP_TRUE@ ./$(DEPDIR)/pvr2.Po ./$(DEPDIR)/pvr2mem.Po \
6.204 -@AMDEP_TRUE@ ./$(DEPDIR)/rendbkg.Po ./$(DEPDIR)/rendcore.Po \
6.205 -@AMDEP_TRUE@ ./$(DEPDIR)/render.Po ./$(DEPDIR)/rendsave.Po \
6.206 -@AMDEP_TRUE@ ./$(DEPDIR)/rendsort.Po ./$(DEPDIR)/scif.Po \
6.207 +@AMDEP_TRUE@ ./$(DEPDIR)/gl_fbo.Po ./$(DEPDIR)/gl_sl.Po \
6.208 +@AMDEP_TRUE@ ./$(DEPDIR)/gl_slsrc.Po ./$(DEPDIR)/glrender.Po \
6.209 +@AMDEP_TRUE@ ./$(DEPDIR)/glutil.Po ./$(DEPDIR)/gtkcb.Po \
6.210 +@AMDEP_TRUE@ ./$(DEPDIR)/gtkui.Po ./$(DEPDIR)/i386-dis.Po \
6.211 +@AMDEP_TRUE@ ./$(DEPDIR)/ide.Po ./$(DEPDIR)/insparse.Po \
6.212 +@AMDEP_TRUE@ ./$(DEPDIR)/intc.Po ./$(DEPDIR)/joy_linux.Po \
6.213 +@AMDEP_TRUE@ ./$(DEPDIR)/kbd.Po ./$(DEPDIR)/loader.Po \
6.214 +@AMDEP_TRUE@ ./$(DEPDIR)/main.Po ./$(DEPDIR)/main_win.Po \
6.215 +@AMDEP_TRUE@ ./$(DEPDIR)/maple.Po ./$(DEPDIR)/mem.Po \
6.216 +@AMDEP_TRUE@ ./$(DEPDIR)/mmio_win.Po ./$(DEPDIR)/mmu.Po \
6.217 +@AMDEP_TRUE@ ./$(DEPDIR)/mouse.Po ./$(DEPDIR)/nrg.Po \
6.218 +@AMDEP_TRUE@ ./$(DEPDIR)/path_dlg.Po ./$(DEPDIR)/pvr2.Po \
6.219 +@AMDEP_TRUE@ ./$(DEPDIR)/pvr2mem.Po ./$(DEPDIR)/rendbkg.Po \
6.220 +@AMDEP_TRUE@ ./$(DEPDIR)/rendsave.Po ./$(DEPDIR)/rendsort.Po \
6.221 +@AMDEP_TRUE@ ./$(DEPDIR)/scene.Po ./$(DEPDIR)/scif.Po \
6.222 @AMDEP_TRUE@ ./$(DEPDIR)/sh4.Po ./$(DEPDIR)/sh4core.Po \
6.223 @AMDEP_TRUE@ ./$(DEPDIR)/sh4dasm.Po ./$(DEPDIR)/sh4mem.Po \
6.224 @AMDEP_TRUE@ ./$(DEPDIR)/sh4mmio.Po ./$(DEPDIR)/sh4stat.Po \
6.225 @@ -409,7 +436,8 @@
6.226 @AMDEP_TRUE@ ./$(DEPDIR)/syscall.Po ./$(DEPDIR)/tacore.Po \
6.227 @AMDEP_TRUE@ ./$(DEPDIR)/testsh4x86.Po ./$(DEPDIR)/testxlt.Po \
6.228 @AMDEP_TRUE@ ./$(DEPDIR)/texcache.Po ./$(DEPDIR)/timer.Po \
6.229 -@AMDEP_TRUE@ ./$(DEPDIR)/util.Po ./$(DEPDIR)/video_glx.Po \
6.230 +@AMDEP_TRUE@ ./$(DEPDIR)/util.Po ./$(DEPDIR)/video_gdk.Po \
6.231 +@AMDEP_TRUE@ ./$(DEPDIR)/video_gl.Po ./$(DEPDIR)/video_glx.Po \
6.232 @AMDEP_TRUE@ ./$(DEPDIR)/video_gtk.Po ./$(DEPDIR)/video_null.Po \
6.233 @AMDEP_TRUE@ ./$(DEPDIR)/watch.Po ./$(DEPDIR)/x86dasm.Po \
6.234 @AMDEP_TRUE@ ./$(DEPDIR)/xltcache.Po ./$(DEPDIR)/yuv.Po
6.235 @@ -522,10 +550,11 @@
6.236 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdrom_menu.Po@am__quote@
6.237 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gendec.Po@am__quote@
6.238 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/genglsl.Po@am__quote@
6.239 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_common.Po@am__quote@
6.240 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_fbo.Po@am__quote@
6.241 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_sl.Po@am__quote@
6.242 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gl_slsrc.Po@am__quote@
6.243 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glrender.Po@am__quote@
6.244 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glutil.Po@am__quote@
6.245 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtkcb.Po@am__quote@
6.246 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtkui.Po@am__quote@
6.247 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i386-dis.Po@am__quote@
6.248 @@ -547,10 +576,9 @@
6.249 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pvr2.Po@am__quote@
6.250 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pvr2mem.Po@am__quote@
6.251 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rendbkg.Po@am__quote@
6.252 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rendcore.Po@am__quote@
6.253 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/render.Po@am__quote@
6.254 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rendsave.Po@am__quote@
6.255 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rendsort.Po@am__quote@
6.256 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scene.Po@am__quote@
6.257 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scif.Po@am__quote@
6.258 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sh4.Po@am__quote@
6.259 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sh4core.Po@am__quote@
6.260 @@ -567,6 +595,8 @@
6.261 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/texcache.Po@am__quote@
6.262 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timer.Po@am__quote@
6.263 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util.Po@am__quote@
6.264 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/video_gdk.Po@am__quote@
6.265 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/video_gl.Po@am__quote@
6.266 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/video_glx.Po@am__quote@
6.267 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/video_gtk.Po@am__quote@
6.268 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/video_null.Po@am__quote@
6.269 @@ -1279,50 +1309,6 @@
6.270 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.271 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tacore.obj `if test -f 'pvr2/tacore.c'; then $(CYGPATH_W) 'pvr2/tacore.c'; else $(CYGPATH_W) '$(srcdir)/pvr2/tacore.c'; fi`
6.272
6.273 -render.o: pvr2/render.c
6.274 -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT render.o -MD -MP -MF "$(DEPDIR)/render.Tpo" \
6.275 -@am__fastdepCC_TRUE@ -c -o render.o `test -f 'pvr2/render.c' || echo '$(srcdir)/'`pvr2/render.c; \
6.276 -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/render.Tpo" "$(DEPDIR)/render.Po"; \
6.277 -@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/render.Tpo"; exit 1; \
6.278 -@am__fastdepCC_TRUE@ fi
6.279 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pvr2/render.c' object='render.o' libtool=no @AMDEPBACKSLASH@
6.280 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/render.Po' tmpdepfile='$(DEPDIR)/render.TPo' @AMDEPBACKSLASH@
6.281 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.282 -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o render.o `test -f 'pvr2/render.c' || echo '$(srcdir)/'`pvr2/render.c
6.283 -
6.284 -render.obj: pvr2/render.c
6.285 -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT render.obj -MD -MP -MF "$(DEPDIR)/render.Tpo" \
6.286 -@am__fastdepCC_TRUE@ -c -o render.obj `if test -f 'pvr2/render.c'; then $(CYGPATH_W) 'pvr2/render.c'; else $(CYGPATH_W) '$(srcdir)/pvr2/render.c'; fi`; \
6.287 -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/render.Tpo" "$(DEPDIR)/render.Po"; \
6.288 -@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/render.Tpo"; exit 1; \
6.289 -@am__fastdepCC_TRUE@ fi
6.290 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pvr2/render.c' object='render.obj' libtool=no @AMDEPBACKSLASH@
6.291 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/render.Po' tmpdepfile='$(DEPDIR)/render.TPo' @AMDEPBACKSLASH@
6.292 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.293 -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o render.obj `if test -f 'pvr2/render.c'; then $(CYGPATH_W) 'pvr2/render.c'; else $(CYGPATH_W) '$(srcdir)/pvr2/render.c'; fi`
6.294 -
6.295 -rendcore.o: pvr2/rendcore.c
6.296 -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT rendcore.o -MD -MP -MF "$(DEPDIR)/rendcore.Tpo" \
6.297 -@am__fastdepCC_TRUE@ -c -o rendcore.o `test -f 'pvr2/rendcore.c' || echo '$(srcdir)/'`pvr2/rendcore.c; \
6.298 -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/rendcore.Tpo" "$(DEPDIR)/rendcore.Po"; \
6.299 -@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/rendcore.Tpo"; exit 1; \
6.300 -@am__fastdepCC_TRUE@ fi
6.301 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pvr2/rendcore.c' object='rendcore.o' libtool=no @AMDEPBACKSLASH@
6.302 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/rendcore.Po' tmpdepfile='$(DEPDIR)/rendcore.TPo' @AMDEPBACKSLASH@
6.303 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.304 -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o rendcore.o `test -f 'pvr2/rendcore.c' || echo '$(srcdir)/'`pvr2/rendcore.c
6.305 -
6.306 -rendcore.obj: pvr2/rendcore.c
6.307 -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT rendcore.obj -MD -MP -MF "$(DEPDIR)/rendcore.Tpo" \
6.308 -@am__fastdepCC_TRUE@ -c -o rendcore.obj `if test -f 'pvr2/rendcore.c'; then $(CYGPATH_W) 'pvr2/rendcore.c'; else $(CYGPATH_W) '$(srcdir)/pvr2/rendcore.c'; fi`; \
6.309 -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/rendcore.Tpo" "$(DEPDIR)/rendcore.Po"; \
6.310 -@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/rendcore.Tpo"; exit 1; \
6.311 -@am__fastdepCC_TRUE@ fi
6.312 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pvr2/rendcore.c' object='rendcore.obj' libtool=no @AMDEPBACKSLASH@
6.313 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/rendcore.Po' tmpdepfile='$(DEPDIR)/rendcore.TPo' @AMDEPBACKSLASH@
6.314 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.315 -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o rendcore.obj `if test -f 'pvr2/rendcore.c'; then $(CYGPATH_W) 'pvr2/rendcore.c'; else $(CYGPATH_W) '$(srcdir)/pvr2/rendcore.c'; fi`
6.316 -
6.317 rendbkg.o: pvr2/rendbkg.c
6.318 @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT rendbkg.o -MD -MP -MF "$(DEPDIR)/rendbkg.Tpo" \
6.319 @am__fastdepCC_TRUE@ -c -o rendbkg.o `test -f 'pvr2/rendbkg.c' || echo '$(srcdir)/'`pvr2/rendbkg.c; \
6.320 @@ -1433,6 +1419,116 @@
6.321 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.322 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o rendsave.obj `if test -f 'pvr2/rendsave.c'; then $(CYGPATH_W) 'pvr2/rendsave.c'; else $(CYGPATH_W) '$(srcdir)/pvr2/rendsave.c'; fi`
6.323
6.324 +scene.o: pvr2/scene.c
6.325 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT scene.o -MD -MP -MF "$(DEPDIR)/scene.Tpo" \
6.326 +@am__fastdepCC_TRUE@ -c -o scene.o `test -f 'pvr2/scene.c' || echo '$(srcdir)/'`pvr2/scene.c; \
6.327 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/scene.Tpo" "$(DEPDIR)/scene.Po"; \
6.328 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/scene.Tpo"; exit 1; \
6.329 +@am__fastdepCC_TRUE@ fi
6.330 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pvr2/scene.c' object='scene.o' libtool=no @AMDEPBACKSLASH@
6.331 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/scene.Po' tmpdepfile='$(DEPDIR)/scene.TPo' @AMDEPBACKSLASH@
6.332 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.333 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o scene.o `test -f 'pvr2/scene.c' || echo '$(srcdir)/'`pvr2/scene.c
6.334 +
6.335 +scene.obj: pvr2/scene.c
6.336 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT scene.obj -MD -MP -MF "$(DEPDIR)/scene.Tpo" \
6.337 +@am__fastdepCC_TRUE@ -c -o scene.obj `if test -f 'pvr2/scene.c'; then $(CYGPATH_W) 'pvr2/scene.c'; else $(CYGPATH_W) '$(srcdir)/pvr2/scene.c'; fi`; \
6.338 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/scene.Tpo" "$(DEPDIR)/scene.Po"; \
6.339 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/scene.Tpo"; exit 1; \
6.340 +@am__fastdepCC_TRUE@ fi
6.341 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pvr2/scene.c' object='scene.obj' libtool=no @AMDEPBACKSLASH@
6.342 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/scene.Po' tmpdepfile='$(DEPDIR)/scene.TPo' @AMDEPBACKSLASH@
6.343 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.344 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o scene.obj `if test -f 'pvr2/scene.c'; then $(CYGPATH_W) 'pvr2/scene.c'; else $(CYGPATH_W) '$(srcdir)/pvr2/scene.c'; fi`
6.345 +
6.346 +gl_sl.o: pvr2/gl_sl.c
6.347 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gl_sl.o -MD -MP -MF "$(DEPDIR)/gl_sl.Tpo" \
6.348 +@am__fastdepCC_TRUE@ -c -o gl_sl.o `test -f 'pvr2/gl_sl.c' || echo '$(srcdir)/'`pvr2/gl_sl.c; \
6.349 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/gl_sl.Tpo" "$(DEPDIR)/gl_sl.Po"; \
6.350 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/gl_sl.Tpo"; exit 1; \
6.351 +@am__fastdepCC_TRUE@ fi
6.352 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pvr2/gl_sl.c' object='gl_sl.o' libtool=no @AMDEPBACKSLASH@
6.353 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/gl_sl.Po' tmpdepfile='$(DEPDIR)/gl_sl.TPo' @AMDEPBACKSLASH@
6.354 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.355 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gl_sl.o `test -f 'pvr2/gl_sl.c' || echo '$(srcdir)/'`pvr2/gl_sl.c
6.356 +
6.357 +gl_sl.obj: pvr2/gl_sl.c
6.358 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gl_sl.obj -MD -MP -MF "$(DEPDIR)/gl_sl.Tpo" \
6.359 +@am__fastdepCC_TRUE@ -c -o gl_sl.obj `if test -f 'pvr2/gl_sl.c'; then $(CYGPATH_W) 'pvr2/gl_sl.c'; else $(CYGPATH_W) '$(srcdir)/pvr2/gl_sl.c'; fi`; \
6.360 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/gl_sl.Tpo" "$(DEPDIR)/gl_sl.Po"; \
6.361 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/gl_sl.Tpo"; exit 1; \
6.362 +@am__fastdepCC_TRUE@ fi
6.363 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pvr2/gl_sl.c' object='gl_sl.obj' libtool=no @AMDEPBACKSLASH@
6.364 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/gl_sl.Po' tmpdepfile='$(DEPDIR)/gl_sl.TPo' @AMDEPBACKSLASH@
6.365 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.366 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gl_sl.obj `if test -f 'pvr2/gl_sl.c'; then $(CYGPATH_W) 'pvr2/gl_sl.c'; else $(CYGPATH_W) '$(srcdir)/pvr2/gl_sl.c'; fi`
6.367 +
6.368 +gl_slsrc.o: pvr2/gl_slsrc.c
6.369 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gl_slsrc.o -MD -MP -MF "$(DEPDIR)/gl_slsrc.Tpo" \
6.370 +@am__fastdepCC_TRUE@ -c -o gl_slsrc.o `test -f 'pvr2/gl_slsrc.c' || echo '$(srcdir)/'`pvr2/gl_slsrc.c; \
6.371 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/gl_slsrc.Tpo" "$(DEPDIR)/gl_slsrc.Po"; \
6.372 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/gl_slsrc.Tpo"; exit 1; \
6.373 +@am__fastdepCC_TRUE@ fi
6.374 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pvr2/gl_slsrc.c' object='gl_slsrc.o' libtool=no @AMDEPBACKSLASH@
6.375 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/gl_slsrc.Po' tmpdepfile='$(DEPDIR)/gl_slsrc.TPo' @AMDEPBACKSLASH@
6.376 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.377 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gl_slsrc.o `test -f 'pvr2/gl_slsrc.c' || echo '$(srcdir)/'`pvr2/gl_slsrc.c
6.378 +
6.379 +gl_slsrc.obj: pvr2/gl_slsrc.c
6.380 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gl_slsrc.obj -MD -MP -MF "$(DEPDIR)/gl_slsrc.Tpo" \
6.381 +@am__fastdepCC_TRUE@ -c -o gl_slsrc.obj `if test -f 'pvr2/gl_slsrc.c'; then $(CYGPATH_W) 'pvr2/gl_slsrc.c'; else $(CYGPATH_W) '$(srcdir)/pvr2/gl_slsrc.c'; fi`; \
6.382 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/gl_slsrc.Tpo" "$(DEPDIR)/gl_slsrc.Po"; \
6.383 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/gl_slsrc.Tpo"; exit 1; \
6.384 +@am__fastdepCC_TRUE@ fi
6.385 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pvr2/gl_slsrc.c' object='gl_slsrc.obj' libtool=no @AMDEPBACKSLASH@
6.386 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/gl_slsrc.Po' tmpdepfile='$(DEPDIR)/gl_slsrc.TPo' @AMDEPBACKSLASH@
6.387 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.388 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gl_slsrc.obj `if test -f 'pvr2/gl_slsrc.c'; then $(CYGPATH_W) 'pvr2/gl_slsrc.c'; else $(CYGPATH_W) '$(srcdir)/pvr2/gl_slsrc.c'; fi`
6.389 +
6.390 +glutil.o: pvr2/glutil.c
6.391 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT glutil.o -MD -MP -MF "$(DEPDIR)/glutil.Tpo" \
6.392 +@am__fastdepCC_TRUE@ -c -o glutil.o `test -f 'pvr2/glutil.c' || echo '$(srcdir)/'`pvr2/glutil.c; \
6.393 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/glutil.Tpo" "$(DEPDIR)/glutil.Po"; \
6.394 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/glutil.Tpo"; exit 1; \
6.395 +@am__fastdepCC_TRUE@ fi
6.396 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pvr2/glutil.c' object='glutil.o' libtool=no @AMDEPBACKSLASH@
6.397 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/glutil.Po' tmpdepfile='$(DEPDIR)/glutil.TPo' @AMDEPBACKSLASH@
6.398 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.399 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o glutil.o `test -f 'pvr2/glutil.c' || echo '$(srcdir)/'`pvr2/glutil.c
6.400 +
6.401 +glutil.obj: pvr2/glutil.c
6.402 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT glutil.obj -MD -MP -MF "$(DEPDIR)/glutil.Tpo" \
6.403 +@am__fastdepCC_TRUE@ -c -o glutil.obj `if test -f 'pvr2/glutil.c'; then $(CYGPATH_W) 'pvr2/glutil.c'; else $(CYGPATH_W) '$(srcdir)/pvr2/glutil.c'; fi`; \
6.404 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/glutil.Tpo" "$(DEPDIR)/glutil.Po"; \
6.405 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/glutil.Tpo"; exit 1; \
6.406 +@am__fastdepCC_TRUE@ fi
6.407 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pvr2/glutil.c' object='glutil.obj' libtool=no @AMDEPBACKSLASH@
6.408 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/glutil.Po' tmpdepfile='$(DEPDIR)/glutil.TPo' @AMDEPBACKSLASH@
6.409 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.410 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o glutil.obj `if test -f 'pvr2/glutil.c'; then $(CYGPATH_W) 'pvr2/glutil.c'; else $(CYGPATH_W) '$(srcdir)/pvr2/glutil.c'; fi`
6.411 +
6.412 +glrender.o: pvr2/glrender.c
6.413 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT glrender.o -MD -MP -MF "$(DEPDIR)/glrender.Tpo" \
6.414 +@am__fastdepCC_TRUE@ -c -o glrender.o `test -f 'pvr2/glrender.c' || echo '$(srcdir)/'`pvr2/glrender.c; \
6.415 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/glrender.Tpo" "$(DEPDIR)/glrender.Po"; \
6.416 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/glrender.Tpo"; exit 1; \
6.417 +@am__fastdepCC_TRUE@ fi
6.418 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pvr2/glrender.c' object='glrender.o' libtool=no @AMDEPBACKSLASH@
6.419 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/glrender.Po' tmpdepfile='$(DEPDIR)/glrender.TPo' @AMDEPBACKSLASH@
6.420 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.421 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o glrender.o `test -f 'pvr2/glrender.c' || echo '$(srcdir)/'`pvr2/glrender.c
6.422 +
6.423 +glrender.obj: pvr2/glrender.c
6.424 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT glrender.obj -MD -MP -MF "$(DEPDIR)/glrender.Tpo" \
6.425 +@am__fastdepCC_TRUE@ -c -o glrender.obj `if test -f 'pvr2/glrender.c'; then $(CYGPATH_W) 'pvr2/glrender.c'; else $(CYGPATH_W) '$(srcdir)/pvr2/glrender.c'; fi`; \
6.426 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/glrender.Tpo" "$(DEPDIR)/glrender.Po"; \
6.427 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/glrender.Tpo"; exit 1; \
6.428 +@am__fastdepCC_TRUE@ fi
6.429 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pvr2/glrender.c' object='glrender.obj' libtool=no @AMDEPBACKSLASH@
6.430 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/glrender.Po' tmpdepfile='$(DEPDIR)/glrender.TPo' @AMDEPBACKSLASH@
6.431 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.432 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o glrender.obj `if test -f 'pvr2/glrender.c'; then $(CYGPATH_W) 'pvr2/glrender.c'; else $(CYGPATH_W) '$(srcdir)/pvr2/glrender.c'; fi`
6.433 +
6.434 maple.o: maple/maple.c
6.435 @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT maple.o -MD -MP -MF "$(DEPDIR)/maple.Tpo" \
6.436 @am__fastdepCC_TRUE@ -c -o maple.o `test -f 'maple/maple.c' || echo '$(srcdir)/'`maple/maple.c; \
6.437 @@ -1565,27 +1661,27 @@
6.438 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.439 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o video_null.obj `if test -f 'drivers/video_null.c'; then $(CYGPATH_W) 'drivers/video_null.c'; else $(CYGPATH_W) '$(srcdir)/drivers/video_null.c'; fi`
6.440
6.441 -gl_common.o: drivers/gl_common.c
6.442 -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gl_common.o -MD -MP -MF "$(DEPDIR)/gl_common.Tpo" \
6.443 -@am__fastdepCC_TRUE@ -c -o gl_common.o `test -f 'drivers/gl_common.c' || echo '$(srcdir)/'`drivers/gl_common.c; \
6.444 -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/gl_common.Tpo" "$(DEPDIR)/gl_common.Po"; \
6.445 -@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/gl_common.Tpo"; exit 1; \
6.446 +video_gl.o: drivers/video_gl.c
6.447 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT video_gl.o -MD -MP -MF "$(DEPDIR)/video_gl.Tpo" \
6.448 +@am__fastdepCC_TRUE@ -c -o video_gl.o `test -f 'drivers/video_gl.c' || echo '$(srcdir)/'`drivers/video_gl.c; \
6.449 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/video_gl.Tpo" "$(DEPDIR)/video_gl.Po"; \
6.450 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/video_gl.Tpo"; exit 1; \
6.451 @am__fastdepCC_TRUE@ fi
6.452 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drivers/gl_common.c' object='gl_common.o' libtool=no @AMDEPBACKSLASH@
6.453 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/gl_common.Po' tmpdepfile='$(DEPDIR)/gl_common.TPo' @AMDEPBACKSLASH@
6.454 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drivers/video_gl.c' object='video_gl.o' libtool=no @AMDEPBACKSLASH@
6.455 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/video_gl.Po' tmpdepfile='$(DEPDIR)/video_gl.TPo' @AMDEPBACKSLASH@
6.456 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.457 -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gl_common.o `test -f 'drivers/gl_common.c' || echo '$(srcdir)/'`drivers/gl_common.c
6.458 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o video_gl.o `test -f 'drivers/video_gl.c' || echo '$(srcdir)/'`drivers/video_gl.c
6.459
6.460 -gl_common.obj: drivers/gl_common.c
6.461 -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gl_common.obj -MD -MP -MF "$(DEPDIR)/gl_common.Tpo" \
6.462 -@am__fastdepCC_TRUE@ -c -o gl_common.obj `if test -f 'drivers/gl_common.c'; then $(CYGPATH_W) 'drivers/gl_common.c'; else $(CYGPATH_W) '$(srcdir)/drivers/gl_common.c'; fi`; \
6.463 -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/gl_common.Tpo" "$(DEPDIR)/gl_common.Po"; \
6.464 -@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/gl_common.Tpo"; exit 1; \
6.465 +video_gl.obj: drivers/video_gl.c
6.466 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT video_gl.obj -MD -MP -MF "$(DEPDIR)/video_gl.Tpo" \
6.467 +@am__fastdepCC_TRUE@ -c -o video_gl.obj `if test -f 'drivers/video_gl.c'; then $(CYGPATH_W) 'drivers/video_gl.c'; else $(CYGPATH_W) '$(srcdir)/drivers/video_gl.c'; fi`; \
6.468 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/video_gl.Tpo" "$(DEPDIR)/video_gl.Po"; \
6.469 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/video_gl.Tpo"; exit 1; \
6.470 @am__fastdepCC_TRUE@ fi
6.471 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drivers/gl_common.c' object='gl_common.obj' libtool=no @AMDEPBACKSLASH@
6.472 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/gl_common.Po' tmpdepfile='$(DEPDIR)/gl_common.TPo' @AMDEPBACKSLASH@
6.473 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drivers/video_gl.c' object='video_gl.obj' libtool=no @AMDEPBACKSLASH@
6.474 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/video_gl.Po' tmpdepfile='$(DEPDIR)/video_gl.TPo' @AMDEPBACKSLASH@
6.475 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.476 -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gl_common.obj `if test -f 'drivers/gl_common.c'; then $(CYGPATH_W) 'drivers/gl_common.c'; else $(CYGPATH_W) '$(srcdir)/drivers/gl_common.c'; fi`
6.477 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o video_gl.obj `if test -f 'drivers/video_gl.c'; then $(CYGPATH_W) 'drivers/video_gl.c'; else $(CYGPATH_W) '$(srcdir)/drivers/video_gl.c'; fi`
6.478
6.479 gl_fbo.o: drivers/gl_fbo.c
6.480 @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gl_fbo.o -MD -MP -MF "$(DEPDIR)/gl_fbo.Tpo" \
6.481 @@ -1609,50 +1705,6 @@
6.482 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.483 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gl_fbo.obj `if test -f 'drivers/gl_fbo.c'; then $(CYGPATH_W) 'drivers/gl_fbo.c'; else $(CYGPATH_W) '$(srcdir)/drivers/gl_fbo.c'; fi`
6.484
6.485 -gl_sl.o: drivers/gl_sl.c
6.486 -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gl_sl.o -MD -MP -MF "$(DEPDIR)/gl_sl.Tpo" \
6.487 -@am__fastdepCC_TRUE@ -c -o gl_sl.o `test -f 'drivers/gl_sl.c' || echo '$(srcdir)/'`drivers/gl_sl.c; \
6.488 -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/gl_sl.Tpo" "$(DEPDIR)/gl_sl.Po"; \
6.489 -@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/gl_sl.Tpo"; exit 1; \
6.490 -@am__fastdepCC_TRUE@ fi
6.491 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drivers/gl_sl.c' object='gl_sl.o' libtool=no @AMDEPBACKSLASH@
6.492 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/gl_sl.Po' tmpdepfile='$(DEPDIR)/gl_sl.TPo' @AMDEPBACKSLASH@
6.493 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.494 -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gl_sl.o `test -f 'drivers/gl_sl.c' || echo '$(srcdir)/'`drivers/gl_sl.c
6.495 -
6.496 -gl_sl.obj: drivers/gl_sl.c
6.497 -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gl_sl.obj -MD -MP -MF "$(DEPDIR)/gl_sl.Tpo" \
6.498 -@am__fastdepCC_TRUE@ -c -o gl_sl.obj `if test -f 'drivers/gl_sl.c'; then $(CYGPATH_W) 'drivers/gl_sl.c'; else $(CYGPATH_W) '$(srcdir)/drivers/gl_sl.c'; fi`; \
6.499 -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/gl_sl.Tpo" "$(DEPDIR)/gl_sl.Po"; \
6.500 -@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/gl_sl.Tpo"; exit 1; \
6.501 -@am__fastdepCC_TRUE@ fi
6.502 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drivers/gl_sl.c' object='gl_sl.obj' libtool=no @AMDEPBACKSLASH@
6.503 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/gl_sl.Po' tmpdepfile='$(DEPDIR)/gl_sl.TPo' @AMDEPBACKSLASH@
6.504 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.505 -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gl_sl.obj `if test -f 'drivers/gl_sl.c'; then $(CYGPATH_W) 'drivers/gl_sl.c'; else $(CYGPATH_W) '$(srcdir)/drivers/gl_sl.c'; fi`
6.506 -
6.507 -gl_slsrc.o: drivers/gl_slsrc.c
6.508 -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gl_slsrc.o -MD -MP -MF "$(DEPDIR)/gl_slsrc.Tpo" \
6.509 -@am__fastdepCC_TRUE@ -c -o gl_slsrc.o `test -f 'drivers/gl_slsrc.c' || echo '$(srcdir)/'`drivers/gl_slsrc.c; \
6.510 -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/gl_slsrc.Tpo" "$(DEPDIR)/gl_slsrc.Po"; \
6.511 -@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/gl_slsrc.Tpo"; exit 1; \
6.512 -@am__fastdepCC_TRUE@ fi
6.513 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drivers/gl_slsrc.c' object='gl_slsrc.o' libtool=no @AMDEPBACKSLASH@
6.514 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/gl_slsrc.Po' tmpdepfile='$(DEPDIR)/gl_slsrc.TPo' @AMDEPBACKSLASH@
6.515 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.516 -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gl_slsrc.o `test -f 'drivers/gl_slsrc.c' || echo '$(srcdir)/'`drivers/gl_slsrc.c
6.517 -
6.518 -gl_slsrc.obj: drivers/gl_slsrc.c
6.519 -@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT gl_slsrc.obj -MD -MP -MF "$(DEPDIR)/gl_slsrc.Tpo" \
6.520 -@am__fastdepCC_TRUE@ -c -o gl_slsrc.obj `if test -f 'drivers/gl_slsrc.c'; then $(CYGPATH_W) 'drivers/gl_slsrc.c'; else $(CYGPATH_W) '$(srcdir)/drivers/gl_slsrc.c'; fi`; \
6.521 -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/gl_slsrc.Tpo" "$(DEPDIR)/gl_slsrc.Po"; \
6.522 -@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/gl_slsrc.Tpo"; exit 1; \
6.523 -@am__fastdepCC_TRUE@ fi
6.524 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drivers/gl_slsrc.c' object='gl_slsrc.obj' libtool=no @AMDEPBACKSLASH@
6.525 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/gl_slsrc.Po' tmpdepfile='$(DEPDIR)/gl_slsrc.TPo' @AMDEPBACKSLASH@
6.526 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.527 -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o gl_slsrc.obj `if test -f 'drivers/gl_slsrc.c'; then $(CYGPATH_W) 'drivers/gl_slsrc.c'; else $(CYGPATH_W) '$(srcdir)/drivers/gl_slsrc.c'; fi`
6.528 -
6.529 sh4x86.o: sh4/sh4x86.c
6.530 @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sh4x86.o -MD -MP -MF "$(DEPDIR)/sh4x86.Tpo" \
6.531 @am__fastdepCC_TRUE@ -c -o sh4x86.o `test -f 'sh4/sh4x86.c' || echo '$(srcdir)/'`sh4/sh4x86.c; \
6.532 @@ -2005,6 +2057,28 @@
6.533 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.534 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o video_gtk.obj `if test -f 'drivers/video_gtk.c'; then $(CYGPATH_W) 'drivers/video_gtk.c'; else $(CYGPATH_W) '$(srcdir)/drivers/video_gtk.c'; fi`
6.535
6.536 +video_gdk.o: drivers/video_gdk.c
6.537 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT video_gdk.o -MD -MP -MF "$(DEPDIR)/video_gdk.Tpo" \
6.538 +@am__fastdepCC_TRUE@ -c -o video_gdk.o `test -f 'drivers/video_gdk.c' || echo '$(srcdir)/'`drivers/video_gdk.c; \
6.539 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/video_gdk.Tpo" "$(DEPDIR)/video_gdk.Po"; \
6.540 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/video_gdk.Tpo"; exit 1; \
6.541 +@am__fastdepCC_TRUE@ fi
6.542 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drivers/video_gdk.c' object='video_gdk.o' libtool=no @AMDEPBACKSLASH@
6.543 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/video_gdk.Po' tmpdepfile='$(DEPDIR)/video_gdk.TPo' @AMDEPBACKSLASH@
6.544 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.545 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o video_gdk.o `test -f 'drivers/video_gdk.c' || echo '$(srcdir)/'`drivers/video_gdk.c
6.546 +
6.547 +video_gdk.obj: drivers/video_gdk.c
6.548 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT video_gdk.obj -MD -MP -MF "$(DEPDIR)/video_gdk.Tpo" \
6.549 +@am__fastdepCC_TRUE@ -c -o video_gdk.obj `if test -f 'drivers/video_gdk.c'; then $(CYGPATH_W) 'drivers/video_gdk.c'; else $(CYGPATH_W) '$(srcdir)/drivers/video_gdk.c'; fi`; \
6.550 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/video_gdk.Tpo" "$(DEPDIR)/video_gdk.Po"; \
6.551 +@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/video_gdk.Tpo"; exit 1; \
6.552 +@am__fastdepCC_TRUE@ fi
6.553 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drivers/video_gdk.c' object='video_gdk.obj' libtool=no @AMDEPBACKSLASH@
6.554 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/video_gdk.Po' tmpdepfile='$(DEPDIR)/video_gdk.TPo' @AMDEPBACKSLASH@
6.555 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
6.556 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o video_gdk.obj `if test -f 'drivers/video_gdk.c'; then $(CYGPATH_W) 'drivers/video_gdk.c'; else $(CYGPATH_W) '$(srcdir)/drivers/video_gdk.c'; fi`
6.557 +
6.558 video_glx.o: drivers/video_glx.c
6.559 @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT video_glx.o -MD -MP -MF "$(DEPDIR)/video_glx.Tpo" \
6.560 @am__fastdepCC_TRUE@ -c -o video_glx.o `test -f 'drivers/video_glx.c' || echo '$(srcdir)/'`drivers/video_glx.c; \
6.561 @@ -2445,8 +2519,8 @@
6.562 ./gendec sh4/sh4.def sh4/sh4x86.in -o sh4/sh4x86.c
6.563 sh4/sh4stat.c: gendec sh4/sh4.def sh4/sh4stat.in
6.564 ./gendec sh4/sh4.def sh4/sh4stat.in -o sh4/sh4stat.c
6.565 -drivers/gl_slsrc.c: genglsl drivers/vertex.glsl drivers/fragment.glsl
6.566 - ./genglsl drivers/vertex.glsl drivers/fragment.glsl drivers/gl_slsrc.c
6.567 +pvr2/gl_slsrc.c: genglsl pvr2/vertex.glsl pvr2/fragment.glsl
6.568 + ./genglsl pvr2/vertex.glsl pvr2/fragment.glsl pvr2/gl_slsrc.c
6.569 # Tell versions [3.59,3.63) of GNU make to not export all variables.
6.570 # Otherwise a system limit (for SysV at least) may be exceeded.
6.571 .NOEXPORT:
7.1 --- a/src/drivers/fragment.glsl Sun Mar 02 11:38:08 2008 +0000
7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
7.3 @@ -1,6 +0,0 @@
7.4 -// Standard PVR2 fragment shader
7.5 -
7.6 -void main()
7.7 -{
7.8 - gl_FragColor = gl_Color;
7.9 -}
7.10 \ No newline at end of file
8.1 --- a/src/drivers/gl_common.c Sun Mar 02 11:38:08 2008 +0000
8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
8.3 @@ -1,213 +0,0 @@
8.4 -/**
8.5 - * $Id$
8.6 - *
8.7 - * Common GL code that doesn't depend on a specific implementation
8.8 - *
8.9 - * Copyright (c) 2005 Nathan Keynes.
8.10 - *
8.11 - * This program is free software; you can redistribute it and/or modify
8.12 - * it under the terms of the GNU General Public License as published by
8.13 - * the Free Software Foundation; either version 2 of the License, or
8.14 - * (at your option) any later version.
8.15 - *
8.16 - * This program is distributed in the hope that it will be useful,
8.17 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
8.18 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8.19 - * GNU General Public License for more details.
8.20 - */
8.21 -
8.22 -#include <sys/time.h>
8.23 -
8.24 -#include "display.h"
8.25 -#include "pvr2/pvr2.h"
8.26 -#include "drivers/gl_common.h"
8.27 -
8.28 -extern uint32_t video_width, video_height;
8.29 -
8.30 -char *required_extensions[] = { "GL_EXT_framebuffer_object", NULL };
8.31 -
8.32 -/**
8.33 - * Test if a specific extension is supported. From opengl.org
8.34 - * @param extension extension name to check for
8.35 - * @return TRUE if supported, otherwise FALSE.
8.36 - */
8.37 -gboolean isGLExtensionSupported( const char *extension )
8.38 -{
8.39 - const GLubyte *extensions = NULL;
8.40 - const GLubyte *start;
8.41 - GLubyte *where, *terminator;
8.42 -
8.43 - /* Extension names should not have spaces. */
8.44 - where = (GLubyte *) strchr(extension, ' ');
8.45 - if (where || *extension == '\0')
8.46 - return 0;
8.47 - extensions = glGetString(GL_EXTENSIONS);
8.48 - /* It takes a bit of care to be fool-proof about parsing the
8.49 - OpenGL extensions string. Don't be fooled by sub-strings,
8.50 - etc. */
8.51 - start = extensions;
8.52 - for (;;) {
8.53 - where = (GLubyte *) strstr((const char *) start, extension);
8.54 - if (!where)
8.55 - break;
8.56 - terminator = where + strlen(extension);
8.57 - if (where == start || *(where - 1) == ' ')
8.58 - if (*terminator == ' ' || *terminator == '\0')
8.59 - return TRUE;
8.60 - start = terminator;
8.61 - }
8.62 - return FALSE;
8.63 -}
8.64 -
8.65 -gboolean hasRequiredGLExtensions( )
8.66 -{
8.67 - int i;
8.68 - gboolean isOK = TRUE;
8.69 -
8.70 - for( i=0; required_extensions[i] != NULL; i++ ) {
8.71 - if( !isGLExtensionSupported(required_extensions[i]) ) {
8.72 - ERROR( "Required OpenGL extension not supported: %s", required_extensions[i] );
8.73 - isOK = FALSE;
8.74 - }
8.75 - }
8.76 - return isOK;
8.77 -}
8.78 -
8.79 -/**
8.80 - * Reset the gl state to simple orthographic projection with
8.81 - * texturing, alpha/depth/scissor/cull tests disabled.
8.82 - */
8.83 -void gl_reset_state()
8.84 -{
8.85 - glViewport( 0, 0, video_width, video_height );
8.86 - glMatrixMode(GL_PROJECTION);
8.87 - glLoadIdentity();
8.88 - glOrtho( 0, video_width, video_height, 0, 0, -65535 );
8.89 - glMatrixMode(GL_MODELVIEW);
8.90 - glLoadIdentity();
8.91 - glDisable( GL_TEXTURE_2D );
8.92 - glDisable( GL_ALPHA_TEST );
8.93 - glDisable( GL_DEPTH_TEST );
8.94 - glDisable( GL_SCISSOR_TEST );
8.95 - glDisable( GL_CULL_FACE );
8.96 - glDrawBuffer( GL_FRONT );
8.97 -}
8.98 -
8.99 -void gl_display_render_buffer( render_buffer_t buffer )
8.100 -{
8.101 - gl_texture_window( buffer->width, buffer->height, buffer->buf_id, buffer->inverted );
8.102 -}
8.103 -
8.104 -void gl_texture_window( int width, int height, int tex_id, gboolean inverted )
8.105 -{
8.106 - float top, bottom;
8.107 - if( inverted ) {
8.108 - top = ((float)height);
8.109 - bottom = 0;
8.110 - } else {
8.111 - top = 0;
8.112 - bottom = ((float)height);
8.113 - }
8.114 -
8.115 - /* Reset display parameters */
8.116 - gl_reset_state();
8.117 - glColor3f( 0,0,0 );
8.118 -
8.119 - int x1=0,y1=0,x2=video_width,y2=video_height;
8.120 -
8.121 - int ah = video_width * 0.75;
8.122 -
8.123 - if( ah > video_height ) {
8.124 - int w = (video_height/0.75);
8.125 - x1 = (video_width - w)/2;
8.126 - x2 -= x1;
8.127 -
8.128 - glBegin( GL_QUADS );
8.129 - glVertex2f( 0, 0 );
8.130 - glVertex2f( x1, 0 );
8.131 - glVertex2f( x1, video_height );
8.132 - glVertex2f( 0, video_height);
8.133 - glVertex2f( x2, 0 );
8.134 - glVertex2f( video_width, 0 );
8.135 - glVertex2f( video_width, video_height );
8.136 - glVertex2f( x2, video_height);
8.137 - glEnd();
8.138 - } else if( ah < video_height ) {
8.139 - y1 = (video_height - ah)/2;
8.140 - y2 -= y1;
8.141 - glBegin( GL_QUADS );
8.142 - glVertex2f( 0, 0 );
8.143 - glVertex2f( video_width, 0 );
8.144 - glVertex2f( video_width, y1 );
8.145 - glVertex2f( 0, y1 );
8.146 - glVertex2f( 0, y2 );
8.147 - glVertex2f( video_width, y2 );
8.148 - glVertex2f( video_width, video_height );
8.149 - glVertex2f( 0, video_height );
8.150 - glEnd();
8.151 - }
8.152 -
8.153 - /* Render the textured rectangle */
8.154 - glEnable( GL_TEXTURE_RECTANGLE_ARB );
8.155 - glBindTexture( GL_TEXTURE_RECTANGLE_ARB, tex_id );
8.156 - glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
8.157 - glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
8.158 - glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
8.159 - glEnable( GL_BLEND );
8.160 - glBlendFunc( GL_ONE, GL_ZERO );
8.161 - glBegin( GL_QUADS );
8.162 - glTexCoord2f( 0, top );
8.163 - glVertex2f( x1, y1 );
8.164 - glTexCoord2f( ((float)width), top );
8.165 - glVertex2f( x2, y1 );
8.166 - glTexCoord2f( ((float)width), bottom );
8.167 - glVertex2f( x2, y2 );
8.168 - glTexCoord2f( 0, bottom );
8.169 - glVertex2f( x1, y2 );
8.170 - glEnd();
8.171 - glDisable( GL_TEXTURE_RECTANGLE_ARB );
8.172 - glFlush();
8.173 -}
8.174 -
8.175 -gboolean gl_load_frame_buffer( frame_buffer_t frame, int tex_id )
8.176 -{
8.177 - GLenum type = colour_formats[frame->colour_format].type;
8.178 - GLenum format = colour_formats[frame->colour_format].format;
8.179 - int bpp = colour_formats[frame->colour_format].bpp;
8.180 - int rowstride = (frame->rowstride / bpp) - frame->width;
8.181 -
8.182 - glPixelStorei( GL_UNPACK_ROW_LENGTH, rowstride );
8.183 - glBindTexture( GL_TEXTURE_RECTANGLE_ARB, tex_id );
8.184 - glTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0,0,
8.185 - frame->width, frame->height, format, type, frame->data );
8.186 - return TRUE;
8.187 -}
8.188 -
8.189 -gboolean gl_display_blank( uint32_t colour )
8.190 -{
8.191 - gl_reset_state();
8.192 - glColor3ub( (colour >> 16) & 0xFF, (colour >> 8) & 0xFF, colour & 0xFF );
8.193 - glRecti(0,0, video_width, video_height );
8.194 - glFlush();
8.195 - return TRUE;
8.196 -}
8.197 -
8.198 -/**
8.199 - * Generic GL read_render_buffer. This function assumes that the caller
8.200 - * has already set the appropriate glReadBuffer(); in other words, unless
8.201 - * there's only one buffer this needs to be wrapped.
8.202 - */
8.203 -gboolean gl_read_render_buffer( unsigned char *target, render_buffer_t buffer,
8.204 - int rowstride, int colour_format )
8.205 -{
8.206 - glFinish();
8.207 - GLenum type = colour_formats[colour_format].type;
8.208 - GLenum format = colour_formats[colour_format].format;
8.209 - // int line_size = buffer->width * colour_formats[colour_format].bpp;
8.210 - // int size = line_size * buffer->height;
8.211 - int glrowstride = (rowstride / colour_formats[colour_format].bpp) - buffer->width;
8.212 - glPixelStorei( GL_PACK_ROW_LENGTH, glrowstride );
8.213 -
8.214 - glReadPixels( 0, 0, buffer->width, buffer->height, format, type, target );
8.215 - return TRUE;
8.216 -}
9.1 --- a/src/drivers/gl_common.h Sun Mar 02 11:38:08 2008 +0000
9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
9.3 @@ -1,81 +0,0 @@
9.4 -/**
9.5 - * $Id$
9.6 - *
9.7 - * Parent for all X11 display drivers.
9.8 - *
9.9 - * Copyright (c) 2005 Nathan Keynes.
9.10 - *
9.11 - * This program is free software; you can redistribute it and/or modify
9.12 - * it under the terms of the GNU General Public License as published by
9.13 - * the Free Software Foundation; either version 2 of the License, or
9.14 - * (at your option) any later version.
9.15 - *
9.16 - * This program is distributed in the hope that it will be useful,
9.17 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
9.18 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9.19 - * GNU General Public License for more details.
9.20 - */
9.21 -
9.22 -#ifndef video_gl_common_H
9.23 -#define video_gl_common_H
9.24 -
9.25 -#include "display.h"
9.26 -
9.27 -/**
9.28 - * Test if a specific extension is supported. From opengl.org
9.29 - * @param extension extension name to check for
9.30 - * @return TRUE if supported, otherwise FALSE.
9.31 - */
9.32 -gboolean isGLExtensionSupported( const char *extension );
9.33 -
9.34 -gboolean hasRequiredGLExtensions();
9.35 -
9.36 -/**
9.37 - * Generic GL routine to draw the given frame buffer into a texture
9.38 - */
9.39 -gboolean gl_load_frame_buffer( frame_buffer_t frame, int tex_id );
9.40 -
9.41 -/**
9.42 - * Generic GL routine to blank the display view with the specified colour.
9.43 - */
9.44 -gboolean gl_display_blank( uint32_t colour );
9.45 -
9.46 -/**
9.47 - * Write a rectangular texture (GL_TEXTURE_RECTANGLE_ARB) to the display frame
9.48 - */
9.49 -void gl_display_render_buffer( render_buffer_t buffer );
9.50 -
9.51 -/**
9.52 - * Write a rectangular texture (GL_TEXTURE_RECTANGLE_ARB) to the display frame
9.53 - */
9.54 -void gl_texture_window( int width, int height, int tex_id, gboolean inverted );
9.55 -
9.56 -/**
9.57 - * Redisplay the last frame.
9.58 - */
9.59 -void gl_redisplay_last();
9.60 -
9.61 -/**
9.62 - * Generic GL read_render_buffer. This function assumes that the caller
9.63 - * has already set the appropriate glReadBuffer(); in other words, unless
9.64 - * there's only one buffer this needs to be wrapped.
9.65 - */
9.66 -gboolean gl_read_render_buffer( unsigned char *target, render_buffer_t buffer,
9.67 - int rowstride, int colour_format );
9.68 -
9.69 -
9.70 -/****** FBO handling (gl_fbo.c) ******/
9.71 -gboolean gl_fbo_is_supported();
9.72 -void gl_fbo_shutdown();
9.73 -void gl_fbo_init( display_driver_t driver );
9.74 -void gl_fbo_detach();
9.75 -
9.76 -/****** Shader handling (gl_sl.c) *****/
9.77 -gboolean glsl_is_supported(void);
9.78 -gboolean glsl_load_shaders( const char *vert_shader, const char *frag_shader );
9.79 -void glsl_unload_shaders(void);
9.80 -
9.81 -extern const char *glsl_vertex_shader_src;
9.82 -extern const char *glsl_fragment_shader_src;
9.83 -
9.84 -#endif /* !video_gl_common_H */
10.1 --- a/src/drivers/gl_fbo.c Sun Mar 02 11:38:08 2008 +0000
10.2 +++ b/src/drivers/gl_fbo.c Fri Mar 28 12:32:25 2008 +0000
10.3 @@ -27,7 +27,8 @@
10.4 #include <stdlib.h>
10.5 #include "lxdream.h"
10.6 #include "display.h"
10.7 -#include "drivers/gl_common.h"
10.8 +#include "drivers/video_gl.h"
10.9 +#include "pvr2/glutil.h"
10.10
10.11 #define MAX_FRAMEBUFFERS 2
10.12 #define MAX_TEXTURES_PER_FB 4
10.13 @@ -238,6 +239,7 @@
10.14 gl_fbo_attach_texture( fb, buffer->buf_id );
10.15 /* setup the gl context */
10.16 glViewport( 0, 0, buffer->width, buffer->height );
10.17 + glsl_enable_shader(TRUE);
10.18
10.19 return TRUE;
10.20 }
10.21 @@ -250,6 +252,7 @@
10.22 {
10.23 glFinish();
10.24 gl_fbo_detach();
10.25 + glsl_enable_shader(FALSE);
10.26 gl_display_render_buffer( buffer );
10.27 return TRUE;
10.28 }
10.29 @@ -258,6 +261,7 @@
10.30 {
10.31 glFinish();
10.32 gl_fbo_detach();
10.33 + glsl_enable_shader(FALSE);
10.34 gl_load_frame_buffer( frame, buffer->buf_id );
10.35 }
10.36
10.37 @@ -265,6 +269,7 @@
10.38 {
10.39 glFinish();
10.40 gl_fbo_detach();
10.41 + glsl_enable_shader(FALSE);
10.42 return gl_display_blank( colour );
10.43 }
10.44
11.1 --- a/src/drivers/gl_sl.c Sun Mar 02 11:38:08 2008 +0000
11.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
11.3 @@ -1,173 +0,0 @@
11.4 -/**
11.5 - * $Id$
11.6 - *
11.7 - * GLSL shader loader/unloader. Current version assumes there's exactly
11.8 - * 1 shader program that's used globally. This may turn out not to be the
11.9 - * most efficient approach.
11.10 - *
11.11 - * Copyright (c) 2007 Nathan Keynes.
11.12 - *
11.13 - * This program is free software; you can redistribute it and/or modify
11.14 - * it under the terms of the GNU General Public License as published by
11.15 - * the Free Software Foundation; either version 2 of the License, or
11.16 - * (at your option) any later version.
11.17 - *
11.18 - * This program is distributed in the hope that it will be useful,
11.19 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
11.20 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11.21 - * GNU General Public License for more details.
11.22 - */
11.23 -
11.24 -#define GL_GLEXT_PROTOTYPES 1
11.25 -
11.26 -#include "lxdream.h"
11.27 -#include "display.h"
11.28 -#include "drivers/gl_common.h"
11.29 -
11.30 -#define MAX_ERROR_BUF 4096
11.31 -
11.32 -gboolean glsl_is_supported()
11.33 -{
11.34 - return isGLExtensionSupported("GL_ARB_fragment_shader") &&
11.35 - isGLExtensionSupported("GL_ARB_vertex_shader") &&
11.36 - isGLExtensionSupported("GL_ARB_shading_language_100");
11.37 -}
11.38 -
11.39 -#ifdef GL_ARB_shader_objects
11.40 -static GLhandleARB glsl_program, glsl_vert_shader, glsl_frag_shader;
11.41 -
11.42 -void glsl_print_error( char *msg, GLhandleARB obj )
11.43 -{
11.44 - char buf[MAX_ERROR_BUF];
11.45 - GLsizei length;
11.46 - glGetInfoLogARB( obj, sizeof(buf), &length, buf );
11.47 - ERROR( "%s: %s", msg, buf );
11.48 -}
11.49 -
11.50 -gboolean glsl_check_shader_error( char *msg, GLhandleARB obj )
11.51 -{
11.52 - GLint value;
11.53 -
11.54 - glGetObjectParameterivARB(obj, GL_OBJECT_COMPILE_STATUS_ARB, &value);
11.55 - if( value == 0 ) {
11.56 - glsl_print_error(msg, obj);
11.57 - return FALSE;
11.58 - }
11.59 - return TRUE;
11.60 -}
11.61 -
11.62 -gboolean glsl_check_program_error( char *msg, GLhandleARB obj )
11.63 -{
11.64 - if( glGetError() != GL_NO_ERROR ) {
11.65 - glsl_print_error(msg, obj);
11.66 - }
11.67 - return TRUE;
11.68 -}
11.69 -
11.70 -
11.71 -gboolean glsl_load_shaders( const char *vertex_src, const char *fragment_src )
11.72 -{
11.73 - gboolean vsok, fsok, pok = FALSE;
11.74 - glsl_program = glCreateProgramObjectARB();
11.75 -
11.76 - glsl_vert_shader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
11.77 - glsl_frag_shader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
11.78 - glShaderSourceARB( glsl_vert_shader, 1, &vertex_src, NULL );
11.79 - glCompileShaderARB(glsl_vert_shader);
11.80 - vsok = glsl_check_shader_error("Failed to compile vertex shader", glsl_vert_shader);
11.81 - glShaderSourceARB( glsl_frag_shader, 1, &fragment_src, NULL );
11.82 - glCompileShaderARB(glsl_frag_shader);
11.83 - fsok = glsl_check_shader_error("Failed to compile fragment shader", glsl_frag_shader);
11.84 -
11.85 - if( vsok && fsok ) {
11.86 - glAttachObjectARB(glsl_program, glsl_vert_shader);
11.87 - glAttachObjectARB(glsl_program, glsl_frag_shader);
11.88 - glLinkProgramARB(glsl_program);
11.89 - pok = glsl_check_program_error( "Failed to link shader program", glsl_program );
11.90 - }
11.91 - if( pok ) {
11.92 - glUseProgramObjectARB(glsl_program);
11.93 - pok = glsl_check_program_error( "Failed to apply shader program", glsl_program );
11.94 - } else {
11.95 - glsl_unload_shaders();
11.96 - }
11.97 - return pok;
11.98 -}
11.99 -
11.100 -void glsl_unload_shaders(void)
11.101 -{
11.102 - glUseProgramObjectARB(0);
11.103 - glDetachObjectARB(glsl_program, glsl_vert_shader);
11.104 - glDetachObjectARB(glsl_program, glsl_frag_shader);
11.105 - glDeleteObjectARB(glsl_program);
11.106 - glDeleteObjectARB(glsl_vert_shader);
11.107 - glDeleteObjectARB(glsl_frag_shader);
11.108 -}
11.109 -
11.110 -#else
11.111 -static GLuint glsl_program, glsl_vert_shader, glsl_frag_shader;
11.112 -
11.113 -gboolean glsl_check_shader_error( char *msg, GLuint shader )
11.114 -{
11.115 - GLint value;
11.116 -
11.117 - glGetShaderiv( shader, GL_COMPILE_STATUS, &value );
11.118 - if( value == 0 ) {
11.119 - char buf[MAX_ERROR_BUF];
11.120 - GLsizei length;
11.121 - glGetShaderInfoLog( shader, sizeof(buf), &length, buf );
11.122 - ERROR( "%s: %s", msg, buf );
11.123 - return FALSE;
11.124 - }
11.125 - return TRUE;
11.126 -}
11.127 -gboolean glsl_check_program_error( char *msg, GLuint program )
11.128 -{
11.129 - if( glGetError() != GL_NO_ERROR ) {
11.130 - char buf[MAX_ERROR_BUF];
11.131 - GLsizei length;
11.132 - glGetProgramInfoLog( program, sizeof(buf), &length, buf );
11.133 - ERROR( "%s: %s", msg, buf );
11.134 - return FALSE;
11.135 - }
11.136 - return TRUE;
11.137 -}
11.138 -
11.139 -gboolean glsl_load_shaders( const char *vertex_src, const char *fragment_src )
11.140 -{
11.141 - gboolean vsok, fsok, pok = FALSE;
11.142 - glsl_program = glCreateProgram();
11.143 - glsl_vert_shader = glCreateShader(GL_VERTEX_SHADER);
11.144 - glsl_frag_shader = glCreateShader(GL_FRAGMENT_SHADER);
11.145 - glShaderSource( glsl_vert_shader, 1, &vertex_src, NULL );
11.146 - glCompileShader(glsl_vert_shader);
11.147 - vsok = glsl_check_shader_error( "Failed to compile vertex shader", glsl_vert_shader );
11.148 - glShaderSource( glsl_frag_shader, 1, &fragment_src, NULL );
11.149 - glCompileShader(glsl_frag_shader);
11.150 - fsok = glsl_check_shader_error( "Failed to compile fragment shader", glsl_frag_shader );
11.151 -
11.152 - if( vsok && fsok ) {
11.153 - glAttachShader(glsl_program, glsl_vert_shader);
11.154 - glAttachShader(glsl_program, glsl_frag_shader);
11.155 - glLinkProgram(glsl_program);
11.156 - pok = glsl_check_program_error( "Failed to link shader program", glsl_program );
11.157 - }
11.158 -
11.159 - if( pok ) {
11.160 - glUseProgram(glsl_program);
11.161 - } else {
11.162 - glsl_unload_shaders();
11.163 - }
11.164 - return pok;
11.165 -}
11.166 -
11.167 -void glsl_unload_shaders(void)
11.168 -{
11.169 - glUseProgram(0);
11.170 - glDetachShader(glsl_program, glsl_vert_shader);
11.171 - glDetachShader(glsl_program, glsl_frag_shader);
11.172 - glDeleteProgram(glsl_program);
11.173 - glDeleteShader(glsl_vert_shader);
11.174 - glDeleteShader(glsl_frag_shader);
11.175 -}
11.176 -#endif
12.1 --- a/src/drivers/gl_slsrc.c Sun Mar 02 11:38:08 2008 +0000
12.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
12.3 @@ -1,19 +0,0 @@
12.4 -/**
12.5 - * This file is automatically generated - do not edit
12.6 - */
12.7 -
12.8 -const char *glsl_vertex_shader_src = "// Standard PVR2 vertex shader\n\
12.9 -\n\
12.10 -void main()\n\
12.11 -{\n\
12.12 - gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n\
12.13 -}\n\
12.14 -";
12.15 -
12.16 -const char *glsl_fragment_shader_src = "// Standard PVR2 fragment shader\n\
12.17 -\n\
12.18 -void main()\n\
12.19 -{\n\
12.20 - gl_FragColor = gl_Color;\n\
12.21 -}";
12.22 -
13.1 --- a/src/drivers/vertex.glsl Sun Mar 02 11:38:08 2008 +0000
13.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
13.3 @@ -1,6 +0,0 @@
13.4 -// Standard PVR2 vertex shader
13.5 -
13.6 -void main()
13.7 -{
13.8 - gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
13.9 -}
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
14.2 +++ b/src/drivers/video_gdk.c Fri Mar 28 12:32:25 2008 +0000
14.3 @@ -0,0 +1,203 @@
14.4 +/**
14.5 + * $Id$
14.6 + *
14.7 + * The PC side of the video support (responsible for actually displaying /
14.8 + * rendering frames)
14.9 + *
14.10 + * Copyright (c) 2005 Nathan Keynes.
14.11 + *
14.12 + * This program is free software; you can redistribute it and/or modify
14.13 + * it under the terms of the GNU General Public License as published by
14.14 + * the Free Software Foundation; either version 2 of the License, or
14.15 + * (at your option) any later version.
14.16 + *
14.17 + * This program is distributed in the hope that it will be useful,
14.18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
14.19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14.20 + * GNU General Public License for more details.
14.21 + */
14.22 +#include <assert.h>
14.23 +#include <stdlib.h>
14.24 +#include <gdk/gdk.h>
14.25 +#include <gdk-pixbuf/gdk-pixbuf.h>
14.26 +#include <gtk/gtkwidget.h>
14.27 +#include <GL/osmesa.h>
14.28 +#include "lxdream.h"
14.29 +#include "display.h"
14.30 +
14.31 +#define MAX_PIXBUF 16
14.32 +
14.33 +extern GtkWidget *gtk_video_win;
14.34 +extern int video_width, video_height;
14.35 +
14.36 +static render_buffer_t gdk_pixbuf_create_render_buffer( uint32_t width, uint32_t height );
14.37 +static void gdk_pixbuf_destroy_render_buffer( render_buffer_t buffer );
14.38 +static gboolean gdk_pixbuf_set_render_target( render_buffer_t buffer );
14.39 +static gboolean gdk_pixbuf_display_render_buffer( render_buffer_t buffer );
14.40 +static void gdk_pixbuf_load_frame_buffer( frame_buffer_t frame, render_buffer_t buffer );
14.41 +static gboolean gdk_pixbuf_display_blank( uint32_t colour );
14.42 +static gboolean gdk_pixbuf_read_render_buffer( unsigned char *target, render_buffer_t buffer, int rowstride, int format );
14.43 +
14.44 +static void *pixbuf_array[MAX_PIXBUF];
14.45 +unsigned int pixbuf_max = 0;
14.46 +OSMesaContext osmesa_context = NULL;
14.47 +
14.48 +void video_gdk_init_driver( display_driver_t driver )
14.49 +{
14.50 + pixbuf_max = 0;
14.51 + driver->create_render_buffer = gdk_pixbuf_create_render_buffer;
14.52 + driver->destroy_render_buffer = gdk_pixbuf_destroy_render_buffer;
14.53 + driver->set_render_target = gdk_pixbuf_set_render_target;
14.54 + driver->display_render_buffer = gdk_pixbuf_display_render_buffer;
14.55 + driver->load_frame_buffer = gdk_pixbuf_load_frame_buffer;
14.56 + driver->display_blank = gdk_pixbuf_display_blank;
14.57 + driver->read_render_buffer = gdk_pixbuf_read_render_buffer;
14.58 +
14.59 + osmesa_context = OSMesaCreateContextExt( OSMESA_RGBA, 32, 0, 0, 0 );
14.60 + OSMesaMakeCurrent( osmesa_context, NULL, GL_UNSIGNED_BYTE, 640, 480 );
14.61 + pvr2_setup_gl_context();
14.62 +}
14.63 +
14.64 +int video_gdk_find_free()
14.65 +{
14.66 + unsigned int i;
14.67 + for( i=0; i<pixbuf_max; i++ ) {
14.68 + if( pixbuf_array[i] == NULL ) {
14.69 + return i;
14.70 + }
14.71 + }
14.72 + if( i < MAX_PIXBUF ) {
14.73 + return pixbuf_max++;
14.74 + }
14.75 + return -1;
14.76 +}
14.77 +
14.78 +void video_gdk_shutdown()
14.79 +{
14.80 + unsigned int i;
14.81 + for( i=0; i<pixbuf_max; i++ ) {
14.82 + if( pixbuf_array[i] != NULL ) {
14.83 + g_free(pixbuf_array[i]);
14.84 + pixbuf_array[i] = NULL;
14.85 + }
14.86 + }
14.87 + pixbuf_max = 0;
14.88 + OSMesaDestroyContext( osmesa_context );
14.89 +}
14.90 +
14.91 +
14.92 +static render_buffer_t gdk_pixbuf_create_render_buffer( uint32_t width, uint32_t height )
14.93 +{
14.94 + render_buffer_t buf = g_malloc0(sizeof(struct render_buffer));
14.95 + gboolean alpha = FALSE;
14.96 + buf->width = width;
14.97 + buf->height = height;
14.98 + buf->buf_id = video_gdk_find_free();
14.99 + pixbuf_array[buf->buf_id] = g_malloc0( width * height * 4 );
14.100 + return buf;
14.101 +}
14.102 +
14.103 +static void gdk_pixbuf_destroy_render_buffer( render_buffer_t buffer )
14.104 +{
14.105 + g_free(pixbuf_array[buffer->buf_id] );
14.106 + pixbuf_array[buffer->buf_id] = NULL;
14.107 + if( buffer->buf_id == (pixbuf_max-1) ) {
14.108 + pixbuf_max--;
14.109 + }
14.110 +}
14.111 +
14.112 +static gboolean gdk_pixbuf_display_render_buffer( render_buffer_t buffer )
14.113 +{
14.114 + glFinish();
14.115 +
14.116 + void *pb = pixbuf_array[buffer->buf_id];
14.117 + GdkGC *gc = gtk_video_win->style->fg_gc[GTK_STATE_NORMAL];
14.118 + GdkColor black = {0,0,0,0};
14.119 +
14.120 + assert(gc);
14.121 +
14.122 + int x1=0,y1=0,x2=video_width,y2=video_height;
14.123 +
14.124 + int ah = video_width * 0.75;
14.125 +
14.126 +
14.127 + if( ah > video_height ) {
14.128 + int w = (video_height/0.75);
14.129 + x1 = (video_width - w)/2;
14.130 + x2 -= x1;
14.131 + gdk_gc_set_foreground( gc, &black );
14.132 + gdk_gc_set_background( gc, &black );
14.133 + gdk_draw_rectangle( gtk_video_win->window, gc, TRUE, 0, 0, x1, video_height );
14.134 + gdk_draw_rectangle( gtk_video_win->window, gc, TRUE, x2, 0, video_width, video_height );
14.135 + } else if( ah < video_height ) {
14.136 + y1 = (video_height - ah)/2;
14.137 + y2 -= y1;
14.138 + gdk_gc_set_foreground( gc, &black );
14.139 + gdk_gc_set_background( gc, &black );
14.140 + gdk_draw_rectangle( gtk_video_win->window, gc, TRUE, 0, 0, video_width, y1 );
14.141 + gdk_draw_rectangle( gtk_video_win->window, gc, TRUE, 0, y2, video_width, video_height );
14.142 + }
14.143 + int w = x2-x1;
14.144 + int h = y2-y1;
14.145 +
14.146 + if( w != buffer->width || h != buffer->height ) {
14.147 + gdk_draw_rgb_32_image( gtk_video_win->window, gc, x1, y1, buffer->width, buffer->height, GDK_RGB_DITHER_NONE,
14.148 + pb, buffer->width*4 );
14.149 + } else {
14.150 + gdk_draw_rgb_32_image( gtk_video_win->window, gc, x1, y1, buffer->width, buffer->height, GDK_RGB_DITHER_NONE,
14.151 + pb, buffer->width*4 );
14.152 + }
14.153 +}
14.154 +
14.155 +static gboolean gdk_pixbuf_display_blank( uint32_t colour )
14.156 +{
14.157 + GdkGC *gc = gtk_video_win->style->fg_gc[GTK_STATE_NORMAL];
14.158 + GdkColor col = { };
14.159 +
14.160 + gdk_gc_set_foreground( gc, &col );
14.161 + gdk_gc_set_background( gc, &col );
14.162 + gdk_draw_rectangle( gtk_video_win->window, gc, TRUE, 0, 0, video_width, video_height );
14.163 + return TRUE;
14.164 +}
14.165 +
14.166 +static gboolean gdk_pixbuf_set_render_target( render_buffer_t buffer )
14.167 +{
14.168 + glFinish();
14.169 + void *pb = pixbuf_array[buffer->buf_id];
14.170 + OSMesaMakeCurrent( osmesa_context, pb, GL_UNSIGNED_BYTE,
14.171 + buffer->width, buffer->height );
14.172 + //OSMesaPixelStore( OSMESA_Y_UP, 0 );
14.173 + glViewport( 0, 0, buffer->width, buffer->height );
14.174 + glDrawBuffer(GL_FRONT);
14.175 + return TRUE;
14.176 +}
14.177 +
14.178 +static void gdk_pixbuf_load_frame_buffer( frame_buffer_t frame, render_buffer_t buffer )
14.179 +{
14.180 + glFinish();
14.181 + void *pb = pixbuf_array[buffer->buf_id];
14.182 + OSMesaMakeCurrent( osmesa_context, pb, GL_UNSIGNED_BYTE,
14.183 + buffer->width, buffer->height );
14.184 + GLenum type = colour_formats[frame->colour_format].type;
14.185 + GLenum format = colour_formats[frame->colour_format].format;
14.186 + int bpp = colour_formats[frame->colour_format].bpp;
14.187 + int rowstride = (frame->rowstride / bpp) - frame->width;
14.188 +
14.189 + gl_reset_state();
14.190 + glPixelStorei( GL_UNPACK_ROW_LENGTH, rowstride );
14.191 + glRasterPos2f(0.375, frame->height-0.375);
14.192 + glPixelZoom( 1.0, 1.0 );
14.193 + glDrawPixels( frame->width, frame->height, format, type, frame->data );
14.194 + glFlush();
14.195 +}
14.196 +
14.197 +static gboolean gdk_pixbuf_read_render_buffer( unsigned char *target, render_buffer_t buffer, int rowstride, int format )
14.198 +{
14.199 + glFinish();
14.200 + void *pb = pixbuf_array[buffer->buf_id];
14.201 + OSMesaMakeCurrent( osmesa_context, pb, GL_UNSIGNED_BYTE,
14.202 + buffer->width, buffer->height );
14.203 + glReadBuffer( GL_FRONT );
14.204 + return gl_read_render_buffer( target, buffer, rowstride, format );
14.205 +
14.206 +}
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
15.2 +++ b/src/drivers/video_gl.c Fri Mar 28 12:32:25 2008 +0000
15.3 @@ -0,0 +1,164 @@
15.4 +/**
15.5 + * $Id$
15.6 + *
15.7 + * Common GL code that doesn't depend on a specific implementation
15.8 + *
15.9 + * Copyright (c) 2005 Nathan Keynes.
15.10 + *
15.11 + * This program is free software; you can redistribute it and/or modify
15.12 + * it under the terms of the GNU General Public License as published by
15.13 + * the Free Software Foundation; either version 2 of the License, or
15.14 + * (at your option) any later version.
15.15 + *
15.16 + * This program is distributed in the hope that it will be useful,
15.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
15.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15.19 + * GNU General Public License for more details.
15.20 + */
15.21 +
15.22 +#include <sys/time.h>
15.23 +
15.24 +#include "display.h"
15.25 +#include "pvr2/pvr2.h"
15.26 +#include "drivers/video_gl.h"
15.27 +
15.28 +extern uint32_t video_width, video_height;
15.29 +
15.30 +/**
15.31 + * Reset the gl state to simple orthographic projection with
15.32 + * texturing, alpha/depth/scissor/cull tests disabled.
15.33 + */
15.34 +void gl_reset_state()
15.35 +{
15.36 + glViewport( 0, 0, video_width, video_height );
15.37 + glMatrixMode(GL_PROJECTION);
15.38 + glLoadIdentity();
15.39 + glOrtho( 0, video_width, video_height, 0, 0, 65535 );
15.40 + glMatrixMode(GL_MODELVIEW);
15.41 + glLoadIdentity();
15.42 + glDisable( GL_TEXTURE_2D );
15.43 + glDisable( GL_ALPHA_TEST );
15.44 + glDisable( GL_DEPTH_TEST );
15.45 + glDisable( GL_SCISSOR_TEST );
15.46 + glDisable( GL_CULL_FACE );
15.47 + glDrawBuffer( GL_FRONT );
15.48 +}
15.49 +
15.50 +void gl_display_render_buffer( render_buffer_t buffer )
15.51 +{
15.52 + gl_texture_window( buffer->width, buffer->height, buffer->buf_id, buffer->inverted );
15.53 +}
15.54 +
15.55 +void gl_texture_window( int width, int height, int tex_id, gboolean inverted )
15.56 +{
15.57 + float top, bottom;
15.58 + if( inverted ) {
15.59 + top = ((float)height);
15.60 + bottom = 0;
15.61 + } else {
15.62 + top = 0;
15.63 + bottom = ((float)height);
15.64 + }
15.65 +
15.66 + /* Reset display parameters */
15.67 + gl_reset_state();
15.68 + glColor3f( 0,0,0 );
15.69 +
15.70 + int x1=0,y1=0,x2=video_width,y2=video_height;
15.71 +
15.72 + int ah = video_width * 0.75;
15.73 +
15.74 + if( ah > video_height ) {
15.75 + int w = (video_height/0.75);
15.76 + x1 = (video_width - w)/2;
15.77 + x2 -= x1;
15.78 +
15.79 + glBegin( GL_QUADS );
15.80 + glVertex2f( 0, 0 );
15.81 + glVertex2f( x1, 0 );
15.82 + glVertex2f( x1, video_height );
15.83 + glVertex2f( 0, video_height);
15.84 + glVertex2f( x2, 0 );
15.85 + glVertex2f( video_width, 0 );
15.86 + glVertex2f( video_width, video_height );
15.87 + glVertex2f( x2, video_height);
15.88 + glEnd();
15.89 + } else if( ah < video_height ) {
15.90 + y1 = (video_height - ah)/2;
15.91 + y2 -= y1;
15.92 + glBegin( GL_QUADS );
15.93 + glVertex2f( 0, 0 );
15.94 + glVertex2f( video_width, 0 );
15.95 + glVertex2f( video_width, y1 );
15.96 + glVertex2f( 0, y1 );
15.97 + glVertex2f( 0, y2 );
15.98 + glVertex2f( video_width, y2 );
15.99 + glVertex2f( video_width, video_height );
15.100 + glVertex2f( 0, video_height );
15.101 + glEnd();
15.102 + }
15.103 +
15.104 + /* Render the textured rectangle */
15.105 + glEnable( GL_TEXTURE_RECTANGLE_ARB );
15.106 + glBindTexture( GL_TEXTURE_RECTANGLE_ARB, tex_id );
15.107 + glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
15.108 + glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
15.109 + glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
15.110 + glEnable( GL_BLEND );
15.111 + glBlendFunc( GL_ONE, GL_ZERO );
15.112 + glBegin( GL_QUADS );
15.113 + glTexCoord2f( 0, top );
15.114 + glVertex2f( x1, y1 );
15.115 + glTexCoord2f( ((float)width), top );
15.116 + glVertex2f( x2, y1 );
15.117 + glTexCoord2f( ((float)width), bottom );
15.118 + glVertex2f( x2, y2 );
15.119 + glTexCoord2f( 0, bottom );
15.120 + glVertex2f( x1, y2 );
15.121 + glEnd();
15.122 + glDisable( GL_TEXTURE_RECTANGLE_ARB );
15.123 + glFlush();
15.124 +}
15.125 +
15.126 +gboolean gl_load_frame_buffer( frame_buffer_t frame, int tex_id )
15.127 +{
15.128 + GLenum type = colour_formats[frame->colour_format].type;
15.129 + GLenum format = colour_formats[frame->colour_format].format;
15.130 + int bpp = colour_formats[frame->colour_format].bpp;
15.131 + int rowstride = (frame->rowstride / bpp) - frame->width;
15.132 +
15.133 + glPixelStorei( GL_UNPACK_ROW_LENGTH, rowstride );
15.134 + glBindTexture( GL_TEXTURE_RECTANGLE_ARB, tex_id );
15.135 + glTexSubImage2D( GL_TEXTURE_RECTANGLE_ARB, 0, 0,0,
15.136 + frame->width, frame->height, format, type, frame->data );
15.137 + return TRUE;
15.138 +}
15.139 +
15.140 +gboolean gl_display_blank( uint32_t colour )
15.141 +{
15.142 + gl_reset_state();
15.143 + glColor3ub( (colour >> 16) & 0xFF, (colour >> 8) & 0xFF, colour & 0xFF );
15.144 + glRecti(0,0, video_width, video_height );
15.145 + glFlush();
15.146 + return TRUE;
15.147 +}
15.148 +
15.149 +/**
15.150 + * Generic GL read_render_buffer. This function assumes that the caller
15.151 + * has already set the appropriate glReadBuffer(); in other words, unless
15.152 + * there's only one buffer this needs to be wrapped.
15.153 + */
15.154 +gboolean gl_read_render_buffer( unsigned char *target, render_buffer_t buffer,
15.155 + int rowstride, int colour_format )
15.156 +{
15.157 + glFinish();
15.158 + GLenum type = colour_formats[colour_format].type;
15.159 + GLenum format = colour_formats[colour_format].format;
15.160 + // int line_size = buffer->width * colour_formats[colour_format].bpp;
15.161 + // int size = line_size * buffer->height;
15.162 + int glrowstride = (rowstride / colour_formats[colour_format].bpp) - buffer->width;
15.163 + glPixelStorei( GL_PACK_ROW_LENGTH, glrowstride );
15.164 +
15.165 + glReadPixels( 0, 0, buffer->width, buffer->height, format, type, target );
15.166 + return TRUE;
15.167 +}
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
16.2 +++ b/src/drivers/video_gl.h Fri Mar 28 12:32:25 2008 +0000
16.3 @@ -0,0 +1,57 @@
16.4 +/**
16.5 + * $Id$
16.6 + *
16.7 + * Parent for all X11 display drivers.
16.8 + *
16.9 + * Copyright (c) 2005 Nathan Keynes.
16.10 + *
16.11 + * This program is free software; you can redistribute it and/or modify
16.12 + * it under the terms of the GNU General Public License as published by
16.13 + * the Free Software Foundation; either version 2 of the License, or
16.14 + * (at your option) any later version.
16.15 + *
16.16 + * This program is distributed in the hope that it will be useful,
16.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
16.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16.19 + * GNU General Public License for more details.
16.20 + */
16.21 +
16.22 +#ifndef video_gl_common_H
16.23 +#define video_gl_common_H
16.24 +
16.25 +/**
16.26 + * Generic GL routine to draw the given frame buffer into a texture
16.27 + */
16.28 +gboolean gl_load_frame_buffer( frame_buffer_t frame, int tex_id );
16.29 +
16.30 +/**
16.31 + * Generic GL routine to blank the display view with the specified colour.
16.32 + */
16.33 +gboolean gl_display_blank( uint32_t colour );
16.34 +
16.35 +/**
16.36 + * Write a rectangular texture (GL_TEXTURE_RECTANGLE_ARB) to the display frame
16.37 + */
16.38 +void gl_display_render_buffer( render_buffer_t buffer );
16.39 +
16.40 +/**
16.41 + * Write a rectangular texture (GL_TEXTURE_RECTANGLE_ARB) to the display frame
16.42 + */
16.43 +void gl_texture_window( int width, int height, int tex_id, gboolean inverted );
16.44 +
16.45 +/**
16.46 + * Generic GL read_render_buffer. This function assumes that the caller
16.47 + * has already set the appropriate glReadBuffer(); in other words, unless
16.48 + * there's only one buffer this needs to be wrapped.
16.49 + */
16.50 +gboolean gl_read_render_buffer( unsigned char *target, render_buffer_t buffer,
16.51 + int rowstride, int colour_format );
16.52 +
16.53 +
16.54 +/****** FBO handling (gl_fbo.c) ******/
16.55 +gboolean gl_fbo_is_supported();
16.56 +void gl_fbo_shutdown();
16.57 +void gl_fbo_init( display_driver_t driver );
16.58 +void gl_fbo_detach();
16.59 +
16.60 +#endif /* !video_gl_common_H */
17.1 --- a/src/drivers/video_glx.c Sun Mar 02 11:38:08 2008 +0000
17.2 +++ b/src/drivers/video_glx.c Fri Mar 28 12:32:25 2008 +0000
17.3 @@ -16,12 +16,14 @@
17.4 * GNU General Public License for more details.
17.5 */
17.6
17.7 +#include <string.h>
17.8 #include "display.h"
17.9 -#include "pvr2/pvr2.h"
17.10 -#include "drivers/gl_common.h"
17.11 #include <X11/Xlib.h>
17.12 #include <GL/glx.h>
17.13 +#include "pvr2/pvr2.h"
17.14 +#include "pvr2/glutil.h"
17.15 #include "drivers/video_glx.h"
17.16 +#include "drivers/video_gl.h"
17.17
17.18 /**
17.19 * General X11 parameters. The front-end driver is expected to set this up
17.20 @@ -168,7 +170,14 @@
17.21 WARN( "Not using direct rendering - this is likely to be slow" );
17.22 }
17.23
17.24 - texcache_gl_init();
17.25 + if( glsl_is_supported() ) {
17.26 + //if( !glsl_load_shaders( glsl_vertex_shader_src, glsl_fragment_shader_src ) ) {
17.27 + if( !glsl_load_shaders( glsl_vertex_shader_src, NULL ) ) {
17.28 + WARN( "Unable to load GL shaders" );
17.29 + }
17.30 + }
17.31 +
17.32 + pvr2_setup_gl_context();
17.33 video_x11_display = display;
17.34 video_x11_window = window;
17.35
18.1 --- a/src/drivers/video_gtk.c Sun Mar 02 11:38:08 2008 +0000
18.2 +++ b/src/drivers/video_gtk.c Fri Mar 28 12:32:25 2008 +0000
18.3 @@ -24,11 +24,11 @@
18.4 #include "display.h"
18.5 #include "dckeysyms.h"
18.6 #include "drivers/video_glx.h"
18.7 -#include "drivers/gl_common.h"
18.8 +#include "drivers/video_gl.h"
18.9 #include "pvr2/pvr2.h"
18.10 #include "gtkui/gtkui.h"
18.11
18.12 -static GtkWidget *video_win = NULL;
18.13 +GtkWidget *gtk_video_win = NULL;
18.14 int video_width = 640;
18.15 int video_height = 480;
18.16
18.17 @@ -154,23 +154,28 @@
18.18 gboolean video_gtk_init()
18.19 {
18.20
18.21 - video_win = gtk_gui_get_renderarea();
18.22 - if( video_win == NULL ) {
18.23 + gtk_video_win = gtk_gui_get_renderarea();
18.24 + if( gtk_video_win == NULL ) {
18.25 return FALSE;
18.26 }
18.27
18.28 - g_signal_connect( video_win, "expose_event",
18.29 + g_signal_connect( gtk_video_win, "expose_event",
18.30 G_CALLBACK(video_gtk_expose_callback), NULL );
18.31 - g_signal_connect( video_win, "configure_event",
18.32 + g_signal_connect( gtk_video_win, "configure_event",
18.33 G_CALLBACK(video_gtk_resize_callback), NULL );
18.34 - video_width = video_win->allocation.width;
18.35 - video_height = video_win->allocation.height;
18.36 - Display *display = gdk_x11_display_get_xdisplay( gtk_widget_get_display(GTK_WIDGET(video_win)));
18.37 - Window window = GDK_WINDOW_XWINDOW( GTK_WIDGET(video_win)->window );
18.38 + video_width = gtk_video_win->allocation.width;
18.39 + video_height = gtk_video_win->allocation.height;
18.40 + Display *display = gdk_x11_display_get_xdisplay( gtk_widget_get_display(GTK_WIDGET(gtk_video_win)));
18.41 + Window window = GDK_WINDOW_XWINDOW( GTK_WIDGET(gtk_video_win)->window );
18.42 +#ifdef HAVE_LIBOSMESA
18.43 + video_gdk_init_driver( &display_gtk_driver );
18.44 +#else
18.45 if( ! video_glx_init_context( display, window ) ||
18.46 ! video_glx_init_driver( &display_gtk_driver ) ) {
18.47 return FALSE;
18.48 }
18.49 +#endif
18.50 +
18.51 #ifdef HAVE_LINUX_JOYSTICK
18.52 linux_joystick_init();
18.53 #endif
18.54 @@ -179,21 +184,34 @@
18.55
18.56 gboolean video_gtk_display_blank( uint32_t colour )
18.57 {
18.58 - GdkGC *gc = gdk_gc_new(video_win->window);
18.59 + GdkGC *gc = gdk_gc_new(gtk_video_win->window);
18.60 GdkColor color = {0, ((colour>>16)&0xFF)*257, ((colour>>8)&0xFF)*257, ((colour)&0xFF)*257 };
18.61 GdkColormap *cmap = gdk_colormap_get_system();
18.62 gdk_colormap_alloc_color( cmap, &color, TRUE, TRUE );
18.63 gdk_gc_set_foreground( gc, &color );
18.64 gdk_gc_set_background( gc, &color );
18.65 - gdk_draw_rectangle( video_win->window, gc, TRUE, 0, 0, video_width, video_height );
18.66 + gdk_draw_rectangle( gtk_video_win->window, gc, TRUE, 0, 0, video_width, video_height );
18.67 gdk_gc_destroy(gc);
18.68 gdk_colormap_free_colors( cmap, &color, 1 );
18.69 }
18.70
18.71 +XVisualInfo *video_gtk_get_visual()
18.72 +{
18.73 +#ifdef HAVE_LIBOSMESA
18.74 + return NULL;
18.75 +#else
18.76 + return video_glx_get_visual();
18.77 +#endif
18.78 +}
18.79 +
18.80 void video_gtk_shutdown()
18.81 {
18.82 - if( video_win != NULL ) {
18.83 + if( gtk_video_win != NULL ) {
18.84 +#ifdef HAVE_LIBOSMESA
18.85 + video_gdk_shutdown();
18.86 +#else
18.87 video_glx_shutdown();
18.88 +#endif
18.89 }
18.90 #ifdef HAVE_LINUX_JOYSTICK
18.91 linux_joystick_shutdown();
19.1 --- a/src/gtkui/main_win.c Sun Mar 02 11:38:08 2008 +0000
19.2 +++ b/src/gtkui/main_win.c Fri Mar 28 12:32:25 2008 +0000
19.3 @@ -250,16 +250,21 @@
19.4 Display *display = gdk_x11_display_get_xdisplay( gtk_widget_get_display(win->window));
19.5 Screen *screen = gdk_x11_screen_get_xscreen( gtk_widget_get_screen(win->window));
19.6 int screen_no = XScreenNumberOfScreen(screen);
19.7 +#ifndef HAVE_LIBOSMESA
19.8 if( !video_glx_init(display, screen_no) ) {
19.9 ERROR( "Unable to initialize GLX, aborting" );
19.10 exit(3);
19.11 }
19.12 +#endif
19.13
19.14 - XVisualInfo *visual = video_glx_get_visual();
19.15 - GdkVisual *gdkvis = gdk_x11_screen_lookup_visual( gtk_widget_get_screen(win->window), visual->visualid );
19.16 - GdkColormap *colormap = gdk_colormap_new( gdkvis, FALSE );
19.17 win->video = gtk_drawing_area_new();
19.18 - gtk_widget_set_colormap( win->video, colormap );
19.19 +
19.20 + XVisualInfo *visual = video_gtk_get_visual();
19.21 + if( visual != NULL ) {
19.22 + GdkVisual *gdkvis = gdk_x11_screen_lookup_visual( gtk_widget_get_screen(win->window), visual->visualid );
19.23 + GdkColormap *colormap = gdk_colormap_new( gdkvis, FALSE );
19.24 + gtk_widget_set_colormap( win->video, colormap );
19.25 + }
19.26 GTK_WIDGET_SET_FLAGS(win->video, GTK_CAN_FOCUS|GTK_CAN_DEFAULT);
19.27 gtk_widget_set_size_request( win->video, 640, 480 );
19.28 gtk_widget_set_double_buffered( win->video, FALSE );
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
20.2 +++ b/src/pvr2/fragment.glsl Fri Mar 28 12:32:25 2008 +0000
20.3 @@ -0,0 +1,7 @@
20.4 +// Standard PVR2 fragment shader
20.5 +
20.6 +void main()
20.7 +{
20.8 + gl_FragColor = gl_Color;
20.9 + gl_FragDepth = gl_FragCoord.z;
20.10 +}
20.11 \ No newline at end of file
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
21.2 +++ b/src/pvr2/gl_sl.c Fri Mar 28 12:32:25 2008 +0000
21.3 @@ -0,0 +1,223 @@
21.4 +/**
21.5 + * $Id$
21.6 + *
21.7 + * GLSL shader loader/unloader. Current version assumes there's exactly
21.8 + * 1 shader program that's used globally. This may turn out not to be the
21.9 + * most efficient approach.
21.10 + *
21.11 + * Copyright (c) 2007 Nathan Keynes.
21.12 + *
21.13 + * This program is free software; you can redistribute it and/or modify
21.14 + * it under the terms of the GNU General Public License as published by
21.15 + * the Free Software Foundation; either version 2 of the License, or
21.16 + * (at your option) any later version.
21.17 + *
21.18 + * This program is distributed in the hope that it will be useful,
21.19 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
21.20 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21.21 + * GNU General Public License for more details.
21.22 + */
21.23 +
21.24 +#define GL_GLEXT_PROTOTYPES 1
21.25 +
21.26 +#include "lxdream.h"
21.27 +#include "display.h"
21.28 +#include "pvr2/glutil.h"
21.29 +
21.30 +#define MAX_ERROR_BUF 4096
21.31 +
21.32 +gboolean glsl_is_supported()
21.33 +{
21.34 + return isGLExtensionSupported("GL_ARB_fragment_shader") &&
21.35 + isGLExtensionSupported("GL_ARB_vertex_shader") &&
21.36 + isGLExtensionSupported("GL_ARB_shading_language_100");
21.37 +}
21.38 +
21.39 +#ifdef GL_ARB_shader_objects
21.40 +static GLhandleARB glsl_program = 0, glsl_vert_shader = 0, glsl_frag_shader = 0;
21.41 +
21.42 +void glsl_print_error( char *msg, GLhandleARB obj )
21.43 +{
21.44 + char buf[MAX_ERROR_BUF];
21.45 + GLsizei length;
21.46 + glGetInfoLogARB( obj, sizeof(buf), &length, buf );
21.47 + ERROR( "%s: %s", msg, buf );
21.48 +}
21.49 +
21.50 +gboolean glsl_check_shader_error( char *msg, GLhandleARB obj )
21.51 +{
21.52 + GLint value;
21.53 +
21.54 + glGetObjectParameterivARB(obj, GL_OBJECT_COMPILE_STATUS_ARB, &value);
21.55 + if( value == 0 ) {
21.56 + glsl_print_error(msg, obj);
21.57 + return FALSE;
21.58 + }
21.59 + return TRUE;
21.60 +}
21.61 +
21.62 +gboolean glsl_check_program_error( char *msg, GLhandleARB obj )
21.63 +{
21.64 + if( glGetError() != GL_NO_ERROR ) {
21.65 + glsl_print_error(msg, obj);
21.66 + }
21.67 + return TRUE;
21.68 +}
21.69 +
21.70 +
21.71 +gboolean glsl_load_shaders( const char *vertex_src, const char *fragment_src )
21.72 +{
21.73 + gboolean vsok = TRUE, fsok = TRUE, pok = FALSE;
21.74 +
21.75 + if( vertex_src == NULL && fragment_src == NULL ) {
21.76 + return TRUE; // nothing to do
21.77 + }
21.78 +
21.79 + glsl_program = glCreateProgramObjectARB();
21.80 +
21.81 + if( vertex_src != NULL ) {
21.82 + glsl_vert_shader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
21.83 + glShaderSourceARB( glsl_vert_shader, 1, &vertex_src, NULL );
21.84 + glCompileShaderARB(glsl_vert_shader);
21.85 + vsok = glsl_check_shader_error("Failed to compile vertex shader", glsl_vert_shader);
21.86 + }
21.87 + if( fragment_src != NULL ) {
21.88 + glsl_frag_shader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
21.89 + glShaderSourceARB( glsl_frag_shader, 1, &fragment_src, NULL );
21.90 + glCompileShaderARB(glsl_frag_shader);
21.91 + fsok = glsl_check_shader_error("Failed to compile fragment shader", glsl_frag_shader);
21.92 + }
21.93 +
21.94 + if( vsok && fsok ) {
21.95 + if( vertex_src != NULL ) {
21.96 + glAttachObjectARB(glsl_program, glsl_vert_shader);
21.97 + }
21.98 + if( fragment_src != NULL ) {
21.99 + glAttachObjectARB(glsl_program, glsl_frag_shader);
21.100 + }
21.101 + glLinkProgramARB(glsl_program);
21.102 + pok = glsl_check_program_error( "Failed to link shader program", glsl_program );
21.103 + }
21.104 + if( pok ) {
21.105 + glUseProgramObjectARB(glsl_program);
21.106 + pok = glsl_check_program_error( "Failed to apply shader program", glsl_program );
21.107 + } else {
21.108 + glsl_unload_shaders();
21.109 + }
21.110 + return pok;
21.111 +}
21.112 +
21.113 +void glsl_enable_shader(gboolean en)
21.114 +{
21.115 + if( glsl_program != 0 ) {
21.116 + if( en ) {
21.117 + glUseProgramObjectARB(glsl_program);
21.118 + } else {
21.119 + glUseProgramObjectARB(0);
21.120 + }
21.121 + }
21.122 +}
21.123 +
21.124 +void glsl_unload_shaders(void)
21.125 +{
21.126 + glUseProgramObjectARB(0);
21.127 + glDetachObjectARB(glsl_program, glsl_vert_shader);
21.128 + glDetachObjectARB(glsl_program, glsl_frag_shader);
21.129 + glDeleteObjectARB(glsl_program);
21.130 + glDeleteObjectARB(glsl_vert_shader);
21.131 + glDeleteObjectARB(glsl_frag_shader);
21.132 +}
21.133 +
21.134 +#else
21.135 +static GLuint glsl_program = 0, glsl_vert_shader = 0, glsl_frag_shader = 0;
21.136 +
21.137 +gboolean glsl_check_shader_error( char *msg, GLuint shader )
21.138 +{
21.139 + GLint value;
21.140 +
21.141 + glGetShaderiv( shader, GL_COMPILE_STATUS, &value );
21.142 + if( value == 0 ) {
21.143 + char buf[MAX_ERROR_BUF];
21.144 + GLsizei length;
21.145 + glGetShaderInfoLog( shader, sizeof(buf), &length, buf );
21.146 + ERROR( "%s: %s", msg, buf );
21.147 + return FALSE;
21.148 + }
21.149 + return TRUE;
21.150 +}
21.151 +gboolean glsl_check_program_error( char *msg, GLuint program )
21.152 +{
21.153 + if( glGetError() != GL_NO_ERROR ) {
21.154 + char buf[MAX_ERROR_BUF];
21.155 + GLsizei length;
21.156 + glGetProgramInfoLog( program, sizeof(buf), &length, buf );
21.157 + ERROR( "%s: %s", msg, buf );
21.158 + return FALSE;
21.159 + }
21.160 + return TRUE;
21.161 +}
21.162 +
21.163 +gboolean glsl_load_shaders( const char *vertex_src, const char *fragment_src )
21.164 +{
21.165 + gboolean vsok = TRUE, fsok = TRUE, pok = FALSE;
21.166 +
21.167 + if( vertex_src == NULL && fragment_src == NULL ) {
21.168 + return TRUE;
21.169 + }
21.170 +
21.171 + glsl_program = glCreateProgram();
21.172 +
21.173 + if( vertex_src != NULL ) {
21.174 + glsl_vert_shader = glCreateShader(GL_VERTEX_SHADER);
21.175 + glShaderSource( glsl_vert_shader, 1, &vertex_src, NULL );
21.176 + glCompileShader(glsl_vert_shader);
21.177 + vsok = glsl_check_shader_error( "Failed to compile vertex shader", glsl_vert_shader );
21.178 + }
21.179 + if( fragment_src != NULL ) {
21.180 + glsl_frag_shader = glCreateShader(GL_FRAGMENT_SHADER);
21.181 + glShaderSource( glsl_frag_shader, 1, &fragment_src, NULL );
21.182 + glCompileShader(glsl_frag_shader);
21.183 + fsok = glsl_check_shader_error( "Failed to compile fragment shader", glsl_frag_shader );
21.184 + }
21.185 +
21.186 + if( vsok && fsok ) {
21.187 + if( vertex_src != NULL ) {
21.188 + glAttachShader(glsl_program, glsl_vert_shader);
21.189 + }
21.190 + if( fragment_src != NULL ) {
21.191 + glAttachShader(glsl_program, glsl_frag_shader);
21.192 + }
21.193 + glLinkProgram(glsl_program);
21.194 + pok = glsl_check_program_error( "Failed to link shader program", glsl_program );
21.195 + }
21.196 +
21.197 + if( pok ) {
21.198 + glUseProgram(glsl_program);
21.199 + } else {
21.200 + glsl_unload_shaders();
21.201 + }
21.202 + return pok;
21.203 +}
21.204 +
21.205 +
21.206 +void glsl_enable_shader(gboolean en)
21.207 +{
21.208 + if( glsl_program != 0 ) {
21.209 + if( en ) {
21.210 + glUseProgram(glsl_program);
21.211 + } else {
21.212 + glUseProgram(0);
21.213 + }
21.214 + }
21.215 +}
21.216 +
21.217 +void glsl_unload_shaders(void)
21.218 +{
21.219 + glUseProgram(0);
21.220 + glDetachShader(glsl_program, glsl_vert_shader);
21.221 + glDetachShader(glsl_program, glsl_frag_shader);
21.222 + glDeleteProgram(glsl_program);
21.223 + glDeleteShader(glsl_vert_shader);
21.224 + glDeleteShader(glsl_frag_shader);
21.225 +}
21.226 +#endif
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
22.2 +++ b/src/pvr2/gl_slsrc.c Fri Mar 28 12:32:25 2008 +0000
22.3 @@ -0,0 +1,25 @@
22.4 +/**
22.5 + * This file is automatically generated - do not edit
22.6 + */
22.7 +
22.8 +const char *glsl_vertex_shader_src = "// Standard PVR2 vertex shader\n\
22.9 +\n\
22.10 +void main()\n\
22.11 +{\n\
22.12 + vec4 tmp = ftransform();\n\
22.13 + float w = gl_Vertex.z;\n\
22.14 + gl_Position = tmp * w;\n\
22.15 + gl_FrontColor = gl_Color;\n\
22.16 + gl_FrontSecondaryColor = gl_SecondaryColor;\n\
22.17 + gl_TexCoord[0] = gl_MultiTexCoord0;\n\
22.18 +}\n\
22.19 +";
22.20 +
22.21 +const char *glsl_fragment_shader_src = "// Standard PVR2 fragment shader\n\
22.22 +\n\
22.23 +void main()\n\
22.24 +{\n\
22.25 + gl_FragColor = gl_Color;\n\
22.26 + gl_FragDepth = gl_FragCoord.z;\n\
22.27 +}";
22.28 +
23.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
23.2 +++ b/src/pvr2/glrender.c Fri Mar 28 12:32:25 2008 +0000
23.3 @@ -0,0 +1,305 @@
23.4 +/**
23.5 + * $Id$
23.6 + *
23.7 + * Standard OpenGL rendering engine.
23.8 + *
23.9 + * Copyright (c) 2005 Nathan Keynes.
23.10 + *
23.11 + * This program is free software; you can redistribute it and/or modify
23.12 + * it under the terms of the GNU General Public License as published by
23.13 + * the Free Software Foundation; either version 2 of the License, or
23.14 + * (at your option) any later version.
23.15 + *
23.16 + * This program is distributed in the hope that it will be useful,
23.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
23.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23.19 + * GNU General Public License for more details.
23.20 + */
23.21 +
23.22 +#include <assert.h>
23.23 +#include "display.h"
23.24 +#include "pvr2/pvr2.h"
23.25 +#include "pvr2/scene.h"
23.26 +
23.27 +int pvr2_poly_depthmode[8] = { GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL,
23.28 + GL_GREATER, GL_NOTEQUAL, GL_GEQUAL,
23.29 + GL_ALWAYS };
23.30 +int pvr2_poly_srcblend[8] = {
23.31 + GL_ZERO, GL_ONE, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR,
23.32 + GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA,
23.33 + GL_ONE_MINUS_DST_ALPHA };
23.34 +int pvr2_poly_dstblend[8] = {
23.35 + GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR,
23.36 + GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA,
23.37 + GL_ONE_MINUS_DST_ALPHA };
23.38 +int pvr2_poly_texblend[4] = {
23.39 + GL_REPLACE,
23.40 + GL_MODULATE,
23.41 + GL_DECAL,
23.42 + GL_MODULATE
23.43 +};
23.44 +int pvr2_render_colour_format[8] = {
23.45 + COLFMT_BGRA1555, COLFMT_RGB565, COLFMT_BGRA4444, COLFMT_BGRA1555,
23.46 + COLFMT_BGR888, COLFMT_BGRA8888, COLFMT_BGRA8888, COLFMT_BGRA4444 };
23.47 +
23.48 +
23.49 +/**
23.50 + * Clip the tile bounds to the clipping plane.
23.51 + * @return TRUE if the tile was not clipped completely.
23.52 + */
23.53 +static gboolean clip_tile_bounds( uint32_t *tile, float *clip )
23.54 +{
23.55 + if( tile[0] < clip[0] ) tile[0] = clip[0];
23.56 + if( tile[1] > clip[1] ) tile[1] = clip[1];
23.57 + if( tile[2] < clip[2] ) tile[2] = clip[2];
23.58 + if( tile[3] > clip[3] ) tile[3] = clip[3];
23.59 + return tile[0] < tile[1] && tile[2] < tile[3];
23.60 +}
23.61 +
23.62 +void pvr2_scene_load_textures()
23.63 +{
23.64 + int i;
23.65 + for( i=0; i < pvr2_scene.poly_count; i++ ) {
23.66 + struct polygon_struct *poly = &pvr2_scene.poly_array[i];
23.67 + if( POLY1_TEXTURED(poly->context[0]) ) {
23.68 + poly->tex_id = texcache_get_texture( poly->context[2],
23.69 + POLY2_TEX_WIDTH(poly->context[1]),
23.70 + POLY2_TEX_HEIGHT(poly->context[1]) );
23.71 + if( poly->mod_vertex_index != -1 ) {
23.72 + poly->mod_tex_id = texcache_get_texture( poly->context[4],
23.73 + POLY2_TEX_WIDTH(poly->context[3]),
23.74 + POLY2_TEX_HEIGHT(poly->context[3]) );
23.75 + }
23.76 + } else {
23.77 + poly->tex_id = -1;
23.78 + poly->mod_tex_id = -1;
23.79 + }
23.80 + }
23.81 +}
23.82 +
23.83 +
23.84 +
23.85 +/**
23.86 + * Once-off call to setup the OpenGL context.
23.87 + */
23.88 +void pvr2_setup_gl_context()
23.89 +{
23.90 + texcache_gl_init(); // Allocate texture IDs
23.91 + glCullFace( GL_BACK );
23.92 + glEnable( GL_BLEND );
23.93 + glEnable( GL_DEPTH_TEST );
23.94 + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
23.95 + glMatrixMode(GL_MODELVIEW);
23.96 + glLoadIdentity();
23.97 +
23.98 + glEnableClientState( GL_COLOR_ARRAY );
23.99 + glEnableClientState( GL_VERTEX_ARRAY );
23.100 + glEnableClientState( GL_TEXTURE_COORD_ARRAY );
23.101 + glEnableClientState( GL_SECONDARY_COLOR_ARRAY );
23.102 +
23.103 + glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
23.104 + glClearDepth(0);
23.105 + glClearStencil(0);
23.106 +}
23.107 +
23.108 +/**
23.109 + * Setup the GL context for the supplied polygon context.
23.110 + * @param context pointer to 3 or 5 words of polygon context
23.111 + * @param modified boolean flag indicating that the modified
23.112 + * version should be used, rather than the normal version.
23.113 + */
23.114 +void render_set_context( uint32_t *context, int render_mode )
23.115 +{
23.116 + uint32_t poly1 = context[0], poly2, texture;
23.117 + if( render_mode == RENDER_FULLMOD ) {
23.118 + poly2 = context[3];
23.119 + texture = context[4];
23.120 + } else {
23.121 + poly2 = context[1];
23.122 + texture = context[2];
23.123 + }
23.124 +
23.125 + glDepthFunc( POLY1_DEPTH_MODE(poly1) );
23.126 + glDepthMask( POLY1_DEPTH_WRITE(poly1) ? GL_TRUE : GL_FALSE );
23.127 +
23.128 + switch( POLY1_CULL_MODE(poly1) ) {
23.129 + case CULL_NONE:
23.130 + case CULL_SMALL:
23.131 + glDisable( GL_CULL_FACE );
23.132 + break;
23.133 + case CULL_CCW:
23.134 + glEnable( GL_CULL_FACE );
23.135 + glFrontFace( GL_CW );
23.136 + break;
23.137 + case CULL_CW:
23.138 + glEnable( GL_CULL_FACE );
23.139 + glFrontFace( GL_CCW );
23.140 + break;
23.141 + }
23.142 +
23.143 + if( POLY1_SPECULAR(poly1) ) {
23.144 + glEnable(GL_COLOR_SUM);
23.145 + } else {
23.146 + glDisable(GL_COLOR_SUM);
23.147 + }
23.148 +
23.149 +
23.150 + if( POLY1_TEXTURED(poly1) ) {
23.151 + int width = POLY2_TEX_WIDTH(poly2);
23.152 + int height = POLY2_TEX_HEIGHT(poly2);
23.153 + glEnable(GL_TEXTURE_2D);
23.154 + glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, pvr2_poly_texblend[POLY2_TEX_BLEND(poly2)] );
23.155 + if( POLY2_TEX_CLAMP_U(poly2) ) {
23.156 + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
23.157 + } else {
23.158 + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
23.159 + }
23.160 + if( POLY2_TEX_CLAMP_V(poly2) ) {
23.161 + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
23.162 + } else {
23.163 + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
23.164 + }
23.165 + } else {
23.166 + glDisable( GL_TEXTURE_2D );
23.167 + }
23.168 +
23.169 + glShadeModel( POLY1_SHADE_MODEL(poly1) );
23.170 +
23.171 + int srcblend = POLY2_SRC_BLEND(poly2);
23.172 + int destblend = POLY2_DEST_BLEND(poly2);
23.173 + glBlendFunc( srcblend, destblend );
23.174 +
23.175 + if( POLY2_SRC_BLEND_TARGET(poly2) || POLY2_DEST_BLEND_TARGET(poly2) ) {
23.176 + ERROR( "Accumulation buffer not supported" );
23.177 + }
23.178 +
23.179 +}
23.180 +
23.181 +
23.182 +static void gl_render_poly( struct polygon_struct *poly )
23.183 +{
23.184 + if( poly->tex_id != -1 ) {
23.185 + glBindTexture(GL_TEXTURE_2D, poly->tex_id);
23.186 + }
23.187 + render_set_context( poly->context, RENDER_NORMAL );
23.188 + glDrawArrays(GL_TRIANGLE_STRIP, poly->vertex_index, poly->vertex_count );
23.189 +}
23.190 +
23.191 +void gl_render_tilelist( pvraddr_t tile_entry )
23.192 +{
23.193 + uint32_t *tile_list = (uint32_t *)(video_base+tile_entry);
23.194 + int strip_count;
23.195 + struct polygon_struct *poly;
23.196 +
23.197 + while(1) {
23.198 + uint32_t entry = *tile_list++;
23.199 + switch( entry >> 28 ) {
23.200 + case 0x0F:
23.201 + return; // End-of-list
23.202 + case 0x0E:
23.203 + tile_list = (uint32_t *)(video_base + (entry&0x007FFFFF));
23.204 + break;
23.205 + case 0x08: case 0x09: case 0x0A: case 0x0B:
23.206 + strip_count = ((entry >> 25) & 0x0F)+1;
23.207 + poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];
23.208 + while( strip_count > 0 ) {
23.209 + assert( poly != NULL );
23.210 + gl_render_poly( poly );
23.211 + poly = poly->next;
23.212 + strip_count--;
23.213 + }
23.214 + break;
23.215 + default:
23.216 + if( entry & 0x7E000000 ) {
23.217 + poly = pvr2_scene.buf_to_poly_map[entry&0x000FFFFF];
23.218 + gl_render_poly( poly );
23.219 + }
23.220 + }
23.221 + }
23.222 +}
23.223 +
23.224 +
23.225 +/**
23.226 + * Render the currently defined scene in pvr2_scene
23.227 + */
23.228 +void pvr2_scene_render( render_buffer_t buffer )
23.229 +{
23.230 + /* Scene setup */
23.231 + struct timeval start_tv, tex_tv, end_tv;
23.232 +
23.233 + gettimeofday(&start_tv, NULL);
23.234 + display_driver->set_render_target(buffer);
23.235 + pvr2_check_palette_changed();
23.236 + pvr2_scene_load_textures();
23.237 +
23.238 + gettimeofday( &tex_tv, NULL );
23.239 + uint32_t ms = (tex_tv.tv_sec - start_tv.tv_sec) * 1000 +
23.240 + (tex_tv.tv_usec - start_tv.tv_usec)/1000;
23.241 + DEBUG( "Scene setup in %dms", ms );
23.242 +
23.243 + /* Setup view projection matrix */
23.244 + glMatrixMode(GL_PROJECTION);
23.245 + glLoadIdentity();
23.246 + float nearz = pvr2_scene.bounds[4];
23.247 + float farz = pvr2_scene.bounds[5];
23.248 + if( nearz == farz ) {
23.249 + farz*= 2.0;
23.250 + }
23.251 + glOrtho( 0, pvr2_scene.buffer_width, pvr2_scene.buffer_height, 0,
23.252 + -farz, -nearz );
23.253 + float alphaRef = ((float)(MMIO_READ(PVR2, RENDER_ALPHA_REF)&0xFF)+1)/256.0;
23.254 + glAlphaFunc( GL_GEQUAL, alphaRef );
23.255 +
23.256 + /* Clear the buffer (FIXME: May not want always want to do this) */
23.257 + glDisable( GL_SCISSOR_TEST );
23.258 + glDepthMask( GL_TRUE );
23.259 + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
23.260 +
23.261 + /* Setup vertex array pointers */
23.262 + glInterleavedArrays(GL_T2F_C4UB_V3F, sizeof(struct vertex_struct), pvr2_scene.vertex_array);
23.263 + glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, sizeof(struct vertex_struct), &pvr2_scene.vertex_array[0].offset_rgba );
23.264 +
23.265 + uint32_t bgplane_mode = MMIO_READ(PVR2, RENDER_BGPLANE);
23.266 + uint32_t *bgplane = pvr2_scene.pvr2_pbuf + (((bgplane_mode & 0x00FFFFFF)) >> 3) ;
23.267 + render_backplane( bgplane, pvr2_scene.buffer_width, pvr2_scene.buffer_height, bgplane_mode );
23.268 +
23.269 + glEnable( GL_SCISSOR_TEST );
23.270 +
23.271 + /* Process the segment list */
23.272 + struct tile_segment *segment = pvr2_scene.segment_list;
23.273 + do {
23.274 + int tilex = SEGMENT_X(segment->control);
23.275 + int tiley = SEGMENT_Y(segment->control);
23.276 +
23.277 + int tile_bounds[4] = { tilex << 5, (tilex+1)<<5, tiley<<5, (tiley+1)<<5 };
23.278 + if( !clip_tile_bounds(tile_bounds, pvr2_scene.bounds) ) {
23.279 + continue; // fully clipped, skip tile
23.280 + }
23.281 +
23.282 + /* Clip to the visible part of the tile */
23.283 + glScissor( tile_bounds[0], pvr2_scene.buffer_height-tile_bounds[3],
23.284 + tile_bounds[1]-tile_bounds[0], tile_bounds[3] - tile_bounds[2] );
23.285 + if( IS_TILE_PTR(segment->opaque_ptr) ) {
23.286 + gl_render_tilelist(segment->opaque_ptr);
23.287 + }
23.288 + if( IS_TILE_PTR(segment->trans_ptr) ) {
23.289 + if( pvr2_scene.sort_mode == SORT_NEVER ||
23.290 + (pvr2_scene.sort_mode == SORT_TILEFLAG && (segment->control&SEGMENT_SORT_TRANS))) {
23.291 + gl_render_tilelist(segment->trans_ptr);
23.292 + } else {
23.293 + render_autosort_tile(segment->trans_ptr, RENDER_NORMAL );
23.294 + }
23.295 + }
23.296 + if( IS_TILE_PTR(segment->punchout_ptr) ) {
23.297 + glEnable(GL_ALPHA_TEST );
23.298 + render_autosort_tile(segment->punchout_ptr, RENDER_NORMAL );
23.299 + glDisable(GL_ALPHA_TEST );
23.300 + }
23.301 + } while( !IS_LAST_SEGMENT(segment++) );
23.302 + glDisable( GL_SCISSOR_TEST );
23.303 +
23.304 + gettimeofday( &end_tv, NULL );
23.305 + ms = (end_tv.tv_sec - tex_tv.tv_sec) * 1000 +
23.306 + (end_tv.tv_usec - tex_tv.tv_usec)/1000;
23.307 + DEBUG( "Scene render in %dms", ms );
23.308 +}
24.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
24.2 +++ b/src/pvr2/glutil.c Fri Mar 28 12:32:25 2008 +0000
24.3 @@ -0,0 +1,57 @@
24.4 +/**
24.5 + * $Id$
24.6 + *
24.7 + * GL-based support functions
24.8 + *
24.9 + * Copyright (c) 2005 Nathan Keynes.
24.10 + *
24.11 + * This program is free software; you can redistribute it and/or modify
24.12 + * it under the terms of the GNU General Public License as published by
24.13 + * the Free Software Foundation; either version 2 of the License, or
24.14 + * (at your option) any later version.
24.15 + *
24.16 + * This program is distributed in the hope that it will be useful,
24.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
24.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24.19 + * GNU General Public License for more details.
24.20 + */
24.21 +#include <string.h>
24.22 +#include "pvr2/glutil.h"
24.23 +
24.24 +/**
24.25 + * Test if a specific extension is supported. From opengl.org
24.26 + * @param extension extension name to check for
24.27 + * @return TRUE if supported, otherwise FALSE.
24.28 + */
24.29 +gboolean isGLExtensionSupported( const char *extension )
24.30 +{
24.31 + const GLubyte *extensions = NULL;
24.32 + const GLubyte *start;
24.33 + GLubyte *where, *terminator;
24.34 +
24.35 + /* Extension names should not have spaces. */
24.36 + where = (GLubyte *) strchr(extension, ' ');
24.37 + if (where || *extension == '\0')
24.38 + return 0;
24.39 + extensions = glGetString(GL_EXTENSIONS);
24.40 + if( extensions == NULL ) {
24.41 + /* No GL available, so we're pretty sure the extension isn't
24.42 + * available either. */
24.43 + return FALSE;
24.44 + }
24.45 + /* It takes a bit of care to be fool-proof about parsing the
24.46 + OpenGL extensions string. Don't be fooled by sub-strings,
24.47 + etc. */
24.48 + start = extensions;
24.49 + for (;;) {
24.50 + where = (GLubyte *) strstr((const char *) start, extension);
24.51 + if (!where)
24.52 + break;
24.53 + terminator = where + strlen(extension);
24.54 + if (where == start || *(where - 1) == ' ')
24.55 + if (*terminator == ' ' || *terminator == '\0')
24.56 + return TRUE;
24.57 + start = terminator;
24.58 + }
24.59 + return FALSE;
24.60 +}
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
25.2 +++ b/src/pvr2/glutil.h Fri Mar 28 12:32:25 2008 +0000
25.3 @@ -0,0 +1,40 @@
25.4 +/**
25.5 + * $Id$
25.6 + *
25.7 + * GL-based support functions
25.8 + *
25.9 + * Copyright (c) 2005 Nathan Keynes.
25.10 + *
25.11 + * This program is free software; you can redistribute it and/or modify
25.12 + * it under the terms of the GNU General Public License as published by
25.13 + * the Free Software Foundation; either version 2 of the License, or
25.14 + * (at your option) any later version.
25.15 + *
25.16 + * This program is distributed in the hope that it will be useful,
25.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
25.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25.19 + * GNU General Public License for more details.
25.20 + */
25.21 +
25.22 +#ifndef lxdream_glutil_H
25.23 +#define lxdream_glutil_H
25.24 +
25.25 +#include "display.h"
25.26 +
25.27 +/**
25.28 + * Test if a specific extension is supported. From opengl.org
25.29 + * @param extension extension name to check for
25.30 + * @return TRUE if supported, otherwise FALSE.
25.31 + */
25.32 +gboolean isGLExtensionSupported( const char *extension );
25.33 +
25.34 +
25.35 +/****** Shader handling (gl_sl.c) *****/
25.36 +gboolean glsl_is_supported(void);
25.37 +gboolean glsl_load_shaders( const char *vert_shader, const char *frag_shader );
25.38 +void glsl_unload_shaders(void);
25.39 +
25.40 +extern const char *glsl_vertex_shader_src;
25.41 +extern const char *glsl_fragment_shader_src;
25.42 +
25.43 +#endif /* !lxdream_glutil_H */
26.1 --- a/src/pvr2/pvr2.c Sun Mar 02 11:38:08 2008 +0000
26.2 +++ b/src/pvr2/pvr2.c Fri Mar 28 12:32:25 2008 +0000
26.3 @@ -203,12 +203,17 @@
26.4 }
26.5
26.6 render_buffer_t buffer = pvr2_frame_buffer_to_render_buffer(frame);
26.7 - assert( buffer != NULL );
26.8 - fread( &buffer->rowstride, sizeof(buffer->rowstride), 1, f );
26.9 - fread( &buffer->colour_format, sizeof(buffer->colour_format), 1, f );
26.10 - fread( &buffer->address, sizeof(buffer->address), 1, f );
26.11 - fread( &buffer->scale, sizeof(buffer->scale), 1, f );
26.12 - fread( &buffer->flushed, sizeof(buffer->flushed), 1, f );
26.13 + if( buffer != NULL ) {
26.14 + fread( &buffer->rowstride, sizeof(buffer->rowstride), 1, f );
26.15 + fread( &buffer->colour_format, sizeof(buffer->colour_format), 1, f );
26.16 + fread( &buffer->address, sizeof(buffer->address), 1, f );
26.17 + fread( &buffer->scale, sizeof(buffer->scale), 1, f );
26.18 + fread( &buffer->flushed, sizeof(buffer->flushed), 1, f );
26.19 + } else {
26.20 + fseek( f, sizeof(buffer->rowstride)+sizeof(buffer->colour_format)+
26.21 + sizeof(buffer->address)+sizeof(buffer->scale)+
26.22 + sizeof(buffer->flushed), SEEK_CUR );
26.23 + }
26.24 return buffer;
26.25 }
26.26
26.27 @@ -258,9 +263,7 @@
26.28 }
26.29
26.30 for( i=0; i<count; i++ ) {
26.31 - if( pvr2_load_render_buffer( f ) == NULL ) {
26.32 - return FALSE;
26.33 - }
26.34 + pvr2_load_render_buffer( f );
26.35 }
26.36 return TRUE;
26.37 }
26.38 @@ -454,9 +457,10 @@
26.39 g_free( pvr2_state.save_next_render_filename );
26.40 pvr2_state.save_next_render_filename = NULL;
26.41 }
26.42 + pvr2_scene_read();
26.43 render_buffer_t buffer = pvr2_next_render_buffer();
26.44 if( buffer != NULL ) {
26.45 - pvr2_render_scene( buffer );
26.46 + pvr2_scene_render( buffer );
26.47 }
26.48 asic_event( EVENT_PVR_RENDER_DONE );
26.49 break;
26.50 @@ -581,7 +585,9 @@
26.51 case RENDER_PALETTE:
26.52 MMIO_WRITE( PVR2, reg, val&0x00000003 );
26.53 break;
26.54 -
26.55 + case RENDER_ALPHA_REF:
26.56 + MMIO_WRITE( PVR2, reg, val&0x000000FF );
26.57 + break;
26.58 /********** CRTC registers *************/
26.59 case DISP_HBORDER:
26.60 case DISP_VBORDER:
26.61 @@ -677,9 +683,6 @@
26.62 case PVRUNK5:
26.63 MMIO_WRITE( PVR2, reg, val&0x0000FFFF );
26.64 break;
26.65 - case PVRUNK6:
26.66 - MMIO_WRITE( PVR2, reg, val&0x000000FF );
26.67 - break;
26.68 case PVRUNK7:
26.69 MMIO_WRITE( PVR2, reg, val&0x00000001 );
26.70 break;
26.71 @@ -940,9 +943,9 @@
26.72 render_addr = (render_addr & 0x00FFFFFF) + PVR2_RAM_BASE;
26.73 }
26.74
26.75 - int width, height;
26.76 + int width = pvr2_scene_buffer_width();
26.77 + int height = pvr2_scene_buffer_height();
26.78 int colour_format = pvr2_render_colour_format[render_mode&0x07];
26.79 - pvr2_render_getsize( &width, &height );
26.80
26.81 result = pvr2_alloc_render_buffer( render_addr, width, height );
26.82 /* Setup the buffer */
27.1 --- a/src/pvr2/pvr2.h Sun Mar 02 11:38:08 2008 +0000
27.2 +++ b/src/pvr2/pvr2.h Fri Mar 28 12:32:25 2008 +0000
27.3 @@ -16,7 +16,11 @@
27.4 * GNU General Public License for more details.
27.5 */
27.6
27.7 -#include "dream.h"
27.8 +#ifndef lxdream_pvr2_H
27.9 +#define lxdream_pvr2_H 1
27.10 +
27.11 +#include <stdio.h>
27.12 +#include "lxdream.h"
27.13 #include "mem.h"
27.14 #include "display.h"
27.15 #include "pvr2/pvr2mmio.h"
27.16 @@ -240,6 +244,8 @@
27.17
27.18 /********************************* Renderer ******************************/
27.19
27.20 +void pvr2_read_scene( void );
27.21 +
27.22 /**
27.23 * Render the current scene stored in PVR ram to the GL back buffer.
27.24 */
27.25 @@ -260,7 +266,7 @@
27.26 void pvr2_render_tilebuffer( int width, int height, int clipx1, int clipy1,
27.27 int clipx2, int clipy2 );
27.28
27.29 -float pvr2_render_find_maximum_z();
27.30 +void pvr2_render_find_z_range( float *min, float *max );
27.31
27.32 void pvr2_render_getsize( int *x, int *y );
27.33
27.34 @@ -275,25 +281,6 @@
27.35 float offset_rgba[4]; /* Offset color (RGBA order) */
27.36 };
27.37
27.38 -void render_unpack_quad( struct vertex_unpacked *unpacked, uint32_t poly1,
27.39 - uint32_t *vertexes, int vertex_size,
27.40 - int render_mode );
27.41 -
27.42 -void render_unpack_vertexes( struct vertex_unpacked *out, uint32_t poly1,
27.43 - uint32_t *vertexes, int num_vertexes,
27.44 - int vertex_size, int render_mode );
27.45 -
27.46 -void render_unpacked_vertex_array( uint32_t poly1, struct vertex_unpacked *vertexes[],
27.47 - int num_vertexes );
27.48 -
27.49 -void render_vertex_array( uint32_t poly1, uint32_t *vertexes[], int num_vertexes,
27.50 - int vertex_size, int render_mode );
27.51 -
27.52 -void render_tile( pvraddr_t tile_entry, int render_mode, gboolean cheap_modifier_mode );
27.53 -
27.54 -void render_autosort_tile( pvraddr_t tile_entry, int render_mode, gboolean cheap_modifier_mode );
27.55 -
27.56 -
27.57 /****************************** Texture Cache ****************************/
27.58
27.59 /**
27.60 @@ -338,8 +325,7 @@
27.61 * If the texture has already been bound, return the ID to which it was
27.62 * bound. Otherwise obtain an unused texture ID and set it up appropriately.
27.63 */
27.64 -GLuint texcache_get_texture( uint32_t texture_addr, int width, int height,
27.65 - int mode );
27.66 +GLuint texcache_get_texture( uint32_t texture_word, int width, int height );
27.67
27.68 void pvr2_check_palette_changed(void);
27.69
27.70 @@ -348,8 +334,9 @@
27.71
27.72 /************************* Rendering support macros **************************/
27.73 #define POLY1_DEPTH_MODE(poly1) ( pvr2_poly_depthmode[(poly1)>>29] )
27.74 -#define POLY1_DEPTH_ENABLE(poly1) (((poly1)&0x04000000) == 0 )
27.75 +#define POLY1_DEPTH_WRITE(poly1) (((poly1)&0x04000000) == 0 )
27.76 #define POLY1_CULL_MODE(poly1) (((poly1)>>27)&0x03)
27.77 +#define POLY1_CULL_ENABLE(poly1) (((poly1)>>28)&0x01)
27.78 #define POLY1_TEXTURED(poly1) (((poly1)&0x02000000))
27.79 #define POLY1_SPECULAR(poly1) (((poly1)&0x01000000))
27.80 #define POLY1_GOURAUD_SHADED(poly1) ((poly1)&0x00800000)
27.81 @@ -376,4 +363,28 @@
27.82 extern int pvr2_poly_texblend[4];
27.83 extern int pvr2_render_colour_format[8];
27.84
27.85 -float halftofloat(uint16_t half);
27.86 +#define CULL_NONE 0
27.87 +#define CULL_SMALL 1
27.88 +#define CULL_CCW 2
27.89 +#define CULL_CW 3
27.90 +
27.91 +#define SEGMENT_END 0x80000000
27.92 +#define SEGMENT_ZCLEAR 0x40000000
27.93 +#define SEGMENT_SORT_TRANS 0x20000000
27.94 +#define SEGMENT_START 0x10000000
27.95 +#define SEGMENT_X(c) (((c) >> 2) & 0x3F)
27.96 +#define SEGMENT_Y(c) (((c) >> 8) & 0x3F)
27.97 +#define NO_POINTER 0x80000000
27.98 +#define IS_TILE_PTR(p) ( ((p)&NO_POINTER) == 0 )
27.99 +#define IS_LAST_SEGMENT(s) (((s)->control) & SEGMENT_END)
27.100 +
27.101 +struct tile_segment {
27.102 + uint32_t control;
27.103 + pvraddr_t opaque_ptr;
27.104 + pvraddr_t opaquemod_ptr;
27.105 + pvraddr_t trans_ptr;
27.106 + pvraddr_t transmod_ptr;
27.107 + pvraddr_t punchout_ptr;
27.108 +};
27.109 +
27.110 +#endif /* !lxdream_pvr2_H */
28.1 --- a/src/pvr2/pvr2mem.c Sun Mar 02 11:38:08 2008 +0000
28.2 +++ b/src/pvr2/pvr2mem.c Fri Mar 28 12:32:25 2008 +0000
28.3 @@ -15,10 +15,11 @@
28.4 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28.5 * GNU General Public License for more details.
28.6 */
28.7 +#include <string.h>
28.8 +#include <stdio.h>
28.9 +#include <errno.h>
28.10 #include "pvr2.h"
28.11 #include "asic.h"
28.12 -#include <stdio.h>
28.13 -#include <errno.h>
28.14
28.15 extern unsigned char *video_base;
28.16
29.1 --- a/src/pvr2/pvr2mmio.h Sun Mar 02 11:38:08 2008 +0000
29.2 +++ b/src/pvr2/pvr2mmio.h Fri Mar 28 12:32:25 2008 +0000
29.3 @@ -72,7 +72,7 @@
29.4 LONG_PORT( 0x110, PVRUNK3, PORT_MRW, 0, "PVR2 unknown register 3" )
29.5 LONG_PORT( 0x114, PVRUNK4, PORT_MRW, 0, "PVR2 unknown register 4" )
29.6 LONG_PORT( 0x118, PVRUNK5, PORT_MRW, 0, "PVR2 unkown register 5" )
29.7 - LONG_PORT( 0x11C, PVRUNK6, PORT_MRW, 0, "PVR2 unkown register 6" )
29.8 + LONG_PORT( 0x11C, RENDER_ALPHA_REF, PORT_MRW, 0, "PVR2 reference alpha" )
29.9 LONG_PORT( 0x124, TA_TILEBASE, PORT_MRW, 0, "TA Tile matrix start" )
29.10 LONG_PORT( 0x128, TA_POLYBASE, PORT_MRW, 0, "TA Polygon buffer start" )
29.11 LONG_PORT( 0x12C, TA_LISTEND, PORT_MRW, 0, "TA Tile matrix end" )
30.1 --- a/src/pvr2/rendbkg.c Sun Mar 02 11:38:08 2008 +0000
30.2 +++ b/src/pvr2/rendbkg.c Fri Mar 28 12:32:25 2008 +0000
30.3 @@ -49,6 +49,70 @@
30.4 #define FARGB_B(x) (((float)(((x)&0xFF)+1))/256.0)
30.5
30.6 /**
30.7 + * Convert a half-float (16-bit) FP number to a regular 32-bit float.
30.8 + * Source is 1-bit sign, 5-bit exponent, 10-bit mantissa.
30.9 + * TODO: Check the correctness of this.
30.10 + */
30.11 +static float halftofloat( uint16_t half )
30.12 +{
30.13 + union {
30.14 + float f;
30.15 + uint32_t i;
30.16 + } temp;
30.17 + /* int e = ((half & 0x7C00) >> 10) - 15 + 127;
30.18 +
30.19 + temp.i = ((half & 0x8000) << 16) | (e << 23) |
30.20 + ((half & 0x03FF) << 13); */
30.21 + temp.i = ((uint32_t)half)<<16;
30.22 + return temp.f;
30.23 +}
30.24 +
30.25 +void render_unpack_vertexes( struct vertex_unpacked *out, uint32_t poly1,
30.26 + uint32_t *vertexes, int num_vertexes,
30.27 + int vertex_size, int render_mode )
30.28 +{
30.29 + int m = 0, i;
30.30 + if( render_mode == RENDER_FULLMOD ) {
30.31 + m = (vertex_size - 3)/2;
30.32 + }
30.33 +
30.34 + for( i=0; i<num_vertexes; i++ ) {
30.35 + float *vertexf = (float *)vertexes;
30.36 + int k = m + 3;
30.37 + out[i].x = vertexf[0];
30.38 + out[i].y = vertexf[1];
30.39 + out[i].z = vertexf[2];
30.40 + if( POLY1_TEXTURED(poly1) ) {
30.41 + if( POLY1_UV16(poly1) ) {
30.42 + out[i].u = halftofloat(vertexes[k]>>16);
30.43 + out[i].v = halftofloat(vertexes[k]);
30.44 + k++;
30.45 + } else {
30.46 + out[i].u = vertexf[k];
30.47 + out[i].v = vertexf[k+1];
30.48 + k+=2;
30.49 + }
30.50 + } else {
30.51 + out[i].u = 0;
30.52 + out[i].v = 0;
30.53 + }
30.54 + uint32_t argb = vertexes[k++];
30.55 + out[i].rgba[0] = FARGB_R(argb);
30.56 + out[i].rgba[1] = FARGB_G(argb);
30.57 + out[i].rgba[2] = FARGB_B(argb);
30.58 + out[i].rgba[3] = FARGB_A(argb);
30.59 + if( POLY1_SPECULAR(poly1) ) {
30.60 + uint32_t offset = vertexes[k++];
30.61 + out[i].offset_rgba[0] = FARGB_R(offset);
30.62 + out[i].offset_rgba[1] = FARGB_G(offset);
30.63 + out[i].offset_rgba[2] = FARGB_B(offset);
30.64 + out[i].offset_rgba[3] = FARGB_A(offset);
30.65 + }
30.66 + vertexes += vertex_size;
30.67 + }
30.68 +}
30.69 +
30.70 +/**
30.71 * Compute the line where k = target_k, (where k is normally one of
30.72 * r,g,b,a, or z) and determines the points at which the line intersects
30.73 * the viewport (0,0,width,height).
30.74 @@ -426,15 +490,15 @@
30.75
30.76 center.x = base[1].x;
30.77 center.y = base[1].y;
30.78 - center.z = (1/base[1].z);
30.79 + center.z = base[1].z;
30.80 center.u = base[1].u;
30.81 center.v = base[1].v;
30.82 diff0.x = base[0].x - center.x;
30.83 diff0.y = base[0].y - center.y;
30.84 - diff0.z = (1/base[0].z) - center.z;
30.85 + diff0.z = base[0].z - center.z;
30.86 diff1.x = base[2].x - center.x;
30.87 diff1.y = base[2].y - center.y;
30.88 - diff1.z = (1/base[2].z) - center.z;
30.89 + diff1.z = base[2].z - center.z;
30.90
30.91 float detxy = ((diff1.y) * (diff0.x)) - ((diff0.y) * (diff1.x));
30.92
30.93 @@ -461,7 +525,7 @@
30.94 scene->vertexes[i].rgba[1] = base[2].rgba[1];
30.95 scene->vertexes[i].rgba[2] = base[2].rgba[2];
30.96 scene->vertexes[i].rgba[3] = base[2].rgba[3];
30.97 - scene->vertexes[i].z = 1/base[2].z;
30.98 + scene->vertexes[i].z = base[2].z;
30.99 scene->vertexes[i].u = base[2].u;
30.100 scene->vertexes[i].v = base[2].v;
30.101 }
30.102 @@ -608,4 +672,6 @@
30.103 glDisable(GL_DEPTH_TEST);
30.104 glBlendFunc(GL_ONE, GL_ZERO); /* For now, just disable alpha blending on the bkg */
30.105 bkg_render_region(&scene, 0, screen_vertexes, 4, *polygon);
30.106 + glEnable(GL_CULL_FACE);
30.107 + glEnable(GL_DEPTH_TEST);
30.108 }
31.1 --- a/src/pvr2/rendcore.c Sun Mar 02 11:38:08 2008 +0000
31.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
31.3 @@ -1,780 +0,0 @@
31.4 -/**
31.5 - * $Id$
31.6 - *
31.7 - * PVR2 renderer core.
31.8 - *
31.9 - * Copyright (c) 2005 Nathan Keynes.
31.10 - *
31.11 - * This program is free software; you can redistribute it and/or modify
31.12 - * it under the terms of the GNU General Public License as published by
31.13 - * the Free Software Foundation; either version 2 of the License, or
31.14 - * (at your option) any later version.
31.15 - *
31.16 - * This program is distributed in the hope that it will be useful,
31.17 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
31.18 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31.19 - * GNU General Public License for more details.
31.20 - */
31.21 -#include <sys/time.h>
31.22 -#include "pvr2/pvr2.h"
31.23 -#include "asic.h"
31.24 -#include "display.h"
31.25 -
31.26 -int pvr2_poly_depthmode[8] = { GL_NEVER, GL_LESS, GL_EQUAL, GL_LEQUAL,
31.27 - GL_GREATER, GL_NOTEQUAL, GL_GEQUAL,
31.28 - GL_ALWAYS };
31.29 -int pvr2_poly_srcblend[8] = {
31.30 - GL_ZERO, GL_ONE, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR,
31.31 - GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA,
31.32 - GL_ONE_MINUS_DST_ALPHA };
31.33 -int pvr2_poly_dstblend[8] = {
31.34 - GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR,
31.35 - GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_DST_ALPHA,
31.36 - GL_ONE_MINUS_DST_ALPHA };
31.37 -int pvr2_poly_texblend[4] = {
31.38 - GL_REPLACE,
31.39 - GL_MODULATE,
31.40 - GL_DECAL,
31.41 - GL_MODULATE
31.42 -};
31.43 -int pvr2_render_colour_format[8] = {
31.44 - COLFMT_BGRA1555, COLFMT_RGB565, COLFMT_BGRA4444, COLFMT_BGRA1555,
31.45 - COLFMT_BGR888, COLFMT_BGRA8888, COLFMT_BGRA8888, COLFMT_BGRA4444 };
31.46 -
31.47 -
31.48 -#define CULL_NONE 0
31.49 -#define CULL_SMALL 1
31.50 -#define CULL_CCW 2
31.51 -#define CULL_CW 3
31.52 -
31.53 -#define SEGMENT_END 0x80000000
31.54 -#define SEGMENT_ZCLEAR 0x40000000
31.55 -#define SEGMENT_SORT_TRANS 0x20000000
31.56 -#define SEGMENT_START 0x10000000
31.57 -#define SEGMENT_X(c) (((c) >> 2) & 0x3F)
31.58 -#define SEGMENT_Y(c) (((c) >> 8) & 0x3F)
31.59 -#define NO_POINTER 0x80000000
31.60 -
31.61 -extern char *video_base;
31.62 -
31.63 -gboolean pvr2_force_fragment_alpha = FALSE;
31.64 -gboolean pvr2_debug_render = FALSE;
31.65 -
31.66 -struct tile_segment {
31.67 - uint32_t control;
31.68 - pvraddr_t opaque_ptr;
31.69 - pvraddr_t opaquemod_ptr;
31.70 - pvraddr_t trans_ptr;
31.71 - pvraddr_t transmod_ptr;
31.72 - pvraddr_t punchout_ptr;
31.73 -};
31.74 -
31.75 -void render_print_tilelist( FILE *f, uint32_t tile_entry );
31.76 -
31.77 -/**
31.78 - * Convert a half-float (16-bit) FP number to a regular 32-bit float.
31.79 - * Source is 1-bit sign, 5-bit exponent, 10-bit mantissa.
31.80 - * TODO: Check the correctness of this.
31.81 - */
31.82 -float halftofloat( uint16_t half )
31.83 -{
31.84 - union {
31.85 - float f;
31.86 - uint32_t i;
31.87 - } temp;
31.88 - /* int e = ((half & 0x7C00) >> 10) - 15 + 127;
31.89 -
31.90 - temp.i = ((half & 0x8000) << 16) | (e << 23) |
31.91 - ((half & 0x03FF) << 13); */
31.92 - temp.i = ((uint32_t)half)<<16;
31.93 - return temp.f;
31.94 -}
31.95 -
31.96 -
31.97 -/**
31.98 - * Setup the GL context for the supplied polygon context.
31.99 - * @param context pointer to 3 or 5 words of polygon context
31.100 - * @param modified boolean flag indicating that the modified
31.101 - * version should be used, rather than the normal version.
31.102 - */
31.103 -void render_set_context( uint32_t *context, int render_mode )
31.104 -{
31.105 - uint32_t poly1 = context[0], poly2, texture;
31.106 - if( render_mode == RENDER_FULLMOD ) {
31.107 - poly2 = context[3];
31.108 - texture = context[4];
31.109 - } else {
31.110 - poly2 = context[1];
31.111 - texture = context[2];
31.112 - }
31.113 -
31.114 - if( POLY1_DEPTH_ENABLE(poly1) ) {
31.115 - glEnable( GL_DEPTH_TEST );
31.116 - glDepthFunc( POLY1_DEPTH_MODE(poly1) );
31.117 - } else {
31.118 - glDisable( GL_DEPTH_TEST );
31.119 - }
31.120 -
31.121 - switch( POLY1_CULL_MODE(poly1) ) {
31.122 - case CULL_NONE:
31.123 - case CULL_SMALL:
31.124 - glDisable( GL_CULL_FACE );
31.125 - break;
31.126 - case CULL_CCW:
31.127 - glEnable( GL_CULL_FACE );
31.128 - glFrontFace( GL_CW );
31.129 - break;
31.130 - case CULL_CW:
31.131 - glEnable( GL_CULL_FACE );
31.132 - glFrontFace( GL_CCW );
31.133 - break;
31.134 - }
31.135 -
31.136 - if( POLY1_SPECULAR(poly1) ) {
31.137 - glEnable(GL_COLOR_SUM);
31.138 - } else {
31.139 - glDisable(GL_COLOR_SUM);
31.140 - }
31.141 -
31.142 - pvr2_force_fragment_alpha = POLY2_ALPHA_ENABLE(poly2) ? FALSE : TRUE;
31.143 -
31.144 - if( POLY1_TEXTURED(poly1) ) {
31.145 - int width = POLY2_TEX_WIDTH(poly2);
31.146 - int height = POLY2_TEX_HEIGHT(poly2);
31.147 - glEnable(GL_TEXTURE_2D);
31.148 - texcache_get_texture( (texture&0x000FFFFF)<<3, width, height, texture );
31.149 - switch( POLY2_TEX_BLEND(poly2) ) {
31.150 - case 0: /* Replace */
31.151 - glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
31.152 - break;
31.153 - case 2:/* Decal */
31.154 - glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
31.155 - break;
31.156 - case 1: /* Modulate RGB */
31.157 - /* This is not directly supported by opengl (other than by mucking
31.158 - * with the texture format), but we get the same effect by forcing
31.159 - * the fragment alpha to 1.0 and using GL_MODULATE.
31.160 - */
31.161 - pvr2_force_fragment_alpha = TRUE;
31.162 - case 3: /* Modulate RGBA */
31.163 - glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
31.164 - break;
31.165 - }
31.166 -
31.167 - if( POLY2_TEX_CLAMP_U(poly2) ) {
31.168 - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
31.169 - } else {
31.170 - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
31.171 - }
31.172 - if( POLY2_TEX_CLAMP_V(poly2) ) {
31.173 - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
31.174 - } else {
31.175 - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
31.176 - }
31.177 - } else {
31.178 - glDisable( GL_TEXTURE_2D );
31.179 - }
31.180 -
31.181 - glShadeModel( POLY1_SHADE_MODEL(poly1) );
31.182 -
31.183 - int srcblend = POLY2_SRC_BLEND(poly2);
31.184 - int destblend = POLY2_DEST_BLEND(poly2);
31.185 - glBlendFunc( srcblend, destblend );
31.186 -
31.187 - if( POLY2_SRC_BLEND_TARGET(poly2) || POLY2_DEST_BLEND_TARGET(poly2) ) {
31.188 - ERROR( "Accumulation buffer not supported" );
31.189 - }
31.190 -
31.191 -
31.192 -}
31.193 -
31.194 -#define FARGB_A(x) (((float)(((x)>>24)+1))/256.0)
31.195 -#define FARGB_R(x) (((float)((((x)>>16)&0xFF)+1))/256.0)
31.196 -#define FARGB_G(x) (((float)((((x)>>8)&0xFF)+1))/256.0)
31.197 -#define FARGB_B(x) (((float)(((x)&0xFF)+1))/256.0)
31.198 -
31.199 -void render_unpack_vertexes( struct vertex_unpacked *out, uint32_t poly1,
31.200 - uint32_t *vertexes, int num_vertexes,
31.201 - int vertex_size, int render_mode )
31.202 -{
31.203 - int m = 0, i;
31.204 - if( render_mode == RENDER_FULLMOD ) {
31.205 - m = (vertex_size - 3)/2;
31.206 - }
31.207 -
31.208 - for( i=0; i<num_vertexes; i++ ) {
31.209 - float *vertexf = (float *)vertexes;
31.210 - int k = m + 3;
31.211 - out[i].x = vertexf[0];
31.212 - out[i].y = vertexf[1];
31.213 - out[i].z = vertexf[2];
31.214 - if( POLY1_TEXTURED(poly1) ) {
31.215 - if( POLY1_UV16(poly1) ) {
31.216 - out[i].u = halftofloat(vertexes[k]>>16);
31.217 - out[i].v = halftofloat(vertexes[k]);
31.218 - k++;
31.219 - } else {
31.220 - out[i].u = vertexf[k];
31.221 - out[i].v = vertexf[k+1];
31.222 - k+=2;
31.223 - }
31.224 - } else {
31.225 - out[i].u = 0;
31.226 - out[i].v = 0;
31.227 - }
31.228 - uint32_t argb = vertexes[k++];
31.229 - out[i].rgba[0] = FARGB_R(argb);
31.230 - out[i].rgba[1] = FARGB_G(argb);
31.231 - out[i].rgba[2] = FARGB_B(argb);
31.232 - out[i].rgba[3] = FARGB_A(argb);
31.233 - if( POLY1_SPECULAR(poly1) ) {
31.234 - uint32_t offset = vertexes[k++];
31.235 - out[i].offset_rgba[0] = FARGB_R(offset);
31.236 - out[i].offset_rgba[1] = FARGB_G(offset);
31.237 - out[i].offset_rgba[2] = FARGB_B(offset);
31.238 - out[i].offset_rgba[3] = FARGB_A(offset);
31.239 - }
31.240 - vertexes += vertex_size;
31.241 - }
31.242 -}
31.243 -
31.244 -/**
31.245 - * Unpack the vertexes for a quad, calculating the values for the last
31.246 - * vertex.
31.247 - * FIXME: Integrate this with rendbkg somehow
31.248 - */
31.249 -void render_unpack_quad( struct vertex_unpacked *unpacked, uint32_t poly1,
31.250 - uint32_t *vertexes, int vertex_size,
31.251 - int render_mode )
31.252 -{
31.253 - int i;
31.254 - struct vertex_unpacked diff0, diff1;
31.255 -
31.256 - render_unpack_vertexes( unpacked, poly1, vertexes, 3, vertex_size, render_mode );
31.257 -
31.258 - diff0.x = unpacked[0].x - unpacked[1].x;
31.259 - diff0.y = unpacked[0].y - unpacked[1].y;
31.260 - diff1.x = unpacked[2].x - unpacked[1].x;
31.261 - diff1.y = unpacked[2].y - unpacked[1].y;
31.262 -
31.263 - float detxy = ((diff1.y) * (diff0.x)) - ((diff0.y) * (diff1.x));
31.264 - float *vertexf = (float *)(vertexes+(vertex_size*3));
31.265 - if( detxy == 0 ) {
31.266 - memcpy( &unpacked[3], &unpacked[2], sizeof(struct vertex_unpacked) );
31.267 - unpacked[3].x = vertexf[0];
31.268 - unpacked[3].y = vertexf[1];
31.269 - return;
31.270 - }
31.271 -
31.272 - unpacked[3].x = vertexf[0];
31.273 - unpacked[3].y = vertexf[1];
31.274 - float t = ((unpacked[3].x - unpacked[1].x) * diff1.y -
31.275 - (unpacked[3].y - unpacked[1].y) * diff1.x) / detxy;
31.276 - float s = ((unpacked[3].y - unpacked[1].y) * diff0.x -
31.277 - (unpacked[3].x - unpacked[1].x) * diff0.y) / detxy;
31.278 - diff0.z = (1/unpacked[0].z) - (1/unpacked[1].z);
31.279 - diff1.z = (1/unpacked[2].z) - (1/unpacked[1].z);
31.280 - unpacked[3].z = 1/((1/unpacked[1].z) + (t*diff0.z) + (s*diff1.z));
31.281 -
31.282 - diff0.u = unpacked[0].u - unpacked[1].u;
31.283 - diff0.v = unpacked[0].v - unpacked[1].v;
31.284 - diff1.u = unpacked[2].u - unpacked[1].u;
31.285 - diff1.v = unpacked[2].v - unpacked[1].v;
31.286 - unpacked[3].u = unpacked[1].u + (t*diff0.u) + (s*diff1.u);
31.287 - unpacked[3].v = unpacked[1].v + (t*diff0.v) + (s*diff1.v);
31.288 -
31.289 - if( !POLY1_GOURAUD_SHADED(poly1) ) {
31.290 - memcpy( unpacked[3].rgba, unpacked[2].rgba, sizeof(unpacked[2].rgba) );
31.291 - memcpy( unpacked[3].offset_rgba, unpacked[2].offset_rgba, sizeof(unpacked[2].offset_rgba) );
31.292 - } else {
31.293 - for( i=0; i<4; i++ ) {
31.294 - float d0 = unpacked[0].rgba[i] - unpacked[1].rgba[i];
31.295 - float d1 = unpacked[2].rgba[i] - unpacked[1].rgba[i];
31.296 - unpacked[3].rgba[i] = unpacked[1].rgba[i] + (t*d0) + (s*d1);
31.297 - d0 = unpacked[0].offset_rgba[i] - unpacked[1].offset_rgba[i];
31.298 - d1 = unpacked[2].offset_rgba[i] - unpacked[1].offset_rgba[i];
31.299 - unpacked[3].offset_rgba[i] = unpacked[1].offset_rgba[i] + (t*d0) + (s*d1);
31.300 - }
31.301 - }
31.302 -}
31.303 -
31.304 -void render_unpacked_vertex_array( uint32_t poly1, struct vertex_unpacked *vertexes[],
31.305 - int num_vertexes ) {
31.306 - int i;
31.307 -
31.308 - glBegin( GL_TRIANGLE_STRIP );
31.309 -
31.310 - for( i=0; i<num_vertexes; i++ ) {
31.311 - if( POLY1_TEXTURED(poly1) ) {
31.312 - glTexCoord2f( vertexes[i]->u, vertexes[i]->v );
31.313 - }
31.314 -
31.315 - if( pvr2_force_fragment_alpha ) {
31.316 - glColor4f( vertexes[i]->rgba[0], vertexes[i]->rgba[1], vertexes[i]->rgba[2], 1.0 );
31.317 - } else {
31.318 - glColor4f( vertexes[i]->rgba[0], vertexes[i]->rgba[1], vertexes[i]->rgba[2],
31.319 - vertexes[i]->rgba[3] );
31.320 - }
31.321 - if( POLY1_SPECULAR(poly1) ) {
31.322 - glSecondaryColor3fEXT( vertexes[i]->offset_rgba[0],
31.323 - vertexes[i]->offset_rgba[1],
31.324 - vertexes[i]->offset_rgba[2] );
31.325 - }
31.326 - glVertex3f( vertexes[i]->x, vertexes[i]->y, 1/vertexes[i]->z );
31.327 - }
31.328 -
31.329 - glEnd();
31.330 -}
31.331 -
31.332 -void render_quad_vertexes( uint32_t poly1, uint32_t *vertexes, int vertex_size, int render_mode )
31.333 -{
31.334 - struct vertex_unpacked unpacked[4];
31.335 - struct vertex_unpacked *pt[4] = {&unpacked[0], &unpacked[1], &unpacked[3], &unpacked[2]};
31.336 - render_unpack_quad( unpacked, poly1, vertexes, vertex_size, render_mode );
31.337 - render_unpacked_vertex_array( poly1, pt, 4 );
31.338 -}
31.339 -
31.340 -void render_vertex_array( uint32_t poly1, uint32_t *vert_array[], int num_vertexes, int vertex_size,
31.341 - int render_mode )
31.342 -{
31.343 - int i, m=0;
31.344 -
31.345 - if( render_mode == RENDER_FULLMOD ) {
31.346 - m = (vertex_size - 3)/2;
31.347 - }
31.348 -
31.349 - glBegin( GL_TRIANGLE_STRIP );
31.350 -
31.351 - for( i=0; i<num_vertexes; i++ ) {
31.352 - uint32_t *vertexes = vert_array[i];
31.353 - float *vertexf = (float *)vert_array[i];
31.354 - uint32_t argb;
31.355 - int k = m + 3;
31.356 - if( POLY1_TEXTURED(poly1) ) {
31.357 - if( POLY1_UV16(poly1) ) {
31.358 - glTexCoord2f( halftofloat(vertexes[k]>>16),
31.359 - halftofloat(vertexes[k]) );
31.360 - k++;
31.361 - } else {
31.362 - glTexCoord2f( vertexf[k], vertexf[k+1] );
31.363 - k+=2;
31.364 - }
31.365 - }
31.366 -
31.367 - argb = vertexes[k++];
31.368 - if( pvr2_force_fragment_alpha ) {
31.369 - glColor4ub( (GLubyte)(argb >> 16), (GLubyte)(argb >> 8),
31.370 - (GLubyte)argb, 0xFF );
31.371 - } else {
31.372 - glColor4ub( (GLubyte)(argb >> 16), (GLubyte)(argb >> 8),
31.373 - (GLubyte)argb, (GLubyte)(argb >> 24) );
31.374 - }
31.375 -
31.376 - if( POLY1_SPECULAR(poly1) ) {
31.377 - uint32_t spec = vertexes[k++];
31.378 - glSecondaryColor3ubEXT( (GLubyte)(spec >> 16), (GLubyte)(spec >> 8),
31.379 - (GLubyte)spec );
31.380 - }
31.381 - glVertex3f( vertexf[0], vertexf[1], 1/vertexf[2] );
31.382 - vertexes += vertex_size;
31.383 - }
31.384 -
31.385 - glEnd();
31.386 -}
31.387 -
31.388 -void render_vertexes( uint32_t poly1, uint32_t *vertexes, int num_vertexes, int vertex_size,
31.389 - int render_mode )
31.390 -{
31.391 - uint32_t *vert_array[num_vertexes];
31.392 - int i;
31.393 - for( i=0; i<num_vertexes; i++ ) {
31.394 - vert_array[i] = vertexes;
31.395 - vertexes += vertex_size;
31.396 - }
31.397 - render_vertex_array( poly1, vert_array, num_vertexes, vertex_size, render_mode );
31.398 -}
31.399 -
31.400 -/**
31.401 - * Render a simple (not auto-sorted) tile
31.402 - */
31.403 -void render_tile( pvraddr_t tile_entry, int render_mode, gboolean cheap_modifier_mode ) {
31.404 - uint32_t poly_bank = MMIO_READ(PVR2,RENDER_POLYBASE);
31.405 - uint32_t *tile_list = (uint32_t *)(video_base+tile_entry);
31.406 - do {
31.407 - uint32_t entry = *tile_list++;
31.408 - if( entry >> 28 == 0x0F ) {
31.409 - break;
31.410 - } else if( entry >> 28 == 0x0E ) {
31.411 - tile_list = (uint32_t *)(video_base + (entry&0x007FFFFF));
31.412 - } else {
31.413 - uint32_t *polygon = (uint32_t *)(video_base + poly_bank + ((entry & 0x000FFFFF) << 2));
31.414 - int is_modified = entry & 0x01000000;
31.415 - int vertex_length = (entry >> 21) & 0x07;
31.416 - int context_length = 3;
31.417 - if( is_modified && !cheap_modifier_mode ) {
31.418 - context_length = 5;
31.419 - vertex_length *= 2 ;
31.420 - }
31.421 - vertex_length += 3;
31.422 -
31.423 - if( (entry & 0xE0000000) == 0x80000000 ) {
31.424 - /* Triangle(s) */
31.425 - int strip_count = ((entry >> 25) & 0x0F)+1;
31.426 - int polygon_length = 3 * vertex_length + context_length;
31.427 - int i;
31.428 - for( i=0; i<strip_count; i++ ) {
31.429 - render_set_context( polygon, render_mode );
31.430 - render_vertexes( *polygon, polygon+context_length, 3, vertex_length,
31.431 - render_mode );
31.432 - polygon += polygon_length;
31.433 - }
31.434 - } else if( (entry & 0xE0000000) == 0xA0000000 ) {
31.435 - /* Sprite(s) */
31.436 - int strip_count = ((entry >> 25) & 0x0F)+1;
31.437 - int polygon_length = 4 * vertex_length + context_length;
31.438 - int i;
31.439 - for( i=0; i<strip_count; i++ ) {
31.440 - render_set_context( polygon, render_mode );
31.441 - render_quad_vertexes( *polygon, polygon+context_length, vertex_length,
31.442 - render_mode );
31.443 - polygon += polygon_length;
31.444 - }
31.445 - } else {
31.446 - /* Polygon */
31.447 - int i, first=-1, last = -1;
31.448 - for( i=0; i<6; i++ ) {
31.449 - if( entry & (0x40000000>>i) ) {
31.450 - if( first == -1 ) first = i;
31.451 - last = i;
31.452 - }
31.453 - }
31.454 - if( first != -1 ) {
31.455 - first = 0;
31.456 - render_set_context(polygon, render_mode);
31.457 - render_vertexes( *polygon, polygon+context_length + (first*vertex_length),
31.458 - (last-first+3), vertex_length, render_mode );
31.459 - }
31.460 - }
31.461 - }
31.462 - } while( 1 );
31.463 -}
31.464 -
31.465 -void pvr2_render_tilebuffer( int width, int height, int clipx1, int clipy1,
31.466 - int clipx2, int clipy2 ) {
31.467 -
31.468 - pvraddr_t segmentbase = MMIO_READ( PVR2, RENDER_TILEBASE );
31.469 - int tile_sort;
31.470 - gboolean cheap_shadow;
31.471 -
31.472 - int obj_config = MMIO_READ( PVR2, RENDER_OBJCFG );
31.473 - int isp_config = MMIO_READ( PVR2, RENDER_ISPCFG );
31.474 - int shadow_cfg = MMIO_READ( PVR2, RENDER_SHADOW );
31.475 -
31.476 - if( (obj_config & 0x00200000) == 0 ) {
31.477 - if( isp_config & 1 ) {
31.478 - tile_sort = 0;
31.479 - } else {
31.480 - tile_sort = 2;
31.481 - }
31.482 - } else {
31.483 - tile_sort = 1;
31.484 - }
31.485 -
31.486 - cheap_shadow = shadow_cfg & 0x100 ? TRUE : FALSE;
31.487 -
31.488 - struct tile_segment *segment = (struct tile_segment *)(video_base + segmentbase);
31.489 -
31.490 - glEnable( GL_SCISSOR_TEST );
31.491 - do {
31.492 - // fwrite_dump32v( (uint32_t *)segment, sizeof(struct tile_segment), 6, stderr );
31.493 - int tilex = SEGMENT_X(segment->control);
31.494 - int tiley = SEGMENT_Y(segment->control);
31.495 -
31.496 - int x1 = tilex << 5;
31.497 - int y1 = tiley << 5;
31.498 - if( x1 + 32 <= clipx1 ||
31.499 - y1 + 32 <= clipy1 ||
31.500 - x1 >= clipx2 ||
31.501 - y1 >= clipy2 ) {
31.502 - /* Tile completely clipped, skip */
31.503 - continue;
31.504 - }
31.505 -
31.506 - /* Set a scissor on the visible part of the tile */
31.507 - int w = MIN(x1+32, clipx2) - x1;
31.508 - int h = MIN(y1+32, clipy2) - y1;
31.509 - x1 = MAX(x1,clipx1);
31.510 - y1 = MAX(y1,clipy1);
31.511 - glScissor( x1, height-y1-h, w, h );
31.512 -
31.513 - if( (segment->opaque_ptr & NO_POINTER) == 0 ) {
31.514 - if( pvr2_debug_render ) {
31.515 - fprintf( stderr, "Tile %d,%d Opaque\n", tilex, tiley );
31.516 - render_print_tilelist( stderr, segment->opaque_ptr );
31.517 - }
31.518 - if( (segment->opaquemod_ptr & NO_POINTER) == 0 ) {
31.519 - /* TODO */
31.520 - }
31.521 - render_tile( segment->opaque_ptr, RENDER_NORMAL, cheap_shadow );
31.522 - }
31.523 -
31.524 - if( (segment->trans_ptr & NO_POINTER) == 0 ) {
31.525 - if( pvr2_debug_render ) {
31.526 - fprintf( stderr, "Tile %d,%d Trans\n", tilex, tiley );
31.527 - render_print_tilelist( stderr, segment->trans_ptr );
31.528 - }
31.529 - if( (segment->transmod_ptr & NO_POINTER) == 0 ) {
31.530 - /* TODO */
31.531 - }
31.532 - if( tile_sort == 2 ||
31.533 - (tile_sort == 1 && ((segment->control & SEGMENT_SORT_TRANS)==0)) ) {
31.534 - render_autosort_tile( segment->trans_ptr, RENDER_NORMAL, cheap_shadow );
31.535 - } else {
31.536 - render_tile( segment->trans_ptr, RENDER_NORMAL, cheap_shadow );
31.537 - }
31.538 - }
31.539 -
31.540 - if( (segment->punchout_ptr & NO_POINTER) == 0 ) {
31.541 - if( pvr2_debug_render ) {
31.542 - fprintf( stderr, "Tile %d,%d Punchout\n", tilex, tiley );
31.543 - render_print_tilelist( stderr, segment->punchout_ptr );
31.544 - }
31.545 - render_tile( segment->punchout_ptr, RENDER_NORMAL, cheap_shadow );
31.546 - }
31.547 - } while( ((segment++)->control & SEGMENT_END) == 0 );
31.548 - glDisable( GL_SCISSOR_TEST );
31.549 -}
31.550 -
31.551 -static float render_find_maximum_tile_z( pvraddr_t tile_entry, float inputz )
31.552 -{
31.553 - uint32_t poly_bank = MMIO_READ(PVR2,RENDER_POLYBASE);
31.554 - uint32_t *tile_list = (uint32_t *)(video_base+tile_entry);
31.555 - int shadow_cfg = MMIO_READ( PVR2, RENDER_SHADOW ) & 0x100;
31.556 - int i, j;
31.557 - float z = inputz;
31.558 - do {
31.559 - uint32_t entry = *tile_list++;
31.560 - if( entry >> 28 == 0x0F ) {
31.561 - break;
31.562 - } else if( entry >> 28 == 0x0E ) {
31.563 - tile_list = (uint32_t *)(video_base + (entry&0x007FFFFF));
31.564 - } else {
31.565 - uint32_t *polygon = (uint32_t *)(video_base + poly_bank + ((entry & 0x000FFFFF) << 2));
31.566 - int vertex_length = (entry >> 21) & 0x07;
31.567 - int context_length = 3;
31.568 - if( (entry & 0x01000000) && (shadow_cfg==0) ) {
31.569 - context_length = 5;
31.570 - vertex_length *= 2 ;
31.571 - }
31.572 - vertex_length += 3;
31.573 - if( (entry & 0xE0000000) == 0x80000000 ) {
31.574 - /* Triangle(s) */
31.575 - int strip_count = ((entry >> 25) & 0x0F)+1;
31.576 - float *vertexz = (float *)(polygon+context_length+2);
31.577 - for( i=0; i<strip_count; i++ ) {
31.578 - for( j=0; j<3; j++ ) {
31.579 - if( *vertexz > z ) {
31.580 - z = *vertexz;
31.581 - }
31.582 - vertexz += vertex_length;
31.583 - }
31.584 - vertexz += context_length;
31.585 - }
31.586 - } else if( (entry & 0xE0000000) == 0xA0000000 ) {
31.587 - /* Sprite(s) */
31.588 - int strip_count = ((entry >> 25) & 0x0F)+1;
31.589 - int i;
31.590 - float *vertexz = (float *)(polygon+context_length+2);
31.591 - for( i=0; i<strip_count; i++ ) {
31.592 - for( j=0; j<4; j++ ) {
31.593 - if( *vertexz > z ) {
31.594 - z = *vertexz;
31.595 - }
31.596 - vertexz += vertex_length;
31.597 - }
31.598 - vertexz+=context_length;
31.599 - }
31.600 - } else {
31.601 - /* Polygon */
31.602 - int i;
31.603 - float *vertexz = (float *)polygon+context_length+2;
31.604 - for( i=0; i<6; i++ ) {
31.605 - if( (entry & (0x40000000>>i)) && *vertexz > z ) {
31.606 - z = *vertexz;
31.607 - }
31.608 - vertexz += vertex_length;
31.609 - }
31.610 - }
31.611 - }
31.612 - } while(1);
31.613 - return z;
31.614 -}
31.615 -
31.616 -/**
31.617 - * Scan through the scene to determine the largest z value (in order to set up
31.618 - * an appropriate near clip plane).
31.619 - */
31.620 -float pvr2_render_find_maximum_z( )
31.621 -{
31.622 - pvraddr_t segmentbase = MMIO_READ( PVR2, RENDER_TILEBASE );
31.623 - float maximumz = MMIO_READF( PVR2, RENDER_FARCLIP ); /* Initialize to the far clip plane */
31.624 -
31.625 - struct tile_segment *segment = (struct tile_segment *)(video_base + segmentbase);
31.626 - do {
31.627 -
31.628 - if( (segment->opaque_ptr & NO_POINTER) == 0 ) {
31.629 - maximumz = render_find_maximum_tile_z(segment->opaque_ptr, maximumz);
31.630 - }
31.631 - if( (segment->opaquemod_ptr & NO_POINTER) == 0 ) {
31.632 - maximumz = render_find_maximum_tile_z(segment->opaquemod_ptr, maximumz);
31.633 - }
31.634 - if( (segment->trans_ptr & NO_POINTER) == 0 ) {
31.635 - maximumz = render_find_maximum_tile_z(segment->trans_ptr, maximumz);
31.636 - }
31.637 - if( (segment->transmod_ptr & NO_POINTER) == 0 ) {
31.638 - maximumz = render_find_maximum_tile_z(segment->transmod_ptr, maximumz);
31.639 - }
31.640 - if( (segment->punchout_ptr & NO_POINTER) == 0 ) {
31.641 - maximumz = render_find_maximum_tile_z(segment->punchout_ptr, maximumz);
31.642 - }
31.643 -
31.644 - } while( ((segment++)->control & SEGMENT_END) == 0 );
31.645 -
31.646 - return 1/maximumz;
31.647 -}
31.648 -
31.649 -/**
31.650 - * Scan the segment info to determine the width and height of the render (in
31.651 - * pixels).
31.652 - * @param x,y output values to receive the width and height info.
31.653 - */
31.654 -void pvr2_render_getsize( int *x, int *y )
31.655 -{
31.656 - pvraddr_t segmentbase = MMIO_READ( PVR2, RENDER_TILEBASE );
31.657 - int maxx = 0, maxy = 0;
31.658 -
31.659 - struct tile_segment *segment = (struct tile_segment *)(video_base + segmentbase);
31.660 - do {
31.661 - int tilex = SEGMENT_X(segment->control);
31.662 - int tiley = SEGMENT_Y(segment->control);
31.663 - if( tilex > maxx ) {
31.664 - maxx = tilex;
31.665 - }
31.666 - if( tiley > maxy ) {
31.667 - maxy = tiley;
31.668 - }
31.669 - } while( ((segment++)->control & SEGMENT_END) == 0 );
31.670 -
31.671 - *x = (maxx+1)<<5;
31.672 - *y = (maxy+1)<<5;
31.673 -}
31.674 -
31.675 -void render_print_vertexes( FILE *f, uint32_t poly1, uint32_t *vert_array[],
31.676 - int num_vertexes, int vertex_size )
31.677 -{
31.678 - char buf[256], *p;
31.679 - int i, k;
31.680 - for( i=0; i<num_vertexes; i++ ) {
31.681 - p = buf;
31.682 - float *vertf = (float *)vert_array[i];
31.683 - uint32_t *verti = (uint32_t *)vert_array[i];
31.684 - p += sprintf( p, " V %9.5f,%9.5f,%9.5f ", vertf[0], vertf[1], vertf[2] );
31.685 - k = 3;
31.686 - if( POLY1_TEXTURED(poly1) ) {
31.687 - if( POLY1_UV16(poly1) ) {
31.688 - p += sprintf( p, "uv=%9.5f,%9.5f ",
31.689 - halftofloat(verti[k]>>16),
31.690 - halftofloat(verti[k]) );
31.691 - k++;
31.692 - } else {
31.693 - p += sprintf( p, "uv=%9.5f,%9.5f ", vertf[k], vertf[k+1] );
31.694 - k+=2;
31.695 - }
31.696 - }
31.697 -
31.698 - p += sprintf( p, "%08X ", verti[k++] );
31.699 - if( POLY1_SPECULAR(poly1) ) {
31.700 - p += sprintf( p, "%08X", verti[k++] );
31.701 - }
31.702 - p += sprintf( p, "\n" );
31.703 - fprintf( f, buf );
31.704 - }
31.705 -}
31.706 -
31.707 -void render_print_polygon( FILE *f, uint32_t entry )
31.708 -{
31.709 - uint32_t poly_bank = MMIO_READ(PVR2,RENDER_POLYBASE);
31.710 - int shadow_cfg = MMIO_READ( PVR2, RENDER_SHADOW ) & 0x100;
31.711 - int i;
31.712 -
31.713 - if( entry >> 28 == 0x0F ) {
31.714 - fprintf( f, "EOT\n" );
31.715 - } else if( entry >> 28 == 0x0E ) {
31.716 - fprintf( f, "LINK %08X\n", entry &0x7FFFFF );
31.717 - } else {
31.718 - uint32_t *polygon = (uint32_t *)(video_base + poly_bank + ((entry & 0x000FFFFF) << 2));
31.719 - int vertex_length = (entry >> 21) & 0x07;
31.720 - int context_length = 3;
31.721 - if( (entry & 0x01000000) && (shadow_cfg==0) ) {
31.722 - context_length = 5;
31.723 - vertex_length *= 2 ;
31.724 - }
31.725 - vertex_length += 3;
31.726 - if( (entry & 0xE0000000) == 0x80000000 ) {
31.727 - /* Triangle(s) */
31.728 - int strip_count = ((entry >> 25) & 0x0F)+1;
31.729 - for( i=0; i<strip_count; i++ ) {
31.730 - fprintf( f, "TRI %08X %08X %08X\n", polygon[0], polygon[1], polygon[2] );
31.731 - uint32_t *array[3];
31.732 - array[0] = polygon + context_length;
31.733 - array[1] = array[0] + vertex_length;
31.734 - array[2] = array[1] + vertex_length;
31.735 - render_print_vertexes( f, *polygon, array, 3, vertex_length );
31.736 - polygon = array[2] + vertex_length;
31.737 - }
31.738 - } else if( (entry & 0xE0000000) == 0xA0000000 ) {
31.739 - /* Sprite(s) */
31.740 - int strip_count = ((entry >> 25) & 0x0F)+1;
31.741 - for( i=0; i<strip_count; i++ ) {
31.742 - fprintf( f, "QUAD %08X %08X %08X\n", polygon[0], polygon[1], polygon[2] );
31.743 - uint32_t *array[4];
31.744 - array[0] = polygon + context_length;
31.745 - array[1] = array[0] + vertex_length;
31.746 - array[2] = array[1] + vertex_length;
31.747 - array[3] = array[2] + vertex_length;
31.748 - render_print_vertexes( f, *polygon, array, 4, vertex_length );
31.749 - polygon = array[3] + vertex_length;
31.750 - }
31.751 - } else {
31.752 - /* Polygon */
31.753 - int last = -1;
31.754 - uint32_t *array[8];
31.755 - for( i=0; i<6; i++ ) {
31.756 - if( entry & (0x40000000>>i) ) {
31.757 - last = i;
31.758 - }
31.759 - }
31.760 - fprintf( f, "POLY %08X %08X %08X\n", polygon[0], polygon[1], polygon[2] );
31.761 - for( i=0; i<last+2; i++ ) {
31.762 - array[i] = polygon + context_length + vertex_length*i;
31.763 - }
31.764 - render_print_vertexes( f, *polygon, array, last+2, vertex_length );
31.765 - }
31.766 - }
31.767 -}
31.768 -
31.769 -void render_print_tilelist( FILE *f, uint32_t tile_entry )
31.770 -{
31.771 - uint32_t *tile_list = (uint32_t *)(video_base+tile_entry);
31.772 - do {
31.773 - uint32_t entry = *tile_list++;
31.774 - if( entry >> 28 == 0x0F ) {
31.775 - break;
31.776 - } else if( entry >> 28 == 0x0E ) {
31.777 - tile_list = (uint32_t *)(video_base + (entry&0x007FFFFF));
31.778 - } else {
31.779 - render_print_polygon(f, entry);
31.780 - }
31.781 - } while( 1 );
31.782 -}
31.783 -
32.1 --- a/src/pvr2/render.c Sun Mar 02 11:38:08 2008 +0000
32.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
32.3 @@ -1,150 +0,0 @@
32.4 -/**
32.5 - * $Id$
32.6 - *
32.7 - * PVR2 Renderer support. This part is primarily
32.8 - *
32.9 - * Copyright (c) 2005 Nathan Keynes.
32.10 - *
32.11 - * This program is free software; you can redistribute it and/or modify
32.12 - * it under the terms of the GNU General Public License as published by
32.13 - * the Free Software Foundation; either version 2 of the License, or
32.14 - * (at your option) any later version.
32.15 - *
32.16 - * This program is distributed in the hope that it will be useful,
32.17 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
32.18 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32.19 - * GNU General Public License for more details.
32.20 - */
32.21 -
32.22 -#include <sys/time.h>
32.23 -#include <time.h>
32.24 -#include "pvr2/pvr2.h"
32.25 -#include "asic.h"
32.26 -
32.27 -
32.28 -int pvr2_render_trace = 0;
32.29 -
32.30 -#if 0
32.31 -int pvr2_render_font_list = -1;
32.32 -int glPrintf( int x, int y, const char *fmt, ... )
32.33 -{
32.34 - va_list ap; /* our argument pointer */
32.35 - char buf[256];
32.36 - int len;
32.37 - if (fmt == NULL) /* if there is no string to draw do nothing */
32.38 - return 0;
32.39 - va_start(ap, fmt);
32.40 - len = vsnprintf(buf, sizeof(buf), fmt, ap);
32.41 - va_end(ap);
32.42 -
32.43 -
32.44 - glPushAttrib(GL_LIST_BIT);
32.45 - glDisable( GL_DEPTH_TEST );
32.46 - glDisable( GL_BLEND );
32.47 - glDisable( GL_TEXTURE_2D );
32.48 - glDisable( GL_ALPHA_TEST );
32.49 - glDisable( GL_CULL_FACE );
32.50 - glListBase(pvr2_render_font_list - 32);
32.51 - glColor3f( 1.0, 1.0, 1.0 );
32.52 - glRasterPos2i( x, y );
32.53 - glCallLists(len, GL_UNSIGNED_BYTE, buf);
32.54 - glPopAttrib();
32.55 -
32.56 - return len;
32.57 -}
32.58 -#endif
32.59 -
32.60 -void glDrawGrid( int width, int height )
32.61 -{
32.62 - int i;
32.63 - glDisable( GL_DEPTH_TEST );
32.64 - glLineWidth(1);
32.65 -
32.66 - glBegin( GL_LINES );
32.67 - glColor4f( 1.0, 1.0, 1.0, 1.0 );
32.68 - for( i=32; i<width; i+=32 ) {
32.69 - glVertex3f( i, 0.0, 3.0 );
32.70 - glVertex3f( i,height-1, 3.0 );
32.71 - }
32.72 -
32.73 - for( i=32; i<height; i+=32 ) {
32.74 - glVertex3f( 0.0, i, 3.0 );
32.75 - glVertex3f( width, i, 3.0 );
32.76 - }
32.77 - glEnd();
32.78 -
32.79 -}
32.80 -
32.81 -/**
32.82 - * Prepare the OpenGL context to receive instructions for a new frame.
32.83 - */
32.84 -static void pvr2_render_prepare_context( render_buffer_t buffer,
32.85 - float bgplanez, float nearz )
32.86 -{
32.87 - /* Select and initialize the render context */
32.88 - display_driver->set_render_target(buffer);
32.89 -#if 0
32.90 - if( pvr2_render_font_list == -1 ) {
32.91 - pvr2_render_font_list = video_glx_load_font( "-*-helvetica-*-r-normal--16-*-*-*-p-*-iso8859-1");
32.92 - }
32.93 -#endif
32.94 - pvr2_check_palette_changed();
32.95 -
32.96 - /* Setup the display model */
32.97 - glShadeModel(GL_SMOOTH);
32.98 - glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
32.99 - glMatrixMode(GL_PROJECTION);
32.100 - glLoadIdentity();
32.101 - glOrtho( 0, buffer->width, buffer->height, 0, -bgplanez, -nearz );
32.102 - glMatrixMode(GL_MODELVIEW);
32.103 - glLoadIdentity();
32.104 - glCullFace( GL_BACK );
32.105 - glEnable( GL_BLEND );
32.106 -
32.107 - /* Clear out the buffers */
32.108 - glDisable( GL_SCISSOR_TEST );
32.109 - glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
32.110 - glClearDepth(0);
32.111 - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
32.112 - glEnableClientState( GL_COLOR_ARRAY );
32.113 - glEnableClientState( GL_VERTEX_ARRAY );
32.114 -}
32.115 -
32.116 -/**
32.117 - * Render a complete scene into the OpenGL back buffer.
32.118 - * Note: this will probably need to be broken up eventually once timings are
32.119 - * determined.
32.120 - */
32.121 -void pvr2_render_scene( render_buffer_t buffer )
32.122 -{
32.123 - struct timeval tva, tvb;
32.124 -
32.125 - gettimeofday(&tva, NULL);
32.126 -
32.127 - float bgplanez = 1/MMIO_READF( PVR2, RENDER_FARCLIP );
32.128 - pvr2_render_prepare_context( buffer, bgplanez, 0 );
32.129 -
32.130 - int clip_x = MMIO_READ( PVR2, RENDER_HCLIP ) & 0x03FF;
32.131 - int clip_y = MMIO_READ( PVR2, RENDER_VCLIP ) & 0x03FF;
32.132 - int clip_width = ((MMIO_READ( PVR2, RENDER_HCLIP ) >> 16) & 0x03FF) - clip_x + 1;
32.133 - int clip_height= ((MMIO_READ( PVR2, RENDER_VCLIP ) >> 16) & 0x03FF) - clip_y + 1;
32.134 -
32.135 - /* Fog setup goes here? */
32.136 -
32.137 - /* Render the background plane */
32.138 -
32.139 - uint32_t bgplane_mode = MMIO_READ(PVR2, RENDER_BGPLANE);
32.140 - uint32_t *display_list =
32.141 - (uint32_t *)mem_get_region(PVR2_RAM_BASE + MMIO_READ( PVR2, RENDER_POLYBASE ));
32.142 -
32.143 - uint32_t *bgplane = display_list + (((bgplane_mode & 0x00FFFFFF)) >> 3) ;
32.144 - render_backplane( bgplane, buffer->width, buffer->height, bgplane_mode );
32.145 -
32.146 - pvr2_render_tilebuffer( buffer->width, buffer->height, clip_x, clip_y,
32.147 - clip_x + clip_width, clip_y + clip_height );
32.148 -
32.149 - gettimeofday( &tvb, NULL );
32.150 - uint32_t ms = (tvb.tv_sec - tva.tv_sec) * 1000 +
32.151 - (tvb.tv_usec - tva.tv_usec)/1000;
32.152 - DEBUG( "Rendered frame %d to %08X in %dms", pvr2_get_frame_count(), buffer->address, ms );
32.153 -}
33.1 --- a/src/pvr2/rendsort.c Sun Mar 02 11:38:08 2008 +0000
33.2 +++ b/src/pvr2/rendsort.c Fri Mar 28 12:32:25 2008 +0000
33.3 @@ -16,21 +16,21 @@
33.4 * GNU General Public License for more details.
33.5 */
33.6 #include <sys/time.h>
33.7 +#include <string.h>
33.8 +#include <assert.h>
33.9 #include "pvr2/pvr2.h"
33.10 +#include "pvr2/scene.h"
33.11 #include "asic.h"
33.12
33.13 extern char *video_base;
33.14 -extern gboolean pvr2_force_fragment_alpha;
33.15
33.16 #define MIN3( a,b,c ) ((a) < (b) ? ( (a) < (c) ? (a) : (c) ) : ((b) < (c) ? (b) : (c)) )
33.17 #define MAX3( a,b,c ) ((a) > (b) ? ( (a) > (c) ? (a) : (c) ) : ((b) > (c) ? (b) : (c)) )
33.18
33.19 -struct render_triangle {
33.20 - uint32_t *polygon;
33.21 - int vertex_length; /* Number of 32-bit words in vertex, or 0 for an unpacked vertex */
33.22 - float minx,miny,minz;
33.23 - float maxx,maxy,maxz;
33.24 - float *vertexes[3];
33.25 +struct sort_triangle {
33.26 + struct polygon_struct *poly;
33.27 + int triangle_num; // triangle number in the poly, from 0
33.28 + float maxz;
33.29 };
33.30
33.31 #define SENTINEL 0xDEADBEEF
33.32 @@ -39,7 +39,7 @@
33.33 * Count the number of triangles in the list starting at the given
33.34 * pvr memory address.
33.35 */
33.36 -int render_count_triangles( pvraddr_t tile_entry ) {
33.37 +int sort_count_triangles( pvraddr_t tile_entry ) {
33.38 uint32_t *tile_list = (uint32_t *)(video_base+tile_entry);
33.39 int count = 0;
33.40 while(1) {
33.41 @@ -64,27 +64,12 @@
33.42 return count;
33.43 }
33.44
33.45 -static void compute_triangle_boxes( struct render_triangle *triangle, int num_triangles )
33.46 +/**
33.47 + * Extract a triangle list from the tile (basically indexes into the polygon list, plus
33.48 + * computing maxz while we go through it
33.49 + */
33.50 +int sort_extract_triangles( pvraddr_t tile_entry, struct sort_triangle *triangles )
33.51 {
33.52 - int i;
33.53 - for( i=0; i<num_triangles; i++ ) {
33.54 - triangle[i].minx = MIN3(triangle[i].vertexes[0][0],triangle[i].vertexes[1][0],triangle[i].vertexes[2][0]);
33.55 - triangle[i].maxx = MAX3(triangle[i].vertexes[0][0],triangle[i].vertexes[1][0],triangle[i].vertexes[2][0]);
33.56 - triangle[i].miny = MIN3(triangle[i].vertexes[0][1],triangle[i].vertexes[1][1],triangle[i].vertexes[2][1]);
33.57 - triangle[i].maxy = MAX3(triangle[i].vertexes[0][1],triangle[i].vertexes[1][1],triangle[i].vertexes[2][1]);
33.58 - float az = 1/triangle[i].vertexes[0][2];
33.59 - float bz = 1/triangle[i].vertexes[1][2];
33.60 - float cz = 1/triangle[i].vertexes[2][2];
33.61 - triangle[i].minz = MIN3(az,bz,cz);
33.62 - triangle[i].maxz = MAX3(az,bz,cz);
33.63 - }
33.64 -}
33.65 -
33.66 -void render_extract_triangles( pvraddr_t tile_entry, gboolean cheap_modifier_mode,
33.67 - struct render_triangle *triangles, int num_triangles,
33.68 - struct vertex_unpacked *vertex_space, int render_mode )
33.69 -{
33.70 - uint32_t poly_bank = MMIO_READ(PVR2,RENDER_POLYBASE);
33.71 uint32_t *tile_list = (uint32_t *)(video_base+tile_entry);
33.72 int count = 0;
33.73 while(1) {
33.74 @@ -94,11 +79,11 @@
33.75 } else if( entry >> 28 == 0x0E ) {
33.76 tile_list = (uint32_t *)(video_base+(entry&0x007FFFFF));
33.77 } else {
33.78 - uint32_t *polygon = (uint32_t *)(video_base + poly_bank + ((entry & 0x000FFFFF) << 2));
33.79 + uint32_t poly_addr = entry & 0x000FFFFF;
33.80 int is_modified = entry & 0x01000000;
33.81 int vertex_length = (entry >> 21) & 0x07;
33.82 int context_length = 3;
33.83 - if( is_modified && !cheap_modifier_mode ) {
33.84 + if( is_modified && pvr2_scene.full_shadow ) {
33.85 context_length = 5;
33.86 vertex_length *= 2 ;
33.87 }
33.88 @@ -110,127 +95,108 @@
33.89 int polygon_length = 3 * vertex_length + context_length;
33.90 int i;
33.91 for( i=0; i<strip_count; i++ ) {
33.92 - float *vertex = (float *)(polygon+context_length);
33.93 - triangles[count].polygon = polygon;
33.94 - triangles[count].vertex_length = vertex_length;
33.95 - triangles[count].vertexes[0] = vertex;
33.96 - vertex+=vertex_length;
33.97 - triangles[count].vertexes[1] = vertex;
33.98 - vertex+=vertex_length;
33.99 - triangles[count].vertexes[2] = vertex;
33.100 - polygon += polygon_length;
33.101 + struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[poly_addr];
33.102 + triangles[count].poly = poly;
33.103 + triangles[count].triangle_num = 0;
33.104 + triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index].z,
33.105 + pvr2_scene.vertex_array[poly->vertex_index+1].z,
33.106 + pvr2_scene.vertex_array[poly->vertex_index+2].z );
33.107 + poly_addr += polygon_length;
33.108 count++;
33.109 }
33.110 } else if( (entry & 0xE0000000) == 0xA0000000 ) {
33.111 /* Quad(s) */
33.112 int strip_count = ((entry >> 25) & 0x0F)+1;
33.113 int polygon_length = 4 * vertex_length + context_length;
33.114 -
33.115 int i;
33.116 for( i=0; i<strip_count; i++ ) {
33.117 - render_unpack_quad( vertex_space, *polygon, (polygon+context_length),
33.118 - vertex_length, render_mode );
33.119 - triangles[count].polygon = polygon;
33.120 - triangles[count].vertex_length = 0;
33.121 - triangles[count].vertexes[0] = (float *)vertex_space;
33.122 - triangles[count].vertexes[1] = (float *)(vertex_space + 1);
33.123 - triangles[count].vertexes[2] = (float *)(vertex_space + 3);
33.124 + struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[poly_addr];
33.125 + triangles[count].poly = poly;
33.126 + triangles[count].triangle_num = 0;
33.127 + triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index].z,
33.128 + pvr2_scene.vertex_array[poly->vertex_index+1].z,
33.129 + pvr2_scene.vertex_array[poly->vertex_index+2].z );
33.130 count++;
33.131 - /* Preserve face direction */
33.132 - triangles[count].polygon = polygon;
33.133 - triangles[count].vertex_length = 0;
33.134 - triangles[count].vertexes[0] = (float *)(vertex_space + 1);
33.135 - triangles[count].vertexes[1] = (float *)(vertex_space + 2);
33.136 - triangles[count].vertexes[2] = (float *)(vertex_space + 3);
33.137 + triangles[count].poly = poly;
33.138 + triangles[count].triangle_num = 1;
33.139 + triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index+1].z,
33.140 + pvr2_scene.vertex_array[poly->vertex_index+2].z,
33.141 + pvr2_scene.vertex_array[poly->vertex_index+3].z );
33.142 count++;
33.143 - vertex_space += 4;
33.144 - polygon += polygon_length;
33.145 + poly_addr += polygon_length;
33.146 }
33.147 } else {
33.148 /* Polygon */
33.149 int i;
33.150 - float *vertex = (float *)polygon+context_length;
33.151 + struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[poly_addr];
33.152 for( i=0; i<6; i++ ) {
33.153 if( entry & (0x40000000>>i) ) {
33.154 - triangles[count].polygon = polygon;
33.155 - triangles[count].vertex_length = vertex_length;
33.156 - if( i&1 ) {
33.157 - triangles[count].vertexes[0] = vertex + vertex_length;
33.158 - triangles[count].vertexes[1] = vertex;
33.159 - triangles[count].vertexes[2] = vertex + (vertex_length<<1);
33.160 - } else {
33.161 - triangles[count].vertexes[0] = vertex;
33.162 - triangles[count].vertexes[1] = vertex + vertex_length;
33.163 - triangles[count].vertexes[2] = vertex + (vertex_length<<1);
33.164 - }
33.165 + triangles[count].poly = poly;
33.166 + triangles[count].triangle_num = i;
33.167 + triangles[count].maxz = MAX3( pvr2_scene.vertex_array[poly->vertex_index+i].z,
33.168 + pvr2_scene.vertex_array[poly->vertex_index+i+1].z,
33.169 + pvr2_scene.vertex_array[poly->vertex_index+i+2].z );
33.170 count++;
33.171 }
33.172 - vertex += vertex_length;
33.173 }
33.174 }
33.175 }
33.176 }
33.177 - if( count != num_triangles ) {
33.178 - ERROR( "Extracted triangles do not match expected count!" );
33.179 - }
33.180 + return count;
33.181 }
33.182
33.183 -void render_triangles( struct render_triangle *triangles, int num_triangles,
33.184 - int render_mode )
33.185 +void sort_render_triangles( struct sort_triangle *triangles, int num_triangles,
33.186 + int render_mode )
33.187 {
33.188 int i;
33.189 for( i=0; i<num_triangles; i++ ) {
33.190 - render_set_context( triangles[i].polygon, render_mode );
33.191 - glEnable(GL_DEPTH_TEST);
33.192 + struct polygon_struct *poly = triangles[i].poly;
33.193 + if( poly->tex_id != -1 ) {
33.194 + glBindTexture(GL_TEXTURE_2D, poly->tex_id);
33.195 + }
33.196 + render_set_context( poly->context, RENDER_NORMAL );
33.197 + glDepthMask(GL_FALSE);
33.198 glDepthFunc(GL_GEQUAL);
33.199 - if( triangles[i].vertex_length == 0 ) {
33.200 - render_unpacked_vertex_array( *triangles[i].polygon, (struct vertex_unpacked **)triangles[i].vertexes, 3 );
33.201 + /* Fix cull direction */
33.202 + if( triangles[i].triangle_num & 1 ) {
33.203 + glCullFace(GL_FRONT);
33.204 } else {
33.205 - render_vertex_array( *triangles[i].polygon, (uint32_t **)triangles[i].vertexes, 3,
33.206 - triangles[i].vertex_length, render_mode );
33.207 + glCullFace(GL_BACK);
33.208 }
33.209 +
33.210 + glDrawArrays(GL_TRIANGLE_STRIP, poly->vertex_index + triangles[i].triangle_num, 3 );
33.211 }
33.212 -
33.213 -
33.214 }
33.215
33.216 int compare_triangles( const void *a, const void *b )
33.217 {
33.218 - const struct render_triangle *tri1 = a;
33.219 - const struct render_triangle *tri2 = b;
33.220 - if( tri1->minz < tri2->minz ) {
33.221 - return 1; // No these _aren't_ back to front...
33.222 - } else if( tri1->minz > tri2->minz ) {
33.223 - return -1;
33.224 - } else {
33.225 - return 0;
33.226 - }
33.227 + const struct sort_triangle *tri1 = a;
33.228 + const struct sort_triangle *tri2 = b;
33.229 + return tri2->maxz - tri1->maxz;
33.230 }
33.231
33.232 -void sort_triangles( struct render_triangle *triangles, int num_triangles )
33.233 +void sort_triangles( struct sort_triangle *triangles, int num_triangles )
33.234 {
33.235 - qsort( triangles, num_triangles, sizeof(struct render_triangle), compare_triangles );
33.236 + qsort( triangles, num_triangles, sizeof(struct sort_triangle), compare_triangles );
33.237 }
33.238
33.239 -void render_autosort_tile( pvraddr_t tile_entry, int render_mode, gboolean cheap_modifier_mode )
33.240 +void render_autosort_tile( pvraddr_t tile_entry, int render_mode )
33.241 {
33.242 - int num_triangles = render_count_triangles(tile_entry);
33.243 + int num_triangles = sort_count_triangles(tile_entry);
33.244 if( num_triangles == 0 ) {
33.245 return; /* nothing to do */
33.246 } else if( num_triangles == 1 ) { /* Triangle can hardly overlap with itself */
33.247 - render_tile( tile_entry, render_mode, cheap_modifier_mode );
33.248 + gl_render_tilelist(tile_entry);
33.249 } else { /* Ooh boy here we go... */
33.250 - struct render_triangle triangles[num_triangles+1];
33.251 - struct vertex_unpacked vertex_space[num_triangles << 1];
33.252 + struct sort_triangle triangles[num_triangles+1];
33.253 // Reserve space for num_triangles / 2 * 4 vertexes (maximum possible number of
33.254 // quad vertices)
33.255 - triangles[num_triangles].polygon = (void *)SENTINEL;
33.256 - render_extract_triangles(tile_entry, cheap_modifier_mode, triangles, num_triangles, vertex_space, render_mode);
33.257 - compute_triangle_boxes(triangles, num_triangles);
33.258 + triangles[num_triangles].poly = (void *)SENTINEL;
33.259 + int extracted_triangles = sort_extract_triangles(tile_entry, triangles);
33.260 + assert( extracted_triangles == num_triangles );
33.261 sort_triangles( triangles, num_triangles );
33.262 - render_triangles(triangles, num_triangles, render_mode);
33.263 - if( triangles[num_triangles].polygon != (void *)SENTINEL ) {
33.264 - fprintf( stderr, "Triangle overflow in render_autosort_tile!" );
33.265 - }
33.266 + sort_render_triangles(triangles, num_triangles, render_mode);
33.267 + glCullFace(GL_BACK);
33.268 + assert( triangles[num_triangles].poly == (void *)SENTINEL );
33.269 }
33.270 }
34.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
34.2 +++ b/src/pvr2/scene.c Fri Mar 28 12:32:25 2008 +0000
34.3 @@ -0,0 +1,651 @@
34.4 +/**
34.5 + * $Id$
34.6 + *
34.7 + * Manage the internal vertex/polygon buffers and scene data structure.
34.8 + * Where possible this uses VBOs for the vertex + index data.
34.9 + *
34.10 + * Copyright (c) 2005 Nathan Keynes.
34.11 + *
34.12 + * This program is free software; you can redistribute it and/or modify
34.13 + * it under the terms of the GNU General Public License as published by
34.14 + * the Free Software Foundation; either version 2 of the License, or
34.15 + * (at your option) any later version.
34.16 + *
34.17 + * This program is distributed in the hope that it will be useful,
34.18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
34.19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34.20 + * GNU General Public License for more details.
34.21 + */
34.22 +
34.23 +#include <assert.h>
34.24 +#include <string.h>
34.25 +#include <math.h>
34.26 +#include "lxdream.h"
34.27 +#include "display.h"
34.28 +#include "pvr2/pvr2.h"
34.29 +#include "pvr2/glutil.h"
34.30 +#include "pvr2/scene.h"
34.31 +
34.32 +#define VBO_EXT_STRING "GL_ARB_vertex_buffer_object"
34.33 +#define PBO_EXT_STRING "GL_ARB_pixel_buffer_object"
34.34 +
34.35 +static inline uint32_t bgra_to_rgba(uint32_t bgra)
34.36 +{
34.37 + return (bgra&0xFF00FF00) | ((bgra&0x00FF0000)>>16) | ((bgra&0x000000FF)<<16);
34.38 +}
34.39 +
34.40 +/**
34.41 + * Convert a half-float (16-bit) FP number to a regular 32-bit float.
34.42 + * Source is 1-bit sign, 5-bit exponent, 10-bit mantissa.
34.43 + * TODO: Check the correctness of this.
34.44 + */
34.45 +static float halftofloat( uint16_t half )
34.46 +{
34.47 + union {
34.48 + float f;
34.49 + uint32_t i;
34.50 + } temp;
34.51 + temp.i = ((uint32_t)half)<<16;
34.52 + return temp.f;
34.53 +}
34.54 +
34.55 +
34.56 +
34.57 +
34.58 +
34.59 +struct pvr2_scene_struct pvr2_scene;
34.60 +
34.61 +static gboolean vbo_init = FALSE;
34.62 +static gboolean vbo_supported = FALSE;
34.63 +
34.64 +/**
34.65 + * Test for VBO support, and allocate all the system memory needed for the
34.66 + * temporary structures. GL context must have been initialized before this
34.67 + * point.
34.68 + */
34.69 +void pvr2_scene_init()
34.70 +{
34.71 + if( !vbo_init ) {
34.72 +#ifdef ENABLE_VERTEX_BUFFER
34.73 + if( isGLExtensionSupported(VBO_EXT_STRING) ) {
34.74 + vbo_supported = TRUE;
34.75 + pvr2_scene.vbo_id = 1;
34.76 + }
34.77 +#endif
34.78 + pvr2_scene.vertex_array = NULL;
34.79 + pvr2_scene.vertex_array_size = 0;
34.80 + pvr2_scene.poly_array = g_malloc( MAX_POLY_BUFFER_SIZE );
34.81 + pvr2_scene.buf_to_poly_map = g_malloc0( BUF_POLY_MAP_SIZE );
34.82 + vbo_init = TRUE;
34.83 + }
34.84 +}
34.85 +
34.86 +/**
34.87 + * Clear the scene data structures in preparation for fresh data
34.88 + */
34.89 +void pvr2_scene_reset()
34.90 +{
34.91 + pvr2_scene.poly_count = 0;
34.92 + pvr2_scene.vertex_count = 0;
34.93 + memset( pvr2_scene.buf_to_poly_map, 0, BUF_POLY_MAP_SIZE );
34.94 +}
34.95 +
34.96 +void pvr2_scene_shutdown()
34.97 +{
34.98 +#ifdef ENABLE_VERTEX_BUFFER
34.99 + if( vbo_supported ) {
34.100 + glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 );
34.101 + glDeleteBuffersARB( 1, &pvr2_scene.vbo_id );
34.102 + pvr2_scene.vbo_id = 0;
34.103 + } else {
34.104 +#endif
34.105 + g_free( pvr2_scene.vertex_array );
34.106 + pvr2_scene.vertex_array = NULL;
34.107 +#ifdef ENABLE_VERTEX_BUFFER
34.108 + }
34.109 +#endif
34.110 +
34.111 + g_free( pvr2_scene.poly_array );
34.112 + pvr2_scene.poly_array = NULL;
34.113 + g_free( pvr2_scene.buf_to_poly_map );
34.114 + pvr2_scene.buf_to_poly_map = NULL;
34.115 + vbo_init = FALSE;
34.116 +}
34.117 +
34.118 +void *vertex_buffer_map()
34.119 +{
34.120 + glGetError();
34.121 + uint32_t size = pvr2_scene.vertex_count * sizeof(struct vertex_struct);
34.122 +#ifdef ENABLE_VERTEX_BUFFER
34.123 + if( vbo_supported ) {
34.124 + glBindBufferARB( GL_ARRAY_BUFFER_ARB, pvr2_scene.vbo_id );
34.125 + if( size > pvr2_scene.vertex_array_size ) {
34.126 + glBufferDataARB( GL_ARRAY_BUFFER_ARB, size, NULL, GL_DYNAMIC_DRAW_ARB );
34.127 + int status = glGetError();
34.128 + if( status != 0 ) {
34.129 + fprintf( stderr, "Error %08X allocating vertex buffer\n", status );
34.130 + abort();
34.131 + }
34.132 + pvr2_scene.vertex_array_size = size;
34.133 + }
34.134 + pvr2_scene.vertex_array = glMapBufferARB( GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB );
34.135 + assert(pvr2_scene.vertex_array != NULL );
34.136 + } else {
34.137 +#endif
34.138 + if( size > pvr2_scene.vertex_array_size ) {
34.139 + pvr2_scene.vertex_array = g_realloc( pvr2_scene.vertex_array, size );
34.140 + }
34.141 +#ifdef ENABLE_VERTEX_BUFFER
34.142 + }
34.143 +#endif
34.144 + return pvr2_scene.vertex_array;
34.145 +}
34.146 +
34.147 +gboolean vertex_buffer_unmap()
34.148 +{
34.149 +#ifdef ENABLE_VERTEX_BUFFER
34.150 + if( vbo_supported ) {
34.151 + pvr2_scene.vertex_array = NULL;
34.152 + return glUnmapBufferARB( GL_ARRAY_BUFFER_ARB );
34.153 + } else {
34.154 + return TRUE;
34.155 + }
34.156 +#else
34.157 + return TRUE;
34.158 +#endif
34.159 +}
34.160 +
34.161 +static struct polygon_struct *scene_add_polygon( pvraddr_t poly_idx, int vertex_count,
34.162 + gboolean is_modified )
34.163 +{
34.164 + int vert_mul = is_modified ? 2 : 1;
34.165 +
34.166 + if( pvr2_scene.buf_to_poly_map[poly_idx] != NULL ) {
34.167 + if( vertex_count > pvr2_scene.buf_to_poly_map[poly_idx]->vertex_count ) {
34.168 + pvr2_scene.vertex_count += (vertex_count - pvr2_scene.buf_to_poly_map[poly_idx]->vertex_count) * vert_mul;
34.169 + pvr2_scene.buf_to_poly_map[poly_idx]->vertex_count = vertex_count;
34.170 + }
34.171 + return pvr2_scene.buf_to_poly_map[poly_idx];
34.172 + } else {
34.173 + struct polygon_struct *poly = &pvr2_scene.poly_array[pvr2_scene.poly_count++];
34.174 + poly->context = (uint32_t *)(video_base + MMIO_READ(PVR2,RENDER_POLYBASE) + (poly_idx<<2));
34.175 + poly->vertex_count = vertex_count;
34.176 + poly->vertex_index = -1;
34.177 + poly->mod_vertex_index = -1;
34.178 + poly->next = NULL;
34.179 + pvr2_scene.buf_to_poly_map[poly_idx] = poly;
34.180 + pvr2_scene.vertex_count += (vertex_count * vert_mul);
34.181 + return poly;
34.182 + }
34.183 +}
34.184 +
34.185 +/**
34.186 + * Decode a single PVR2 renderable vertex (opaque/trans/punch-out, but not shadow
34.187 + * volume)
34.188 + * @param vert Pointer to output vertex structure
34.189 + * @param poly1 First word of polygon context (needed to understand vertex)
34.190 + * @param poly2 Second word of polygon context
34.191 + * @param pvr2_data Pointer to raw pvr2 vertex data (in VRAM)
34.192 + * @param modify_offset Offset in 32-bit words to the tex/color data. 0 for
34.193 + * the normal vertex, half the vertex length for the modified vertex.
34.194 + */
34.195 +static void pvr2_decode_render_vertex( struct vertex_struct *vert, uint32_t poly1,
34.196 + uint32_t poly2, uint32_t *pvr2_data,
34.197 + int modify_offset )
34.198 +{
34.199 + gboolean force_alpha = !POLY2_ALPHA_ENABLE(poly2);
34.200 + union pvr2_data_type {
34.201 + uint32_t *ival;
34.202 + float *fval;
34.203 + } data;
34.204 +
34.205 + data.ival = pvr2_data;
34.206 +
34.207 + vert->x = *data.fval++;
34.208 + vert->y = *data.fval++;
34.209 +
34.210 + float z = *data.fval++;
34.211 + if( !isfinite(z) ) {
34.212 + z = 0;
34.213 + } else if( z != 0 ) {
34.214 + z = 1/z;
34.215 + }
34.216 + if( z > pvr2_scene.bounds[5] ) {
34.217 + pvr2_scene.bounds[5] = z;
34.218 + } else if( z < pvr2_scene.bounds[4] && z != 0 ) {
34.219 + pvr2_scene.bounds[4] = z;
34.220 + }
34.221 + vert->z = z;
34.222 + data.ival += modify_offset;
34.223 +
34.224 +
34.225 + if( POLY1_TEXTURED(poly1) ) {
34.226 + if( POLY1_UV16(poly1) ) {
34.227 + vert->u = halftofloat( *data.ival>>16 );
34.228 + vert->v = halftofloat( *data.ival );
34.229 + data.ival++;
34.230 + } else {
34.231 + vert->u = *data.fval++;
34.232 + vert->v = *data.fval++;
34.233 + }
34.234 + if( POLY2_TEX_BLEND(poly2) == 1 ) {
34.235 + force_alpha = TRUE;
34.236 + }
34.237 + }
34.238 + if( force_alpha ) {
34.239 + vert->rgba = bgra_to_rgba((*data.ival++) | 0xFF000000);
34.240 + if( POLY1_SPECULAR(poly1) ) {
34.241 + vert->offset_rgba = bgra_to_rgba((*data.ival++) | 0xFF000000);
34.242 + } else {
34.243 + vert->offset_rgba = 0;
34.244 + }
34.245 + } else {
34.246 + vert->rgba = bgra_to_rgba(*data.ival++);
34.247 + if( POLY1_SPECULAR(poly1) ) {
34.248 + vert->offset_rgba = bgra_to_rgba(*data.ival++);
34.249 + } else {
34.250 + vert->offset_rgba = 0;
34.251 + }
34.252 + }
34.253 +}
34.254 +
34.255 +/**
34.256 + * Compute texture, colour, and z values for a result point by interpolating from
34.257 + * a set of 3 input points. The result point must define its x,y.
34.258 + */
34.259 +static void scene_compute_vertex( struct vertex_struct *result,
34.260 + struct vertex_struct *input,
34.261 + gboolean is_solid_shaded )
34.262 +{
34.263 + int i;
34.264 + float sx = input[2].x - input[1].x;
34.265 + float sy = input[2].y - input[1].y;
34.266 + float tx = input[0].x - input[1].x;
34.267 + float ty = input[0].y - input[1].y;
34.268 +
34.269 + float detxy = ((sy) * (tx)) - ((ty) * (sx));
34.270 + if( detxy == 0 ) {
34.271 + result->z = input[2].z;
34.272 + result->u = input[2].u;
34.273 + result->v = input[2].v;
34.274 + result->rgba = input[2].rgba;
34.275 + result->offset_rgba = input[2].offset_rgba;
34.276 + return;
34.277 + }
34.278 + float t = ((result->x - input[1].x) * sy -
34.279 + (result->y - input[1].y) * sx) / detxy;
34.280 + float s = ((result->y - input[1].y) * tx -
34.281 + (result->x - input[1].x) * ty) / detxy;
34.282 +
34.283 + float sz = input[2].z - input[1].z;
34.284 + float tz = input[0].z - input[1].z;
34.285 + float su = input[2].u - input[1].u;
34.286 + float tu = input[0].u - input[1].u;
34.287 + float sv = input[2].v - input[1].v;
34.288 + float tv = input[0].v - input[1].v;
34.289 +
34.290 + float rz = input[1].z + (t*tz) + (s*sz);
34.291 + if( rz > pvr2_scene.bounds[5] ) {
34.292 + pvr2_scene.bounds[5] = rz;
34.293 + } else if( rz < pvr2_scene.bounds[4] ) {
34.294 + pvr2_scene.bounds[4] = rz;
34.295 + }
34.296 + result->z = rz;
34.297 + result->u = input[1].u + (t*tu) + (s*su);
34.298 + result->v = input[1].v + (t*tv) + (s*sv);
34.299 +
34.300 + if( is_solid_shaded ) {
34.301 + result->rgba = input[2].rgba;
34.302 + result->offset_rgba = input[2].offset_rgba;
34.303 + } else {
34.304 + uint8_t *rgba0 = (uint8_t *)&input[0].rgba;
34.305 + uint8_t *rgba1 = (uint8_t *)&input[1].rgba;
34.306 + uint8_t *rgba2 = (uint8_t *)&input[2].rgba;
34.307 + uint8_t *rgba3 = (uint8_t *)&result->rgba;
34.308 + for( i=0; i<8; i++ ) { // note: depends on rgba & offset_rgba being adjacent
34.309 + float tc = *rgba0++ - *rgba1;
34.310 + float sc = *rgba2++ - *rgba1;
34.311 + float rc = *rgba1++ + (t*tc) + (s*sc);
34.312 + if( rc < 0 ) {
34.313 + rc = 0;
34.314 + } else if( rc > 255 ) {
34.315 + rc = 255;
34.316 + }
34.317 + *rgba3++ = rc;
34.318 + }
34.319 + }
34.320 +
34.321 +}
34.322 +
34.323 +static void scene_add_vertexes( pvraddr_t poly_idx, int vertex_length,
34.324 + gboolean is_modified )
34.325 +{
34.326 + struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[poly_idx];
34.327 + uint32_t *ptr = &pvr2_scene.pvr2_pbuf[poly_idx];
34.328 + uint32_t *context = ptr;
34.329 + unsigned int i;
34.330 +
34.331 + if( poly->vertex_index == -1 ) {
34.332 + ptr += (is_modified ? 5 : 3 );
34.333 + poly->vertex_index = pvr2_scene.vertex_index;
34.334 +
34.335 + assert( poly != NULL );
34.336 + assert( pvr2_scene.vertex_index + poly->vertex_count <= pvr2_scene.vertex_count );
34.337 + for( i=0; i<poly->vertex_count; i++ ) {
34.338 + pvr2_decode_render_vertex( &pvr2_scene.vertex_array[pvr2_scene.vertex_index++], context[0], context[1], ptr, 0 );
34.339 + ptr += vertex_length;
34.340 + }
34.341 + if( is_modified ) {
34.342 + int mod_offset = (vertex_length - 3)>>1;
34.343 + assert( pvr2_scene.vertex_index + poly->vertex_count <= pvr2_scene.vertex_count );
34.344 + ptr = &pvr2_scene.pvr2_pbuf[poly_idx] + 5;
34.345 + poly->mod_vertex_index = pvr2_scene.vertex_index;
34.346 + for( i=0; i<poly->vertex_count; i++ ) {
34.347 + pvr2_decode_render_vertex( &pvr2_scene.vertex_array[pvr2_scene.vertex_index++], context[0], context[3], ptr, mod_offset );
34.348 + ptr += vertex_length;
34.349 + }
34.350 + }
34.351 + }
34.352 +}
34.353 +
34.354 +static void scene_add_quad_vertexes( pvraddr_t poly_idx, int vertex_length,
34.355 + gboolean is_modified )
34.356 +{
34.357 + struct polygon_struct *poly = pvr2_scene.buf_to_poly_map[poly_idx];
34.358 + uint32_t *ptr = &pvr2_scene.pvr2_pbuf[poly_idx];
34.359 + uint32_t *context = ptr;
34.360 + unsigned int i;
34.361 +
34.362 + if( poly->vertex_index == -1 ) {
34.363 + // Construct it locally and copy to the vertex buffer, as the VBO is
34.364 + // allowed to be horribly slow for reads (ie it could be direct-mapped
34.365 + // vram).
34.366 + struct vertex_struct quad[4];
34.367 +
34.368 + assert( poly != NULL );
34.369 + assert( pvr2_scene.vertex_index + poly->vertex_count <= pvr2_scene.vertex_count );
34.370 + ptr += (is_modified ? 5 : 3 );
34.371 + poly->vertex_index = pvr2_scene.vertex_index;
34.372 + for( i=0; i<4; i++ ) {
34.373 + pvr2_decode_render_vertex( &quad[i], context[0], context[1], ptr, 0 );
34.374 + ptr += vertex_length;
34.375 + }
34.376 + scene_compute_vertex( &quad[3], &quad[0], !POLY1_GOURAUD_SHADED(context[0]) );
34.377 + // Swap last two vertexes (quad arrangement => tri strip arrangement)
34.378 + memcpy( &pvr2_scene.vertex_array[pvr2_scene.vertex_index], quad, sizeof(struct vertex_struct)*2 );
34.379 + memcpy( &pvr2_scene.vertex_array[pvr2_scene.vertex_index+2], &quad[3], sizeof(struct vertex_struct) );
34.380 + memcpy( &pvr2_scene.vertex_array[pvr2_scene.vertex_index+3], &quad[2], sizeof(struct vertex_struct) );
34.381 + pvr2_scene.vertex_index += 4;
34.382 +
34.383 + if( is_modified ) {
34.384 + int mod_offset = (vertex_length - 3)>>1;
34.385 + assert( pvr2_scene.vertex_index + poly->vertex_count <= pvr2_scene.vertex_count );
34.386 + ptr = &pvr2_scene.pvr2_pbuf[poly_idx] + 5;
34.387 + poly->mod_vertex_index = pvr2_scene.vertex_index;
34.388 + for( i=0; i<4; i++ ) {
34.389 + pvr2_decode_render_vertex( &quad[4], context[0], context[3], ptr, mod_offset );
34.390 + ptr += vertex_length;
34.391 + }
34.392 + scene_compute_vertex( &quad[3], &quad[0], !POLY1_GOURAUD_SHADED(context[0]) );
34.393 + memcpy( &pvr2_scene.vertex_array[pvr2_scene.vertex_index], quad, sizeof(struct vertex_struct)*2 );
34.394 + memcpy( &pvr2_scene.vertex_array[pvr2_scene.vertex_index+2], &quad[3], sizeof(struct vertex_struct) );
34.395 + memcpy( &pvr2_scene.vertex_array[pvr2_scene.vertex_index+3], &quad[2], sizeof(struct vertex_struct) );
34.396 + pvr2_scene.vertex_index += 4;
34.397 + }
34.398 + }
34.399 +}
34.400 +
34.401 +static void scene_extract_polygons( pvraddr_t tile_entry )
34.402 +{
34.403 + uint32_t *tile_list = (uint32_t *)(video_base+tile_entry);
34.404 + do {
34.405 + uint32_t entry = *tile_list++;
34.406 + if( entry >> 28 == 0x0F ) {
34.407 + break;
34.408 + } else if( entry >> 28 == 0x0E ) {
34.409 + tile_list = (uint32_t *)(video_base + (entry&0x007FFFFF));
34.410 + } else {
34.411 + pvraddr_t polyaddr = entry&0x000FFFFF;
34.412 + int is_modified = (entry & 0x01000000) && pvr2_scene.full_shadow;
34.413 + int vertex_length = (entry >> 21) & 0x07;
34.414 + int context_length = 3;
34.415 + if( is_modified ) {
34.416 + context_length = 5;
34.417 + vertex_length <<= 1 ;
34.418 + }
34.419 + vertex_length += 3;
34.420 +
34.421 + if( (entry & 0xE0000000) == 0x80000000 ) {
34.422 + /* Triangle(s) */
34.423 + int strip_count = ((entry >> 25) & 0x0F)+1;
34.424 + int polygon_length = 3 * vertex_length + context_length;
34.425 + int i;
34.426 + struct polygon_struct *last_poly = NULL;
34.427 + for( i=0; i<strip_count; i++ ) {
34.428 + struct polygon_struct *poly = scene_add_polygon( polyaddr, 3, is_modified );
34.429 + polyaddr += polygon_length;
34.430 + if( last_poly != NULL && last_poly->next == NULL ) {
34.431 + last_poly->next = poly;
34.432 + }
34.433 + last_poly = poly;
34.434 + }
34.435 + } else if( (entry & 0xE0000000) == 0xA0000000 ) {
34.436 + /* Sprite(s) */
34.437 + int strip_count = ((entry >> 25) & 0x0F)+1;
34.438 + int polygon_length = 4 * vertex_length + context_length;
34.439 + int i;
34.440 + struct polygon_struct *last_poly = NULL;
34.441 + for( i=0; i<strip_count; i++ ) {
34.442 + struct polygon_struct *poly = scene_add_polygon( polyaddr, 4, is_modified );
34.443 + polyaddr += polygon_length;
34.444 + if( last_poly != NULL && last_poly->next == NULL ) {
34.445 + last_poly->next = poly;
34.446 + }
34.447 + last_poly = poly;
34.448 + }
34.449 + } else {
34.450 + /* Polygon */
34.451 + int i, last = -1;
34.452 + for( i=5; i>=0; i-- ) {
34.453 + if( entry & (0x40000000>>i) ) {
34.454 + last = i;
34.455 + break;
34.456 + }
34.457 + }
34.458 + if( last != -1 ) {
34.459 + scene_add_polygon( polyaddr, last+3, is_modified );
34.460 + }
34.461 + }
34.462 + }
34.463 + } while( 1 );
34.464 +}
34.465 +
34.466 +static void scene_extract_vertexes( pvraddr_t tile_entry )
34.467 +{
34.468 + uint32_t *tile_list = (uint32_t *)(video_base+tile_entry);
34.469 + do {
34.470 + uint32_t entry = *tile_list++;
34.471 + if( entry >> 28 == 0x0F ) {
34.472 + break;
34.473 + } else if( entry >> 28 == 0x0E ) {
34.474 + tile_list = (uint32_t *)(video_base + (entry&0x007FFFFF));
34.475 + } else {
34.476 + pvraddr_t polyaddr = entry&0x000FFFFF;
34.477 + int is_modified = (entry & 0x01000000) && pvr2_scene.full_shadow;
34.478 + int vertex_length = (entry >> 21) & 0x07;
34.479 + int context_length = 3;
34.480 + if( is_modified ) {
34.481 + context_length = 5;
34.482 + vertex_length <<=1 ;
34.483 + }
34.484 + vertex_length += 3;
34.485 +
34.486 + if( (entry & 0xE0000000) == 0x80000000 ) {
34.487 + /* Triangle(s) */
34.488 + int strip_count = ((entry >> 25) & 0x0F)+1;
34.489 + int polygon_length = 3 * vertex_length + context_length;
34.490 + int i;
34.491 + for( i=0; i<strip_count; i++ ) {
34.492 + scene_add_vertexes( polyaddr, vertex_length, is_modified );
34.493 + polyaddr += polygon_length;
34.494 + }
34.495 + } else if( (entry & 0xE0000000) == 0xA0000000 ) {
34.496 + /* Sprite(s) */
34.497 + int strip_count = ((entry >> 25) & 0x0F)+1;
34.498 + int polygon_length = 4 * vertex_length + context_length;
34.499 + int i;
34.500 + for( i=0; i<strip_count; i++ ) {
34.501 + scene_add_quad_vertexes( polyaddr, vertex_length, is_modified );
34.502 + polyaddr += polygon_length;
34.503 + }
34.504 + } else {
34.505 + /* Polygon */
34.506 + int i, last = -1;
34.507 + for( i=5; i>=0; i-- ) {
34.508 + if( entry & (0x40000000>>i) ) {
34.509 + last = i;
34.510 + break;
34.511 + }
34.512 + }
34.513 + if( last != -1 ) {
34.514 + scene_add_vertexes( polyaddr, vertex_length, is_modified );
34.515 + }
34.516 + }
34.517 + }
34.518 + } while( 1 );
34.519 +}
34.520 +
34.521 +uint32_t pvr2_scene_buffer_width()
34.522 +{
34.523 + return pvr2_scene.buffer_width;
34.524 +}
34.525 +
34.526 +uint32_t pvr2_scene_buffer_height()
34.527 +{
34.528 + return pvr2_scene.buffer_height;
34.529 +}
34.530 +
34.531 +/**
34.532 + * Extract the current scene into the rendering structures. We run two passes
34.533 + * - first pass extracts the polygons into pvr2_scene.poly_array (finding vertex counts),
34.534 + * second pass extracts the vertex data into the VBO/vertex array.
34.535 + *
34.536 + * Difficult to do in single pass as we don't generally know the size of a
34.537 + * polygon for certain until we've seen all tiles containing it. It also means we
34.538 + * can count the vertexes and allocate the appropriate size VBO.
34.539 + *
34.540 + * FIXME: accesses into VRAM need to be bounds-checked properly
34.541 + */
34.542 +void pvr2_scene_read( void )
34.543 +{
34.544 + pvr2_scene_init();
34.545 + pvr2_scene_reset();
34.546 +
34.547 + pvr2_scene.bounds[0] = MMIO_READ( PVR2, RENDER_HCLIP ) & 0x03FF;
34.548 + pvr2_scene.bounds[1] = ((MMIO_READ( PVR2, RENDER_HCLIP ) >> 16) & 0x03FF) + 1;
34.549 + pvr2_scene.bounds[2] = MMIO_READ( PVR2, RENDER_VCLIP ) & 0x03FF;
34.550 + pvr2_scene.bounds[3] = ((MMIO_READ( PVR2, RENDER_VCLIP ) >> 16) & 0x03FF) + 1;
34.551 + pvr2_scene.bounds[4] = pvr2_scene.bounds[5] = MMIO_READF( PVR2, RENDER_FARCLIP );
34.552 +
34.553 + uint32_t *tilebuffer = (uint32_t *)(video_base + MMIO_READ( PVR2, RENDER_TILEBASE ));
34.554 + uint32_t *segment = tilebuffer;
34.555 + pvr2_scene.segment_list = (struct tile_segment *)tilebuffer;
34.556 + pvr2_scene.pvr2_pbuf = (uint32_t *)(video_base + MMIO_READ(PVR2,RENDER_POLYBASE));
34.557 + pvr2_scene.full_shadow = MMIO_READ( PVR2, RENDER_SHADOW ) & 0x100 ? FALSE : TRUE;
34.558 +
34.559 + int max_tile_x = 0;
34.560 + int max_tile_y = 0;
34.561 + int obj_config = MMIO_READ( PVR2, RENDER_OBJCFG );
34.562 + int isp_config = MMIO_READ( PVR2, RENDER_ISPCFG );
34.563 +
34.564 + if( (obj_config & 0x00200000) == 0 ) {
34.565 + if( isp_config & 1 ) {
34.566 + pvr2_scene.sort_mode = SORT_NEVER;
34.567 + } else {
34.568 + pvr2_scene.sort_mode = SORT_ALWAYS;
34.569 + }
34.570 + } else {
34.571 + pvr2_scene.sort_mode = SORT_TILEFLAG;
34.572 + }
34.573 +
34.574 + // Pass 1: Extract polygon list
34.575 + uint32_t control;
34.576 + int i;
34.577 + do {
34.578 + control = *segment++;
34.579 + int tile_x = SEGMENT_X(control);
34.580 + int tile_y = SEGMENT_Y(control);
34.581 + if( tile_x > max_tile_x ) {
34.582 + max_tile_x = tile_x;
34.583 + }
34.584 + if( tile_y > max_tile_y ) {
34.585 + max_tile_y = tile_y;
34.586 + }
34.587 + for( i=0; i<5; i++ ) {
34.588 + if( (*segment & NO_POINTER) == 0 ) {
34.589 + scene_extract_polygons( *segment );
34.590 + }
34.591 + segment++;
34.592 + }
34.593 + } while( (control & SEGMENT_END) == 0 );
34.594 +
34.595 + pvr2_scene.buffer_width = (max_tile_x+1)<<5;
34.596 + pvr2_scene.buffer_height = (max_tile_y+1)<<5;
34.597 +
34.598 + if( pvr2_scene.vertex_count > 0 ) {
34.599 + // Pass 2: Extract vertex data
34.600 + vertex_buffer_map();
34.601 + pvr2_scene.vertex_index = 0;
34.602 + segment = tilebuffer;
34.603 + do {
34.604 + control = *segment++;
34.605 + for( i=0; i<5; i++ ) {
34.606 + if( (*segment & NO_POINTER) == 0 ) {
34.607 + scene_extract_vertexes( *segment );
34.608 + }
34.609 + segment++;
34.610 + }
34.611 + } while( (control & SEGMENT_END) == 0 );
34.612 + vertex_buffer_unmap();
34.613 + }
34.614 +}
34.615 +
34.616 +/**
34.617 + * Dump the current scene to file in a (mostly) human readable form
34.618 + */
34.619 +void pvr2_scene_dump( FILE *f )
34.620 +{
34.621 + int i,j;
34.622 +
34.623 + fprintf( f, "Polygons: %d\n", pvr2_scene.poly_count );
34.624 + for( i=0; i<pvr2_scene.poly_count; i++ ) {
34.625 + struct polygon_struct *poly = &pvr2_scene.poly_array[i];
34.626 + fprintf( f, " %08X ", ((char *)poly->context) - video_base );
34.627 + switch( poly->vertex_count ) {
34.628 + case 3: fprintf( f, "Tri " ); break;
34.629 + case 4: fprintf( f, "Quad " ); break;
34.630 + default: fprintf( f,"%d-Strip ", poly->vertex_count-2 ); break;
34.631 + }
34.632 + fprintf( f, "%08X %08X %08X ", poly->context[0], poly->context[1], poly->context[2] );
34.633 + if( poly->mod_vertex_index != -1 ) {
34.634 + fprintf( f, "%08X %08X\n", poly->context[3], poly->context[5] );
34.635 + } else {
34.636 + fprintf( f, "\n" );
34.637 + }
34.638 +
34.639 + for( j=0; j<poly->vertex_count; j++ ) {
34.640 + struct vertex_struct *v = &pvr2_scene.vertex_array[poly->vertex_index+j];
34.641 + fprintf( f, " %.5f %.5f %.5f, (%.5f,%.5f) %08X %08X\n", v->x, v->y, v->z, v->u, v->v,
34.642 + v->rgba, v->offset_rgba );
34.643 + }
34.644 + if( poly->mod_vertex_index != -1 ) {
34.645 + fprintf( f, " ---\n" );
34.646 + for( j=0; j<poly->vertex_count; j++ ) {
34.647 + struct vertex_struct *v = &pvr2_scene.vertex_array[poly->mod_vertex_index+j];
34.648 + fprintf( f, " %.5f %.5f %.5f, (%.5f,%.5f) %08X %08X\n", v->x, v->y, v->z, v->u, v->v,
34.649 + v->rgba, v->offset_rgba );
34.650 + }
34.651 + }
34.652 + }
34.653 +
34.654 +}
35.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
35.2 +++ b/src/pvr2/scene.h Fri Mar 28 12:32:25 2008 +0000
35.3 @@ -0,0 +1,138 @@
35.4 +/**
35.5 + * $Id$
35.6 + *
35.7 + * PVR2 rendering functions (private)
35.8 + *
35.9 + * Copyright (c) 2005 Nathan Keynes.
35.10 + *
35.11 + * This program is free software; you can redistribute it and/or modify
35.12 + * it under the terms of the GNU General Public License as published by
35.13 + * the Free Software Foundation; either version 2 of the License, or
35.14 + * (at your option) any later version.
35.15 + *
35.16 + * This program is distributed in the hope that it will be useful,
35.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
35.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35.19 + * GNU General Public License for more details.
35.20 + */
35.21 +
35.22 +#ifndef lxdream_render_H
35.23 +#define lxdream_render_H 1
35.24 +
35.25 +/************************* Intermediate vertex buffer ************************/
35.26 +
35.27 +typedef enum {
35.28 + SORT_NEVER = 0,
35.29 + SORT_TILEFLAG = 1, /* In this mode, sorting is controlled by the per-segment flag */
35.30 + SORT_ALWAYS = 2
35.31 +} tile_sort_mode_t;
35.32 +
35.33 +struct vertex_struct {
35.34 + float u,v;
35.35 + uint32_t rgba;
35.36 + float x,y,z;
35.37 + uint32_t offset_rgba;
35.38 +};
35.39 +
35.40 +struct polygon_struct {
35.41 + uint32_t *context;
35.42 + int cull; // culling mode
35.43 + uint32_t vertex_count; // number of vertexes in polygon
35.44 + uint32_t tex_id;
35.45 + int32_t vertex_index; // index of first vertex in vertex buffer
35.46 + uint32_t mod_tex_id;
35.47 + int32_t mod_vertex_index; // index of first modified vertex in vertex buffer
35.48 + float center_z;
35.49 + struct polygon_struct *next; // chain for tri/quad arrays
35.50 +};
35.51 +
35.52 +void pvr2_scene_init(void);
35.53 +void pvr2_scene_read(void);
35.54 +void pvr2_scene_shutdown();
35.55 +
35.56 +extern char *video_base;
35.57 +
35.58 +/**
35.59 + * Maximum possible size of the vertex buffer. This is figured as follows:
35.60 + * PVR2 polygon buffer is limited to 4MB. The tightest polygon format
35.61 + * is 3 vertexes in 48 bytes = 16 bytes/vertex, (shadow triangle)
35.62 + * (the next tightest is 8 vertex in 140 bytes (6-strip colour-only)).
35.63 + * giving a theoretical maximum of 262144 vertexes.
35.64 + * The expanded structure is 44 bytes/vertex, giving
35.65 + * 11534336 bytes...
35.66 + */
35.67 +#define MAX_VERTEXES 262144
35.68 +#define MAX_VERTEX_BUFFER_SIZE (MAX_VERTEXES*sizeof(struct vertex_struct))
35.69 +
35.70 +/**
35.71 + * Maximum polygons - smallest is 1 polygon in 48 bytes, giving
35.72 + * 87381
35.73 + *
35.74 + */
35.75 +#define MAX_POLYGONS 87382
35.76 +#define MAX_POLY_BUFFER_SIZE (MAX_POLYGONS*sizeof(struct polygon_struct))
35.77 +#define BUF_POLY_MAP_SIZE (4 MB)
35.78 +
35.79 +/*************************************************************************/
35.80 +
35.81 +/* Scene data - this structure holds all the intermediate data used during
35.82 + * the rendering process.
35.83 + *
35.84 + * Special note: if vbo_supported == FALSE, then vertex_array points to a
35.85 + * malloced chunk of system RAM. Otherwise, vertex_array will be either NULL
35.86 + * (if the VBO is unmapped), or a pointer into a chunk of GL managed RAM
35.87 + * (possibly direct-mapped VRAM).
35.88 + */
35.89 +struct pvr2_scene_struct {
35.90 + /** GL ID of the VBO used by the scene (or 0 if VBOs are not in use). */
35.91 + GLuint vbo_id;
35.92 + /** Pointer to the vertex array data, or NULL for unmapped VBOs */
35.93 + struct vertex_struct *vertex_array;
35.94 + /** Current allocated size (in bytes) of the vertex array */
35.95 + uint32_t vertex_array_size;
35.96 + /** Total number of vertexes in the scene (note modified vertexes
35.97 + * count for 2 vertexes */
35.98 + uint32_t vertex_count;
35.99 +
35.100 + /** Pointer to the polygon data for the scene (main ram).
35.101 + * This will always have room for at least MAX_POLYGONS */
35.102 + struct polygon_struct *poly_array;
35.103 + /** Total number of polygons in the scene */
35.104 + uint32_t poly_count;
35.105 +
35.106 + /** Image bounds in 3D - x1,x2,y1,y2,z1,z2
35.107 + * x and y values are determined by the clip planes, while z values are
35.108 + * determined from the vertex data itself.
35.109 + */
35.110 + float bounds[6];
35.111 +
35.112 + /* Total size of the image buffer, determined by the tile map used to
35.113 + * render the scene */
35.114 + uint32_t buffer_width, buffer_height;
35.115 +
35.116 + /** True if modifier volumes use the two-parameter form, False if they
35.117 + * use the cheap-shadow option.
35.118 + */
35.119 + gboolean full_shadow;
35.120 + /** Specifies the translucency auto-sort mode for the scene */
35.121 + tile_sort_mode_t sort_mode;
35.122 +
35.123 + /** Pointer to the start of the tile segment list in PVR2 VRAM (32-bit) */
35.124 + struct tile_segment *segment_list;
35.125 + /** Map from PVR2 polygon address to an element of poly_array. */
35.126 + struct polygon_struct **buf_to_poly_map;
35.127 + /** Pointer to the start of the raw polygon buffer in PVR2 VRAM (32-bit).
35.128 + * Also only used during parsing */
35.129 + uint32_t *pvr2_pbuf;
35.130 + /** Current vertex index during parsing */
35.131 + uint32_t vertex_index;
35.132 +};
35.133 +
35.134 +/**
35.135 + * Current scene structure. Note this should only be written to by vertex bufer
35.136 + * functions
35.137 + */
35.138 +extern struct pvr2_scene_struct pvr2_scene;
35.139 +
35.140 +
35.141 +#endif /* !lxdream_render_H */
36.1 --- a/src/pvr2/tacore.c Sun Mar 02 11:38:08 2008 +0000
36.2 +++ b/src/pvr2/tacore.c Fri Mar 28 12:32:25 2008 +0000
36.3 @@ -15,6 +15,7 @@
36.4 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36.5 * GNU General Public License for more details.
36.6 */
36.7 +#include <string.h>
36.8 #include "pvr2.h"
36.9 #include "asic.h"
36.10
37.1 --- a/src/pvr2/texcache.c Sun Mar 02 11:38:08 2008 +0000
37.2 +++ b/src/pvr2/texcache.c Fri Mar 28 12:32:25 2008 +0000
37.3 @@ -19,6 +19,7 @@
37.4 */
37.5
37.6 #include <assert.h>
37.7 +#include <string.h>
37.8 #include "pvr2/pvr2.h"
37.9
37.10 /** Specifies the maximum number of OpenGL
37.11 @@ -67,6 +68,7 @@
37.12 for( i=0; i<MAX_TEXTURES; i++ ) {
37.13 texcache_free_list[i] = i;
37.14 texcache_active_list[i].texture_addr = -1;
37.15 + texcache_active_list[i].next = EMPTY_ENTRY;
37.16 }
37.17 texcache_free_ptr = 0;
37.18 texcache_ref_counter = 0;
37.19 @@ -99,6 +101,7 @@
37.20 }
37.21 for( i=0; i<MAX_TEXTURES; i++ ) {
37.22 texcache_free_list[i] = i;
37.23 + texcache_active_list[i].next = EMPTY_ENTRY;
37.24 }
37.25 texcache_free_ptr = 0;
37.26 texcache_ref_counter = 0;
37.27 @@ -507,25 +510,25 @@
37.28 * If the texture has already been bound, return the ID to which it was
37.29 * bound. Otherwise obtain an unused texture ID and set it up appropriately.
37.30 */
37.31 -GLuint texcache_get_texture( uint32_t texture_addr, int width, int height,
37.32 - int mode )
37.33 +GLuint texcache_get_texture( uint32_t texture_word, int width, int height )
37.34 {
37.35 + uint32_t texture_addr = (texture_word & 0x000FFFFF)<<3;
37.36 uint32_t texture_page = texture_addr >> 12;
37.37 texcache_entry_index next;
37.38 texcache_entry_index idx = texcache_page_lookup[texture_page];
37.39 while( idx != EMPTY_ENTRY ) {
37.40 texcache_entry_t entry = &texcache_active_list[idx];
37.41 if( entry->texture_addr == texture_addr &&
37.42 - entry->mode == mode &&
37.43 + entry->mode == texture_word &&
37.44 entry->width == width &&
37.45 entry->height == height ) {
37.46 entry->lru_count = texcache_ref_counter++;
37.47 - glBindTexture( GL_TEXTURE_2D, entry->texture_id );
37.48 return entry->texture_id;
37.49 }
37.50 idx = entry->next;
37.51 }
37.52
37.53 +
37.54 /* Not found - check the free list */
37.55 texcache_entry_index slot = 0;
37.56
37.57 @@ -539,7 +542,7 @@
37.58 texcache_active_list[slot].texture_addr = texture_addr;
37.59 texcache_active_list[slot].width = width;
37.60 texcache_active_list[slot].height = height;
37.61 - texcache_active_list[slot].mode = mode;
37.62 + texcache_active_list[slot].mode = texture_word;
37.63 texcache_active_list[slot].lru_count = texcache_ref_counter++;
37.64
37.65 /* Add entry to the lookup table */
37.66 @@ -560,7 +563,45 @@
37.67
37.68 /* Construct the GL texture */
37.69 glBindTexture( GL_TEXTURE_2D, texcache_active_list[slot].texture_id );
37.70 - texcache_load_texture( texture_addr, width, height, mode );
37.71 -
37.72 + texcache_load_texture( texture_addr, width, height, texture_word );
37.73 +
37.74 return texcache_active_list[slot].texture_id;
37.75 }
37.76 +
37.77 +/**
37.78 + * Check the integrity of the texcache. Verifies that every cache slot
37.79 + * appears exactly once on either the free list or one page list. For
37.80 + * active slots, the texture address must also match the page it appears on.
37.81 + *
37.82 + */
37.83 +void texcache_integrity_check()
37.84 +{
37.85 + int i;
37.86 + int slot_found[MAX_TEXTURES];
37.87 +
37.88 + memset( slot_found, 0, sizeof(slot_found) );
37.89 +
37.90 + /* Check entries on the free list */
37.91 + for( i= texcache_free_ptr; i< MAX_TEXTURES; i++ ) {
37.92 + int slot = texcache_free_list[i];
37.93 + assert( slot_found[slot] == 0 );
37.94 + assert( texcache_active_list[slot].next == EMPTY_ENTRY );
37.95 + slot_found[slot] = 1;
37.96 + }
37.97 +
37.98 + /* Check entries on the active lists */
37.99 + for( i=0; i< PVR2_RAM_PAGES; i++ ) {
37.100 + int slot = texcache_page_lookup[i];
37.101 + while( slot != EMPTY_ENTRY ) {
37.102 + assert( slot_found[slot] == 0 );
37.103 + assert( (texcache_active_list[slot].texture_addr >> 12) == i );
37.104 + slot_found[slot] = 2;
37.105 + slot = texcache_active_list[slot].next;
37.106 + }
37.107 + }
37.108 +
37.109 + /* Make sure we didn't miss any entries */
37.110 + for( i=0; i<MAX_TEXTURES; i++ ) {
37.111 + assert( slot_found[i] != 0 );
37.112 + }
37.113 +}
38.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
38.2 +++ b/src/pvr2/vertex.glsl Fri Mar 28 12:32:25 2008 +0000
38.3 @@ -0,0 +1,11 @@
38.4 +// Standard PVR2 vertex shader
38.5 +
38.6 +void main()
38.7 +{
38.8 + vec4 tmp = ftransform();
38.9 + float w = gl_Vertex.z;
38.10 + gl_Position = tmp * w;
38.11 + gl_FrontColor = gl_Color;
38.12 + gl_FrontSecondaryColor = gl_SecondaryColor;
38.13 + gl_TexCoord[0] = gl_MultiTexCoord0;
38.14 +}
.