Compare commits
220 Commits
mesa_7_6_1
...
android-x8
Author | SHA1 | Date | |
---|---|---|---|
|
74237c1a10 | ||
|
ce5af556aa | ||
|
f457f7a31c | ||
|
11ff6a0e6f | ||
|
b4bf8be547 | ||
|
6ec4bba0ea | ||
|
893bc24da3 | ||
|
c83d23d30d | ||
|
e786472b8d | ||
|
27c1ec2334 | ||
|
607a4393e7 | ||
|
74174dd5d6 | ||
|
35f9a9c5c9 | ||
|
d5e732764b | ||
|
ef1a6243ef | ||
|
8911b7d7a1 | ||
|
1ba61c244f | ||
|
dce62509e5 | ||
|
25e6736400 | ||
|
6059e6a8f2 | ||
|
3c718c0e95 | ||
|
3806be3ddb | ||
|
94f9330609 | ||
|
08b9155eee | ||
|
87b5e03290 | ||
|
94fe206c56 | ||
|
62e7cd2aca | ||
|
16678f5dbf | ||
|
705fed33ea | ||
|
4e547d5155 | ||
|
d535d82b32 | ||
|
dea3bc04c1 | ||
|
a49adc545b | ||
|
b4d0fdf8d2 | ||
|
a5a8bdfd9b | ||
|
e2ba90a9cc | ||
|
b4b8800315 | ||
|
4e5934fed1 | ||
|
c4a8ce7ffd | ||
|
9199889374 | ||
|
80c0f18f2d | ||
|
4db23069f9 | ||
|
77e2b23ea6 | ||
|
5f32756254 | ||
|
9e9a4cf471 | ||
|
985cefb769 | ||
|
554361e2b2 | ||
|
a1842a4f11 | ||
|
73f3765270 | ||
|
33640499b9 | ||
|
0878cce17d | ||
|
cbd17236c8 | ||
|
8077986205 | ||
|
542c26fa4f | ||
|
a98c282c7d | ||
|
dc2ddb27d3 | ||
|
0fc1cd5e91 | ||
|
5f471a37aa | ||
|
9562ca3628 | ||
|
e6f4bc9d82 | ||
|
2ae5bf72c2 | ||
|
cc0d078977 | ||
|
4938cb77f8 | ||
|
a00d4ab589 | ||
|
b5abf7b08b | ||
|
70b6b622bf | ||
|
440882f547 | ||
|
e5501bd823 | ||
|
919fbc5524 | ||
|
55c73512c9 | ||
|
4cf0415cc0 | ||
|
3de1a6584f | ||
|
3c417b27a2 | ||
|
9ac1d3e36f | ||
|
610e200429 | ||
|
de8b4f3bbd | ||
|
4132e67e31 | ||
|
5c8873a311 | ||
|
b7c133b5c2 | ||
|
1c497bd4c6 | ||
|
17f2649e26 | ||
|
57ce3ab323 | ||
|
7f8045ab4e | ||
|
6fcf6a5a7f | ||
|
b04d58c0b1 | ||
|
8df670164f | ||
|
940b525a5a | ||
|
93c3911ca8 | ||
|
c9ae896376 | ||
|
bae850f9af | ||
|
ec86469c55 | ||
|
5bcfe4b5c8 | ||
|
57377d5d69 | ||
|
b565e7b88c | ||
|
c7ebd40185 | ||
|
57d16c4cc3 | ||
|
a79eecb913 | ||
|
08b7d32140 | ||
|
622b31925b | ||
|
4099bb7614 | ||
|
4108ed7e80 | ||
|
672c5f52d1 | ||
|
1fc4100225 | ||
|
7c0152fbae | ||
|
0ef5b62787 | ||
|
4781c1f459 | ||
|
6bc36f29c7 | ||
|
209031701a | ||
|
de059d35c3 | ||
|
afcaa45a94 | ||
|
759696defb | ||
|
71b3ccc4b0 | ||
|
d9dc4cb0e4 | ||
|
8c37a4c8fd | ||
|
85a716bf62 | ||
|
feb74e7753 | ||
|
57d0934bc5 | ||
|
974dec2e7b | ||
|
16886c8be3 | ||
|
6be1a98ab9 | ||
|
3167c2e8a0 | ||
|
18882f4d30 | ||
|
36dd53a3cd | ||
|
e669dc2b0d | ||
|
7dfe54a60e | ||
|
f89751e719 | ||
|
c7291f69a0 | ||
|
6a405b4a21 | ||
|
4c3a48ad0c | ||
|
48f19c0bcd | ||
|
c3c80c5c22 | ||
|
8e6b925d2a | ||
|
bd3b59da63 | ||
|
4139bc8f43 | ||
|
b0b131b023 | ||
|
abc160b664 | ||
|
cdbbcdf3bd | ||
|
da912a7a16 | ||
|
01c831576e | ||
|
5604b27b93 | ||
|
4d85a6b393 | ||
|
49c230709c | ||
|
7bf6347362 | ||
|
94a8157ef6 | ||
|
3fed69eb16 | ||
|
da9ed257a3 | ||
|
ca246dd186 | ||
|
5aaa45de4c | ||
|
8947cf6728 | ||
|
f78eafcacb | ||
|
97cbaab541 | ||
|
079ae4c38c | ||
|
126696caf7 | ||
|
e589a37f7b | ||
|
d112132840 | ||
|
547b726484 | ||
|
d585616f5b | ||
|
6e61d06209 | ||
|
3833587818 | ||
|
530fbd314e | ||
|
9fff4b46d3 | ||
|
f959ccdfa6 | ||
|
92d7ed8a20 | ||
|
ec9e729580 | ||
|
b11a8ea863 | ||
|
0310aafd9e | ||
|
0e5c2598ec | ||
|
b4922b5331 | ||
|
3e4539a471 | ||
|
15c0cc5cf4 | ||
|
ea6dab2537 | ||
|
58a57e3fc4 | ||
|
b2de028523 | ||
|
e61215242b | ||
|
8e8d3470be | ||
|
ced699b37a | ||
|
abdf2e14bc | ||
|
00aac1d29a | ||
|
e6ad286a80 | ||
|
e34ea368d9 | ||
|
2c307c7750 | ||
|
fcb94f6e3e | ||
|
79f48c9f9e | ||
|
b481fb2c6d | ||
|
1127201088 | ||
|
e4c76c02f7 | ||
|
de8376e2f2 | ||
|
0c2ea24338 | ||
|
fa0f4b35be | ||
|
4da20234f3 | ||
|
b1eff018c7 | ||
|
866fbacf2b | ||
|
6b129a8222 | ||
|
8be72bb764 | ||
|
970823978c | ||
|
826d441cdf | ||
|
617202b578 | ||
|
7b8ec0d8e7 | ||
|
23663ae914 | ||
|
4d63c626d0 | ||
|
886e7b318d | ||
|
b2951ffe96 | ||
|
f477fa7a85 | ||
|
0e5293a240 | ||
|
bcb62ae78a | ||
|
4fdc96db1d | ||
|
1ddb22675c | ||
|
4b01e6f614 | ||
|
9778731732 | ||
|
80ea03bd17 | ||
|
8f990f928b | ||
|
9ab19a3900 | ||
|
60ca65c016 | ||
|
8fd7586bcc | ||
|
0612ad4f19 | ||
|
a47858e45e | ||
|
8f7f22ca1d | ||
|
11a4292d4e | ||
|
07cc2311a8 | ||
|
8567d003d5 |
1
Android.mk
Normal file
1
Android.mk
Normal file
@@ -0,0 +1 @@
|
||||
include $(call all-subdir-makefiles)
|
24
Makefile
24
Makefile
@@ -105,6 +105,8 @@ irix6-n32-static \
|
||||
irix6-o32 \
|
||||
irix6-o32-static \
|
||||
linux \
|
||||
mine \
|
||||
mine-dri \
|
||||
linux-alpha \
|
||||
linux-alpha-static \
|
||||
linux-cell \
|
||||
@@ -182,7 +184,7 @@ ultrix-gcc:
|
||||
|
||||
# Rules for making release tarballs
|
||||
|
||||
VERSION=7.6.1
|
||||
VERSION=7.7-devel
|
||||
DIRECTORY = Mesa-$(VERSION)
|
||||
LIB_NAME = MesaLib-$(VERSION)
|
||||
DEMO_NAME = MesaDemos-$(VERSION)
|
||||
@@ -303,10 +305,25 @@ MAIN_FILES = \
|
||||
$(DIRECTORY)/progs/util/sampleMakefile \
|
||||
$(DIRECTORY)/windows/VC8/
|
||||
|
||||
EGL_FILES = \
|
||||
$(DIRECTORY)/include/EGL/*.h \
|
||||
ES_FILES = \
|
||||
$(DIRECTORY)/include/GLES/*.h \
|
||||
$(DIRECTORY)/include/GLES2/*.h \
|
||||
$(DIRECTORY)/src/mesa/glapi/*.xml \
|
||||
$(DIRECTORY)/src/mesa/glapi/*.py \
|
||||
$(DIRECTORY)/src/mesa/glapi/*.dtd \
|
||||
$(DIRECTORY)/src/mesa/es/glapi/Makefile \
|
||||
$(DIRECTORY)/src/mesa/es/glapi/*.xml \
|
||||
$(DIRECTORY)/src/mesa/es/glapi/*.py \
|
||||
$(DIRECTORY)/src/mesa/es/state_tracker/*.[ch] \
|
||||
$(DIRECTORY)/src/mesa/es/main/*.[ch] \
|
||||
$(DIRECTORY)/src/mesa/es/main/*.py \
|
||||
$(DIRECTORY)/src/mesa/es/main/*.txt \
|
||||
$(DIRECTORY)/src/mesa/es/main/es*_special \
|
||||
$(DIRECTORY)/src/mesa/es/Makefile \
|
||||
$(DIRECTORY)/src/mesa/es/sources.mak \
|
||||
|
||||
EGL_FILES = \
|
||||
$(DIRECTORY)/include/EGL/*.h \
|
||||
$(DIRECTORY)/src/egl/Makefile \
|
||||
$(DIRECTORY)/src/egl/*/Makefile \
|
||||
$(DIRECTORY)/src/egl/*/*.[ch] \
|
||||
@@ -471,6 +488,7 @@ DEPEND_FILES = \
|
||||
|
||||
LIB_FILES = \
|
||||
$(MAIN_FILES) \
|
||||
$(ES_FILES) \
|
||||
$(EGL_FILES) \
|
||||
$(GALLIUM_FILES) \
|
||||
$(DRI_FILES) \
|
||||
|
@@ -59,7 +59,7 @@ def AddOptions(opts):
|
||||
opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine,
|
||||
allowed_values=('generic', 'ppc', 'x86', 'x86_64')))
|
||||
opts.Add(EnumOption('platform', 'target platform', default_platform,
|
||||
allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince')))
|
||||
allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince', 'darwin')))
|
||||
opts.Add(EnumOption('toolchain', 'compiler toolchain', 'default',
|
||||
allowed_values=('default', 'crossmingw', 'winsdk', 'winddk')))
|
||||
opts.Add(BoolOption('llvm', 'use LLVM', 'no'))
|
||||
|
@@ -124,7 +124,7 @@ INSTALL_INC_DIR = $(includedir)
|
||||
DRI_DRIVER_INSTALL_DIR = @DRI_DRIVER_INSTALL_DIR@
|
||||
|
||||
# Where libGL will look for DRI hardware drivers
|
||||
DRI_DRIVER_SEARCH_DIR = @DRI_DRIVER_SEARCH_DIR@
|
||||
DRI_DRIVER_SEARCH_DIR = $(DRI_DRIVER_INSTALL_DIR)
|
||||
|
||||
# Xorg driver install directory (for xorg state-tracker)
|
||||
XORG_DRIVER_INSTALL_DIR = @XORG_DRIVER_INSTALL_DIR@
|
||||
|
@@ -9,8 +9,8 @@ CONFIG_NAME = default
|
||||
|
||||
# Version info
|
||||
MESA_MAJOR=7
|
||||
MESA_MINOR=6
|
||||
MESA_TINY=1
|
||||
MESA_MINOR=7
|
||||
MESA_TINY=0
|
||||
MESA_VERSION = $(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY)
|
||||
|
||||
# external projects. This should be useless now that we use libdrm.
|
||||
@@ -23,7 +23,6 @@ HOST_CC = $(CC)
|
||||
CFLAGS = -O
|
||||
CXXFLAGS = -O
|
||||
LDFLAGS =
|
||||
HOST_CFLAGS = $(CFLAGS)
|
||||
GLU_CFLAGS =
|
||||
|
||||
# Compiler for building demos/tests/etc
|
||||
|
82
configs/mine
Normal file
82
configs/mine
Normal file
@@ -0,0 +1,82 @@
|
||||
# -*-makefile-*-
|
||||
# Configuration for linux-dri: Linux DRI hardware drivers for XFree86 & others
|
||||
|
||||
include $(TOP)/configs/default
|
||||
|
||||
CONFIG_NAME = mine
|
||||
|
||||
# Compiler and flags
|
||||
CC = ccache gcc
|
||||
CXX = ccache g++
|
||||
|
||||
#MKDEP = /usr/X11R6/bin/makedepend
|
||||
#MKDEP = gcc -M
|
||||
#MKDEP_OPTIONS = -MF depend
|
||||
|
||||
OPT_FLAGS = -O0 -g
|
||||
PIC_FLAGS = -fPIC
|
||||
|
||||
# Add '-DGLX_USE_TLS' to ARCH_FLAGS to enable TLS support.
|
||||
ARCH_FLAGS ?=
|
||||
|
||||
DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
|
||||
-D_BSD_SOURCE -D_GNU_SOURCE \
|
||||
-DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 \
|
||||
-DGLX_DIRECT_RENDERING \
|
||||
-DHAVE_ALIAS -DHAVE_POSIX_MEMALIGN
|
||||
|
||||
X11_INCLUDES = -I/usr/X11R6/include
|
||||
|
||||
CFLAGS = -Wall -Wmissing-prototypes -std=c99 -ffast-math \
|
||||
$(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) $(ASM_FLAGS)
|
||||
|
||||
CXXFLAGS = -Wall $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES)
|
||||
|
||||
GLUT_CFLAGS = -fexceptions
|
||||
|
||||
# Work around aliasing bugs - developers should comment this out
|
||||
CFLAGS += -fno-strict-aliasing
|
||||
CXXFLAGS += -fno-strict-aliasing
|
||||
|
||||
MESA_ASM_SOURCES =
|
||||
|
||||
# Library/program dependencies
|
||||
EXTRA_LIB_PATH=-L/usr/X11R6/lib
|
||||
|
||||
DRI_LIB_DEPS = $(EXTRA_LIB_PATH) -lm -lpthread -lexpat -ldl $(LIBDRM_LIB)
|
||||
GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lXdamage -lXfixes \
|
||||
-lm -lpthread -ldl $(LIBDRM_LIB)
|
||||
|
||||
|
||||
# Directories
|
||||
SRC_DIRS = egl mesa gallium gallium/winsys
|
||||
PROGRAM_DIRS := egl openvg/demos demos xdemos
|
||||
|
||||
# EGL directories
|
||||
EGL_DRIVERS_DIRS = glx xdri
|
||||
|
||||
ifeq ($(USE_DRI),yes)
|
||||
DEFINES += -DIN_DRI_DRIVER -DGLX_INDIRECT_RENDERING
|
||||
|
||||
LIBDRM_CFLAGS = $(shell pkg-config --cflags libdrm)
|
||||
LIBDRM_LIB = $(shell pkg-config --libs libdrm)
|
||||
|
||||
SRC_DIRS := glx/x11 $(SRC_DIRS)
|
||||
DRIVER_DIRS = dri
|
||||
WINDOW_SYSTEM = dri
|
||||
DRI_DIRS = i915
|
||||
|
||||
GALLIUM_WINSYS_DIRS = drm egl_xlib
|
||||
GALLIUM_WINSYS_DRM_DIRS = intel
|
||||
GALLIUM_STATE_TRACKERS_DIRS = egl glx vega
|
||||
|
||||
else
|
||||
|
||||
DRIVER_DIRS =
|
||||
WINDOW_SYSTEM =
|
||||
DRI_DIRS =
|
||||
|
||||
GALLIUM_WINSYS_DIRS = egl_xlib xlib
|
||||
GALLIUM_STATE_TRACKERS_DIRS = glx vega
|
||||
|
||||
endif
|
5
configs/mine-dri
Normal file
5
configs/mine-dri
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*-makefile-*-
|
||||
# Configuration for linux-dri: Linux DRI hardware drivers for XFree86 & others
|
||||
|
||||
USE_DRI = yes
|
||||
include $(TOP)/configs/mine
|
16
configure.ac
16
configure.ac
@@ -230,8 +230,6 @@ else
|
||||
LIB_EXTENSION='dylib' ;;
|
||||
cygwin* )
|
||||
LIB_EXTENSION='dll' ;;
|
||||
aix* )
|
||||
LIB_EXTENSION='a' ;;
|
||||
* )
|
||||
LIB_EXTENSION='so' ;;
|
||||
esac
|
||||
@@ -649,13 +647,6 @@ AC_ARG_WITH([dri-driverdir],
|
||||
[DRI_DRIVER_INSTALL_DIR="$withval"],
|
||||
[DRI_DRIVER_INSTALL_DIR='${libdir}/dri'])
|
||||
AC_SUBST([DRI_DRIVER_INSTALL_DIR])
|
||||
dnl Extra search path for DRI drivers
|
||||
AC_ARG_WITH([dri-searchpath],
|
||||
[AS_HELP_STRING([--with-dri-searchpath=DIRS...],
|
||||
[semicolon delimited DRI driver search directories @<:@${libdir}/dri@:>@])],
|
||||
[DRI_DRIVER_SEARCH_DIR="$withval"],
|
||||
[DRI_DRIVER_SEARCH_DIR='${DRI_DRIVER_INSTALL_DIR}'])
|
||||
AC_SUBST([DRI_DRIVER_SEARCH_DIR])
|
||||
dnl Direct rendering or just indirect rendering
|
||||
AC_ARG_ENABLE([driglx-direct],
|
||||
[AS_HELP_STRING([--disable-driglx-direct],
|
||||
@@ -1157,11 +1148,6 @@ yes)
|
||||
if test "$tracker" = egl && test "x$enable_egl" != xyes; then
|
||||
AC_MSG_ERROR([cannot build egl state tracker without EGL library])
|
||||
fi
|
||||
if test "$tracker" = xorg; then
|
||||
PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1],
|
||||
HAVE_XEXTPROTO_71="yes"; DEFINES="$DEFINES -DHAVE_XEXTPROTO_71"
|
||||
HAVE_XEXTPROTO_71="no")
|
||||
fi
|
||||
done
|
||||
GALLIUM_STATE_TRACKERS_DIRS="$state_trackers"
|
||||
;;
|
||||
@@ -1216,7 +1202,7 @@ if test "x$enable_gallium_radeon" = xyes; then
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl Gallium Nouveau configuration
|
||||
dnl Gallium Radeon configuration
|
||||
dnl
|
||||
AC_ARG_ENABLE([gallium-nouveau],
|
||||
[AS_HELP_STRING([--enable-gallium-nouveau],
|
||||
|
@@ -10,17 +10,6 @@
|
||||
|
||||
<H1>News</H1>
|
||||
|
||||
<h2>September 28, 2009</h2>
|
||||
<p>
|
||||
<a href="relnotes-7.6.html">Mesa 7.6</a> is released. This is a new feature
|
||||
release. Those especially concerned about stability may want to wait for the
|
||||
follow-on 7.6.1 bug-fix release.
|
||||
</p>
|
||||
<p>
|
||||
<a href="relnotes-7.5.2.html">Mesa 7.5.2</a> is also released.
|
||||
This is a stable release fixing bugs since the 7.5.1 release.
|
||||
</p>
|
||||
|
||||
|
||||
<h2>September 3, 2009</h2>
|
||||
<p>
|
||||
|
@@ -8,7 +8,7 @@
|
||||
|
||||
<body bgcolor="#eeeeee">
|
||||
|
||||
<H1>Mesa 7.5.2 Release Notes, 28 September 2009</H1>
|
||||
<H1>Mesa 7.5.2 Release Notes, (date tbd)</H1>
|
||||
|
||||
<p>
|
||||
Mesa 7.5.2 is a bug-fix release fixing issues found since the 7.5.1 release.
|
||||
@@ -31,15 +31,7 @@ for DRI hardware acceleration.
|
||||
|
||||
<h2>MD5 checksums</h2>
|
||||
<pre>
|
||||
43a90191dd9f76cd65dcc1ac91f3be70 MesaLib-7.5.2.tar.gz
|
||||
94e47a499f1226803869c2e37a6a8e3a MesaLib-7.5.2.tar.bz2
|
||||
1ecb822b567ad67a0617361d45206b67 MesaLib-7.5.2.zip
|
||||
2718fdce7e075911d6147beb8f27104b MesaDemos-7.5.2.tar.gz
|
||||
4e0f5ccd58afe21eddcd94327d926e86 MesaDemos-7.5.2.tar.bz2
|
||||
f621f8c223b278d7c8e49a012d56ca25 MesaDemos-7.5.2.zip
|
||||
83c16c1d6bcfcc3f97aab5d2fe430b4c MesaGLUT-7.5.2.tar.gz
|
||||
e5d03bedae369ea3705783573bb33813 MesaGLUT-7.5.2.tar.bz2
|
||||
e82ba28e00d653e6f437d32be8ca8481 MesaGLUT-7.5.2.zip
|
||||
tbd
|
||||
</pre>
|
||||
|
||||
|
||||
@@ -53,15 +45,8 @@ e82ba28e00d653e6f437d32be8ca8481 MesaGLUT-7.5.2.zip
|
||||
<ul>
|
||||
<li>Assorted bug fixes for i965/i945 drivers
|
||||
<li>Fixed Gallium glDrawPixels(GL_STENCIL_INDEX) failure.
|
||||
<li>Fixed GLSL linker/preprocessor version directive issue seen in Wine
|
||||
(such as bug 23946)
|
||||
<li>glUseProgram() is now compiled into display lists (bug 23746).
|
||||
<li>glUniform functions are now compiled into display lists
|
||||
<li>Auto mipmap generation didn't work reliably with Gallium.
|
||||
<li>Fixed random number usage in GLX code.
|
||||
<li>Fixed invalid GL_OUT_OF_MEMORY error sometimes raised by glTexSubImage2D
|
||||
when using Gallium.
|
||||
</ul>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -1,60 +0,0 @@
|
||||
<HTML>
|
||||
|
||||
<TITLE>Mesa Release Notes</TITLE>
|
||||
|
||||
<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
|
||||
|
||||
<BODY>
|
||||
|
||||
<body bgcolor="#eeeeee">
|
||||
|
||||
<H1>Mesa 7.6.1 Release Notes, (date tbd)</H1>
|
||||
|
||||
<p>
|
||||
Mesa 7.6.1 is a bug-fix release fixing issues since version 7.6.
|
||||
</p>
|
||||
<p>
|
||||
Mesa 7.6.1 implements the OpenGL 2.1 API, but the version reported by
|
||||
glGetString(GL_VERSION) depends on the particular driver being used.
|
||||
Some drivers don't support all the features required in OpenGL 2.1.
|
||||
</p>
|
||||
<p>
|
||||
See the <a href="install.html">Compiling/Installing page</a> for prerequisites
|
||||
for DRI hardware acceleration.
|
||||
</p>
|
||||
|
||||
|
||||
<h2>MD5 checksums</h2>
|
||||
<pre>
|
||||
tbd
|
||||
</pre>
|
||||
|
||||
|
||||
<h2>New features</h2>
|
||||
<ul>
|
||||
<li>Upgraded GL/glext.h to version 56, GL/glxext.h to version 25,
|
||||
GL/wglext.h to version 17
|
||||
<li>New 3D driver, r600, for Radeon R6xx, R7xx hardware
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Bug fixes</h2>
|
||||
<ul>
|
||||
<li>Fixed crash caused by glXCopyContext() and glXDestroyContext(), bug 24217
|
||||
<li>glXQueryContext(GLX_RENDER_TYPE) returned wrong values (bug 24211)
|
||||
<li>GLSL sqrt(0) returned unpredictable results
|
||||
<li>Fixed default texture binding bug when a bound texture was deleted.
|
||||
<li>r300: Work around an issue with very large fragment programs on R500.
|
||||
<li>Fake glXQueryDrawable() didn't return good values (bug 24320)
|
||||
<li>Fixed AUX buffer breakage (bug 24426).
|
||||
<li>Fixed locale-dependent float parsing bug in GLSL compiler (bug 24531)
|
||||
<li>Fixed Gallium Cell driver compilation failure.
|
||||
<li>Fixed glGetTexLevelParameter(GL_TEXTURE_INTERNAL_FORMAT) query so that
|
||||
it returns the actual compressed format chosen.
|
||||
<li>Fixed glBitmap bugs in Intel drivers.
|
||||
<li>Fixed a number of Microsoft Visual Studio compilation problems.
|
||||
<li>Fixed clipping / provoking vertex bugs in i965 driver.
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
</html>
|
@@ -8,7 +8,7 @@
|
||||
|
||||
<body bgcolor="#eeeeee">
|
||||
|
||||
<H1>Mesa 7.6 Release Notes, 28 September 2009</H1>
|
||||
<H1>Mesa 7.6 Release Notes / date TBD</H1>
|
||||
|
||||
<p>
|
||||
Mesa 7.6 is a new development release.
|
||||
@@ -28,15 +28,7 @@ for DRI hardware acceleration.
|
||||
|
||||
<h2>MD5 checksums</h2>
|
||||
<pre>
|
||||
5ffa7d7abf8973f57a1bc4f813e6dade MesaLib-7.6.tar.gz
|
||||
8c75f90cd0303cfac9e4b6d54f6759ca MesaLib-7.6.tar.bz2
|
||||
27fcfd69708599c978cb34ba5cd363e1 MesaLib-7.6.zip
|
||||
e7befb3ae604f591806194a4da445628 MesaDemos-7.6.tar.gz
|
||||
0ede7adf217951acd90dbe4551210c07 MesaDemos-7.6.tar.bz2
|
||||
ed9298409cf6613bc0964525ca4afc8a MesaDemos-7.6.zip
|
||||
666955668e44ff14acf7d15dc78407d3 MesaGLUT-7.6.tar.gz
|
||||
b8b59706f827d18d1b784a0ff98b4dc2 MesaGLUT-7.6.tar.bz2
|
||||
c49c19c2bbef4f3b7f1389974dff25f4 MesaGLUT-7.6.zip
|
||||
tbd
|
||||
</pre>
|
||||
|
||||
|
||||
@@ -58,8 +50,6 @@ This was written by Zack Rusin at Tungsten Graphics.
|
||||
<li>Rewritten radeon/r200/r300 driver using a buffer manager
|
||||
<li>radeon/r200/r300 GL_EXT_framebuffer_object support when used with
|
||||
kernel memory manager
|
||||
<li>radeon/r200/r300 support for GL_ARB_occlusion_query</li>
|
||||
<li>r300 driver supports OpenGL 1.5</li>
|
||||
<li>r300 driver support for GL_EXT_vertex_array_bgra, GL_EXT_texture_sRGB
|
||||
<li>i915/945 driver support for GL_ARB_point_sprite, GL_EXT_stencil_two_side
|
||||
and GL_ATI_separate_stencil extensions
|
||||
@@ -67,10 +57,6 @@ This was written by Zack Rusin at Tungsten Graphics.
|
||||
GL_ARB_fragment_program.</li>
|
||||
<li>Added configure --with-max-width=W, --with-max-height=H options to specify
|
||||
max framebuffer, viewport size.
|
||||
<li>Initial version of Gallium llvmpipe driver. This is a new driver based
|
||||
on LLVM which makes exensive use of run-time code generation. This is
|
||||
an "alpha" stage driver. See the src/gallium/drivers/llvmpipe/README
|
||||
file for more information.
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -80,5 +66,10 @@ This was written by Zack Rusin at Tungsten Graphics.
|
||||
buffers (GLSL uniforms)
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Changes</h2>
|
||||
<ul>
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
53
docs/relnotes-7.7.html
Normal file
53
docs/relnotes-7.7.html
Normal file
@@ -0,0 +1,53 @@
|
||||
<HTML>
|
||||
|
||||
<TITLE>Mesa Release Notes</TITLE>
|
||||
|
||||
<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
|
||||
|
||||
<BODY>
|
||||
|
||||
<body bgcolor="#eeeeee">
|
||||
|
||||
<H1>Mesa 7.7 Release Notes / date TBD</H1>
|
||||
|
||||
<p>
|
||||
Mesa 7.7 is a new development release.
|
||||
People who are concerned with stability and reliability should stick
|
||||
with a previous release or wait for Mesa 7.7.1.
|
||||
</p>
|
||||
<p>
|
||||
Mesa 7.7 implements the OpenGL 2.1 API, but the version reported by
|
||||
glGetString(GL_VERSION) depends on the particular driver being used.
|
||||
Some drivers don't support all the features required in OpenGL 2.1.
|
||||
</p>
|
||||
<p>
|
||||
See the <a href="install.html">Compiling/Installing page</a> for prerequisites
|
||||
for DRI hardware acceleration.
|
||||
</p>
|
||||
|
||||
|
||||
<h2>MD5 checksums</h2>
|
||||
<pre>
|
||||
tbd
|
||||
</pre>
|
||||
|
||||
|
||||
<h2>New features</h2>
|
||||
<ul>
|
||||
<li>GL_ARB_draw_elements_base_vertex (supported in Intel i965 and software drivers)</li>
|
||||
<li>GL_ARB_depth_clamp (supported in Intel i965 DRI and software drivers)</li>
|
||||
<li>GL_NV_depth_clamp (supported in Intel i965 DRI and software drivers)</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Bug fixes</h2>
|
||||
<ul>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Changes</h2>
|
||||
<ul>
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
</html>
|
@@ -13,7 +13,7 @@ The release notes summarize what's new or changed in each Mesa release.
|
||||
</p>
|
||||
|
||||
<UL>
|
||||
<LI><A HREF="relnotes-7.6.1.html">7.6.1 release notes</A>
|
||||
<LI><A HREF="relnotes-7.7.html">7.7 release notes</A>
|
||||
<LI><A HREF="relnotes-7.6.html">7.6 release notes</A>
|
||||
<LI><A HREF="relnotes-7.5.2.html">7.5.2 release notes</A>
|
||||
<LI><A HREF="relnotes-7.5.1.html">7.5.1 release notes</A>
|
||||
|
@@ -6,7 +6,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Copyright (c) 2007 The Khronos Group Inc.
|
||||
** Copyright (c) 2007-2009 The Khronos Group Inc.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||
** copy of this software and/or associated documentation files (the
|
||||
@@ -33,9 +33,9 @@ extern "C" {
|
||||
/*************************************************************/
|
||||
|
||||
/* Header file version number */
|
||||
/* eglext.h last updated 2007/11/20 */
|
||||
/* Current version at http://www.khronos.org/registry/egl/ */
|
||||
#define EGL_EGLEXT_VERSION 1
|
||||
/* $Revision: 7244 $ on $Date: 2009-01-20 17:06:59 -0800 (Tue, 20 Jan 2009) $ */
|
||||
#define EGL_EGLEXT_VERSION 3
|
||||
|
||||
#ifndef EGL_KHR_config_attribs
|
||||
#define EGL_KHR_config_attribs 1
|
||||
@@ -79,12 +79,12 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay display
|
||||
#define EGL_KHR_image 1
|
||||
#define EGL_NATIVE_PIXMAP_KHR 0x30B0 /* eglCreateImageKHR target */
|
||||
typedef void *EGLImageKHR;
|
||||
extern const EGLImageKHR EGL_NO_IMAGE_KHR;
|
||||
#define EGL_NO_IMAGE_KHR ((EGLImageKHR)0)
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, EGLint *attr_list);
|
||||
EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image);
|
||||
#endif /* EGL_EGLEXT_PROTOTYPES */
|
||||
typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, EGLint *attr_list);
|
||||
typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image);
|
||||
#endif
|
||||
|
||||
@@ -179,6 +179,17 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOPYCONTEXTMESA) (EGLDisplay dpy, EGLCont
|
||||
|
||||
#endif /* EGL_MESA_copy_context */
|
||||
|
||||
#ifndef EGL_KHR_image_base
|
||||
#define EGL_KHR_image_base 1
|
||||
/* Most interfaces defined by EGL_KHR_image_pixmap above */
|
||||
#define EGL_IMAGE_PRESERVED_KHR 0x30D2 /* eglCreateImageKHR attribute */
|
||||
#endif
|
||||
|
||||
#ifndef EGL_KHR_image_pixmap
|
||||
#define EGL_KHR_image_pixmap 1
|
||||
/* Interfaces defined by EGL_KHR_image above */
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
27
include/EGL/internal/eglimage_dri.h
Normal file
27
include/EGL/internal/eglimage_dri.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef EGLIMAGE_DRI_INCLUDED
|
||||
#define EGLIMAGE_DRI_INCLUDED
|
||||
|
||||
#include "GL/internal/dri_interface.h"
|
||||
|
||||
#define __DRI_EGL_IMAGE_MAGIC \
|
||||
(('D' << 24) | \
|
||||
('R' << 16) | \
|
||||
('I' << 8) | \
|
||||
('0'))
|
||||
|
||||
typedef void *__DRIEGLImageHandle;
|
||||
typedef struct __DRIEGLImageRec __DRIEGLImage;
|
||||
|
||||
struct __DRIEGLImageRec {
|
||||
GLint magic;
|
||||
|
||||
__DRIdrawable *drawable;
|
||||
|
||||
GLboolean texture_format_rgba;
|
||||
GLint level;
|
||||
GLint __pad[4];
|
||||
};
|
||||
|
||||
extern __DRIEGLImage *_eglClientGetImageData(__DRIEGLImageHandle handle);
|
||||
|
||||
#endif /* EGLIMAGE_DRI_INCLUDED */
|
@@ -1740,9 +1740,6 @@ GLAPI void GLAPIENTRY glSeparableFilter2D( GLenum target,
|
||||
GLAPI void GLAPIENTRY glGetSeparableFilter( GLenum target, GLenum format,
|
||||
GLenum type, GLvoid *row, GLvoid *column, GLvoid *span );
|
||||
|
||||
typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
|
||||
typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@@ -1948,18 +1945,6 @@ GLAPI void GLAPIENTRY glMultTransposeMatrixf( const GLfloat m[16] );
|
||||
GLAPI void GLAPIENTRY glSampleCoverage( GLclampf value, GLboolean invert );
|
||||
|
||||
|
||||
typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
|
||||
typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert);
|
||||
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
|
||||
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
|
||||
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
|
||||
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
|
||||
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
|
||||
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
|
||||
typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* GL_ARB_multitexture (ARB extension 1 and OpenGL 1.2.1)
|
||||
*/
|
||||
|
@@ -108,20 +108,12 @@
|
||||
#define glBlendColorEXT MANGLE(BlendColorEXT)
|
||||
#define glBlendColor MANGLE(BlendColor)
|
||||
#define glBlendEquationEXT MANGLE(BlendEquationEXT)
|
||||
#define glBlendEquationi MANGLE(BlendEquationi)
|
||||
#define glBlendEquationIndexedAMD MANGLE(BlendEquationIndexedAMD)
|
||||
#define glBlendEquation MANGLE(BlendEquation)
|
||||
#define glBlendEquationSeparateATI MANGLE(BlendEquationSeparateATI)
|
||||
#define glBlendEquationSeparateEXT MANGLE(BlendEquationSeparateEXT)
|
||||
#define glBlendEquationSeparatei MANGLE(BlendEquationSeparatei)
|
||||
#define glBlendEquationSeparateIndexedAMD MANGLE(BlendEquationSeparateIndexedAMD)
|
||||
#define glBlendEquationSeparate MANGLE(BlendEquationSeparate)
|
||||
#define glBlendFunci MANGLE(BlendFunci)
|
||||
#define glBlendFuncIndexedAMD MANGLE(BlendFuncIndexedAMD)
|
||||
#define glBlendFunc MANGLE(BlendFunc)
|
||||
#define glBlendFuncSeparateEXT MANGLE(BlendFuncSeparateEXT)
|
||||
#define glBlendFuncSeparatei MANGLE(BlendFuncSeparatei)
|
||||
#define glBlendFuncSeparateIndexedAMD MANGLE(BlendFuncSeparateIndexedAMD)
|
||||
#define glBlendFuncSeparateINGR MANGLE(BlendFuncSeparateINGR)
|
||||
#define glBlendFuncSeparate MANGLE(BlendFuncSeparate)
|
||||
#define glBlitFramebufferEXT MANGLE(BlitFramebufferEXT)
|
||||
@@ -156,7 +148,6 @@
|
||||
#define glClientActiveTexture MANGLE(ClientActiveTexture)
|
||||
#define glClientActiveVertexStreamATI MANGLE(ClientActiveVertexStreamATI)
|
||||
#define glClientAttribDefaultEXT MANGLE(ClientAttribDefaultEXT)
|
||||
#define glClientWaitSync MANGLE(ClientWaitSync)
|
||||
#define glClipPlane MANGLE(ClipPlane)
|
||||
#define glColor3b MANGLE(Color3b)
|
||||
#define glColor3bv MANGLE(Color3bv)
|
||||
@@ -329,7 +320,6 @@
|
||||
#define glDeleteRenderbuffersEXT MANGLE(DeleteRenderbuffersEXT)
|
||||
#define glDeleteRenderbuffers MANGLE(DeleteRenderbuffers)
|
||||
#define glDeleteShader MANGLE(DeleteShader)
|
||||
#define glDeleteSync MANGLE(DeleteSync)
|
||||
#define glDeleteTexturesEXT MANGLE(DeleteTexturesEXT)
|
||||
#define glDeleteTextures MANGLE(DeleteTextures)
|
||||
#define glDeleteTransformFeedbacksNV MANGLE(DeleteTransformFeedbacksNV)
|
||||
@@ -351,7 +341,6 @@
|
||||
#define glDisableIndexedEXT MANGLE(DisableIndexedEXT)
|
||||
#define glDisable MANGLE(Disable)
|
||||
#define glDisableVariantClientStateEXT MANGLE(DisableVariantClientStateEXT)
|
||||
#define glDisableVertexAttribAPPLE MANGLE(DisableVertexAttribAPPLE)
|
||||
#define glDisableVertexAttribArrayARB MANGLE(DisableVertexAttribArrayARB)
|
||||
#define glDisableVertexAttribArray MANGLE(DisableVertexAttribArray)
|
||||
#define glDrawArraysEXT MANGLE(DrawArraysEXT)
|
||||
@@ -365,9 +354,7 @@
|
||||
#define glDrawBuffers MANGLE(DrawBuffers)
|
||||
#define glDrawElementArrayAPPLE MANGLE(DrawElementArrayAPPLE)
|
||||
#define glDrawElementArrayATI MANGLE(DrawElementArrayATI)
|
||||
#define glDrawElementsBaseVertex MANGLE(DrawElementsBaseVertex)
|
||||
#define glDrawElementsInstancedARB MANGLE(DrawElementsInstancedARB)
|
||||
#define glDrawElementsInstancedBaseVertex MANGLE(DrawElementsInstancedBaseVertex)
|
||||
#define glDrawElementsInstancedEXT MANGLE(DrawElementsInstancedEXT)
|
||||
#define glDrawElementsInstanced MANGLE(DrawElementsInstanced)
|
||||
#define glDrawElements MANGLE(DrawElements)
|
||||
@@ -375,7 +362,6 @@
|
||||
#define glDrawPixels MANGLE(DrawPixels)
|
||||
#define glDrawRangeElementArrayAPPLE MANGLE(DrawRangeElementArrayAPPLE)
|
||||
#define glDrawRangeElementArrayATI MANGLE(DrawRangeElementArrayATI)
|
||||
#define glDrawRangeElementsBaseVertex MANGLE(DrawRangeElementsBaseVertex)
|
||||
#define glDrawRangeElementsEXT MANGLE(DrawRangeElementsEXT)
|
||||
#define glDrawRangeElements MANGLE(DrawRangeElements)
|
||||
#define glDrawTransformFeedbackNV MANGLE(DrawTransformFeedbackNV)
|
||||
@@ -392,7 +378,6 @@
|
||||
#define glEnableIndexedEXT MANGLE(EnableIndexedEXT)
|
||||
#define glEnable MANGLE(Enable)
|
||||
#define glEnableVariantClientStateEXT MANGLE(EnableVariantClientStateEXT)
|
||||
#define glEnableVertexAttribAPPLE MANGLE(EnableVertexAttribAPPLE)
|
||||
#define glEnableVertexAttribArrayARB MANGLE(EnableVertexAttribArrayARB)
|
||||
#define glEnableVertexAttribArray MANGLE(EnableVertexAttribArray)
|
||||
#define glEndConditionalRender MANGLE(EndConditionalRender)
|
||||
@@ -424,7 +409,6 @@
|
||||
#define glExecuteProgramNV MANGLE(ExecuteProgramNV)
|
||||
#define glExtractComponentEXT MANGLE(ExtractComponentEXT)
|
||||
#define glFeedbackBuffer MANGLE(FeedbackBuffer)
|
||||
#define glFenceSync MANGLE(FenceSync)
|
||||
#define glFinalCombinerInputNV MANGLE(FinalCombinerInputNV)
|
||||
#define glFinishAsyncSGIX MANGLE(FinishAsyncSGIX)
|
||||
#define glFinishFenceAPPLE MANGLE(FinishFenceAPPLE)
|
||||
@@ -485,11 +469,9 @@
|
||||
#define glFramebufferTextureEXT MANGLE(FramebufferTextureEXT)
|
||||
#define glFramebufferTextureFaceARB MANGLE(FramebufferTextureFaceARB)
|
||||
#define glFramebufferTextureFaceEXT MANGLE(FramebufferTextureFaceEXT)
|
||||
#define glFramebufferTextureFace MANGLE(FramebufferTextureFace)
|
||||
#define glFramebufferTextureLayerARB MANGLE(FramebufferTextureLayerARB)
|
||||
#define glFramebufferTextureLayerEXT MANGLE(FramebufferTextureLayerEXT)
|
||||
#define glFramebufferTextureLayer MANGLE(FramebufferTextureLayer)
|
||||
#define glFramebufferTexture MANGLE(FramebufferTexture)
|
||||
#define glFrameTerminatorGREMEDY MANGLE(FrameTerminatorGREMEDY)
|
||||
#define glFrameZoomSGIX MANGLE(FrameZoomSGIX)
|
||||
#define glFreeObjectBufferATI MANGLE(FreeObjectBufferATI)
|
||||
@@ -541,7 +523,6 @@
|
||||
#define glGetBooleanIndexedvEXT MANGLE(GetBooleanIndexedvEXT)
|
||||
#define glGetBooleani_v MANGLE(GetBooleani_v)
|
||||
#define glGetBooleanv MANGLE(GetBooleanv)
|
||||
#define glGetBufferParameteri64v MANGLE(GetBufferParameteri64v)
|
||||
#define glGetBufferParameterivARB MANGLE(GetBufferParameterivARB)
|
||||
#define glGetBufferParameteriv MANGLE(GetBufferParameteriv)
|
||||
#define glGetBufferPointervARB MANGLE(GetBufferPointervARB)
|
||||
@@ -605,8 +586,6 @@
|
||||
#define glGetImageTransformParameterivHP MANGLE(GetImageTransformParameterivHP)
|
||||
#define glGetInfoLogARB MANGLE(GetInfoLogARB)
|
||||
#define glGetInstrumentsSGIX MANGLE(GetInstrumentsSGIX)
|
||||
#define glGetInteger64i_v MANGLE(GetInteger64i_v)
|
||||
#define glGetInteger64v MANGLE(GetInteger64v)
|
||||
#define glGetIntegerIndexedvEXT MANGLE(GetIntegerIndexedvEXT)
|
||||
#define glGetIntegeri_v MANGLE(GetIntegeri_v)
|
||||
#define glGetIntegerv MANGLE(GetIntegerv)
|
||||
@@ -636,7 +615,6 @@
|
||||
#define glGetMinmaxParameterfv MANGLE(GetMinmaxParameterfv)
|
||||
#define glGetMinmaxParameterivEXT MANGLE(GetMinmaxParameterivEXT)
|
||||
#define glGetMinmaxParameteriv MANGLE(GetMinmaxParameteriv)
|
||||
#define glGetMultisamplefv MANGLE(GetMultisamplefv)
|
||||
#define glGetMultisamplefvNV MANGLE(GetMultisamplefvNV)
|
||||
#define glGetMultiTexEnvfvEXT MANGLE(GetMultiTexEnvfvEXT)
|
||||
#define glGetMultiTexEnvivEXT MANGLE(GetMultiTexEnvivEXT)
|
||||
@@ -664,7 +642,6 @@
|
||||
#define glGetObjectBufferfvATI MANGLE(GetObjectBufferfvATI)
|
||||
#define glGetObjectBufferivATI MANGLE(GetObjectBufferivATI)
|
||||
#define glGetObjectParameterfvARB MANGLE(GetObjectParameterfvARB)
|
||||
#define glGetObjectParameterivAPPLE MANGLE(GetObjectParameterivAPPLE)
|
||||
#define glGetObjectParameterivARB MANGLE(GetObjectParameterivARB)
|
||||
#define glGetOcclusionQueryivNV MANGLE(GetOcclusionQueryivNV)
|
||||
#define glGetOcclusionQueryuivNV MANGLE(GetOcclusionQueryuivNV)
|
||||
@@ -721,7 +698,6 @@
|
||||
#define glGetSharpenTexFuncSGIS MANGLE(GetSharpenTexFuncSGIS)
|
||||
#define glGetStringi MANGLE(GetStringi)
|
||||
#define glGetString MANGLE(GetString)
|
||||
#define glGetSynciv MANGLE(GetSynciv)
|
||||
#define glGetTexBumpParameterfvATI MANGLE(GetTexBumpParameterfvATI)
|
||||
#define glGetTexBumpParameterivATI MANGLE(GetTexBumpParameterivATI)
|
||||
#define glGetTexEnvfv MANGLE(GetTexEnvfv)
|
||||
@@ -739,7 +715,6 @@
|
||||
#define glGetTexParameterIuivEXT MANGLE(GetTexParameterIuivEXT)
|
||||
#define glGetTexParameterIuiv MANGLE(GetTexParameterIuiv)
|
||||
#define glGetTexParameteriv MANGLE(GetTexParameteriv)
|
||||
#define glGetTexParameterPointervAPPLE MANGLE(GetTexParameterPointervAPPLE)
|
||||
#define glGetTextureImageEXT MANGLE(GetTextureImageEXT)
|
||||
#define glGetTextureLevelParameterfvEXT MANGLE(GetTextureLevelParameterfvEXT)
|
||||
#define glGetTextureLevelParameterivEXT MANGLE(GetTextureLevelParameterivEXT)
|
||||
@@ -850,14 +825,12 @@
|
||||
#define glIsRenderbufferEXT MANGLE(IsRenderbufferEXT)
|
||||
#define glIsRenderbuffer MANGLE(IsRenderbuffer)
|
||||
#define glIsShader MANGLE(IsShader)
|
||||
#define glIsSync MANGLE(IsSync)
|
||||
#define glIsTextureEXT MANGLE(IsTextureEXT)
|
||||
#define glIsTexture MANGLE(IsTexture)
|
||||
#define glIsTransformFeedbackNV MANGLE(IsTransformFeedbackNV)
|
||||
#define glIsVariantEnabledEXT MANGLE(IsVariantEnabledEXT)
|
||||
#define glIsVertexArrayAPPLE MANGLE(IsVertexArrayAPPLE)
|
||||
#define glIsVertexArray MANGLE(IsVertexArray)
|
||||
#define glIsVertexAttribEnabledAPPLE MANGLE(IsVertexAttribEnabledAPPLE)
|
||||
#define glLightEnviSGIX MANGLE(LightEnviSGIX)
|
||||
#define glLightf MANGLE(Lightf)
|
||||
#define glLightfv MANGLE(Lightfv)
|
||||
@@ -904,10 +877,6 @@
|
||||
#define glMapObjectBufferATI MANGLE(MapObjectBufferATI)
|
||||
#define glMapParameterfvNV MANGLE(MapParameterfvNV)
|
||||
#define glMapParameterivNV MANGLE(MapParameterivNV)
|
||||
#define glMapVertexAttrib1dAPPLE MANGLE(MapVertexAttrib1dAPPLE)
|
||||
#define glMapVertexAttrib1fAPPLE MANGLE(MapVertexAttrib1fAPPLE)
|
||||
#define glMapVertexAttrib2dAPPLE MANGLE(MapVertexAttrib2dAPPLE)
|
||||
#define glMapVertexAttrib2fAPPLE MANGLE(MapVertexAttrib2fAPPLE)
|
||||
#define glMaterialf MANGLE(Materialf)
|
||||
#define glMaterialfv MANGLE(Materialfv)
|
||||
#define glMateriali MANGLE(Materiali)
|
||||
@@ -938,11 +907,9 @@
|
||||
#define glMatrixTranslatefEXT MANGLE(MatrixTranslatefEXT)
|
||||
#define glMinmaxEXT MANGLE(MinmaxEXT)
|
||||
#define glMinmax MANGLE(Minmax)
|
||||
#define glMinSampleShading MANGLE(MinSampleShading)
|
||||
#define glMultiDrawArraysEXT MANGLE(MultiDrawArraysEXT)
|
||||
#define glMultiDrawArrays MANGLE(MultiDrawArrays)
|
||||
#define glMultiDrawElementArrayAPPLE MANGLE(MultiDrawElementArrayAPPLE)
|
||||
#define glMultiDrawElementsBaseVertex MANGLE(MultiDrawElementsBaseVertex)
|
||||
#define glMultiDrawElementsEXT MANGLE(MultiDrawElementsEXT)
|
||||
#define glMultiDrawElements MANGLE(MultiDrawElements)
|
||||
#define glMultiDrawRangeElementArrayAPPLE MANGLE(MultiDrawRangeElementArrayAPPLE)
|
||||
@@ -1105,8 +1072,6 @@
|
||||
#define glNormalStream3ivATI MANGLE(NormalStream3ivATI)
|
||||
#define glNormalStream3sATI MANGLE(NormalStream3sATI)
|
||||
#define glNormalStream3svATI MANGLE(NormalStream3svATI)
|
||||
#define glObjectPurgeableAPPLE MANGLE(ObjectPurgeableAPPLE)
|
||||
#define glObjectUnpurgeableAPPLE MANGLE(ObjectUnpurgeableAPPLE)
|
||||
#define glOrtho MANGLE(Ortho)
|
||||
#define glPassTexCoordATI MANGLE(PassTexCoordATI)
|
||||
#define glPassThrough MANGLE(PassThrough)
|
||||
@@ -1197,7 +1162,6 @@
|
||||
#define glProgramParameter4fvNV MANGLE(ProgramParameter4fvNV)
|
||||
#define glProgramParameteriARB MANGLE(ProgramParameteriARB)
|
||||
#define glProgramParameteriEXT MANGLE(ProgramParameteriEXT)
|
||||
#define glProgramParameteri MANGLE(ProgramParameteri)
|
||||
#define glProgramParameters4dvNV MANGLE(ProgramParameters4dvNV)
|
||||
#define glProgramParameters4fvNV MANGLE(ProgramParameters4fvNV)
|
||||
#define glProgramStringARB MANGLE(ProgramStringARB)
|
||||
@@ -1236,7 +1200,6 @@
|
||||
#define glProgramUniformMatrix4x3fvEXT MANGLE(ProgramUniformMatrix4x3fvEXT)
|
||||
#define glProgramVertexLimitNV MANGLE(ProgramVertexLimitNV)
|
||||
#define glProvokingVertexEXT MANGLE(ProvokingVertexEXT)
|
||||
#define glProvokingVertex MANGLE(ProvokingVertex)
|
||||
#define glPushAttrib MANGLE(PushAttrib)
|
||||
#define glPushClientAttribDefaultEXT MANGLE(PushClientAttribDefaultEXT)
|
||||
#define glPushClientAttrib MANGLE(PushClientAttrib)
|
||||
@@ -1320,7 +1283,6 @@
|
||||
#define glSampleCoverage MANGLE(SampleCoverage)
|
||||
#define glSampleMapATI MANGLE(SampleMapATI)
|
||||
#define glSampleMaskEXT MANGLE(SampleMaskEXT)
|
||||
#define glSampleMaski MANGLE(SampleMaski)
|
||||
#define glSampleMaskIndexedNV MANGLE(SampleMaskIndexedNV)
|
||||
#define glSampleMaskSGIS MANGLE(SampleMaskSGIS)
|
||||
#define glSamplePatternEXT MANGLE(SamplePatternEXT)
|
||||
@@ -1492,10 +1454,8 @@
|
||||
#define glTexGeniv MANGLE(TexGeniv)
|
||||
#define glTexImage1D MANGLE(TexImage1D)
|
||||
#define glTexImage2D MANGLE(TexImage2D)
|
||||
#define glTexImage2DMultisample MANGLE(TexImage2DMultisample)
|
||||
#define glTexImage3DEXT MANGLE(TexImage3DEXT)
|
||||
#define glTexImage3D MANGLE(TexImage3D)
|
||||
#define glTexImage3DMultisample MANGLE(TexImage3DMultisample)
|
||||
#define glTexImage4DSGIS MANGLE(TexImage4DSGIS)
|
||||
#define glTexParameterf MANGLE(TexParameterf)
|
||||
#define glTexParameterfv MANGLE(TexParameterfv)
|
||||
@@ -1527,7 +1487,6 @@
|
||||
#define glTextureParameterIivEXT MANGLE(TextureParameterIivEXT)
|
||||
#define glTextureParameterIuivEXT MANGLE(TextureParameterIuivEXT)
|
||||
#define glTextureParameterivEXT MANGLE(TextureParameterivEXT)
|
||||
#define glTextureRangeAPPLE MANGLE(TextureRangeAPPLE)
|
||||
#define glTextureRenderbufferEXT MANGLE(TextureRenderbufferEXT)
|
||||
#define glTextureSubImage1DEXT MANGLE(TextureSubImage1DEXT)
|
||||
#define glTextureSubImage2DEXT MANGLE(TextureSubImage2DEXT)
|
||||
@@ -1869,7 +1828,6 @@
|
||||
#define glVertexWeighthvNV MANGLE(VertexWeighthvNV)
|
||||
#define glVertexWeightPointerEXT MANGLE(VertexWeightPointerEXT)
|
||||
#define glViewport MANGLE(Viewport)
|
||||
#define glWaitSync MANGLE(WaitSync)
|
||||
#define glWeightbvARB MANGLE(WeightbvARB)
|
||||
#define glWeightdvARB MANGLE(WeightdvARB)
|
||||
#define glWeightfvARB MANGLE(WeightfvARB)
|
||||
|
@@ -29,9 +29,9 @@ extern "C" {
|
||||
*/
|
||||
|
||||
/* Header file version number, required by OpenGL ABI for Linux */
|
||||
/* glext.h last updated $Date: 2009-09-24 13:55:03 -0700 (Thu, 24 Sep 2009) $ */
|
||||
/* glext.h last updated $Date: 2009-08-03 02:13:51 -0700 (Mon, 03 Aug 2009) $ */
|
||||
/* Current version at http://www.opengl.org/registry/ */
|
||||
#define GL_GLEXT_VERSION 56
|
||||
#define GL_GLEXT_VERSION 54
|
||||
|
||||
/* Function declaration macros - to move into glplatform.h */
|
||||
|
||||
@@ -4236,7 +4236,7 @@ extern "C" {
|
||||
#define GL_LUMINANCE16_SNORM 0x9019
|
||||
#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A
|
||||
#define GL_INTENSITY16_SNORM 0x901B
|
||||
/* reuse GL_RED_SNORM */
|
||||
/* reuse GL_R_SNORM */
|
||||
/* reuse GL_RG_SNORM */
|
||||
/* reuse GL_RGB_SNORM */
|
||||
/* reuse GL_RGBA_SNORM */
|
||||
@@ -4311,88 +4311,6 @@ extern "C" {
|
||||
#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16
|
||||
#endif
|
||||
|
||||
#ifndef GL_APPLE_rgb_422
|
||||
#define GL_RGB_422_APPLE 0x8A1F
|
||||
/* reuse GL_UNSIGNED_SHORT_8_8_APPLE */
|
||||
/* reuse GL_UNSIGNED_SHORT_8_8_REV_APPLE */
|
||||
#endif
|
||||
|
||||
#ifndef GL_NV_video_capture
|
||||
#define GL_VIDEO_BUFFER_NV 0x9020
|
||||
#define GL_VIDEO_BUFFER_BINDING_NV 0x9021
|
||||
#define GL_FIELD_UPPER_NV 0x9022
|
||||
#define GL_FIELD_LOWER_NV 0x9023
|
||||
#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024
|
||||
#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025
|
||||
#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026
|
||||
#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027
|
||||
#define GL_VIDEO_BUFFER_PITCH_NV 0x9028
|
||||
#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029
|
||||
#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A
|
||||
#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B
|
||||
#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C
|
||||
#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D
|
||||
#define GL_PARTIAL_SUCCESS_NV 0x902E
|
||||
#define GL_SUCCESS_NV 0x902F
|
||||
#define GL_FAILURE_NV 0x9030
|
||||
#define GL_YCBYCR8_422_NV 0x9031
|
||||
#define GL_YCBAYCR8A_4224_NV 0x9032
|
||||
#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033
|
||||
#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034
|
||||
#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035
|
||||
#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036
|
||||
#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037
|
||||
#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038
|
||||
#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039
|
||||
#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A
|
||||
#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B
|
||||
#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C
|
||||
#endif
|
||||
|
||||
#ifndef GL_NV_copy_image
|
||||
#endif
|
||||
|
||||
#ifndef GL_EXT_separate_shader_objects
|
||||
#define GL_ACTIVE_PROGRAM_EXT 0x8B8D
|
||||
#endif
|
||||
|
||||
#ifndef GL_NV_parameter_buffer_object2
|
||||
#endif
|
||||
|
||||
#ifndef GL_NV_shader_buffer_load
|
||||
#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D
|
||||
#define GL_GPU_ADDRESS_NV 0x8F34
|
||||
#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35
|
||||
#endif
|
||||
|
||||
#ifndef GL_NV_vertex_buffer_unified_memory
|
||||
#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E
|
||||
#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F
|
||||
#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20
|
||||
#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21
|
||||
#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22
|
||||
#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23
|
||||
#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24
|
||||
#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25
|
||||
#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26
|
||||
#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27
|
||||
#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28
|
||||
#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29
|
||||
#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A
|
||||
#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B
|
||||
#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C
|
||||
#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D
|
||||
#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E
|
||||
#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F
|
||||
#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30
|
||||
#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31
|
||||
#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32
|
||||
#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33
|
||||
#endif
|
||||
|
||||
#ifndef GL_NV_texture_barrier
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
@@ -9327,136 +9245,6 @@ typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType,
|
||||
#define GL_APPLE_row_bytes 1
|
||||
#endif
|
||||
|
||||
#ifndef GL_APPLE_rgb_422
|
||||
#define GL_APPLE_rgb_422 1
|
||||
#endif
|
||||
|
||||
#ifndef GL_NV_video_capture
|
||||
#define GL_NV_video_capture 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint);
|
||||
GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint, GLuint, GLenum, GLintptrARB);
|
||||
GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint, GLuint, GLenum, GLenum, GLuint);
|
||||
GLAPI void APIENTRY glEndVideoCaptureNV (GLuint);
|
||||
GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint, GLenum, GLint *);
|
||||
GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint, GLuint, GLenum, GLint *);
|
||||
GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint, GLuint, GLenum, GLfloat *);
|
||||
GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint, GLuint, GLenum, GLdouble *);
|
||||
GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint, GLuint *, GLuint64EXT *);
|
||||
GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint, GLuint, GLenum, const GLint *);
|
||||
GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint, GLuint, GLenum, const GLfloat *);
|
||||
GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint, GLuint, GLenum, const GLdouble *);
|
||||
#endif /* GL_GLEXT_PROTOTYPES */
|
||||
typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot);
|
||||
typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset);
|
||||
typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture);
|
||||
typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot);
|
||||
typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params);
|
||||
typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params);
|
||||
typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params);
|
||||
typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params);
|
||||
typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time);
|
||||
typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params);
|
||||
typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params);
|
||||
typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params);
|
||||
#endif
|
||||
|
||||
#ifndef GL_NV_copy_image
|
||||
#define GL_NV_copy_image 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glCopyImageSubDataNV (GLuint, GLenum, GLint, GLint, GLint, GLint, GLuint, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei);
|
||||
#endif /* GL_GLEXT_PROTOTYPES */
|
||||
typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
|
||||
#endif
|
||||
|
||||
#ifndef GL_EXT_separate_shader_objects
|
||||
#define GL_EXT_separate_shader_objects 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glUseShaderProgramEXT (GLenum, GLuint);
|
||||
GLAPI void APIENTRY glActiveProgramEXT (GLuint);
|
||||
GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum, const GLchar *);
|
||||
#endif /* GL_GLEXT_PROTOTYPES */
|
||||
typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program);
|
||||
typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program);
|
||||
typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string);
|
||||
#endif
|
||||
|
||||
#ifndef GL_NV_parameter_buffer_object2
|
||||
#define GL_NV_parameter_buffer_object2 1
|
||||
#endif
|
||||
|
||||
#ifndef GL_NV_shader_buffer_load
|
||||
#define GL_NV_shader_buffer_load 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glMakeBufferResidentNV (GLenum, GLenum);
|
||||
GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum);
|
||||
GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum);
|
||||
GLAPI void APIENTRY glNamedMakeBufferResidentNV (GLuint, GLenum);
|
||||
GLAPI void APIENTRY glNamedMakeBufferNonResidentNV (GLuint);
|
||||
GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint);
|
||||
GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum, GLenum, GLuint64EXT *);
|
||||
GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint, GLenum, GLuint64EXT *);
|
||||
GLAPI void APIENTRY glGetIntegerui64vNV (GLenum, GLuint64EXT *);
|
||||
GLAPI void APIENTRY glUniformui64NV (GLint, GLuint64EXT);
|
||||
GLAPI void APIENTRY glUniformui64vNV (GLint, GLsizei, const GLuint64EXT *);
|
||||
GLAPI void APIENTRY glGetUniformui64vNV (GLuint, GLint, GLuint64EXT *);
|
||||
GLAPI void APIENTRY glProgramUniformui64NV (GLuint, GLint, GLuint64EXT);
|
||||
GLAPI void APIENTRY glProgramUniformui64vNV (GLuint, GLint, GLsizei, const GLuint64EXT *);
|
||||
#endif /* GL_GLEXT_PROTOTYPES */
|
||||
typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access);
|
||||
typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target);
|
||||
typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target);
|
||||
typedef void (APIENTRYP PFNGLNAMEDMAKEBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access);
|
||||
typedef void (APIENTRYP PFNGLNAMEDMAKEBUFFERNONRESIDENTNVPROC) (GLuint buffer);
|
||||
typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer);
|
||||
typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params);
|
||||
typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params);
|
||||
typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result);
|
||||
typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value);
|
||||
typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value);
|
||||
typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params);
|
||||
typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value);
|
||||
typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value);
|
||||
#endif
|
||||
|
||||
#ifndef GL_NV_vertex_buffer_unified_memory
|
||||
#define GL_NV_vertex_buffer_unified_memory 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glBufferAddressRangeNV (GLenum, GLuint, GLuint64EXT, GLsizeiptr);
|
||||
GLAPI void APIENTRY glVertexFormatNV (GLint, GLenum, GLsizei);
|
||||
GLAPI void APIENTRY glNormalFormatNV (GLenum, GLsizei);
|
||||
GLAPI void APIENTRY glColorFormatNV (GLint, GLenum, GLsizei);
|
||||
GLAPI void APIENTRY glIndexFormatNV (GLenum, GLsizei);
|
||||
GLAPI void APIENTRY glTexCoordFormatNV (GLint, GLenum, GLsizei);
|
||||
GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei);
|
||||
GLAPI void APIENTRY glSecondaryColorFormatNV (GLint, GLenum, GLsizei);
|
||||
GLAPI void APIENTRY glFogCoordFormatNV (GLenum, GLsizei);
|
||||
GLAPI void APIENTRY glVertexAttribFormatNV (GLuint, GLint, GLenum, GLboolean, GLsizei);
|
||||
GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint, GLint, GLenum, GLsizei);
|
||||
GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum, GLuint, GLuint64EXT *);
|
||||
#endif /* GL_GLEXT_PROTOTYPES */
|
||||
typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length);
|
||||
typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
|
||||
typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride);
|
||||
typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
|
||||
typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride);
|
||||
typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
|
||||
typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride);
|
||||
typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride);
|
||||
typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride);
|
||||
typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result);
|
||||
#endif
|
||||
|
||||
#ifndef GL_NV_texture_barrier
|
||||
#define GL_NV_texture_barrier 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glTextureBarrierNV (void);
|
||||
#endif /* GL_GLEXT_PROTOTYPES */
|
||||
typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@@ -48,9 +48,9 @@ extern "C" {
|
||||
/*************************************************************/
|
||||
|
||||
/* Header file version number, required by OpenGL ABI for Linux */
|
||||
/* glxext.h last updated 2009/10/08 */
|
||||
/* glxext.h last updated 2009/08/03 */
|
||||
/* Current version at http://www.opengl.org/registry/ */
|
||||
#define GLX_GLXEXT_VERSION 25
|
||||
#define GLX_GLXEXT_VERSION 23
|
||||
|
||||
#ifndef GLX_VERSION_1_3
|
||||
#define GLX_WINDOW_BIT 0x00000001
|
||||
@@ -382,20 +382,6 @@ extern "C" {
|
||||
#ifndef GLX_NV_swap_group
|
||||
#endif
|
||||
|
||||
#ifndef GLX_NV_video_capture
|
||||
#define GLX_DEVICE_ID_NV 0x20CD
|
||||
#define GLX_UNIQUE_ID_NV 0x20CE
|
||||
#define GLX_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF
|
||||
#endif
|
||||
|
||||
#ifndef GLX_EXT_swap_control
|
||||
#define GLX_SWAP_INTERVAL_EXT 0x20F1
|
||||
#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2
|
||||
#endif
|
||||
|
||||
#ifndef GLX_NV_copy_image
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
@@ -429,14 +415,6 @@ typedef struct {
|
||||
} GLXBufferClobberEventSGIX;
|
||||
#endif
|
||||
|
||||
#ifndef GLX_NV_video_output
|
||||
typedef unsigned int GLXVideoDeviceNV;
|
||||
#endif
|
||||
|
||||
#ifndef GLX_NV_video_capture
|
||||
typedef XID GLXVideoCaptureDeviceNV;
|
||||
#endif
|
||||
|
||||
#ifndef GLEXT_64_TYPES_DEFINED
|
||||
/* This code block is duplicated in glext.h, so must be protected */
|
||||
#define GLEXT_64_TYPES_DEFINED
|
||||
@@ -849,80 +827,14 @@ typedef void ( * PFNGLXRELEASETEXIMAGEEXTPROC) (Display *dpy, GLXDrawable drawab
|
||||
|
||||
#ifndef GLX_NV_present_video
|
||||
#define GLX_NV_present_video 1
|
||||
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||
extern unsigned int * glXEnumerateVideoDevicesNV (Display *, int, int *);
|
||||
extern int glXBindVideoDeviceNV (Display *, unsigned int, unsigned int, const int *);
|
||||
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||
typedef unsigned int * ( * PFNGLXENUMERATEVIDEODEVICESNVPROC) (Display *dpy, int screen, int *nelements);
|
||||
typedef int ( * PFNGLXBINDVIDEODEVICENVPROC) (Display *dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list);
|
||||
#endif
|
||||
|
||||
#ifndef GLX_NV_video_output
|
||||
#define GLX_NV_video_output 1
|
||||
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||
extern int glXGetVideoDeviceNV (Display *, int, int, GLXVideoDeviceNV *);
|
||||
extern int glXReleaseVideoDeviceNV (Display *, int, GLXVideoDeviceNV);
|
||||
extern int glXBindVideoImageNV (Display *, GLXVideoDeviceNV, GLXPbuffer, int);
|
||||
extern int glXReleaseVideoImageNV (Display *, GLXPbuffer);
|
||||
extern int glXSendPbufferToVideoNV (Display *, GLXPbuffer, int, unsigned long *, GLboolean);
|
||||
extern int glXGetVideoInfoNV (Display *, int, GLXVideoDeviceNV, unsigned long *, unsigned long *);
|
||||
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||
typedef int ( * PFNGLXGETVIDEODEVICENVPROC) (Display *dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice);
|
||||
typedef int ( * PFNGLXRELEASEVIDEODEVICENVPROC) (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice);
|
||||
typedef int ( * PFNGLXBINDVIDEOIMAGENVPROC) (Display *dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer);
|
||||
typedef int ( * PFNGLXRELEASEVIDEOIMAGENVPROC) (Display *dpy, GLXPbuffer pbuf);
|
||||
typedef int ( * PFNGLXSENDPBUFFERTOVIDEONVPROC) (Display *dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock);
|
||||
typedef int ( * PFNGLXGETVIDEOINFONVPROC) (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo);
|
||||
#ifndef GLX_NV_video_out
|
||||
#define GLX_NV_video_out 1
|
||||
#endif
|
||||
|
||||
#ifndef GLX_NV_swap_group
|
||||
#define GLX_NV_swap_group 1
|
||||
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||
extern Bool glXJoinSwapGroupNV (Display *, GLXDrawable, GLuint);
|
||||
extern Bool glXBindSwapBarrierNV (Display *, GLuint, GLuint);
|
||||
extern Bool glXQuerySwapGroupNV (Display *, GLXDrawable, GLuint *, GLuint *);
|
||||
extern Bool glXQueryMaxSwapGroupsNV (Display *, int, GLuint *, GLuint *);
|
||||
extern Bool glXQueryFrameCountNV (Display *, int, GLuint *);
|
||||
extern Bool glXResetFrameCountNV (Display *, int);
|
||||
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||
typedef Bool ( * PFNGLXJOINSWAPGROUPNVPROC) (Display *dpy, GLXDrawable drawable, GLuint group);
|
||||
typedef Bool ( * PFNGLXBINDSWAPBARRIERNVPROC) (Display *dpy, GLuint group, GLuint barrier);
|
||||
typedef Bool ( * PFNGLXQUERYSWAPGROUPNVPROC) (Display *dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier);
|
||||
typedef Bool ( * PFNGLXQUERYMAXSWAPGROUPSNVPROC) (Display *dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers);
|
||||
typedef Bool ( * PFNGLXQUERYFRAMECOUNTNVPROC) (Display *dpy, int screen, GLuint *count);
|
||||
typedef Bool ( * PFNGLXRESETFRAMECOUNTNVPROC) (Display *dpy, int screen);
|
||||
#endif
|
||||
|
||||
#ifndef GLX_NV_video_capture
|
||||
#define GLX_NV_video_capture 1
|
||||
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||
extern int glXBindVideoCaptureDeviceNV (Display *, unsigned int, GLXVideoCaptureDeviceNV);
|
||||
extern GLXVideoCaptureDeviceNV * glXEnumerateVideoCaptureDevicesNV (Display *, int, int *);
|
||||
extern void glXLockVideoCaptureDeviceNV (Display *, GLXVideoCaptureDeviceNV);
|
||||
extern int glXQueryVideoCaptureDeviceNV (Display *, GLXVideoCaptureDeviceNV, int, int *);
|
||||
extern void glXReleaseVideoCaptureDeviceNV (Display *, GLXVideoCaptureDeviceNV);
|
||||
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||
typedef int ( * PFNGLXBINDVIDEOCAPTUREDEVICENVPROC) (Display *dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device);
|
||||
typedef GLXVideoCaptureDeviceNV * ( * PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC) (Display *dpy, int screen, int *nelements);
|
||||
typedef void ( * PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device);
|
||||
typedef int ( * PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value);
|
||||
typedef void ( * PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device);
|
||||
#endif
|
||||
|
||||
#ifndef GLX_EXT_swap_control
|
||||
#define GLX_EXT_swap_control 1
|
||||
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||
extern int glXSwapIntervalEXT (Display *, GLXDrawable, int);
|
||||
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||
typedef int ( * PFNGLXSWAPINTERVALEXTPROC) (Display *dpy, GLXDrawable drawable, int interval);
|
||||
#endif
|
||||
|
||||
#ifndef GLX_NV_copy_image
|
||||
#define GLX_NV_copy_image 1
|
||||
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||
extern void glXCopyImageSubDataNV (Display *, GLXContext, GLuint, GLenum, GLint, GLint, GLint, GLint, GLXContext, GLuint, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei);
|
||||
#endif /* GLX_GLXEXT_PROTOTYPES */
|
||||
typedef void ( * PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
|
||||
#endif
|
||||
|
||||
|
||||
|
@@ -708,6 +708,19 @@ struct __DRIdri2LoaderExtensionRec {
|
||||
int *out_count, void *loaderPrivate);
|
||||
};
|
||||
|
||||
#define __DRI_COPY_BUFFER "DRI_CopyBuffer"
|
||||
#define __DRI_COPY_BUFFER_VERSION 1
|
||||
typedef struct __DRIcopyBufferExtensionRec __DRIcopyBufferExtension;
|
||||
struct __DRIcopyBufferExtensionRec {
|
||||
__DRIextension base;
|
||||
|
||||
int (*copyBuffer)(__DRIcontext *context,
|
||||
__DRIbuffer *dst, int dst_x, int dst_y,
|
||||
__DRIdrawable *src, unsigned int src_attachment,
|
||||
int x, int y, int width, int height);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This extension provides alternative screen, drawable and context
|
||||
* constructors for DRI2.
|
||||
|
@@ -48,9 +48,9 @@ extern "C" {
|
||||
/*************************************************************/
|
||||
|
||||
/* Header file version number */
|
||||
/* wglext.h last updated 2009/09/16 */
|
||||
/* wglext.h last updated 2009/08/03 */
|
||||
/* Current version at http://www.opengl.org/registry/ */
|
||||
#define WGL_WGLEXT_VERSION 17
|
||||
#define WGL_WGLEXT_VERSION 15
|
||||
|
||||
#ifndef WGL_ARB_buffer_region
|
||||
#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001
|
||||
@@ -388,14 +388,6 @@ extern "C" {
|
||||
#define WGL_GPU_NUM_SPI_AMD 0x21A8
|
||||
#endif
|
||||
|
||||
#ifndef NV_video_capture
|
||||
#define WGL_UNIQUE_ID_NV 0x20CE
|
||||
#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF
|
||||
#endif
|
||||
|
||||
#ifndef NV_copy_image
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
@@ -408,7 +400,7 @@ DECLARE_HANDLE(HPBUFFEREXT);
|
||||
#ifndef WGL_NV_present_video
|
||||
DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV);
|
||||
#endif
|
||||
#ifndef WGL_NV_video_output
|
||||
#ifndef WGL_NV_video_out
|
||||
DECLARE_HANDLE(HPVIDEODEV);
|
||||
#endif
|
||||
#ifndef WGL_NV_gpu_affinity
|
||||
@@ -423,9 +415,6 @@ typedef struct _GPU_DEVICE {
|
||||
RECT rcVirtualScreen;
|
||||
} GPU_DEVICE, *PGPU_DEVICE;
|
||||
#endif
|
||||
#ifndef WGL_NV_video_capture
|
||||
DECLARE_HANDLE(HVIDEOINPUTDEVICENV);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_buffer_region
|
||||
#define WGL_ARB_buffer_region 1
|
||||
@@ -761,8 +750,8 @@ typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVide
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_video_output
|
||||
#define WGL_NV_video_output 1
|
||||
#ifndef WGL_NV_video_out
|
||||
#define WGL_NV_video_out 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern BOOL WINAPI wglGetVideoDeviceNV (HDC, int, HPVIDEODEV *);
|
||||
extern BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV);
|
||||
@@ -837,30 +826,6 @@ typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void);
|
||||
typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_video_capture
|
||||
#define WGL_NV_video_capture 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT, HVIDEOINPUTDEVICENV);
|
||||
extern UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC, HVIDEOINPUTDEVICENV *);
|
||||
extern BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC, HVIDEOINPUTDEVICENV);
|
||||
extern BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC, HVIDEOINPUTDEVICENV, int, int *);
|
||||
extern BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC, HVIDEOINPUTDEVICENV);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice);
|
||||
typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList);
|
||||
typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
|
||||
typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue);
|
||||
typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_NV_copy_image
|
||||
#define WGL_NV_copy_image 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
extern BOOL WINAPI wglCopyImageSubDataNV (HGLRC, GLuint, GLenum, GLint, GLint, GLint, GLint, HGLRC, GLuint, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei);
|
||||
#endif /* WGL_WGLEXT_PROTOTYPES */
|
||||
typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@@ -15,22 +15,18 @@ message:
|
||||
|
||||
|
||||
subdirs:
|
||||
@if test -n "$(SUBDIRS)" ; then \
|
||||
for dir in $(SUBDIRS) ; do \
|
||||
if [ -d $$dir ] ; then \
|
||||
(cd $$dir && $(MAKE)) || exit 1 ; \
|
||||
fi \
|
||||
done \
|
||||
fi
|
||||
@for dir in $(SUBDIRS) ; do \
|
||||
if [ -d $$dir ] ; then \
|
||||
(cd $$dir && $(MAKE)) || exit 1 ; \
|
||||
fi \
|
||||
done
|
||||
|
||||
# Dummy install target
|
||||
install:
|
||||
|
||||
clean:
|
||||
-@if test -n "$(SUBDIRS)" ; then \
|
||||
for dir in $(SUBDIRS) tests ; do \
|
||||
if [ -d $$dir ] ; then \
|
||||
(cd $$dir && $(MAKE) clean) ; \
|
||||
fi \
|
||||
done \
|
||||
fi
|
||||
-@for dir in $(SUBDIRS) tests ; do \
|
||||
if [ -d $$dir ] ; then \
|
||||
(cd $$dir && $(MAKE) clean) ; \
|
||||
fi \
|
||||
done
|
||||
|
@@ -26,6 +26,7 @@ static int Scissor = 0;
|
||||
static float Xzoom, Yzoom;
|
||||
static GLboolean DrawFront = GL_FALSE;
|
||||
static GLboolean Dither = GL_TRUE;
|
||||
static GLboolean Invert = GL_FALSE;
|
||||
|
||||
|
||||
static void Reset( void )
|
||||
@@ -59,6 +60,15 @@ static void Display( void )
|
||||
if (Scissor)
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
|
||||
if (Invert) {
|
||||
glPixelTransferf(GL_RED_SCALE, -1.0);
|
||||
glPixelTransferf(GL_GREEN_SCALE, -1.0);
|
||||
glPixelTransferf(GL_BLUE_SCALE, -1.0);
|
||||
glPixelTransferf(GL_RED_BIAS, 1.0);
|
||||
glPixelTransferf(GL_GREEN_BIAS, 1.0);
|
||||
glPixelTransferf(GL_BLUE_BIAS, 1.0);
|
||||
}
|
||||
|
||||
/* draw copy */
|
||||
glPixelZoom(Xzoom, Yzoom);
|
||||
glWindowPos2iARB(Xpos, Ypos);
|
||||
@@ -67,6 +77,15 @@ static void Display( void )
|
||||
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
|
||||
if (Invert) {
|
||||
glPixelTransferf(GL_RED_SCALE, 1.0);
|
||||
glPixelTransferf(GL_GREEN_SCALE, 1.0);
|
||||
glPixelTransferf(GL_BLUE_SCALE, 1.0);
|
||||
glPixelTransferf(GL_RED_BIAS, 0.0);
|
||||
glPixelTransferf(GL_GREEN_BIAS, 0.0);
|
||||
glPixelTransferf(GL_BLUE_BIAS, 0.0);
|
||||
}
|
||||
|
||||
if (DrawFront)
|
||||
glFinish();
|
||||
else
|
||||
@@ -105,6 +124,9 @@ static void Key( unsigned char key, int x, int y )
|
||||
else
|
||||
glDisable(GL_DITHER);
|
||||
break;
|
||||
case 'i':
|
||||
Invert = !Invert;
|
||||
break;
|
||||
case 's':
|
||||
Scissor = !Scissor;
|
||||
break;
|
||||
|
77
progs/es1/xegl/Makefile
Normal file
77
progs/es1/xegl/Makefile
Normal file
@@ -0,0 +1,77 @@
|
||||
# progs/es1/xegl/Makefile
|
||||
|
||||
TOP = ../../..
|
||||
include $(TOP)/configs/current
|
||||
|
||||
|
||||
INCLUDE_DIRS = \
|
||||
-I$(TOP)/include \
|
||||
|
||||
HEADERS = $(TOP)/include/GLES/egl.h
|
||||
|
||||
|
||||
ES1_LIB_DEPS = \
|
||||
$(TOP)/$(LIB_DIR)/libEGL.so \
|
||||
$(TOP)/$(LIB_DIR)/libGLESv1_CM.so
|
||||
|
||||
|
||||
ES1_LIBS = \
|
||||
-L$(TOP)/$(LIB_DIR) -lEGL \
|
||||
-L$(TOP)/$(LIB_DIR) -lGLESv1_CM $(LIBDRM_LIB) -lX11
|
||||
|
||||
PROGRAMS = \
|
||||
drawtex \
|
||||
es1_info \
|
||||
msaa \
|
||||
pbuffer \
|
||||
render_tex \
|
||||
torus \
|
||||
tri \
|
||||
two_win
|
||||
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
default: $(PROGRAMS)
|
||||
|
||||
|
||||
|
||||
drawtex: drawtex.o $(ES1_LIB_DEPS)
|
||||
$(CC) $(CFLAGS) drawtex.o $(ES1_LIBS) -o $@
|
||||
|
||||
|
||||
es1_info: es1_info.o $(ES1_LIB_DEPS)
|
||||
$(CC) $(CFLAGS) es1_info.o $(ES1_LIBS) -o $@
|
||||
|
||||
|
||||
msaa: msaa.o $(ES1_LIB_DEPS)
|
||||
$(CC) $(CFLAGS) msaa.o $(ES1_LIBS) -o $@
|
||||
|
||||
|
||||
pbuffer: pbuffer.o $(ES1_LIB_DEPS)
|
||||
$(CC) $(CFLAGS) pbuffer.o $(ES1_LIBS) -o $@
|
||||
|
||||
|
||||
render_tex: render_tex.o $(ES1_LIB_DEPS)
|
||||
$(CC) $(CFLAGS) render_tex.o $(ES1_LIBS) -o $@
|
||||
|
||||
|
||||
torus: torus.o $(ES1_LIB_DEPS)
|
||||
$(CC) $(CFLAGS) torus.o $(ES1_LIBS) -o $@
|
||||
|
||||
|
||||
two_win: two_win.o $(ES1_LIB_DEPS)
|
||||
$(CC) $(CFLAGS) two_win.o $(ES1_LIBS) -o $@
|
||||
|
||||
|
||||
tri: tri.o $(ES1_LIB_DEPS)
|
||||
$(CC) $(CFLAGS) tri.o $(ES1_LIBS) -o $@
|
||||
|
||||
|
||||
clean:
|
||||
rm -f *.o *~
|
||||
rm -f $(PROGRAMS)
|
||||
|
427
progs/es1/xegl/drawtex.c
Normal file
427
progs/es1/xegl/drawtex.c
Normal file
@@ -0,0 +1,427 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Tunsgten Graphics,Inc. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test GL_OES_draw_texture
|
||||
* Brian Paul
|
||||
* August 2008
|
||||
*/
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
#include <EGL/egl.h>
|
||||
|
||||
|
||||
|
||||
static GLfloat view_posx = 10.0, view_posy = 20.0;
|
||||
static GLfloat width = 200, height = 200;
|
||||
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glDrawTexfOES(view_posx, view_posy, 0.0, width, height);
|
||||
}
|
||||
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int width, int height)
|
||||
{
|
||||
GLfloat ar = (GLfloat) width / (GLfloat) height;
|
||||
|
||||
glViewport(0, 0, (GLint) width, (GLint) height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
||||
#ifdef GL_VERSION_ES_CM_1_0
|
||||
glFrustumf(-ar, ar, -1, 1, 5.0, 60.0);
|
||||
#else
|
||||
glFrustum(-ar, ar, -1, 1, 5.0, 60.0);
|
||||
#endif
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -15.0);
|
||||
}
|
||||
|
||||
|
||||
static float
|
||||
dist(GLuint i, GLuint j, float x, float y)
|
||||
{
|
||||
return sqrt((i-x) * (i-x) + (j-y) * (j-y));
|
||||
}
|
||||
|
||||
static void
|
||||
make_smile_texture(void)
|
||||
{
|
||||
#define SZ 128
|
||||
GLenum Filter = GL_LINEAR;
|
||||
GLubyte image[SZ][SZ][4];
|
||||
GLuint i, j;
|
||||
GLint cropRect[4];
|
||||
|
||||
for (i = 0; i < SZ; i++) {
|
||||
for (j = 0; j < SZ; j++) {
|
||||
GLfloat d_mouth = dist(i, j, SZ/2, SZ/2);
|
||||
GLfloat d_rt_eye = dist(i, j, SZ*3/4, SZ*3/4);
|
||||
GLfloat d_lt_eye = dist(i, j, SZ*3/4, SZ*1/4);
|
||||
if (d_rt_eye < SZ / 8 || d_lt_eye < SZ / 8) {
|
||||
image[i][j][0] = 20;
|
||||
image[i][j][1] = 50;
|
||||
image[i][j][2] = 255;
|
||||
image[i][j][3] = 255;
|
||||
}
|
||||
else if (i < SZ/2 && d_mouth < SZ/3) {
|
||||
image[i][j][0] = 255;
|
||||
image[i][j][1] = 20;
|
||||
image[i][j][2] = 20;
|
||||
image[i][j][3] = 255;
|
||||
}
|
||||
else {
|
||||
image[i][j][0] = 200;
|
||||
image[i][j][1] = 200;
|
||||
image[i][j][2] = 200;
|
||||
image[i][j][3] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE0); /* unit 0 */
|
||||
glBindTexture(GL_TEXTURE_2D, 42);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SZ, SZ, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, image);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, Filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, Filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
||||
cropRect[0] = 0;
|
||||
cropRect[1] = 0;
|
||||
cropRect[2] = SZ;
|
||||
cropRect[3] = SZ;
|
||||
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, cropRect);
|
||||
#undef SZ
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
const char *ext = (char *) glGetString(GL_EXTENSIONS);
|
||||
|
||||
if (!strstr(ext, "GL_OES_draw_texture")) {
|
||||
fprintf(stderr, "Sorry, this program requires GL_OES_draw_texture");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glClearColor(0.4, 0.4, 0.4, 0.0);
|
||||
|
||||
make_smile_texture();
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create an RGB, double-buffered X window.
|
||||
* Return the window and context handles.
|
||||
*/
|
||||
static void
|
||||
make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
|
||||
const char *name,
|
||||
int x, int y, int width, int height,
|
||||
Window *winRet,
|
||||
EGLContext *ctxRet,
|
||||
EGLSurface *surfRet)
|
||||
{
|
||||
static const EGLint attribs[] = {
|
||||
EGL_RED_SIZE, 1,
|
||||
EGL_GREEN_SIZE, 1,
|
||||
EGL_BLUE_SIZE, 1,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
int scrnum;
|
||||
XSetWindowAttributes attr;
|
||||
unsigned long mask;
|
||||
Window root;
|
||||
Window win;
|
||||
XVisualInfo *visInfo, visTemplate;
|
||||
int num_visuals;
|
||||
EGLContext ctx;
|
||||
EGLConfig config;
|
||||
EGLint num_configs;
|
||||
EGLint vid;
|
||||
|
||||
scrnum = DefaultScreen( x_dpy );
|
||||
root = RootWindow( x_dpy, scrnum );
|
||||
|
||||
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
|
||||
printf("Error: couldn't get an EGL visual config\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
assert(config);
|
||||
assert(num_configs > 0);
|
||||
|
||||
if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
||||
printf("Error: eglGetConfigAttrib() failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* The X window visual must match the EGL config */
|
||||
visTemplate.visualid = vid;
|
||||
visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
|
||||
if (!visInfo) {
|
||||
printf("Error: couldn't get X visual\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* window attributes */
|
||||
attr.background_pixel = 0;
|
||||
attr.border_pixel = 0;
|
||||
attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone);
|
||||
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
|
||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
||||
|
||||
win = XCreateWindow( x_dpy, root, 0, 0, width, height,
|
||||
0, visInfo->depth, InputOutput,
|
||||
visInfo->visual, mask, &attr );
|
||||
|
||||
/* set hints and properties */
|
||||
{
|
||||
XSizeHints sizehints;
|
||||
sizehints.x = x;
|
||||
sizehints.y = y;
|
||||
sizehints.width = width;
|
||||
sizehints.height = height;
|
||||
sizehints.flags = USSize | USPosition;
|
||||
XSetNormalHints(x_dpy, win, &sizehints);
|
||||
XSetStandardProperties(x_dpy, win, name, name,
|
||||
None, (char **)NULL, 0, &sizehints);
|
||||
}
|
||||
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
|
||||
ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL );
|
||||
if (!ctx) {
|
||||
printf("Error: eglCreateContext failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
*surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL);
|
||||
|
||||
if (!*surfRet) {
|
||||
printf("Error: eglCreateWindowSurface failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
XFree(visInfo);
|
||||
|
||||
*winRet = win;
|
||||
*ctxRet = ctx;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
event_loop(Display *dpy, Window win,
|
||||
EGLDisplay egl_dpy, EGLSurface egl_surf)
|
||||
{
|
||||
int anim = 0;
|
||||
|
||||
while (1) {
|
||||
int redraw = 0;
|
||||
|
||||
if (!anim || XPending(dpy)) {
|
||||
XEvent event;
|
||||
XNextEvent(dpy, &event);
|
||||
|
||||
switch (event.type) {
|
||||
case Expose:
|
||||
redraw = 1;
|
||||
break;
|
||||
case ConfigureNotify:
|
||||
reshape(event.xconfigure.width, event.xconfigure.height);
|
||||
break;
|
||||
case KeyPress:
|
||||
{
|
||||
char buffer[10];
|
||||
int r, code;
|
||||
code = XLookupKeysym(&event.xkey, 0);
|
||||
if (code == XK_Left) {
|
||||
view_posx -= 1.0;
|
||||
}
|
||||
else if (code == XK_Right) {
|
||||
view_posx += 1.0;
|
||||
}
|
||||
else if (code == XK_Up) {
|
||||
view_posy += 1.0;
|
||||
}
|
||||
else if (code == XK_Down) {
|
||||
view_posy -= 1.0;
|
||||
}
|
||||
else {
|
||||
r = XLookupString(&event.xkey, buffer, sizeof(buffer),
|
||||
NULL, NULL);
|
||||
if (buffer[0] == ' ') {
|
||||
anim = !anim;
|
||||
}
|
||||
else if (buffer[0] == 'w') {
|
||||
width -= 1.0f;
|
||||
}
|
||||
else if (buffer[0] == 'W') {
|
||||
width += 1.0f;
|
||||
}
|
||||
else if (buffer[0] == 'h') {
|
||||
height -= 1.0f;
|
||||
}
|
||||
else if (buffer[0] == 'H') {
|
||||
height += 1.0f;
|
||||
}
|
||||
else if (buffer[0] == 27) {
|
||||
/* escape */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
redraw = 1;
|
||||
break;
|
||||
default:
|
||||
; /*no-op*/
|
||||
}
|
||||
}
|
||||
|
||||
if (anim) {
|
||||
view_posx += 1.0;
|
||||
view_posy += 2.0;
|
||||
redraw = 1;
|
||||
}
|
||||
|
||||
if (redraw) {
|
||||
draw();
|
||||
eglSwapBuffers(egl_dpy, egl_surf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf(" -display <displayname> set the display to run on\n");
|
||||
printf(" -info display OpenGL renderer info\n");
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
const int winWidth = 400, winHeight = 300;
|
||||
Display *x_dpy;
|
||||
Window win;
|
||||
EGLSurface egl_surf;
|
||||
EGLContext egl_ctx;
|
||||
EGLDisplay egl_dpy;
|
||||
char *dpyName = NULL;
|
||||
GLboolean printInfo = GL_FALSE;
|
||||
EGLint egl_major, egl_minor;
|
||||
int i;
|
||||
const char *s;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-display") == 0) {
|
||||
dpyName = argv[i+1];
|
||||
i++;
|
||||
}
|
||||
else if (strcmp(argv[i], "-info") == 0) {
|
||||
printInfo = GL_TRUE;
|
||||
}
|
||||
else {
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
x_dpy = XOpenDisplay(dpyName);
|
||||
if (!x_dpy) {
|
||||
printf("Error: couldn't open display %s\n",
|
||||
dpyName ? dpyName : getenv("DISPLAY"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
egl_dpy = eglGetDisplay(x_dpy);
|
||||
if (!egl_dpy) {
|
||||
printf("Error: eglGetDisplay() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
|
||||
printf("Error: eglInitialize() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_VERSION);
|
||||
printf("EGL_VERSION = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_VENDOR);
|
||||
printf("EGL_VENDOR = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_EXTENSIONS);
|
||||
printf("EGL_EXTENSIONS = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_CLIENT_APIS);
|
||||
printf("EGL_CLIENT_APIS = %s\n", s);
|
||||
|
||||
make_x_window(x_dpy, egl_dpy,
|
||||
"drawtex", 0, 0, winWidth, winHeight,
|
||||
&win, &egl_ctx, &egl_surf);
|
||||
|
||||
XMapWindow(x_dpy, win);
|
||||
if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) {
|
||||
printf("Error: eglMakeCurrent() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (printInfo) {
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
/* Set initial projection/viewing transformation.
|
||||
* We can't be sure we'll get a ConfigureNotify event when the window
|
||||
* first appears.
|
||||
*/
|
||||
reshape(winWidth, winHeight);
|
||||
|
||||
event_loop(x_dpy, win, egl_dpy, egl_surf);
|
||||
|
||||
eglDestroyContext(egl_dpy, egl_ctx);
|
||||
eglDestroySurface(egl_dpy, egl_surf);
|
||||
eglTerminate(egl_dpy);
|
||||
|
||||
|
||||
XDestroyWindow(x_dpy, win);
|
||||
XCloseDisplay(x_dpy);
|
||||
|
||||
return 0;
|
||||
}
|
274
progs/es1/xegl/es1_info.c
Normal file
274
progs/es1/xegl/es1_info.c
Normal file
@@ -0,0 +1,274 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Tunsgten Graphics,Inc. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* List OpenGL ES extensions.
|
||||
* Print ES 1 or ES 2 extensions depending on which library we're
|
||||
* linked with: libGLESv1_CM.so vs libGLESv2.so
|
||||
*/
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
#include <EGL/egl.h>
|
||||
|
||||
|
||||
/*
|
||||
* Print a list of extensions, with word-wrapping.
|
||||
*/
|
||||
static void
|
||||
print_extension_list(const char *ext)
|
||||
{
|
||||
const char *indentString = " ";
|
||||
const int indent = 4;
|
||||
const int max = 79;
|
||||
int width, i, j;
|
||||
|
||||
if (!ext || !ext[0])
|
||||
return;
|
||||
|
||||
width = indent;
|
||||
printf(indentString);
|
||||
i = j = 0;
|
||||
while (1) {
|
||||
if (ext[j] == ' ' || ext[j] == 0) {
|
||||
/* found end of an extension name */
|
||||
const int len = j - i;
|
||||
if (width + len > max) {
|
||||
/* start a new line */
|
||||
printf("\n");
|
||||
width = indent;
|
||||
printf(indentString);
|
||||
}
|
||||
/* print the extension name between ext[i] and ext[j] */
|
||||
while (i < j) {
|
||||
printf("%c", ext[i]);
|
||||
i++;
|
||||
}
|
||||
/* either we're all done, or we'll continue with next extension */
|
||||
width += len + 1;
|
||||
if (ext[j] == 0) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
i++;
|
||||
j++;
|
||||
if (ext[j] == 0)
|
||||
break;
|
||||
printf(", ");
|
||||
width += 2;
|
||||
}
|
||||
}
|
||||
j++;
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
info(EGLDisplay egl_dpy)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_VERSION);
|
||||
printf("EGL_VERSION = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_VENDOR);
|
||||
printf("EGL_VENDOR = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_EXTENSIONS);
|
||||
printf("EGL_EXTENSIONS = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_CLIENT_APIS);
|
||||
printf("EGL_CLIENT_APIS = %s\n", s);
|
||||
|
||||
printf("GL_VERSION: %s\n", (char *) glGetString(GL_VERSION));
|
||||
printf("GL_RENDERER: %s\n", (char *) glGetString(GL_RENDERER));
|
||||
printf("GL_EXTENSIONS:\n");
|
||||
print_extension_list((char *) glGetString(GL_EXTENSIONS));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create an RGB, double-buffered X window.
|
||||
* Return the window and context handles.
|
||||
*/
|
||||
static void
|
||||
make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
|
||||
const char *name,
|
||||
int x, int y, int width, int height,
|
||||
Window *winRet,
|
||||
EGLContext *ctxRet,
|
||||
EGLSurface *surfRet)
|
||||
{
|
||||
static const EGLint attribs[] = {
|
||||
EGL_RED_SIZE, 1,
|
||||
EGL_GREEN_SIZE, 1,
|
||||
EGL_BLUE_SIZE, 1,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
int scrnum;
|
||||
XSetWindowAttributes attr;
|
||||
unsigned long mask;
|
||||
Window root;
|
||||
Window win;
|
||||
XVisualInfo *visInfo, visTemplate;
|
||||
int num_visuals;
|
||||
EGLContext ctx;
|
||||
EGLConfig config;
|
||||
EGLint num_configs;
|
||||
EGLint vid;
|
||||
|
||||
scrnum = DefaultScreen( x_dpy );
|
||||
root = RootWindow( x_dpy, scrnum );
|
||||
|
||||
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
|
||||
printf("Error: couldn't get an EGL visual config\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
assert(config);
|
||||
assert(num_configs > 0);
|
||||
|
||||
if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
||||
printf("Error: eglGetConfigAttrib() failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* The X window visual must match the EGL config */
|
||||
visTemplate.visualid = vid;
|
||||
visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
|
||||
if (!visInfo) {
|
||||
printf("Error: couldn't get X visual\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* window attributes */
|
||||
attr.background_pixel = 0;
|
||||
attr.border_pixel = 0;
|
||||
attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone);
|
||||
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
|
||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
||||
|
||||
win = XCreateWindow( x_dpy, root, 0, 0, width, height,
|
||||
0, visInfo->depth, InputOutput,
|
||||
visInfo->visual, mask, &attr );
|
||||
|
||||
/* set hints and properties */
|
||||
{
|
||||
XSizeHints sizehints;
|
||||
sizehints.x = x;
|
||||
sizehints.y = y;
|
||||
sizehints.width = width;
|
||||
sizehints.height = height;
|
||||
sizehints.flags = USSize | USPosition;
|
||||
XSetNormalHints(x_dpy, win, &sizehints);
|
||||
XSetStandardProperties(x_dpy, win, name, name,
|
||||
None, (char **)NULL, 0, &sizehints);
|
||||
}
|
||||
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
|
||||
ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL );
|
||||
if (!ctx) {
|
||||
printf("Error: eglCreateContext failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
*surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL);
|
||||
|
||||
if (!*surfRet) {
|
||||
printf("Error: eglCreateWindowSurface failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
XFree(visInfo);
|
||||
|
||||
*winRet = win;
|
||||
*ctxRet = ctx;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf(" -display <displayname> set the display to run on\n");
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
const int winWidth = 400, winHeight = 300;
|
||||
Display *x_dpy;
|
||||
Window win;
|
||||
EGLSurface egl_surf;
|
||||
EGLContext egl_ctx;
|
||||
EGLDisplay egl_dpy;
|
||||
char *dpyName = NULL;
|
||||
EGLint egl_major, egl_minor;
|
||||
int i;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-display") == 0) {
|
||||
dpyName = argv[i+1];
|
||||
i++;
|
||||
}
|
||||
else {
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
x_dpy = XOpenDisplay(dpyName);
|
||||
if (!x_dpy) {
|
||||
printf("Error: couldn't open display %s\n",
|
||||
dpyName ? dpyName : getenv("DISPLAY"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
egl_dpy = eglGetDisplay(x_dpy);
|
||||
if (!egl_dpy) {
|
||||
printf("Error: eglGetDisplay() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
|
||||
printf("Error: eglInitialize() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
make_x_window(x_dpy, egl_dpy,
|
||||
"ES info", 0, 0, winWidth, winHeight,
|
||||
&win, &egl_ctx, &egl_surf);
|
||||
|
||||
/*XMapWindow(x_dpy, win);*/
|
||||
if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) {
|
||||
printf("Error: eglMakeCurrent() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
info(egl_dpy);
|
||||
|
||||
eglDestroyContext(egl_dpy, egl_ctx);
|
||||
eglDestroySurface(egl_dpy, egl_surf);
|
||||
eglTerminate(egl_dpy);
|
||||
|
||||
|
||||
XDestroyWindow(x_dpy, win);
|
||||
XCloseDisplay(x_dpy);
|
||||
|
||||
return 0;
|
||||
}
|
442
progs/es1/xegl/msaa.c
Normal file
442
progs/es1/xegl/msaa.c
Normal file
@@ -0,0 +1,442 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test MSAA with X/EGL and OpenGL ES 1.x
|
||||
* Brian Paul
|
||||
* 15 September 2008
|
||||
*/
|
||||
|
||||
#define USE_FULL_GL 0
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#if USE_FULL_GL
|
||||
#include <GL/gl.h> /* use full OpenGL */
|
||||
#else
|
||||
#include <GLES/gl.h> /* use OpenGL ES 1.x */
|
||||
#include <GLES/glext.h>
|
||||
#endif
|
||||
#include <EGL/egl.h>
|
||||
|
||||
|
||||
|
||||
static GLfloat view_rotx = 0.0, view_roty = 0.0, view_rotz = 0.0;
|
||||
static GLboolean AA = 0*GL_TRUE;
|
||||
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
float a;
|
||||
|
||||
static const GLfloat verts[4][2] = {
|
||||
{ -1, -.1 },
|
||||
{ 1, -.1 },
|
||||
{ -1, .1 },
|
||||
{ 1, .1 }
|
||||
};
|
||||
static const GLfloat colors[4][4] = {
|
||||
{ 1, 0, 0, 1 },
|
||||
{ 0, 1, 0, 1 },
|
||||
{ 0, 0, 1, 1 },
|
||||
{ 1, 0, 1, 1 }
|
||||
};
|
||||
|
||||
if (AA) {
|
||||
printf("MSAA enabled\n");
|
||||
glEnable(GL_MULTISAMPLE);
|
||||
}
|
||||
else {
|
||||
printf("MSAA disabled\n");
|
||||
glDisable(GL_MULTISAMPLE);
|
||||
}
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(view_rotx, 1, 0, 0);
|
||||
glRotatef(view_roty, 0, 1, 0);
|
||||
glRotatef(view_rotz, 0, 0, 1);
|
||||
|
||||
{
|
||||
glVertexPointer(2, GL_FLOAT, 0, verts);
|
||||
glColorPointer(4, GL_FLOAT, 0, colors);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
for (a = 0; a < 360; a += 20.0) {
|
||||
glPushMatrix();
|
||||
|
||||
glRotatef(a, 0, 0, 1);
|
||||
glTranslatef(1.5, 0, 0);
|
||||
|
||||
/* draw triangle */
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int width, int height)
|
||||
{
|
||||
GLfloat ary = 3.0;
|
||||
GLfloat arx = ary * (GLfloat) width / (GLfloat) height;
|
||||
|
||||
glViewport(0, 0, (GLint) width, (GLint) height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
#ifdef GL_VERSION_ES_CM_1_0
|
||||
glOrthof(-arx, arx, -ary, ary, -1.0, 1.0);
|
||||
#else
|
||||
glOrtho(-arx, arx, -ary, ary, -1.0, 1.0);
|
||||
#endif
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
printf("Press 'a' to toggle multisample antialiasing\n");
|
||||
printf("Press 'Esc' to exit\n");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create an RGB, double-buffered X window.
|
||||
* Return the window and context handles.
|
||||
*/
|
||||
static void
|
||||
make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
|
||||
const char *name,
|
||||
int x, int y, int width, int height,
|
||||
Window *winRet,
|
||||
EGLContext *ctxRet,
|
||||
EGLSurface *surfRet)
|
||||
{
|
||||
static const EGLint attribs[] = {
|
||||
EGL_RED_SIZE, 1,
|
||||
EGL_GREEN_SIZE, 1,
|
||||
EGL_BLUE_SIZE, 1,
|
||||
EGL_DEPTH_SIZE, 1,
|
||||
EGL_SAMPLES, 1,
|
||||
EGL_SAMPLE_BUFFERS, 1,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
int scrnum;
|
||||
XSetWindowAttributes attr;
|
||||
unsigned long mask;
|
||||
Window root;
|
||||
Window win;
|
||||
XVisualInfo *visInfo, visTemplate;
|
||||
int num_visuals;
|
||||
EGLContext ctx;
|
||||
EGLConfig config;
|
||||
EGLint num_configs;
|
||||
EGLint vid;
|
||||
|
||||
scrnum = DefaultScreen( x_dpy );
|
||||
root = RootWindow( x_dpy, scrnum );
|
||||
|
||||
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
|
||||
printf("Error: couldn't get an EGL visual config\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (num_configs < 1) {
|
||||
printf("Error: Unable to find multisample pixel format.\n");
|
||||
printf("Try running glxinfo to see if your server supports MSAA.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
||||
printf("Error: eglGetConfigAttrib() failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* The X window visual must match the EGL config */
|
||||
visTemplate.visualid = vid;
|
||||
visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
|
||||
if (!visInfo) {
|
||||
printf("Error: couldn't get X visual\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* window attributes */
|
||||
attr.background_pixel = 0;
|
||||
attr.border_pixel = 0;
|
||||
attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone);
|
||||
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
|
||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
||||
|
||||
win = XCreateWindow( x_dpy, root, 0, 0, width, height,
|
||||
0, visInfo->depth, InputOutput,
|
||||
visInfo->visual, mask, &attr );
|
||||
|
||||
/* set hints and properties */
|
||||
{
|
||||
XSizeHints sizehints;
|
||||
sizehints.x = x;
|
||||
sizehints.y = y;
|
||||
sizehints.width = width;
|
||||
sizehints.height = height;
|
||||
sizehints.flags = USSize | USPosition;
|
||||
XSetNormalHints(x_dpy, win, &sizehints);
|
||||
XSetStandardProperties(x_dpy, win, name, name,
|
||||
None, (char **)NULL, 0, &sizehints);
|
||||
}
|
||||
|
||||
#if USE_FULL_GL
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
#else
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
#endif
|
||||
|
||||
ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL );
|
||||
if (!ctx) {
|
||||
printf("Error: eglCreateContext failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
*surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL);
|
||||
|
||||
if (!*surfRet) {
|
||||
printf("Error: eglCreateWindowSurface failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
XFree(visInfo);
|
||||
|
||||
*winRet = win;
|
||||
*ctxRet = ctx;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
event_loop(Display *dpy, Window win,
|
||||
EGLDisplay egl_dpy, EGLSurface egl_surf)
|
||||
{
|
||||
while (1) {
|
||||
int redraw = 0;
|
||||
XEvent event;
|
||||
|
||||
XNextEvent(dpy, &event);
|
||||
|
||||
switch (event.type) {
|
||||
case Expose:
|
||||
redraw = 1;
|
||||
break;
|
||||
case ConfigureNotify:
|
||||
reshape(event.xconfigure.width, event.xconfigure.height);
|
||||
break;
|
||||
case KeyPress:
|
||||
{
|
||||
char buffer[10];
|
||||
int r, code;
|
||||
code = XLookupKeysym(&event.xkey, 0);
|
||||
if (code == XK_Left) {
|
||||
view_roty += 5.0;
|
||||
}
|
||||
else if (code == XK_Right) {
|
||||
view_roty -= 5.0;
|
||||
}
|
||||
else if (code == XK_Up) {
|
||||
view_rotx += 5.0;
|
||||
}
|
||||
else if (code == XK_Down) {
|
||||
view_rotx -= 5.0;
|
||||
}
|
||||
else {
|
||||
r = XLookupString(&event.xkey, buffer, sizeof(buffer),
|
||||
NULL, NULL);
|
||||
if (buffer[0] == 'a') {
|
||||
AA = !AA;
|
||||
redraw = 1;
|
||||
}
|
||||
else if (buffer[0] == 27) {
|
||||
/* escape */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
redraw = 1;
|
||||
break;
|
||||
default:
|
||||
; /*no-op*/
|
||||
}
|
||||
|
||||
if (redraw) {
|
||||
draw();
|
||||
eglSwapBuffers(egl_dpy, egl_surf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf(" -display <displayname> set the display to run on\n");
|
||||
printf(" -info display OpenGL renderer info\n");
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
const int winWidth = 600, winHeight = 600;
|
||||
Display *x_dpy;
|
||||
Window win;
|
||||
EGLSurface egl_surf;
|
||||
EGLContext egl_ctx;
|
||||
EGLDisplay egl_dpy;
|
||||
char *dpyName = NULL;
|
||||
GLboolean printInfo = GL_FALSE;
|
||||
EGLint egl_major, egl_minor;
|
||||
int i;
|
||||
const char *s;
|
||||
|
||||
static struct {
|
||||
char *name;
|
||||
GLenum value;
|
||||
enum {GetString, GetInteger} type;
|
||||
} info_items[] = {
|
||||
{"GL_RENDERER", GL_RENDERER, GetString},
|
||||
{"GL_VERSION", GL_VERSION, GetString},
|
||||
{"GL_VENDOR", GL_VENDOR, GetString},
|
||||
{"GL_EXTENSIONS", GL_EXTENSIONS, GetString},
|
||||
{"GL_MAX_PALETTE_MATRICES_OES", GL_MAX_PALETTE_MATRICES_OES, GetInteger},
|
||||
{"GL_MAX_VERTEX_UNITS_OES", GL_MAX_VERTEX_UNITS_OES, GetInteger},
|
||||
};
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-display") == 0) {
|
||||
dpyName = argv[i+1];
|
||||
i++;
|
||||
}
|
||||
else if (strcmp(argv[i], "-info") == 0) {
|
||||
printInfo = GL_TRUE;
|
||||
}
|
||||
else {
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
x_dpy = XOpenDisplay(dpyName);
|
||||
if (!x_dpy) {
|
||||
printf("Error: couldn't open display %s\n",
|
||||
dpyName ? dpyName : getenv("DISPLAY"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
egl_dpy = eglGetDisplay(x_dpy);
|
||||
if (!egl_dpy) {
|
||||
printf("Error: eglGetDisplay() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
|
||||
printf("Error: eglInitialize() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_VERSION);
|
||||
printf("EGL_VERSION = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_VENDOR);
|
||||
printf("EGL_VENDOR = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_EXTENSIONS);
|
||||
printf("EGL_EXTENSIONS = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_CLIENT_APIS);
|
||||
printf("EGL_CLIENT_APIS = %s\n", s);
|
||||
|
||||
make_x_window(x_dpy, egl_dpy,
|
||||
"msaa", 0, 0, winWidth, winHeight,
|
||||
&win, &egl_ctx, &egl_surf);
|
||||
|
||||
XMapWindow(x_dpy, win);
|
||||
if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) {
|
||||
printf("Error: eglMakeCurrent() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (printInfo) {
|
||||
for (i = 0; i < sizeof(info_items)/sizeof(info_items[0]); i++) {
|
||||
switch (info_items[i].type) {
|
||||
case GetString:
|
||||
printf("%s = %s\n", info_items[i].name, (char *)glGetString(info_items[i].value));
|
||||
break;
|
||||
case GetInteger: {
|
||||
GLint rv = -1;
|
||||
glGetIntegerv(info_items[i].value, &rv);
|
||||
printf("%s = %d\n", info_items[i].name, rv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
init();
|
||||
|
||||
/* Set initial projection/viewing transformation.
|
||||
* We can't be sure we'll get a ConfigureNotify event when the window
|
||||
* first appears.
|
||||
*/
|
||||
reshape(winWidth, winHeight);
|
||||
|
||||
event_loop(x_dpy, win, egl_dpy, egl_surf);
|
||||
|
||||
eglDestroyContext(egl_dpy, egl_ctx);
|
||||
eglDestroySurface(egl_dpy, egl_surf);
|
||||
eglTerminate(egl_dpy);
|
||||
|
||||
|
||||
XDestroyWindow(x_dpy, win);
|
||||
XCloseDisplay(x_dpy);
|
||||
|
||||
return 0;
|
||||
}
|
607
progs/es1/xegl/pbuffer.c
Normal file
607
progs/es1/xegl/pbuffer.c
Normal file
@@ -0,0 +1,607 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Tunsgten Graphics,Inc. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test EGL Pbuffers
|
||||
* Brian Paul
|
||||
* August 2008
|
||||
*/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
#include <EGL/egl.h>
|
||||
|
||||
|
||||
|
||||
static int WinWidth = 300, WinHeight = 300;
|
||||
|
||||
static GLfloat view_rotx = 0.0, view_roty = 0.0, view_rotz = 0.0;
|
||||
|
||||
|
||||
static void
|
||||
Normal(GLfloat *n, GLfloat nx, GLfloat ny, GLfloat nz)
|
||||
{
|
||||
n[0] = nx;
|
||||
n[1] = ny;
|
||||
n[2] = nz;
|
||||
}
|
||||
|
||||
static void
|
||||
Vertex(GLfloat *v, GLfloat vx, GLfloat vy, GLfloat vz)
|
||||
{
|
||||
v[0] = vx;
|
||||
v[1] = vy;
|
||||
v[2] = vz;
|
||||
}
|
||||
|
||||
static void
|
||||
Texcoord(GLfloat *v, GLfloat s, GLfloat t)
|
||||
{
|
||||
v[0] = s;
|
||||
v[1] = t;
|
||||
}
|
||||
|
||||
|
||||
/* Borrowed from glut, adapted */
|
||||
static void
|
||||
draw_torus(GLfloat r, GLfloat R, GLint nsides, GLint rings)
|
||||
{
|
||||
int i, j;
|
||||
GLfloat theta, phi, theta1;
|
||||
GLfloat cosTheta, sinTheta;
|
||||
GLfloat cosTheta1, sinTheta1;
|
||||
GLfloat ringDelta, sideDelta;
|
||||
GLfloat varray[100][3], narray[100][3], tarray[100][2];
|
||||
int vcount;
|
||||
|
||||
glVertexPointer(3, GL_FLOAT, 0, varray);
|
||||
glNormalPointer(GL_FLOAT, 0, narray);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, tarray);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
ringDelta = 2.0 * M_PI / rings;
|
||||
sideDelta = 2.0 * M_PI / nsides;
|
||||
|
||||
theta = 0.0;
|
||||
cosTheta = 1.0;
|
||||
sinTheta = 0.0;
|
||||
for (i = rings - 1; i >= 0; i--) {
|
||||
theta1 = theta + ringDelta;
|
||||
cosTheta1 = cos(theta1);
|
||||
sinTheta1 = sin(theta1);
|
||||
|
||||
vcount = 0; /* glBegin(GL_QUAD_STRIP); */
|
||||
|
||||
phi = 0.0;
|
||||
for (j = nsides; j >= 0; j--) {
|
||||
GLfloat s0, s1, t;
|
||||
GLfloat cosPhi, sinPhi, dist;
|
||||
|
||||
phi += sideDelta;
|
||||
cosPhi = cos(phi);
|
||||
sinPhi = sin(phi);
|
||||
dist = R + r * cosPhi;
|
||||
|
||||
s0 = 20.0 * theta / (2.0 * M_PI);
|
||||
s1 = 20.0 * theta1 / (2.0 * M_PI);
|
||||
t = 8.0 * phi / (2.0 * M_PI);
|
||||
|
||||
Normal(narray[vcount], cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
|
||||
Texcoord(tarray[vcount], s1, t);
|
||||
Vertex(varray[vcount], cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
|
||||
vcount++;
|
||||
|
||||
Normal(narray[vcount], cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
|
||||
Texcoord(tarray[vcount], s0, t);
|
||||
Vertex(varray[vcount], cosTheta * dist, -sinTheta * dist, r * sinPhi);
|
||||
vcount++;
|
||||
}
|
||||
|
||||
/*glEnd();*/
|
||||
assert(vcount <= 100);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, vcount);
|
||||
|
||||
theta = theta1;
|
||||
cosTheta = cosTheta1;
|
||||
sinTheta = sinTheta1;
|
||||
}
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(view_rotx, 1, 0, 0);
|
||||
glRotatef(view_roty, 0, 1, 0);
|
||||
glRotatef(view_rotz, 0, 0, 1);
|
||||
glScalef(0.5, 0.5, 0.5);
|
||||
|
||||
draw_torus(1.0, 3.0, 30, 60);
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glFinish();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draw to both the window and pbuffer and compare results.
|
||||
*/
|
||||
static void
|
||||
draw_both(EGLDisplay egl_dpy, EGLSurface egl_surf, EGLSurface egl_pbuf,
|
||||
EGLContext egl_ctx)
|
||||
{
|
||||
unsigned *wbuf, *pbuf;
|
||||
int x = 100, y = 110;
|
||||
int i, dif;
|
||||
|
||||
wbuf = (unsigned *) malloc(WinWidth * WinHeight * 4);
|
||||
pbuf = (unsigned *) malloc(WinWidth * WinHeight * 4);
|
||||
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
|
||||
/* first draw to window */
|
||||
if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) {
|
||||
printf("Error: eglMakeCurrent(window) failed\n");
|
||||
return;
|
||||
}
|
||||
draw();
|
||||
glReadPixels(0, 0, WinWidth, WinHeight, GL_RGBA, GL_UNSIGNED_BYTE, wbuf);
|
||||
printf("Window[%d,%d] = 0x%08x\n", x, y, wbuf[y*WinWidth+x]);
|
||||
|
||||
/* then draw to pbuffer */
|
||||
if (!eglMakeCurrent(egl_dpy, egl_pbuf, egl_pbuf, egl_ctx)) {
|
||||
printf("Error: eglMakeCurrent(pbuffer) failed\n");
|
||||
return;
|
||||
}
|
||||
draw();
|
||||
glReadPixels(0, 0, WinWidth, WinHeight, GL_RGBA, GL_UNSIGNED_BYTE, pbuf);
|
||||
printf("Pbuffer[%d,%d] = 0x%08x\n", x, y, pbuf[y*WinWidth+x]);
|
||||
|
||||
eglSwapBuffers(egl_dpy, egl_surf);
|
||||
|
||||
/* compare renderings */
|
||||
for (dif = i = 0; i < WinWidth * WinHeight; i++) {
|
||||
if (wbuf[i] != pbuf[i]) {
|
||||
dif = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (dif)
|
||||
printf("Difference at %d: 0x%08x vs. 0x%08x\n", i, wbuf[i], pbuf[i]);
|
||||
else
|
||||
printf("Window rendering matches Pbuffer rendering!\n");
|
||||
|
||||
free(wbuf);
|
||||
free(pbuf);
|
||||
}
|
||||
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int width, int height)
|
||||
{
|
||||
GLfloat ar = (GLfloat) width / (GLfloat) height;
|
||||
|
||||
WinWidth = width;
|
||||
WinHeight = height;
|
||||
|
||||
glViewport(0, 0, (GLint) width, (GLint) height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
||||
#ifdef GL_VERSION_ES_CM_1_0
|
||||
glFrustumf(-ar, ar, -1, 1, 5.0, 60.0);
|
||||
#else
|
||||
glFrustum(-ar, ar, -1, 1, 5.0, 60.0);
|
||||
#endif
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -15.0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
make_texture(void)
|
||||
{
|
||||
#define SZ 64
|
||||
GLenum Filter = GL_LINEAR;
|
||||
GLubyte image[SZ][SZ][4];
|
||||
GLuint i, j;
|
||||
|
||||
for (i = 0; i < SZ; i++) {
|
||||
for (j = 0; j < SZ; j++) {
|
||||
GLfloat d = (i - SZ/2) * (i - SZ/2) + (j - SZ/2) * (j - SZ/2);
|
||||
d = sqrt(d);
|
||||
if (d < SZ/3) {
|
||||
image[i][j][0] = 255;
|
||||
image[i][j][1] = 255;
|
||||
image[i][j][2] = 255;
|
||||
image[i][j][3] = 255;
|
||||
}
|
||||
else {
|
||||
image[i][j][0] = 127;
|
||||
image[i][j][1] = 127;
|
||||
image[i][j][2] = 127;
|
||||
image[i][j][3] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE0); /* unit 0 */
|
||||
glBindTexture(GL_TEXTURE_2D, 42);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SZ, SZ, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, image);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, Filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, Filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
#undef SZ
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
static const GLfloat red[4] = {1, 0, 0, 0};
|
||||
static const GLfloat white[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
static const GLfloat diffuse[4] = {0.7, 0.7, 0.7, 1.0};
|
||||
static const GLfloat specular[4] = {0.001, 0.001, 0.001, 1.0};
|
||||
static const GLfloat pos[4] = {20, 20, 50, 1};
|
||||
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, red);
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white);
|
||||
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 9.0);
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, pos);
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
|
||||
glLightfv(GL_LIGHT0, GL_SPECULAR, specular);
|
||||
|
||||
glClearColor(0.4, 0.4, 0.4, 0.0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
make_texture();
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create an RGB, double-buffered X window.
|
||||
* Return the window and context handles.
|
||||
*/
|
||||
static void
|
||||
make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
|
||||
const char *name,
|
||||
int x, int y, int width, int height,
|
||||
Window *winRet,
|
||||
EGLContext *ctxRet,
|
||||
EGLSurface *surfRet)
|
||||
{
|
||||
static const EGLint attribs[] = {
|
||||
EGL_RED_SIZE, 1,
|
||||
EGL_GREEN_SIZE, 1,
|
||||
EGL_BLUE_SIZE, 1,
|
||||
EGL_DEPTH_SIZE, 1,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
int scrnum;
|
||||
XSetWindowAttributes attr;
|
||||
unsigned long mask;
|
||||
Window root;
|
||||
Window win;
|
||||
XVisualInfo *visInfo, visTemplate;
|
||||
int num_visuals;
|
||||
EGLContext ctx;
|
||||
EGLConfig config;
|
||||
EGLint num_configs;
|
||||
EGLint vid;
|
||||
|
||||
scrnum = DefaultScreen( x_dpy );
|
||||
root = RootWindow( x_dpy, scrnum );
|
||||
|
||||
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
|
||||
printf("Error: couldn't get an EGL visual config\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
assert(config);
|
||||
assert(num_configs > 0);
|
||||
|
||||
if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
||||
printf("Error: eglGetConfigAttrib() failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* The X window visual must match the EGL config */
|
||||
visTemplate.visualid = vid;
|
||||
visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
|
||||
if (!visInfo) {
|
||||
printf("Error: couldn't get X visual\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* window attributes */
|
||||
attr.background_pixel = 0;
|
||||
attr.border_pixel = 0;
|
||||
attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone);
|
||||
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
|
||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
||||
|
||||
win = XCreateWindow( x_dpy, root, 0, 0, width, height,
|
||||
0, visInfo->depth, InputOutput,
|
||||
visInfo->visual, mask, &attr );
|
||||
|
||||
/* set hints and properties */
|
||||
{
|
||||
XSizeHints sizehints;
|
||||
sizehints.x = x;
|
||||
sizehints.y = y;
|
||||
sizehints.width = width;
|
||||
sizehints.height = height;
|
||||
sizehints.flags = USSize | USPosition;
|
||||
XSetNormalHints(x_dpy, win, &sizehints);
|
||||
XSetStandardProperties(x_dpy, win, name, name,
|
||||
None, (char **)NULL, 0, &sizehints);
|
||||
}
|
||||
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
|
||||
ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL );
|
||||
if (!ctx) {
|
||||
printf("Error: eglCreateContext failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
*surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL);
|
||||
|
||||
if (!*surfRet) {
|
||||
printf("Error: eglCreateWindowSurface failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
XFree(visInfo);
|
||||
|
||||
*winRet = win;
|
||||
*ctxRet = ctx;
|
||||
}
|
||||
|
||||
|
||||
static EGLSurface
|
||||
make_pbuffer(Display *x_dpy, EGLDisplay egl_dpy, int width, int height)
|
||||
{
|
||||
static const EGLint config_attribs[] = {
|
||||
EGL_RED_SIZE, 1,
|
||||
EGL_GREEN_SIZE, 1,
|
||||
EGL_BLUE_SIZE, 1,
|
||||
EGL_DEPTH_SIZE, 1,
|
||||
EGL_NONE
|
||||
};
|
||||
EGLConfig config;
|
||||
EGLSurface pbuf;
|
||||
EGLint num_configs;
|
||||
EGLint pbuf_attribs[5];
|
||||
|
||||
pbuf_attribs[0] = EGL_WIDTH;
|
||||
pbuf_attribs[1] = width;
|
||||
pbuf_attribs[2] = EGL_HEIGHT;
|
||||
pbuf_attribs[3] = height;
|
||||
pbuf_attribs[4] = EGL_NONE;
|
||||
|
||||
if (!eglChooseConfig( egl_dpy, config_attribs, &config, 1, &num_configs)) {
|
||||
printf("Error: couldn't get an EGL config for pbuffer\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pbuf = eglCreatePbufferSurface(egl_dpy, config, pbuf_attribs);
|
||||
|
||||
return pbuf;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
event_loop(Display *dpy, Window win,
|
||||
EGLDisplay egl_dpy, EGLSurface egl_surf, EGLSurface egl_pbuf,
|
||||
EGLContext egl_ctx)
|
||||
{
|
||||
int anim = 0;
|
||||
|
||||
while (1) {
|
||||
int redraw = 0;
|
||||
|
||||
if (!anim || XPending(dpy)) {
|
||||
XEvent event;
|
||||
XNextEvent(dpy, &event);
|
||||
|
||||
switch (event.type) {
|
||||
case Expose:
|
||||
redraw = 1;
|
||||
break;
|
||||
case ConfigureNotify:
|
||||
if (event.xconfigure.window == win)
|
||||
reshape(event.xconfigure.width, event.xconfigure.height);
|
||||
break;
|
||||
case KeyPress:
|
||||
{
|
||||
char buffer[10];
|
||||
int r, code;
|
||||
code = XLookupKeysym(&event.xkey, 0);
|
||||
if (code == XK_Left) {
|
||||
view_roty += 5.0;
|
||||
}
|
||||
else if (code == XK_Right) {
|
||||
view_roty -= 5.0;
|
||||
}
|
||||
else if (code == XK_Up) {
|
||||
view_rotx += 5.0;
|
||||
}
|
||||
else if (code == XK_Down) {
|
||||
view_rotx -= 5.0;
|
||||
}
|
||||
else {
|
||||
r = XLookupString(&event.xkey, buffer, sizeof(buffer),
|
||||
NULL, NULL);
|
||||
if (buffer[0] == ' ') {
|
||||
anim = !anim;
|
||||
}
|
||||
else if (buffer[0] == 27) {
|
||||
/* escape */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
redraw = 1;
|
||||
break;
|
||||
default:
|
||||
; /*no-op*/
|
||||
}
|
||||
}
|
||||
|
||||
if (anim) {
|
||||
view_rotx += 1.0;
|
||||
view_roty += 2.0;
|
||||
redraw = 1;
|
||||
}
|
||||
|
||||
if (redraw) {
|
||||
draw_both(egl_dpy, egl_surf, egl_pbuf, egl_ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf(" -display <displayname> set the display to run on\n");
|
||||
printf(" -info display OpenGL renderer info\n");
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
Display *x_dpy;
|
||||
Window win;
|
||||
EGLSurface egl_surf, egl_pbuf;
|
||||
EGLContext egl_ctx;
|
||||
EGLDisplay egl_dpy;
|
||||
char *dpyName = NULL;
|
||||
GLboolean printInfo = GL_FALSE;
|
||||
EGLint egl_major, egl_minor;
|
||||
int i;
|
||||
const char *s;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-display") == 0) {
|
||||
dpyName = argv[i+1];
|
||||
i++;
|
||||
}
|
||||
else if (strcmp(argv[i], "-info") == 0) {
|
||||
printInfo = GL_TRUE;
|
||||
}
|
||||
else {
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
x_dpy = XOpenDisplay(dpyName);
|
||||
if (!x_dpy) {
|
||||
printf("Error: couldn't open display %s\n",
|
||||
dpyName ? dpyName : getenv("DISPLAY"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
egl_dpy = eglGetDisplay(x_dpy);
|
||||
if (!egl_dpy) {
|
||||
printf("Error: eglGetDisplay() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
|
||||
printf("Error: eglInitialize() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_VERSION);
|
||||
printf("EGL_VERSION = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_VENDOR);
|
||||
printf("EGL_VENDOR = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_EXTENSIONS);
|
||||
printf("EGL_EXTENSIONS = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_CLIENT_APIS);
|
||||
printf("EGL_CLIENT_APIS = %s\n", s);
|
||||
|
||||
make_x_window(x_dpy, egl_dpy,
|
||||
"pbuffer", 0, 0, WinWidth, WinHeight,
|
||||
&win, &egl_ctx, &egl_surf);
|
||||
|
||||
egl_pbuf = make_pbuffer(x_dpy, egl_dpy, WinWidth, WinHeight);
|
||||
if (!egl_pbuf) {
|
||||
printf("Error: eglCreatePBufferSurface() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
XMapWindow(x_dpy, win);
|
||||
if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) {
|
||||
printf("Error: eglMakeCurrent() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (printInfo) {
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
/* Set initial projection/viewing transformation.
|
||||
* We can't be sure we'll get a ConfigureNotify event when the window
|
||||
* first appears.
|
||||
*/
|
||||
reshape(WinWidth, WinHeight);
|
||||
|
||||
event_loop(x_dpy, win, egl_dpy, egl_surf, egl_pbuf, egl_ctx);
|
||||
|
||||
eglDestroyContext(egl_dpy, egl_ctx);
|
||||
eglDestroySurface(egl_dpy, egl_surf);
|
||||
eglTerminate(egl_dpy);
|
||||
|
||||
|
||||
XDestroyWindow(x_dpy, win);
|
||||
XCloseDisplay(x_dpy);
|
||||
|
||||
return 0;
|
||||
}
|
657
progs/es1/xegl/render_tex.c
Normal file
657
progs/es1/xegl/render_tex.c
Normal file
@@ -0,0 +1,657 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Tunsgten Graphics,Inc. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test EGL render to texture.
|
||||
* Brian Paul
|
||||
* August 2008
|
||||
*/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
#include <EGL/egl.h>
|
||||
|
||||
|
||||
static int TexWidth = 256, TexHeight = 256;
|
||||
|
||||
static int WinWidth = 300, WinHeight = 300;
|
||||
|
||||
static GLfloat view_rotx = 0.0, view_roty = 0.0, view_rotz = 0.0;
|
||||
|
||||
static GLuint DotTexture, RenderTexture;
|
||||
|
||||
|
||||
static void
|
||||
Normal(GLfloat *n, GLfloat nx, GLfloat ny, GLfloat nz)
|
||||
{
|
||||
n[0] = nx;
|
||||
n[1] = ny;
|
||||
n[2] = nz;
|
||||
}
|
||||
|
||||
static void
|
||||
Vertex(GLfloat *v, GLfloat vx, GLfloat vy, GLfloat vz)
|
||||
{
|
||||
v[0] = vx;
|
||||
v[1] = vy;
|
||||
v[2] = vz;
|
||||
}
|
||||
|
||||
static void
|
||||
Texcoord(GLfloat *v, GLfloat s, GLfloat t)
|
||||
{
|
||||
v[0] = s;
|
||||
v[1] = t;
|
||||
}
|
||||
|
||||
|
||||
/* Borrowed from glut, adapted */
|
||||
static void
|
||||
draw_torus(GLfloat r, GLfloat R, GLint nsides, GLint rings)
|
||||
{
|
||||
int i, j;
|
||||
GLfloat theta, phi, theta1;
|
||||
GLfloat cosTheta, sinTheta;
|
||||
GLfloat cosTheta1, sinTheta1;
|
||||
GLfloat ringDelta, sideDelta;
|
||||
GLfloat varray[100][3], narray[100][3], tarray[100][2];
|
||||
int vcount;
|
||||
|
||||
glVertexPointer(3, GL_FLOAT, 0, varray);
|
||||
glNormalPointer(GL_FLOAT, 0, narray);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, tarray);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
ringDelta = 2.0 * M_PI / rings;
|
||||
sideDelta = 2.0 * M_PI / nsides;
|
||||
|
||||
theta = 0.0;
|
||||
cosTheta = 1.0;
|
||||
sinTheta = 0.0;
|
||||
for (i = rings - 1; i >= 0; i--) {
|
||||
theta1 = theta + ringDelta;
|
||||
cosTheta1 = cos(theta1);
|
||||
sinTheta1 = sin(theta1);
|
||||
|
||||
vcount = 0; /* glBegin(GL_QUAD_STRIP); */
|
||||
|
||||
phi = 0.0;
|
||||
for (j = nsides; j >= 0; j--) {
|
||||
GLfloat s0, s1, t;
|
||||
GLfloat cosPhi, sinPhi, dist;
|
||||
|
||||
phi += sideDelta;
|
||||
cosPhi = cos(phi);
|
||||
sinPhi = sin(phi);
|
||||
dist = R + r * cosPhi;
|
||||
|
||||
s0 = 20.0 * theta / (2.0 * M_PI);
|
||||
s1 = 20.0 * theta1 / (2.0 * M_PI);
|
||||
t = 8.0 * phi / (2.0 * M_PI);
|
||||
|
||||
Normal(narray[vcount], cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
|
||||
Texcoord(tarray[vcount], s1, t);
|
||||
Vertex(varray[vcount], cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
|
||||
vcount++;
|
||||
|
||||
Normal(narray[vcount], cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
|
||||
Texcoord(tarray[vcount], s0, t);
|
||||
Vertex(varray[vcount], cosTheta * dist, -sinTheta * dist, r * sinPhi);
|
||||
vcount++;
|
||||
}
|
||||
|
||||
/*glEnd();*/
|
||||
assert(vcount <= 100);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, vcount);
|
||||
|
||||
theta = theta1;
|
||||
cosTheta = cosTheta1;
|
||||
sinTheta = sinTheta1;
|
||||
}
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
draw_torus_to_texture(void)
|
||||
{
|
||||
glViewport(0, 0, TexWidth, TexHeight);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustumf(-1, 1, -1, 1, 5.0, 60.0);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -15.0);
|
||||
|
||||
glClearColor(0.4, 0.4, 0.4, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, DotTexture);
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(view_roty, 0, 1, 0);
|
||||
glScalef(0.5, 0.5, 0.5);
|
||||
|
||||
draw_torus(1.0, 3.0, 30, 60);
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
#if 0
|
||||
glBindTexture(GL_TEXTURE_2D, RenderTexture);
|
||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, TexWidth, TexHeight);
|
||||
#endif
|
||||
|
||||
glFinish();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
draw_textured_quad(void)
|
||||
{
|
||||
GLfloat ar = (GLfloat) WinWidth / (GLfloat) WinHeight;
|
||||
|
||||
glViewport(0, 0, WinWidth, WinHeight);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustumf(-ar, ar, -1, 1, 5.0, 60.0);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -8.0);
|
||||
|
||||
glClearColor(0.4, 0.4, 1.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, RenderTexture);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(view_rotx, 1, 0, 0);
|
||||
glRotatef(view_rotz, 0, 0, 1);
|
||||
|
||||
{
|
||||
static const GLfloat texcoord[4][2] = {
|
||||
{ 0, 0 }, { 1, 0 }, { 0, 1 }, { 1, 1 }
|
||||
};
|
||||
static const GLfloat vertex[4][2] = {
|
||||
{ -1, -1 }, { 1, -1 }, { -1, 1 }, { 1, 1 }
|
||||
};
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, 0, vertex);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, texcoord);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
draw(EGLDisplay egl_dpy, EGLSurface egl_surf, EGLSurface egl_pbuf,
|
||||
EGLContext egl_ctx)
|
||||
{
|
||||
/*printf("Begin draw\n");*/
|
||||
|
||||
/* first draw torus to pbuffer /texture */
|
||||
#if 01
|
||||
if (!eglMakeCurrent(egl_dpy, egl_pbuf, egl_pbuf, egl_ctx)) {
|
||||
#else
|
||||
if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) {
|
||||
#endif
|
||||
printf("Error: eglMakeCurrent(pbuf) failed\n");
|
||||
return;
|
||||
}
|
||||
glBindTexture(GL_TEXTURE_2D, RenderTexture);
|
||||
eglBindTexImage(egl_dpy, egl_pbuf, EGL_BACK_BUFFER);
|
||||
draw_torus_to_texture();
|
||||
eglReleaseTexImage(egl_dpy, egl_pbuf, EGL_BACK_BUFFER);
|
||||
|
||||
/* draw textured quad to window */
|
||||
if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) {
|
||||
printf("Error: eglMakeCurrent(pbuffer) failed\n");
|
||||
return;
|
||||
}
|
||||
draw_textured_quad();
|
||||
eglSwapBuffers(egl_dpy, egl_surf);
|
||||
|
||||
/*printf("End draw\n");*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
make_dot_texture(void)
|
||||
{
|
||||
#define SZ 64
|
||||
GLenum Filter = GL_LINEAR;
|
||||
GLubyte image[SZ][SZ][4];
|
||||
GLuint i, j;
|
||||
|
||||
for (i = 0; i < SZ; i++) {
|
||||
for (j = 0; j < SZ; j++) {
|
||||
GLfloat d = (i - SZ/2) * (i - SZ/2) + (j - SZ/2) * (j - SZ/2);
|
||||
d = sqrt(d);
|
||||
if (d < SZ/3) {
|
||||
image[i][j][0] = 255;
|
||||
image[i][j][1] = 255;
|
||||
image[i][j][2] = 255;
|
||||
image[i][j][3] = 255;
|
||||
}
|
||||
else {
|
||||
image[i][j][0] = 127;
|
||||
image[i][j][1] = 127;
|
||||
image[i][j][2] = 127;
|
||||
image[i][j][3] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glGenTextures(1, &DotTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, DotTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SZ, SZ, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, image);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, Filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, Filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
#undef SZ
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
make_render_texture(void)
|
||||
{
|
||||
GLenum Filter = GL_LINEAR;
|
||||
glGenTextures(1, &RenderTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, RenderTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TexWidth, TexHeight, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, Filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, Filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
static const GLfloat red[4] = {1, 0, 0, 0};
|
||||
static const GLfloat white[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
static const GLfloat diffuse[4] = {0.7, 0.7, 0.7, 1.0};
|
||||
static const GLfloat specular[4] = {0.001, 0.001, 0.001, 1.0};
|
||||
static const GLfloat pos[4] = {20, 20, 50, 1};
|
||||
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, red);
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white);
|
||||
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 9.0);
|
||||
|
||||
glEnable(GL_LIGHT0);
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, pos);
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
|
||||
glLightfv(GL_LIGHT0, GL_SPECULAR, specular);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
make_dot_texture();
|
||||
make_render_texture();
|
||||
|
||||
printf("DotTexture=%u RenderTexture=%u\n", DotTexture, RenderTexture);
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create an RGB, double-buffered X window.
|
||||
* Return the window and context handles.
|
||||
*/
|
||||
static void
|
||||
make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
|
||||
const char *name,
|
||||
int x, int y, int width, int height,
|
||||
Window *winRet,
|
||||
EGLContext *ctxRet,
|
||||
EGLSurface *surfRet)
|
||||
{
|
||||
static const EGLint attribs[] = {
|
||||
EGL_RED_SIZE, 1,
|
||||
EGL_GREEN_SIZE, 1,
|
||||
EGL_BLUE_SIZE, 1,
|
||||
EGL_DEPTH_SIZE, 1,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
int scrnum;
|
||||
XSetWindowAttributes attr;
|
||||
unsigned long mask;
|
||||
Window root;
|
||||
Window win;
|
||||
XVisualInfo *visInfo, visTemplate;
|
||||
int num_visuals;
|
||||
EGLContext ctx;
|
||||
EGLConfig config;
|
||||
EGLint num_configs;
|
||||
EGLint vid;
|
||||
|
||||
scrnum = DefaultScreen( x_dpy );
|
||||
root = RootWindow( x_dpy, scrnum );
|
||||
|
||||
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
|
||||
printf("Error: couldn't get an EGL visual config\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
assert(config);
|
||||
assert(num_configs > 0);
|
||||
|
||||
if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
||||
printf("Error: eglGetConfigAttrib() failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* The X window visual must match the EGL config */
|
||||
visTemplate.visualid = vid;
|
||||
visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
|
||||
if (!visInfo) {
|
||||
printf("Error: couldn't get X visual\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* window attributes */
|
||||
attr.background_pixel = 0;
|
||||
attr.border_pixel = 0;
|
||||
attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone);
|
||||
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
|
||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
||||
|
||||
win = XCreateWindow( x_dpy, root, 0, 0, width, height,
|
||||
0, visInfo->depth, InputOutput,
|
||||
visInfo->visual, mask, &attr );
|
||||
|
||||
/* set hints and properties */
|
||||
{
|
||||
XSizeHints sizehints;
|
||||
sizehints.x = x;
|
||||
sizehints.y = y;
|
||||
sizehints.width = width;
|
||||
sizehints.height = height;
|
||||
sizehints.flags = USSize | USPosition;
|
||||
XSetNormalHints(x_dpy, win, &sizehints);
|
||||
XSetStandardProperties(x_dpy, win, name, name,
|
||||
None, (char **)NULL, 0, &sizehints);
|
||||
}
|
||||
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
|
||||
ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL );
|
||||
if (!ctx) {
|
||||
printf("Error: eglCreateContext failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
*surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL);
|
||||
|
||||
if (!*surfRet) {
|
||||
printf("Error: eglCreateWindowSurface failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
XFree(visInfo);
|
||||
|
||||
*winRet = win;
|
||||
*ctxRet = ctx;
|
||||
}
|
||||
|
||||
|
||||
static EGLSurface
|
||||
make_pbuffer(Display *x_dpy, EGLDisplay egl_dpy, int width, int height)
|
||||
{
|
||||
static const EGLint config_attribs[] = {
|
||||
EGL_RED_SIZE, 1,
|
||||
EGL_GREEN_SIZE, 1,
|
||||
EGL_BLUE_SIZE, 1,
|
||||
EGL_DEPTH_SIZE, 1,
|
||||
EGL_NONE
|
||||
};
|
||||
EGLConfig config;
|
||||
EGLSurface pbuf;
|
||||
EGLint num_configs;
|
||||
EGLint pbuf_attribs[15];
|
||||
int i = 0;
|
||||
|
||||
pbuf_attribs[i++] = EGL_WIDTH;
|
||||
pbuf_attribs[i++] = width;
|
||||
pbuf_attribs[i++] = EGL_HEIGHT;
|
||||
pbuf_attribs[i++] = height;
|
||||
pbuf_attribs[i++] = EGL_TEXTURE_FORMAT;
|
||||
pbuf_attribs[i++] = EGL_TEXTURE_RGBA;
|
||||
pbuf_attribs[i++] = EGL_TEXTURE_TARGET;
|
||||
pbuf_attribs[i++] = EGL_TEXTURE_2D;
|
||||
pbuf_attribs[i++] = EGL_MIPMAP_TEXTURE;
|
||||
pbuf_attribs[i++] = EGL_FALSE;
|
||||
pbuf_attribs[i++] = EGL_NONE;
|
||||
assert(i <= 15);
|
||||
|
||||
if (!eglChooseConfig( egl_dpy, config_attribs, &config, 1, &num_configs)) {
|
||||
printf("Error: couldn't get an EGL config for pbuffer\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
pbuf = eglCreatePbufferSurface(egl_dpy, config, pbuf_attribs);
|
||||
|
||||
return pbuf;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
event_loop(Display *dpy, Window win,
|
||||
EGLDisplay egl_dpy, EGLSurface egl_surf, EGLSurface egl_pbuf,
|
||||
EGLContext egl_ctx)
|
||||
{
|
||||
int anim = 0;
|
||||
|
||||
while (1) {
|
||||
int redraw = 0;
|
||||
|
||||
if (!anim || XPending(dpy)) {
|
||||
XEvent event;
|
||||
XNextEvent(dpy, &event);
|
||||
|
||||
switch (event.type) {
|
||||
case Expose:
|
||||
redraw = 1;
|
||||
break;
|
||||
case ConfigureNotify:
|
||||
if (event.xconfigure.window == win) {
|
||||
WinWidth = event.xconfigure.width;
|
||||
WinHeight = event.xconfigure.height;
|
||||
}
|
||||
break;
|
||||
case KeyPress:
|
||||
{
|
||||
char buffer[10];
|
||||
int r, code;
|
||||
code = XLookupKeysym(&event.xkey, 0);
|
||||
if (code == XK_Left) {
|
||||
view_roty += 5.0;
|
||||
}
|
||||
else if (code == XK_Right) {
|
||||
view_roty -= 5.0;
|
||||
}
|
||||
else if (code == XK_Up) {
|
||||
view_rotx += 5.0;
|
||||
}
|
||||
else if (code == XK_Down) {
|
||||
view_rotx -= 5.0;
|
||||
}
|
||||
else {
|
||||
r = XLookupString(&event.xkey, buffer, sizeof(buffer),
|
||||
NULL, NULL);
|
||||
if (buffer[0] == ' ') {
|
||||
anim = !anim;
|
||||
}
|
||||
else if (buffer[0] == 'z') {
|
||||
view_rotz += 5.0;
|
||||
}
|
||||
else if (buffer[0] == 'Z') {
|
||||
view_rotz -= 5.0;
|
||||
}
|
||||
else if (buffer[0] == 27) {
|
||||
/* escape */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
redraw = 1;
|
||||
break;
|
||||
default:
|
||||
; /*no-op*/
|
||||
}
|
||||
}
|
||||
|
||||
if (anim) {
|
||||
view_rotx += 1.0;
|
||||
view_roty += 2.0;
|
||||
redraw = 1;
|
||||
}
|
||||
|
||||
if (redraw) {
|
||||
draw(egl_dpy, egl_surf, egl_pbuf, egl_ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf(" -display <displayname> set the display to run on\n");
|
||||
printf(" -info display OpenGL renderer info\n");
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
Display *x_dpy;
|
||||
Window win;
|
||||
EGLSurface egl_surf, egl_pbuf;
|
||||
EGLContext egl_ctx;
|
||||
EGLDisplay egl_dpy;
|
||||
char *dpyName = NULL;
|
||||
GLboolean printInfo = GL_FALSE;
|
||||
EGLint egl_major, egl_minor;
|
||||
int i;
|
||||
const char *s;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-display") == 0) {
|
||||
dpyName = argv[i+1];
|
||||
i++;
|
||||
}
|
||||
else if (strcmp(argv[i], "-info") == 0) {
|
||||
printInfo = GL_TRUE;
|
||||
}
|
||||
else {
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
x_dpy = XOpenDisplay(dpyName);
|
||||
if (!x_dpy) {
|
||||
printf("Error: couldn't open display %s\n",
|
||||
dpyName ? dpyName : getenv("DISPLAY"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
egl_dpy = eglGetDisplay(x_dpy);
|
||||
if (!egl_dpy) {
|
||||
printf("Error: eglGetDisplay() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
|
||||
printf("Error: eglInitialize() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_VERSION);
|
||||
printf("EGL_VERSION = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_VENDOR);
|
||||
printf("EGL_VENDOR = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_EXTENSIONS);
|
||||
printf("EGL_EXTENSIONS = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_CLIENT_APIS);
|
||||
printf("EGL_CLIENT_APIS = %s\n", s);
|
||||
|
||||
make_x_window(x_dpy, egl_dpy,
|
||||
"render_tex", 0, 0, WinWidth, WinHeight,
|
||||
&win, &egl_ctx, &egl_surf);
|
||||
|
||||
egl_pbuf = make_pbuffer(x_dpy, egl_dpy, TexWidth, TexHeight);
|
||||
if (!egl_pbuf) {
|
||||
printf("Error: eglCreatePBufferSurface() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
XMapWindow(x_dpy, win);
|
||||
if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) {
|
||||
printf("Error: eglMakeCurrent() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (printInfo) {
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
event_loop(x_dpy, win, egl_dpy, egl_surf, egl_pbuf, egl_ctx);
|
||||
|
||||
eglDestroyContext(egl_dpy, egl_ctx);
|
||||
eglDestroySurface(egl_dpy, egl_surf);
|
||||
eglTerminate(egl_dpy);
|
||||
|
||||
|
||||
XDestroyWindow(x_dpy, win);
|
||||
XCloseDisplay(x_dpy);
|
||||
|
||||
return 0;
|
||||
}
|
509
progs/es1/xegl/torus.c
Normal file
509
progs/es1/xegl/torus.c
Normal file
@@ -0,0 +1,509 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Tunsgten Graphics,Inc. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Draw a lit, textured torus with X/EGL and OpenGL ES 1.x
|
||||
* Brian Paul
|
||||
* July 2008
|
||||
*/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
#include <EGL/egl.h>
|
||||
|
||||
|
||||
|
||||
|
||||
static GLfloat view_rotx = 0.0, view_roty = 0.0, view_rotz = 0.0;
|
||||
|
||||
|
||||
static void
|
||||
Normal(GLfloat *n, GLfloat nx, GLfloat ny, GLfloat nz)
|
||||
{
|
||||
n[0] = nx;
|
||||
n[1] = ny;
|
||||
n[2] = nz;
|
||||
}
|
||||
|
||||
static void
|
||||
Vertex(GLfloat *v, GLfloat vx, GLfloat vy, GLfloat vz)
|
||||
{
|
||||
v[0] = vx;
|
||||
v[1] = vy;
|
||||
v[2] = vz;
|
||||
}
|
||||
|
||||
static void
|
||||
Texcoord(GLfloat *v, GLfloat s, GLfloat t)
|
||||
{
|
||||
v[0] = s;
|
||||
v[1] = t;
|
||||
}
|
||||
|
||||
|
||||
/* Borrowed from glut, adapted */
|
||||
static void
|
||||
draw_torus(GLfloat r, GLfloat R, GLint nsides, GLint rings)
|
||||
{
|
||||
int i, j;
|
||||
GLfloat theta, phi, theta1;
|
||||
GLfloat cosTheta, sinTheta;
|
||||
GLfloat cosTheta1, sinTheta1;
|
||||
GLfloat ringDelta, sideDelta;
|
||||
GLfloat varray[100][3], narray[100][3], tarray[100][2];
|
||||
int vcount;
|
||||
|
||||
glVertexPointer(3, GL_FLOAT, 0, varray);
|
||||
glNormalPointer(GL_FLOAT, 0, narray);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, tarray);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
ringDelta = 2.0 * M_PI / rings;
|
||||
sideDelta = 2.0 * M_PI / nsides;
|
||||
|
||||
theta = 0.0;
|
||||
cosTheta = 1.0;
|
||||
sinTheta = 0.0;
|
||||
for (i = rings - 1; i >= 0; i--) {
|
||||
theta1 = theta + ringDelta;
|
||||
cosTheta1 = cos(theta1);
|
||||
sinTheta1 = sin(theta1);
|
||||
|
||||
vcount = 0; /* glBegin(GL_QUAD_STRIP); */
|
||||
|
||||
phi = 0.0;
|
||||
for (j = nsides; j >= 0; j--) {
|
||||
GLfloat s0, s1, t;
|
||||
GLfloat cosPhi, sinPhi, dist;
|
||||
|
||||
phi += sideDelta;
|
||||
cosPhi = cos(phi);
|
||||
sinPhi = sin(phi);
|
||||
dist = R + r * cosPhi;
|
||||
|
||||
s0 = 20.0 * theta / (2.0 * M_PI);
|
||||
s1 = 20.0 * theta1 / (2.0 * M_PI);
|
||||
t = 8.0 * phi / (2.0 * M_PI);
|
||||
|
||||
Normal(narray[vcount], cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
|
||||
Texcoord(tarray[vcount], s1, t);
|
||||
Vertex(varray[vcount], cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
|
||||
vcount++;
|
||||
|
||||
Normal(narray[vcount], cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
|
||||
Texcoord(tarray[vcount], s0, t);
|
||||
Vertex(varray[vcount], cosTheta * dist, -sinTheta * dist, r * sinPhi);
|
||||
vcount++;
|
||||
}
|
||||
|
||||
/*glEnd();*/
|
||||
assert(vcount <= 100);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, vcount);
|
||||
|
||||
theta = theta1;
|
||||
cosTheta = cosTheta1;
|
||||
sinTheta = sinTheta1;
|
||||
}
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(view_rotx, 1, 0, 0);
|
||||
glRotatef(view_roty, 0, 1, 0);
|
||||
glRotatef(view_rotz, 0, 0, 1);
|
||||
glScalef(0.5, 0.5, 0.5);
|
||||
|
||||
draw_torus(1.0, 3.0, 30, 60);
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int width, int height)
|
||||
{
|
||||
GLfloat ar = (GLfloat) width / (GLfloat) height;
|
||||
|
||||
glViewport(0, 0, (GLint) width, (GLint) height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
||||
#ifdef GL_VERSION_ES_CM_1_0
|
||||
glFrustumf(-ar, ar, -1, 1, 5.0, 60.0);
|
||||
#else
|
||||
glFrustum(-ar, ar, -1, 1, 5.0, 60.0);
|
||||
#endif
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -15.0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
make_texture(void)
|
||||
{
|
||||
#define SZ 64
|
||||
GLenum Filter = GL_LINEAR;
|
||||
GLubyte image[SZ][SZ][4];
|
||||
GLuint i, j;
|
||||
|
||||
for (i = 0; i < SZ; i++) {
|
||||
for (j = 0; j < SZ; j++) {
|
||||
GLfloat d = (i - SZ/2) * (i - SZ/2) + (j - SZ/2) * (j - SZ/2);
|
||||
d = sqrt(d);
|
||||
if (d < SZ/3) {
|
||||
image[i][j][0] = 255;
|
||||
image[i][j][1] = 255;
|
||||
image[i][j][2] = 255;
|
||||
image[i][j][3] = 255;
|
||||
}
|
||||
else {
|
||||
image[i][j][0] = 127;
|
||||
image[i][j][1] = 127;
|
||||
image[i][j][2] = 127;
|
||||
image[i][j][3] = 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE0); /* unit 0 */
|
||||
glBindTexture(GL_TEXTURE_2D, 42);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SZ, SZ, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, image);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, Filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, Filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
#undef SZ
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
static const GLfloat red[4] = {1, 0, 0, 0};
|
||||
static const GLfloat white[4] = {1.0, 1.0, 1.0, 1.0};
|
||||
static const GLfloat diffuse[4] = {0.7, 0.7, 0.7, 1.0};
|
||||
static const GLfloat specular[4] = {0.001, 0.001, 0.001, 1.0};
|
||||
static const GLfloat pos[4] = {20, 20, 50, 1};
|
||||
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, red);
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white);
|
||||
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 9.0);
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, pos);
|
||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);
|
||||
glLightfv(GL_LIGHT0, GL_SPECULAR, specular);
|
||||
|
||||
glClearColor(0.4, 0.4, 0.4, 0.0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
make_texture();
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create an RGB, double-buffered X window.
|
||||
* Return the window and context handles.
|
||||
*/
|
||||
static void
|
||||
make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
|
||||
const char *name,
|
||||
int x, int y, int width, int height,
|
||||
Window *winRet,
|
||||
EGLContext *ctxRet,
|
||||
EGLSurface *surfRet)
|
||||
{
|
||||
static const EGLint attribs[] = {
|
||||
EGL_RED_SIZE, 1,
|
||||
EGL_GREEN_SIZE, 1,
|
||||
EGL_BLUE_SIZE, 1,
|
||||
EGL_DEPTH_SIZE, 1,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
int scrnum;
|
||||
XSetWindowAttributes attr;
|
||||
unsigned long mask;
|
||||
Window root;
|
||||
Window win;
|
||||
XVisualInfo *visInfo, visTemplate;
|
||||
int num_visuals;
|
||||
EGLContext ctx;
|
||||
EGLConfig config;
|
||||
EGLint num_configs;
|
||||
EGLint vid;
|
||||
|
||||
scrnum = DefaultScreen( x_dpy );
|
||||
root = RootWindow( x_dpy, scrnum );
|
||||
|
||||
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
|
||||
printf("Error: couldn't get an EGL visual config\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
assert(config);
|
||||
assert(num_configs > 0);
|
||||
|
||||
if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
||||
printf("Error: eglGetConfigAttrib() failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* The X window visual must match the EGL config */
|
||||
visTemplate.visualid = vid;
|
||||
visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
|
||||
if (!visInfo) {
|
||||
printf("Error: couldn't get X visual\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* window attributes */
|
||||
attr.background_pixel = 0;
|
||||
attr.border_pixel = 0;
|
||||
attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone);
|
||||
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
|
||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
||||
|
||||
win = XCreateWindow( x_dpy, root, 0, 0, width, height,
|
||||
0, visInfo->depth, InputOutput,
|
||||
visInfo->visual, mask, &attr );
|
||||
|
||||
/* set hints and properties */
|
||||
{
|
||||
XSizeHints sizehints;
|
||||
sizehints.x = x;
|
||||
sizehints.y = y;
|
||||
sizehints.width = width;
|
||||
sizehints.height = height;
|
||||
sizehints.flags = USSize | USPosition;
|
||||
XSetNormalHints(x_dpy, win, &sizehints);
|
||||
XSetStandardProperties(x_dpy, win, name, name,
|
||||
None, (char **)NULL, 0, &sizehints);
|
||||
}
|
||||
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
|
||||
ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL );
|
||||
if (!ctx) {
|
||||
printf("Error: eglCreateContext failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
*surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL);
|
||||
|
||||
if (!*surfRet) {
|
||||
printf("Error: eglCreateWindowSurface failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
XFree(visInfo);
|
||||
|
||||
*winRet = win;
|
||||
*ctxRet = ctx;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
event_loop(Display *dpy, Window win,
|
||||
EGLDisplay egl_dpy, EGLSurface egl_surf)
|
||||
{
|
||||
int anim = 1;
|
||||
|
||||
while (1) {
|
||||
int redraw = 0;
|
||||
|
||||
if (!anim || XPending(dpy)) {
|
||||
XEvent event;
|
||||
XNextEvent(dpy, &event);
|
||||
|
||||
switch (event.type) {
|
||||
case Expose:
|
||||
redraw = 1;
|
||||
break;
|
||||
case ConfigureNotify:
|
||||
reshape(event.xconfigure.width, event.xconfigure.height);
|
||||
break;
|
||||
case KeyPress:
|
||||
{
|
||||
char buffer[10];
|
||||
int r, code;
|
||||
code = XLookupKeysym(&event.xkey, 0);
|
||||
if (code == XK_Left) {
|
||||
view_roty += 5.0;
|
||||
}
|
||||
else if (code == XK_Right) {
|
||||
view_roty -= 5.0;
|
||||
}
|
||||
else if (code == XK_Up) {
|
||||
view_rotx += 5.0;
|
||||
}
|
||||
else if (code == XK_Down) {
|
||||
view_rotx -= 5.0;
|
||||
}
|
||||
else {
|
||||
r = XLookupString(&event.xkey, buffer, sizeof(buffer),
|
||||
NULL, NULL);
|
||||
if (buffer[0] == ' ') {
|
||||
anim = !anim;
|
||||
}
|
||||
else if (buffer[0] == 27) {
|
||||
/* escape */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
redraw = 1;
|
||||
break;
|
||||
default:
|
||||
; /*no-op*/
|
||||
}
|
||||
}
|
||||
|
||||
if (anim) {
|
||||
view_rotx += 1.0;
|
||||
view_roty += 2.0;
|
||||
redraw = 1;
|
||||
}
|
||||
|
||||
if (redraw) {
|
||||
draw();
|
||||
eglSwapBuffers(egl_dpy, egl_surf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf(" -display <displayname> set the display to run on\n");
|
||||
printf(" -info display OpenGL renderer info\n");
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
const int winWidth = 300, winHeight = 300;
|
||||
Display *x_dpy;
|
||||
Window win;
|
||||
EGLSurface egl_surf;
|
||||
EGLContext egl_ctx;
|
||||
EGLDisplay egl_dpy;
|
||||
char *dpyName = NULL;
|
||||
GLboolean printInfo = GL_FALSE;
|
||||
EGLint egl_major, egl_minor;
|
||||
int i;
|
||||
const char *s;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-display") == 0) {
|
||||
dpyName = argv[i+1];
|
||||
i++;
|
||||
}
|
||||
else if (strcmp(argv[i], "-info") == 0) {
|
||||
printInfo = GL_TRUE;
|
||||
}
|
||||
else {
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
x_dpy = XOpenDisplay(dpyName);
|
||||
if (!x_dpy) {
|
||||
printf("Error: couldn't open display %s\n",
|
||||
dpyName ? dpyName : getenv("DISPLAY"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
egl_dpy = eglGetDisplay(x_dpy);
|
||||
if (!egl_dpy) {
|
||||
printf("Error: eglGetDisplay() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
|
||||
printf("Error: eglInitialize() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_VERSION);
|
||||
printf("EGL_VERSION = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_VENDOR);
|
||||
printf("EGL_VENDOR = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_EXTENSIONS);
|
||||
printf("EGL_EXTENSIONS = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_CLIENT_APIS);
|
||||
printf("EGL_CLIENT_APIS = %s\n", s);
|
||||
|
||||
make_x_window(x_dpy, egl_dpy,
|
||||
"torus", 0, 0, winWidth, winHeight,
|
||||
&win, &egl_ctx, &egl_surf);
|
||||
|
||||
XMapWindow(x_dpy, win);
|
||||
if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) {
|
||||
printf("Error: eglMakeCurrent() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (printInfo) {
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
/* Set initial projection/viewing transformation.
|
||||
* We can't be sure we'll get a ConfigureNotify event when the window
|
||||
* first appears.
|
||||
*/
|
||||
reshape(winWidth, winHeight);
|
||||
|
||||
event_loop(x_dpy, win, egl_dpy, egl_surf);
|
||||
|
||||
eglDestroyContext(egl_dpy, egl_ctx);
|
||||
eglDestroySurface(egl_dpy, egl_surf);
|
||||
eglTerminate(egl_dpy);
|
||||
|
||||
|
||||
XDestroyWindow(x_dpy, win);
|
||||
XCloseDisplay(x_dpy);
|
||||
|
||||
return 0;
|
||||
}
|
473
progs/es1/xegl/tri.c
Normal file
473
progs/es1/xegl/tri.c
Normal file
@@ -0,0 +1,473 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Draw a triangle with X/EGL and OpenGL ES 1.x
|
||||
* Brian Paul
|
||||
* 5 June 2008
|
||||
*/
|
||||
|
||||
#define USE_FULL_GL 0
|
||||
|
||||
#define USE_FIXED_POINT 0
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#if USE_FULL_GL
|
||||
#include <GL/gl.h> /* use full OpenGL */
|
||||
#else
|
||||
#include <GLES/gl.h> /* use OpenGL ES 1.x */
|
||||
#include <GLES/glext.h>
|
||||
#endif
|
||||
#include <EGL/egl.h>
|
||||
|
||||
|
||||
#define FLOAT_TO_FIXED(X) ((X) * 65535.0)
|
||||
|
||||
|
||||
|
||||
static GLfloat view_rotx = 0.0, view_roty = 0.0, view_rotz = 0.0;
|
||||
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
#if USE_FIXED_POINT
|
||||
static const GLfixed verts[3][2] = {
|
||||
{ -65536, -65536 },
|
||||
{ 65536, -65536 },
|
||||
{ 0, 65536 }
|
||||
};
|
||||
static const GLfixed colors[3][4] = {
|
||||
{ 65536, 0, 0, 65536 },
|
||||
{ 0, 65536, 0 , 65536},
|
||||
{ 0, 0, 65536 , 65536}
|
||||
};
|
||||
#else
|
||||
static const GLfloat verts[3][2] = {
|
||||
{ -1, -1 },
|
||||
{ 1, -1 },
|
||||
{ 0, 1 }
|
||||
};
|
||||
static const GLfloat colors[3][4] = {
|
||||
{ 1, 0, 0, 1 },
|
||||
{ 0, 1, 0, 1 },
|
||||
{ 0, 0, 1, 1 }
|
||||
};
|
||||
#endif
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(view_rotx, 1, 0, 0);
|
||||
glRotatef(view_roty, 0, 1, 0);
|
||||
glRotatef(view_rotz, 0, 0, 1);
|
||||
|
||||
{
|
||||
#if USE_FIXED_POINT
|
||||
glVertexPointer(2, GL_FIXED, 0, verts);
|
||||
glColorPointer(4, GL_FIXED, 0, colors);
|
||||
#else
|
||||
glVertexPointer(2, GL_FLOAT, 0, verts);
|
||||
glColorPointer(4, GL_FLOAT, 0, colors);
|
||||
#endif
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
/* draw triangle */
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
|
||||
/* draw some points */
|
||||
glPointSizex(FLOAT_TO_FIXED(15.5));
|
||||
glDrawArrays(GL_POINTS, 0, 3);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
if (0) {
|
||||
/* test code */
|
||||
GLfixed size;
|
||||
glGetFixedv(GL_POINT_SIZE, &size);
|
||||
printf("GL_POINT_SIZE = 0x%x %f\n", size, size / 65536.0);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int width, int height)
|
||||
{
|
||||
GLfloat ar = (GLfloat) width / (GLfloat) height;
|
||||
|
||||
glViewport(0, 0, (GLint) width, (GLint) height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
#ifdef GL_VERSION_ES_CM_1_0
|
||||
glFrustumf(-ar, ar, -1, 1, 5.0, 60.0);
|
||||
#else
|
||||
glFrustum(-ar, ar, -1, 1, 5.0, 60.0);
|
||||
#endif
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -10.0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_query_matrix(void)
|
||||
{
|
||||
PFNGLQUERYMATRIXXOESPROC procQueryMatrixx;
|
||||
typedef void (*voidproc)();
|
||||
GLfixed mantissa[16];
|
||||
GLint exponent[16];
|
||||
GLbitfield rv;
|
||||
int i;
|
||||
voidproc p = eglGetProcAddress("eglCreateContext");
|
||||
|
||||
assert(p);
|
||||
procQueryMatrixx = (PFNGLQUERYMATRIXXOESPROC) eglGetProcAddress("glQueryMatrixxOES");
|
||||
assert(procQueryMatrixx);
|
||||
/* Actually try out this one */
|
||||
rv = (*procQueryMatrixx)(mantissa, exponent);
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (rv & (1<<i)) {
|
||||
printf("matrix[%d] invalid\n", i);
|
||||
}
|
||||
else {
|
||||
printf("matrix[%d] = %f * 2^(%d)\n", i, mantissa[i]/65536.0, exponent[i]);
|
||||
}
|
||||
}
|
||||
p = eglGetProcAddress("glFoo");
|
||||
assert(!p);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
glClearColor(0.4, 0.4, 0.4, 0.0);
|
||||
|
||||
if (0)
|
||||
test_query_matrix();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create an RGB, double-buffered X window.
|
||||
* Return the window and context handles.
|
||||
*/
|
||||
static void
|
||||
make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
|
||||
const char *name,
|
||||
int x, int y, int width, int height,
|
||||
Window *winRet,
|
||||
EGLContext *ctxRet,
|
||||
EGLSurface *surfRet)
|
||||
{
|
||||
static const EGLint attribs[] = {
|
||||
EGL_RED_SIZE, 1,
|
||||
EGL_GREEN_SIZE, 1,
|
||||
EGL_BLUE_SIZE, 1,
|
||||
EGL_DEPTH_SIZE, 1,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
int scrnum;
|
||||
XSetWindowAttributes attr;
|
||||
unsigned long mask;
|
||||
Window root;
|
||||
Window win;
|
||||
XVisualInfo *visInfo, visTemplate;
|
||||
int num_visuals;
|
||||
EGLContext ctx;
|
||||
EGLConfig config;
|
||||
EGLint num_configs;
|
||||
EGLint vid;
|
||||
|
||||
scrnum = DefaultScreen( x_dpy );
|
||||
root = RootWindow( x_dpy, scrnum );
|
||||
|
||||
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
|
||||
printf("Error: couldn't get an EGL visual config\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
assert(config);
|
||||
assert(num_configs > 0);
|
||||
|
||||
if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
||||
printf("Error: eglGetConfigAttrib() failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* The X window visual must match the EGL config */
|
||||
visTemplate.visualid = vid;
|
||||
visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
|
||||
if (!visInfo) {
|
||||
printf("Error: couldn't get X visual\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* window attributes */
|
||||
attr.background_pixel = 0;
|
||||
attr.border_pixel = 0;
|
||||
attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone);
|
||||
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
|
||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
||||
|
||||
win = XCreateWindow( x_dpy, root, 0, 0, width, height,
|
||||
0, visInfo->depth, InputOutput,
|
||||
visInfo->visual, mask, &attr );
|
||||
|
||||
/* set hints and properties */
|
||||
{
|
||||
XSizeHints sizehints;
|
||||
sizehints.x = x;
|
||||
sizehints.y = y;
|
||||
sizehints.width = width;
|
||||
sizehints.height = height;
|
||||
sizehints.flags = USSize | USPosition;
|
||||
XSetNormalHints(x_dpy, win, &sizehints);
|
||||
XSetStandardProperties(x_dpy, win, name, name,
|
||||
None, (char **)NULL, 0, &sizehints);
|
||||
}
|
||||
|
||||
#if USE_FULL_GL
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
#else
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
#endif
|
||||
|
||||
ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL );
|
||||
if (!ctx) {
|
||||
printf("Error: eglCreateContext failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
*surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL);
|
||||
|
||||
if (!*surfRet) {
|
||||
printf("Error: eglCreateWindowSurface failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
XFree(visInfo);
|
||||
|
||||
*winRet = win;
|
||||
*ctxRet = ctx;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
event_loop(Display *dpy, Window win,
|
||||
EGLDisplay egl_dpy, EGLSurface egl_surf)
|
||||
{
|
||||
while (1) {
|
||||
int redraw = 0;
|
||||
XEvent event;
|
||||
|
||||
XNextEvent(dpy, &event);
|
||||
|
||||
switch (event.type) {
|
||||
case Expose:
|
||||
redraw = 1;
|
||||
break;
|
||||
case ConfigureNotify:
|
||||
reshape(event.xconfigure.width, event.xconfigure.height);
|
||||
break;
|
||||
case KeyPress:
|
||||
{
|
||||
char buffer[10];
|
||||
int r, code;
|
||||
code = XLookupKeysym(&event.xkey, 0);
|
||||
if (code == XK_Left) {
|
||||
view_roty += 5.0;
|
||||
}
|
||||
else if (code == XK_Right) {
|
||||
view_roty -= 5.0;
|
||||
}
|
||||
else if (code == XK_Up) {
|
||||
view_rotx += 5.0;
|
||||
}
|
||||
else if (code == XK_Down) {
|
||||
view_rotx -= 5.0;
|
||||
}
|
||||
else {
|
||||
r = XLookupString(&event.xkey, buffer, sizeof(buffer),
|
||||
NULL, NULL);
|
||||
if (buffer[0] == 27) {
|
||||
/* escape */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
redraw = 1;
|
||||
break;
|
||||
default:
|
||||
; /*no-op*/
|
||||
}
|
||||
|
||||
if (redraw) {
|
||||
draw();
|
||||
eglSwapBuffers(egl_dpy, egl_surf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf(" -display <displayname> set the display to run on\n");
|
||||
printf(" -info display OpenGL renderer info\n");
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
const int winWidth = 300, winHeight = 300;
|
||||
Display *x_dpy;
|
||||
Window win;
|
||||
EGLSurface egl_surf;
|
||||
EGLContext egl_ctx;
|
||||
EGLDisplay egl_dpy;
|
||||
char *dpyName = NULL;
|
||||
GLboolean printInfo = GL_FALSE;
|
||||
EGLint egl_major, egl_minor;
|
||||
int i;
|
||||
const char *s;
|
||||
|
||||
static struct {
|
||||
char *name;
|
||||
GLenum value;
|
||||
enum {GetString, GetInteger} type;
|
||||
} info_items[] = {
|
||||
{"GL_RENDERER", GL_RENDERER, GetString},
|
||||
{"GL_VERSION", GL_VERSION, GetString},
|
||||
{"GL_VENDOR", GL_VENDOR, GetString},
|
||||
{"GL_EXTENSIONS", GL_EXTENSIONS, GetString},
|
||||
{"GL_MAX_PALETTE_MATRICES_OES", GL_MAX_PALETTE_MATRICES_OES, GetInteger},
|
||||
{"GL_MAX_VERTEX_UNITS_OES", GL_MAX_VERTEX_UNITS_OES, GetInteger},
|
||||
};
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-display") == 0) {
|
||||
dpyName = argv[i+1];
|
||||
i++;
|
||||
}
|
||||
else if (strcmp(argv[i], "-info") == 0) {
|
||||
printInfo = GL_TRUE;
|
||||
}
|
||||
else {
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
x_dpy = XOpenDisplay(dpyName);
|
||||
if (!x_dpy) {
|
||||
printf("Error: couldn't open display %s\n",
|
||||
dpyName ? dpyName : getenv("DISPLAY"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
egl_dpy = eglGetDisplay(x_dpy);
|
||||
if (!egl_dpy) {
|
||||
printf("Error: eglGetDisplay() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
|
||||
printf("Error: eglInitialize() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_VERSION);
|
||||
printf("EGL_VERSION = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_VENDOR);
|
||||
printf("EGL_VENDOR = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_EXTENSIONS);
|
||||
printf("EGL_EXTENSIONS = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_CLIENT_APIS);
|
||||
printf("EGL_CLIENT_APIS = %s\n", s);
|
||||
|
||||
make_x_window(x_dpy, egl_dpy,
|
||||
"OpenGL ES 1.x tri", 0, 0, winWidth, winHeight,
|
||||
&win, &egl_ctx, &egl_surf);
|
||||
|
||||
XMapWindow(x_dpy, win);
|
||||
if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) {
|
||||
printf("Error: eglMakeCurrent() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (printInfo) {
|
||||
for (i = 0; i < sizeof(info_items)/sizeof(info_items[0]); i++) {
|
||||
switch (info_items[i].type) {
|
||||
case GetString:
|
||||
printf("%s = %s\n", info_items[i].name, (char *)glGetString(info_items[i].value));
|
||||
break;
|
||||
case GetInteger: {
|
||||
GLint rv = -1;
|
||||
glGetIntegerv(info_items[i].value, &rv);
|
||||
printf("%s = %d\n", info_items[i].name, rv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
init();
|
||||
|
||||
/* Set initial projection/viewing transformation.
|
||||
* We can't be sure we'll get a ConfigureNotify event when the window
|
||||
* first appears.
|
||||
*/
|
||||
reshape(winWidth, winHeight);
|
||||
|
||||
event_loop(x_dpy, win, egl_dpy, egl_surf);
|
||||
|
||||
eglDestroyContext(egl_dpy, egl_ctx);
|
||||
eglDestroySurface(egl_dpy, egl_surf);
|
||||
eglTerminate(egl_dpy);
|
||||
|
||||
|
||||
XDestroyWindow(x_dpy, win);
|
||||
XCloseDisplay(x_dpy);
|
||||
|
||||
return 0;
|
||||
}
|
433
progs/es1/xegl/two_win.c
Normal file
433
progs/es1/xegl/two_win.c
Normal file
@@ -0,0 +1,433 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test drawing to two windows.
|
||||
* Brian Paul
|
||||
* August 2008
|
||||
*/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
#include <EGL/egl.h>
|
||||
|
||||
|
||||
static int WinWidth[2] = {150, 300}, WinHeight[2] = {150, 300};
|
||||
|
||||
|
||||
static GLfloat view_rotx = 0.0, view_roty = 0.0, view_rotz = 0.0;
|
||||
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int width, int height)
|
||||
{
|
||||
GLfloat ar = (GLfloat) width / (GLfloat) height;
|
||||
|
||||
glViewport(0, 0, (GLint) width, (GLint) height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
#ifdef GL_VERSION_ES_CM_1_0
|
||||
glFrustumf(-ar, ar, -1, 1, 5.0, 60.0);
|
||||
#else
|
||||
glFrustum(-ar, ar, -1, 1, 5.0, 60.0);
|
||||
#endif
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -10.0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
draw(int win)
|
||||
{
|
||||
static const GLfloat verts[3][2] = {
|
||||
{ -1, -1 },
|
||||
{ 1, -1 },
|
||||
{ 0, 1 }
|
||||
};
|
||||
static const GLfloat colors[3][4] = {
|
||||
{ 1, 0, 0, 1 },
|
||||
{ 0, 1, 0, 1 },
|
||||
{ 0, 0, 1, 1 }
|
||||
};
|
||||
|
||||
assert(win == 0 || win == 1);
|
||||
|
||||
reshape(WinWidth[win], WinHeight[win]);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(view_rotx, 1, 0, 0);
|
||||
glRotatef(view_roty, 0, 1, 0);
|
||||
glRotatef(view_rotz, 0, 0, 1);
|
||||
|
||||
/* draw triangle */
|
||||
{
|
||||
glVertexPointer(2, GL_FLOAT, 0, verts);
|
||||
glColorPointer(4, GL_FLOAT, 0, colors);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
glClearColor(0.4, 0.4, 0.4, 0.0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create an RGB, double-buffered X window.
|
||||
* Return the window and context handles.
|
||||
*/
|
||||
static void
|
||||
make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
|
||||
const char *name,
|
||||
int x, int y, int width, int height,
|
||||
Window *winRet,
|
||||
EGLContext *ctxRet,
|
||||
EGLSurface *surfRet)
|
||||
{
|
||||
static const EGLint attribs[] = {
|
||||
EGL_RED_SIZE, 1,
|
||||
EGL_GREEN_SIZE, 1,
|
||||
EGL_BLUE_SIZE, 1,
|
||||
EGL_DEPTH_SIZE, 1,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
int scrnum;
|
||||
XSetWindowAttributes attr;
|
||||
unsigned long mask;
|
||||
Window root;
|
||||
Window win;
|
||||
XVisualInfo *visInfo, visTemplate;
|
||||
int num_visuals;
|
||||
EGLContext ctx;
|
||||
EGLConfig config;
|
||||
EGLint num_configs;
|
||||
EGLint vid;
|
||||
|
||||
scrnum = DefaultScreen( x_dpy );
|
||||
root = RootWindow( x_dpy, scrnum );
|
||||
|
||||
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
|
||||
printf("Error: couldn't get an EGL visual config\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
assert(config);
|
||||
assert(num_configs > 0);
|
||||
|
||||
if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
||||
printf("Error: eglGetConfigAttrib() failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* The X window visual must match the EGL config */
|
||||
visTemplate.visualid = vid;
|
||||
visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
|
||||
if (!visInfo) {
|
||||
printf("Error: couldn't get X visual\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* window attributes */
|
||||
attr.background_pixel = 0;
|
||||
attr.border_pixel = 0;
|
||||
attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone);
|
||||
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
|
||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
||||
|
||||
win = XCreateWindow( x_dpy, root, x, y, width, height,
|
||||
0, visInfo->depth, InputOutput,
|
||||
visInfo->visual, mask, &attr );
|
||||
|
||||
/* set hints and properties */
|
||||
{
|
||||
XSizeHints sizehints;
|
||||
sizehints.x = x;
|
||||
sizehints.y = y;
|
||||
sizehints.width = width;
|
||||
sizehints.height = height;
|
||||
sizehints.flags = USSize | USPosition;
|
||||
XSetNormalHints(x_dpy, win, &sizehints);
|
||||
XSetStandardProperties(x_dpy, win, name, name,
|
||||
None, (char **)NULL, 0, &sizehints);
|
||||
}
|
||||
|
||||
#if USE_FULL_GL
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
#else
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
#endif
|
||||
|
||||
if (ctxRet) {
|
||||
ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL );
|
||||
if (!ctx) {
|
||||
printf("Error: eglCreateContext failed\n");
|
||||
exit(1);
|
||||
}
|
||||
*ctxRet = ctx;
|
||||
}
|
||||
|
||||
*surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL);
|
||||
|
||||
if (!*surfRet) {
|
||||
printf("Error: eglCreateWindowSurface failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
XFree(visInfo);
|
||||
|
||||
*winRet = win;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
event_loop(Display *dpy, Window win1, Window win2,
|
||||
EGLDisplay egl_dpy, EGLSurface egl_surf1, EGLSurface egl_surf2,
|
||||
EGLContext egl_ctx)
|
||||
{
|
||||
while (1) {
|
||||
int redraw = 0;
|
||||
int win;
|
||||
XEvent event;
|
||||
|
||||
XNextEvent(dpy, &event);
|
||||
|
||||
switch (event.type) {
|
||||
case Expose:
|
||||
redraw = 1;
|
||||
break;
|
||||
case ConfigureNotify:
|
||||
if (event.xconfigure.window == win1)
|
||||
win = 0;
|
||||
else
|
||||
win = 1;
|
||||
WinWidth[win] = event.xconfigure.width;
|
||||
WinHeight[win] = event.xconfigure.height;
|
||||
break;
|
||||
case KeyPress:
|
||||
{
|
||||
char buffer[10];
|
||||
int r, code;
|
||||
code = XLookupKeysym(&event.xkey, 0);
|
||||
if (code == XK_Left) {
|
||||
view_roty += 5.0;
|
||||
}
|
||||
else if (code == XK_Right) {
|
||||
view_roty -= 5.0;
|
||||
}
|
||||
else if (code == XK_Up) {
|
||||
view_rotx += 5.0;
|
||||
}
|
||||
else if (code == XK_Down) {
|
||||
view_rotx -= 5.0;
|
||||
}
|
||||
else {
|
||||
r = XLookupString(&event.xkey, buffer, sizeof(buffer),
|
||||
NULL, NULL);
|
||||
if (buffer[0] == 27) {
|
||||
/* escape */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
redraw = 1;
|
||||
break;
|
||||
default:
|
||||
; /*no-op*/
|
||||
}
|
||||
|
||||
if (redraw) {
|
||||
/* win 1 */
|
||||
if (!eglMakeCurrent(egl_dpy, egl_surf1, egl_surf1, egl_ctx)) {
|
||||
printf("Error: eglMakeCurrent(1) failed\n");
|
||||
return;
|
||||
}
|
||||
draw(0);
|
||||
eglSwapBuffers(egl_dpy, egl_surf1);
|
||||
|
||||
/* win 2 */
|
||||
if (!eglMakeCurrent(egl_dpy, egl_surf2, egl_surf2, egl_ctx)) {
|
||||
printf("Error: eglMakeCurrent(2) failed\n");
|
||||
return;
|
||||
}
|
||||
draw(1);
|
||||
eglSwapBuffers(egl_dpy, egl_surf2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf(" -display <displayname> set the display to run on\n");
|
||||
printf(" -info display OpenGL renderer info\n");
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
Display *x_dpy;
|
||||
Window win1, win2;
|
||||
EGLSurface egl_surf1, egl_surf2;
|
||||
EGLContext egl_ctx;
|
||||
EGLDisplay egl_dpy;
|
||||
char *dpyName = NULL;
|
||||
GLboolean printInfo = GL_FALSE;
|
||||
EGLint egl_major, egl_minor;
|
||||
int i;
|
||||
const char *s;
|
||||
|
||||
static struct {
|
||||
char *name;
|
||||
GLenum value;
|
||||
enum {GetString, GetInteger} type;
|
||||
} info_items[] = {
|
||||
{"GL_RENDERER", GL_RENDERER, GetString},
|
||||
{"GL_VERSION", GL_VERSION, GetString},
|
||||
{"GL_VENDOR", GL_VENDOR, GetString},
|
||||
{"GL_EXTENSIONS", GL_EXTENSIONS, GetString},
|
||||
{"GL_MAX_PALETTE_MATRICES_OES", GL_MAX_PALETTE_MATRICES_OES, GetInteger},
|
||||
{"GL_MAX_VERTEX_UNITS_OES", GL_MAX_VERTEX_UNITS_OES, GetInteger},
|
||||
};
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-display") == 0) {
|
||||
dpyName = argv[i+1];
|
||||
i++;
|
||||
}
|
||||
else if (strcmp(argv[i], "-info") == 0) {
|
||||
printInfo = GL_TRUE;
|
||||
}
|
||||
else {
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
x_dpy = XOpenDisplay(dpyName);
|
||||
if (!x_dpy) {
|
||||
printf("Error: couldn't open display %s\n",
|
||||
dpyName ? dpyName : getenv("DISPLAY"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
egl_dpy = eglGetDisplay(x_dpy);
|
||||
if (!egl_dpy) {
|
||||
printf("Error: eglGetDisplay() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
|
||||
printf("Error: eglInitialize() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_VERSION);
|
||||
printf("EGL_VERSION = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_VENDOR);
|
||||
printf("EGL_VENDOR = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_EXTENSIONS);
|
||||
printf("EGL_EXTENSIONS = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_CLIENT_APIS);
|
||||
printf("EGL_CLIENT_APIS = %s\n", s);
|
||||
|
||||
make_x_window(x_dpy, egl_dpy,
|
||||
"xegl_two_win #1", 0, 0, WinWidth[0], WinHeight[0],
|
||||
&win1, &egl_ctx, &egl_surf1);
|
||||
|
||||
make_x_window(x_dpy, egl_dpy,
|
||||
"xegl_two_win #2", WinWidth[0] + 50, 0,
|
||||
WinWidth[1], WinHeight[1],
|
||||
&win2, NULL, &egl_surf2);
|
||||
|
||||
XMapWindow(x_dpy, win1);
|
||||
|
||||
XMapWindow(x_dpy, win2);
|
||||
|
||||
if (!eglMakeCurrent(egl_dpy, egl_surf1, egl_surf1, egl_ctx)) {
|
||||
printf("Error: eglMakeCurrent() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (printInfo) {
|
||||
for (i = 0; i < sizeof(info_items)/sizeof(info_items[0]); i++) {
|
||||
switch (info_items[i].type) {
|
||||
case GetString:
|
||||
printf("%s = %s\n", info_items[i].name, (char *)glGetString(info_items[i].value));
|
||||
break;
|
||||
case GetInteger: {
|
||||
GLint rv = -1;
|
||||
glGetIntegerv(info_items[i].value, &rv);
|
||||
printf("%s = %d\n", info_items[i].name, rv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
init();
|
||||
|
||||
event_loop(x_dpy, win1, win2, egl_dpy, egl_surf1, egl_surf2, egl_ctx);
|
||||
|
||||
eglDestroyContext(egl_dpy, egl_ctx);
|
||||
eglDestroySurface(egl_dpy, egl_surf1);
|
||||
eglDestroySurface(egl_dpy, egl_surf2);
|
||||
eglTerminate(egl_dpy);
|
||||
|
||||
XDestroyWindow(x_dpy, win1);
|
||||
XDestroyWindow(x_dpy, win2);
|
||||
XCloseDisplay(x_dpy);
|
||||
|
||||
return 0;
|
||||
}
|
51
progs/es2/xegl/Makefile
Normal file
51
progs/es2/xegl/Makefile
Normal file
@@ -0,0 +1,51 @@
|
||||
# progs/es2/xegl/Makefile
|
||||
|
||||
TOP = ../../..
|
||||
include $(TOP)/configs/current
|
||||
|
||||
|
||||
INCLUDE_DIRS = \
|
||||
-I$(TOP)/include \
|
||||
|
||||
HEADERS = $(TOP)/include/GLES/egl.h
|
||||
|
||||
|
||||
ES2_LIB_DEPS = \
|
||||
$(TOP)/$(LIB_DIR)/libEGL.so \
|
||||
$(TOP)/$(LIB_DIR)/libGLESv2.so
|
||||
|
||||
|
||||
ES2_LIBS = \
|
||||
-L$(TOP)/$(LIB_DIR) -lEGL \
|
||||
-L$(TOP)/$(LIB_DIR) -lGLESv2 $(LIBDRM_LIB) -lX11
|
||||
|
||||
PROGRAMS = \
|
||||
es2_info \
|
||||
tri
|
||||
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
default: $(PROGRAMS)
|
||||
|
||||
|
||||
|
||||
es2_info.c:
|
||||
cp ../../es1/xegl/es1_info.c es2_info.c
|
||||
|
||||
es2_info: es2_info.o $(ES2_LIB_DEPS)
|
||||
$(CC) $(CFLAGS) es2_info.o $(ES2_LIBS) -o $@
|
||||
|
||||
tri: tri.o $(ES2_LIB_DEPS)
|
||||
$(CC) $(CFLAGS) tri.o $(ES2_LIBS) -o $@
|
||||
|
||||
|
||||
|
||||
clean:
|
||||
rm -f *.o *~
|
||||
rm -f $(PROGRAMS)
|
||||
rm -f es2_info.c
|
||||
|
516
progs/es2/xegl/tri.c
Normal file
516
progs/es2/xegl/tri.c
Normal file
@@ -0,0 +1,516 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Draw a triangle with X/EGL and OpenGL ES 2.x
|
||||
*/
|
||||
|
||||
#define USE_FULL_GL 0
|
||||
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#if USE_FULL_GL
|
||||
#include <GL/gl.h> /* use full OpenGL */
|
||||
#else
|
||||
#include <GLES2/gl2.h> /* use OpenGL ES 2.x */
|
||||
#endif
|
||||
#include <EGL/egl.h>
|
||||
|
||||
|
||||
#define FLOAT_TO_FIXED(X) ((X) * 65535.0)
|
||||
|
||||
|
||||
|
||||
static GLfloat view_rotx = 0.0, view_roty = 0.0;
|
||||
|
||||
static GLint u_matrix = -1;
|
||||
static GLint attr_pos = 0, attr_color = 1;
|
||||
|
||||
|
||||
static void
|
||||
make_z_rot_matrix(GLfloat angle, GLfloat *m)
|
||||
{
|
||||
float c = cos(angle * M_PI / 180.0);
|
||||
float s = sin(angle * M_PI / 180.0);
|
||||
int i;
|
||||
for (i = 0; i < 16; i++)
|
||||
m[i] = 0.0;
|
||||
m[0] = m[5] = m[10] = m[15] = 1.0;
|
||||
|
||||
m[0] = c;
|
||||
m[1] = s;
|
||||
m[4] = -s;
|
||||
m[5] = c;
|
||||
}
|
||||
|
||||
static void
|
||||
make_scale_matrix(GLfloat xs, GLfloat ys, GLfloat zs, GLfloat *m)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 16; i++)
|
||||
m[i] = 0.0;
|
||||
m[0] = xs;
|
||||
m[5] = ys;
|
||||
m[10] = zs;
|
||||
m[15] = 1.0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
mul_matrix(GLfloat *prod, const GLfloat *a, const GLfloat *b)
|
||||
{
|
||||
#define A(row,col) a[(col<<2)+row]
|
||||
#define B(row,col) b[(col<<2)+row]
|
||||
#define P(row,col) p[(col<<2)+row]
|
||||
GLfloat p[16];
|
||||
GLint i;
|
||||
for (i = 0; i < 4; i++) {
|
||||
const GLfloat ai0=A(i,0), ai1=A(i,1), ai2=A(i,2), ai3=A(i,3);
|
||||
P(i,0) = ai0 * B(0,0) + ai1 * B(1,0) + ai2 * B(2,0) + ai3 * B(3,0);
|
||||
P(i,1) = ai0 * B(0,1) + ai1 * B(1,1) + ai2 * B(2,1) + ai3 * B(3,1);
|
||||
P(i,2) = ai0 * B(0,2) + ai1 * B(1,2) + ai2 * B(2,2) + ai3 * B(3,2);
|
||||
P(i,3) = ai0 * B(0,3) + ai1 * B(1,3) + ai2 * B(2,3) + ai3 * B(3,3);
|
||||
}
|
||||
memcpy(prod, p, sizeof(p));
|
||||
#undef A
|
||||
#undef B
|
||||
#undef PROD
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
static const GLfloat verts[3][2] = {
|
||||
{ -1, -1 },
|
||||
{ 1, -1 },
|
||||
{ 0, 1 }
|
||||
};
|
||||
static const GLfloat colors[3][3] = {
|
||||
{ 1, 0, 0 },
|
||||
{ 0, 1, 0 },
|
||||
{ 0, 0, 1 }
|
||||
};
|
||||
GLfloat mat[16], rot[16], scale[16];
|
||||
|
||||
/* Set modelview/projection matrix */
|
||||
make_z_rot_matrix(view_rotx, rot);
|
||||
make_scale_matrix(0.5, 0.5, 0.5, scale);
|
||||
mul_matrix(mat, rot, scale);
|
||||
glUniformMatrix4fv(u_matrix, 1, GL_FALSE, mat);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
{
|
||||
glVertexAttribPointer(attr_pos, 2, GL_FLOAT, GL_FALSE, 0, verts);
|
||||
glVertexAttribPointer(attr_color, 3, GL_FLOAT, GL_FALSE, 0, colors);
|
||||
glEnableVertexAttribArray(attr_pos);
|
||||
glEnableVertexAttribArray(attr_color);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
|
||||
glDisableVertexAttribArray(attr_pos);
|
||||
glDisableVertexAttribArray(attr_color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int width, int height)
|
||||
{
|
||||
glViewport(0, 0, (GLint) width, (GLint) height);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
create_shaders(void)
|
||||
{
|
||||
static const char *fragShaderText =
|
||||
"varying vec4 v_color;\n"
|
||||
"void main() {\n"
|
||||
" gl_FragColor = v_color;\n"
|
||||
"}\n";
|
||||
static const char *vertShaderText =
|
||||
"uniform mat4 modelviewProjection;\n"
|
||||
"attribute vec4 pos;\n"
|
||||
"attribute vec4 color;\n"
|
||||
"varying vec4 v_color;\n"
|
||||
"void main() {\n"
|
||||
" gl_Position = modelviewProjection * pos;\n"
|
||||
" v_color = color;\n"
|
||||
"}\n";
|
||||
|
||||
GLuint fragShader, vertShader, program;
|
||||
GLint stat;
|
||||
|
||||
fragShader = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
glShaderSource(fragShader, 1, (const char **) &fragShaderText, NULL);
|
||||
glCompileShader(fragShader);
|
||||
glGetShaderiv(fragShader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
printf("Error: fragment shader did not compile!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
vertShader = glCreateShader(GL_VERTEX_SHADER);
|
||||
glShaderSource(vertShader, 1, (const char **) &vertShaderText, NULL);
|
||||
glCompileShader(vertShader);
|
||||
glGetShaderiv(vertShader, GL_COMPILE_STATUS, &stat);
|
||||
if (!stat) {
|
||||
printf("Error: vertex shader did not compile!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
program = glCreateProgram();
|
||||
glAttachShader(program, fragShader);
|
||||
glAttachShader(program, vertShader);
|
||||
glLinkProgram(program);
|
||||
|
||||
glGetProgramiv(program, GL_LINK_STATUS, &stat);
|
||||
if (!stat) {
|
||||
char log[1000];
|
||||
GLsizei len;
|
||||
glGetProgramInfoLog(program, 1000, &len, log);
|
||||
printf("Error: linking:\n%s\n", log);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glUseProgram(program);
|
||||
|
||||
if (1) {
|
||||
/* test setting attrib locations */
|
||||
glBindAttribLocation(program, attr_pos, "pos");
|
||||
glBindAttribLocation(program, attr_color, "color");
|
||||
glLinkProgram(program); /* needed to put attribs into effect */
|
||||
}
|
||||
else {
|
||||
/* test automatic attrib locations */
|
||||
attr_pos = glGetAttribLocation(program, "pos");
|
||||
attr_color = glGetAttribLocation(program, "color");
|
||||
}
|
||||
|
||||
u_matrix = glGetUniformLocation(program, "modelviewProjection");
|
||||
printf("Uniform modelviewProjection at %d\n", u_matrix);
|
||||
printf("Attrib pos at %d\n", attr_pos);
|
||||
printf("Attrib color at %d\n", attr_color);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
init(void)
|
||||
{
|
||||
typedef void (*proc)();
|
||||
|
||||
#if 1 /* test code */
|
||||
proc p = eglGetProcAddress("eglCreateContext");
|
||||
assert(p);
|
||||
p = eglGetProcAddress("glMapBufferOES");
|
||||
assert(p);
|
||||
#endif
|
||||
|
||||
glClearColor(0.4, 0.4, 0.4, 0.0);
|
||||
|
||||
create_shaders();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Create an RGB, double-buffered X window.
|
||||
* Return the window and context handles.
|
||||
*/
|
||||
static void
|
||||
make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
|
||||
const char *name,
|
||||
int x, int y, int width, int height,
|
||||
Window *winRet,
|
||||
EGLContext *ctxRet,
|
||||
EGLSurface *surfRet)
|
||||
{
|
||||
static const EGLint attribs[] = {
|
||||
EGL_RED_SIZE, 1,
|
||||
EGL_GREEN_SIZE, 1,
|
||||
EGL_BLUE_SIZE, 1,
|
||||
EGL_DEPTH_SIZE, 1,
|
||||
EGL_NONE
|
||||
};
|
||||
static const EGLint ctx_attribs[] = {
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
EGL_NONE
|
||||
};
|
||||
int scrnum;
|
||||
XSetWindowAttributes attr;
|
||||
unsigned long mask;
|
||||
Window root;
|
||||
Window win;
|
||||
XVisualInfo *visInfo, visTemplate;
|
||||
int num_visuals;
|
||||
EGLContext ctx;
|
||||
EGLConfig config;
|
||||
EGLint num_configs;
|
||||
EGLint vid;
|
||||
|
||||
scrnum = DefaultScreen( x_dpy );
|
||||
root = RootWindow( x_dpy, scrnum );
|
||||
|
||||
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
|
||||
printf("Error: couldn't get an EGL visual config\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
assert(config);
|
||||
assert(num_configs > 0);
|
||||
|
||||
if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
||||
printf("Error: eglGetConfigAttrib() failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* The X window visual must match the EGL config */
|
||||
visTemplate.visualid = vid;
|
||||
visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
|
||||
if (!visInfo) {
|
||||
printf("Error: couldn't get X visual\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* window attributes */
|
||||
attr.background_pixel = 0;
|
||||
attr.border_pixel = 0;
|
||||
attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone);
|
||||
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
|
||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
||||
|
||||
win = XCreateWindow( x_dpy, root, 0, 0, width, height,
|
||||
0, visInfo->depth, InputOutput,
|
||||
visInfo->visual, mask, &attr );
|
||||
|
||||
/* set hints and properties */
|
||||
{
|
||||
XSizeHints sizehints;
|
||||
sizehints.x = x;
|
||||
sizehints.y = y;
|
||||
sizehints.width = width;
|
||||
sizehints.height = height;
|
||||
sizehints.flags = USSize | USPosition;
|
||||
XSetNormalHints(x_dpy, win, &sizehints);
|
||||
XSetStandardProperties(x_dpy, win, name, name,
|
||||
None, (char **)NULL, 0, &sizehints);
|
||||
}
|
||||
|
||||
#if USE_FULL_GL /* XXX fix this when eglBindAPI() works */
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
#else
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
#endif
|
||||
|
||||
ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, ctx_attribs );
|
||||
if (!ctx) {
|
||||
printf("Error: eglCreateContext failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* test eglQueryContext() */
|
||||
{
|
||||
EGLint val;
|
||||
eglQueryContext(egl_dpy, ctx, EGL_CONTEXT_CLIENT_VERSION, &val);
|
||||
assert(val == 2);
|
||||
}
|
||||
|
||||
*surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL);
|
||||
if (!*surfRet) {
|
||||
printf("Error: eglCreateWindowSurface failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
{
|
||||
EGLint val;
|
||||
eglQuerySurface(egl_dpy, *surfRet, EGL_WIDTH, &val);
|
||||
assert(val == width);
|
||||
eglQuerySurface(egl_dpy, *surfRet, EGL_HEIGHT, &val);
|
||||
assert(val == height);
|
||||
eglQuerySurface(egl_dpy, *surfRet, EGL_SURFACE_TYPE, &val);
|
||||
assert(val == EGL_WINDOW_BIT);
|
||||
}
|
||||
|
||||
XFree(visInfo);
|
||||
|
||||
*winRet = win;
|
||||
*ctxRet = ctx;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
event_loop(Display *dpy, Window win,
|
||||
EGLDisplay egl_dpy, EGLSurface egl_surf)
|
||||
{
|
||||
while (1) {
|
||||
int redraw = 0;
|
||||
XEvent event;
|
||||
|
||||
XNextEvent(dpy, &event);
|
||||
|
||||
switch (event.type) {
|
||||
case Expose:
|
||||
redraw = 1;
|
||||
break;
|
||||
case ConfigureNotify:
|
||||
reshape(event.xconfigure.width, event.xconfigure.height);
|
||||
break;
|
||||
case KeyPress:
|
||||
{
|
||||
char buffer[10];
|
||||
int r, code;
|
||||
code = XLookupKeysym(&event.xkey, 0);
|
||||
if (code == XK_Left) {
|
||||
view_roty += 5.0;
|
||||
}
|
||||
else if (code == XK_Right) {
|
||||
view_roty -= 5.0;
|
||||
}
|
||||
else if (code == XK_Up) {
|
||||
view_rotx += 5.0;
|
||||
}
|
||||
else if (code == XK_Down) {
|
||||
view_rotx -= 5.0;
|
||||
}
|
||||
else {
|
||||
r = XLookupString(&event.xkey, buffer, sizeof(buffer),
|
||||
NULL, NULL);
|
||||
if (buffer[0] == 27) {
|
||||
/* escape */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
redraw = 1;
|
||||
break;
|
||||
default:
|
||||
; /*no-op*/
|
||||
}
|
||||
|
||||
if (redraw) {
|
||||
draw();
|
||||
eglSwapBuffers(egl_dpy, egl_surf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf(" -display <displayname> set the display to run on\n");
|
||||
printf(" -info display OpenGL renderer info\n");
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
const int winWidth = 300, winHeight = 300;
|
||||
Display *x_dpy;
|
||||
Window win;
|
||||
EGLSurface egl_surf;
|
||||
EGLContext egl_ctx;
|
||||
EGLDisplay egl_dpy;
|
||||
char *dpyName = NULL;
|
||||
GLboolean printInfo = GL_FALSE;
|
||||
EGLint egl_major, egl_minor;
|
||||
int i;
|
||||
const char *s;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-display") == 0) {
|
||||
dpyName = argv[i+1];
|
||||
i++;
|
||||
}
|
||||
else if (strcmp(argv[i], "-info") == 0) {
|
||||
printInfo = GL_TRUE;
|
||||
}
|
||||
else {
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
x_dpy = XOpenDisplay(dpyName);
|
||||
if (!x_dpy) {
|
||||
printf("Error: couldn't open display %s\n",
|
||||
dpyName ? dpyName : getenv("DISPLAY"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
egl_dpy = eglGetDisplay(x_dpy);
|
||||
if (!egl_dpy) {
|
||||
printf("Error: eglGetDisplay() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) {
|
||||
printf("Error: eglInitialize() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_VERSION);
|
||||
printf("EGL_VERSION = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_VENDOR);
|
||||
printf("EGL_VENDOR = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_EXTENSIONS);
|
||||
printf("EGL_EXTENSIONS = %s\n", s);
|
||||
|
||||
s = eglQueryString(egl_dpy, EGL_CLIENT_APIS);
|
||||
printf("EGL_CLIENT_APIS = %s\n", s);
|
||||
|
||||
make_x_window(x_dpy, egl_dpy,
|
||||
"OpenGL ES 2.x tri", 0, 0, winWidth, winHeight,
|
||||
&win, &egl_ctx, &egl_surf);
|
||||
|
||||
XMapWindow(x_dpy, win);
|
||||
if (!eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx)) {
|
||||
printf("Error: eglMakeCurrent() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (printInfo) {
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
/* Set initial projection/viewing transformation.
|
||||
* We can't be sure we'll get a ConfigureNotify event when the window
|
||||
* first appears.
|
||||
*/
|
||||
reshape(winWidth, winHeight);
|
||||
|
||||
event_loop(x_dpy, win, egl_dpy, egl_surf);
|
||||
|
||||
eglDestroyContext(egl_dpy, egl_ctx);
|
||||
eglDestroySurface(egl_dpy, egl_surf);
|
||||
eglTerminate(egl_dpy);
|
||||
|
||||
|
||||
XDestroyWindow(x_dpy, win);
|
||||
XCloseDisplay(x_dpy);
|
||||
|
||||
return 0;
|
||||
}
|
@@ -16,9 +16,6 @@
|
||||
#include <GL/glut.h>
|
||||
#include "shaderutil.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.1415926535
|
||||
#endif
|
||||
|
||||
static char *FragProgFile = "skinning.frag";
|
||||
static char *VertProgFile = "skinning.vert";
|
||||
|
@@ -14,9 +14,6 @@
|
||||
#include <GL/glew.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.1415926535
|
||||
#endif
|
||||
|
||||
static GLint WinWidth = 300, WinHeight = 300;
|
||||
static GLint win = 0;
|
||||
|
@@ -16,9 +16,6 @@
|
||||
#include <GL/glut.h>
|
||||
#include "shaderutil.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.1415926535
|
||||
#endif
|
||||
|
||||
static GLint WinWidth = 300, WinHeight = 300;
|
||||
static char *FragProgFile = NULL;
|
||||
|
@@ -28,7 +28,6 @@ SOURCES = \
|
||||
blendminmax.c \
|
||||
blendsquare.c \
|
||||
blendxor.c \
|
||||
blitfb.c \
|
||||
bufferobj.c \
|
||||
bumpmap.c \
|
||||
bug_3050.c \
|
||||
|
@@ -52,7 +52,6 @@ progs = [
|
||||
'blendminmax',
|
||||
'blendsquare',
|
||||
'blendxor',
|
||||
'blitfb',
|
||||
'bufferobj',
|
||||
'bug_3050',
|
||||
'bug_3101',
|
||||
|
@@ -1,259 +0,0 @@
|
||||
/**
|
||||
* Test glFramebufferBlit()
|
||||
* Brian Paul
|
||||
* 27 Oct 2009
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
static int Win;
|
||||
static int WinWidth = 1100, WinHeight = 600;
|
||||
|
||||
static int SrcWidth = 512, SrcHeight = 512;
|
||||
static int DstWidth = 512, DstHeight = 512;
|
||||
|
||||
static GLuint SrcFB, DstFB;
|
||||
static GLuint SrcTex, DstTex;
|
||||
|
||||
#if 0
|
||||
static GLenum SrcTexTarget = GL_TEXTURE_2D, SrcTexFace = GL_TEXTURE_2D;
|
||||
#else
|
||||
static GLenum SrcTexTarget = GL_TEXTURE_CUBE_MAP, SrcTexFace = GL_TEXTURE_CUBE_MAP_POSITIVE_X;
|
||||
#endif
|
||||
|
||||
static GLenum DstTexTarget = GL_TEXTURE_2D, DstTexFace = GL_TEXTURE_2D;
|
||||
|
||||
static GLuint SrcTexLevel = 01, DstTexLevel = 0;
|
||||
|
||||
|
||||
static void
|
||||
Draw(void)
|
||||
{
|
||||
GLboolean rp = GL_FALSE;
|
||||
GLubyte *buf;
|
||||
GLint srcWidth = SrcWidth >> SrcTexLevel;
|
||||
GLint srcHeight = SrcHeight >> SrcTexLevel;
|
||||
GLint dstWidth = DstWidth >> DstTexLevel;
|
||||
GLint dstHeight = DstHeight >> DstTexLevel;
|
||||
GLenum status;
|
||||
|
||||
/* clear window */
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
|
||||
glClearColor(0.5, 0.5, 0.5, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
|
||||
/* clear src buf */
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER, SrcFB);
|
||||
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
assert(status == GL_FRAMEBUFFER_COMPLETE_EXT);
|
||||
glClearColor(0, 1, 0, 0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
/* clear dst buf */
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER, DstFB);
|
||||
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||
assert(status == GL_FRAMEBUFFER_COMPLETE_EXT);
|
||||
glClearColor(1, 0, 0, 0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
/* blit src -> dst */
|
||||
glBindFramebufferEXT(GL_READ_FRAMEBUFFER, SrcFB);
|
||||
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, DstFB);
|
||||
glBlitFramebufferEXT(0, 0, srcWidth, srcHeight,
|
||||
0, 0, dstWidth, dstHeight,
|
||||
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
|
||||
#if 01
|
||||
/* read src results */
|
||||
buf = malloc(4 * srcWidth * srcHeight);
|
||||
memset(buf, 0x88, 4 * srcWidth * srcHeight);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER, SrcFB);
|
||||
if (rp)
|
||||
glReadPixels(0, 0, srcWidth, srcHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf);
|
||||
else {
|
||||
glBindTexture(SrcTexTarget, SrcTex);
|
||||
glGetTexImage(SrcTexFace, SrcTexLevel, GL_RGBA, GL_UNSIGNED_BYTE, buf);
|
||||
}
|
||||
|
||||
/* draw dst in window */
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
|
||||
glWindowPos2i(0, 0);
|
||||
glDrawPixels(srcWidth, srcHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf);
|
||||
|
||||
printf("Src Pix[0] = %d %d %d %d\n", buf[0], buf[1], buf[2], buf[3]);
|
||||
free(buf);
|
||||
#endif
|
||||
|
||||
glFinish();
|
||||
|
||||
/* read dst results */
|
||||
buf = malloc(4 * dstWidth * dstHeight);
|
||||
memset(buf, 0x88, 4 * dstWidth * dstHeight);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER, DstFB);
|
||||
if (rp)
|
||||
glReadPixels(0, 0, dstWidth, dstHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf);
|
||||
else {
|
||||
glBindTexture(DstTexTarget, DstTex);
|
||||
glGetTexImage(DstTexFace, DstTexLevel, GL_RGBA, GL_UNSIGNED_BYTE, buf);
|
||||
}
|
||||
|
||||
/* draw dst in window */
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
|
||||
glWindowPos2i(srcWidth + 2, 0);
|
||||
glDrawPixels(dstWidth, dstHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf);
|
||||
|
||||
printf("Dst Pix[0] = %d %d %d %d\n", buf[0], buf[1], buf[2], buf[3]);
|
||||
free(buf);
|
||||
|
||||
glFinish();
|
||||
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Reshape(int width, int height)
|
||||
{
|
||||
WinWidth = width;
|
||||
WinHeight = height;
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -15.0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Key(unsigned char key, int x, int y)
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (key) {
|
||||
case 27:
|
||||
glutDestroyWindow(Win);
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
SpecialKey(int key, int x, int y)
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (key) {
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
InitFBOs(void)
|
||||
{
|
||||
GLuint w, h, lvl;
|
||||
|
||||
/* Src */
|
||||
glGenTextures(1, &SrcTex);
|
||||
glBindTexture(SrcTexTarget, SrcTex);
|
||||
w = SrcWidth;
|
||||
h = SrcHeight;
|
||||
lvl = 0;
|
||||
for (lvl = 0; ; lvl++) {
|
||||
if (SrcTexTarget == GL_TEXTURE_CUBE_MAP) {
|
||||
GLuint f;
|
||||
for (f = 0; f < 6; f++) {
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + f, lvl, GL_RGBA8,
|
||||
w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* single face */
|
||||
glTexImage2D(SrcTexFace, lvl, GL_RGBA8, w, h, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
}
|
||||
if (w == 1 && h == 1)
|
||||
break;
|
||||
if (w > 1)
|
||||
w /= 2;
|
||||
if (h > 1)
|
||||
h /= 2;
|
||||
}
|
||||
|
||||
glGenFramebuffersEXT(1, &SrcFB);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER, SrcFB);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||
SrcTexFace, SrcTex, SrcTexLevel);
|
||||
|
||||
/* Dst */
|
||||
glGenTextures(1, &DstTex);
|
||||
glBindTexture(DstTexTarget, DstTex);
|
||||
w = DstWidth;
|
||||
h = DstHeight;
|
||||
lvl = 0;
|
||||
for (lvl = 0; ; lvl++) {
|
||||
glTexImage2D(DstTexFace, lvl, GL_RGBA8, w, h, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
if (w == 1 && h == 1)
|
||||
break;
|
||||
if (w > 1)
|
||||
w /= 2;
|
||||
if (h > 1)
|
||||
h /= 2;
|
||||
}
|
||||
|
||||
glGenFramebuffersEXT(1, &DstFB);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER, DstFB);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||
DstTexFace, DstTex, DstTexLevel);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
if (!glutExtensionSupported("GL_EXT_framebuffer_object")) {
|
||||
fprintf(stderr, "This test requires GL_EXT_framebuffer_object\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!glutExtensionSupported("GL_EXT_framebuffer_blit")) {
|
||||
fprintf(stderr, "This test requires GL_EXT_framebuffer_blit,\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
InitFBOs();
|
||||
|
||||
printf("Left rect = src FBO, Right rect = dst FBO.\n");
|
||||
printf("Both should be green.\n");
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
Win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
glutDisplayFunc(Draw);
|
||||
Init();
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -43,8 +43,6 @@ Display(void)
|
||||
|
||||
glUseProgram_func(Program);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
/* draw to user framebuffer */
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBobject);
|
||||
|
||||
@@ -70,23 +68,18 @@ Display(void)
|
||||
glPopMatrix();
|
||||
|
||||
/* read from user framebuffer */
|
||||
/* left half = colorbuffer 0 */
|
||||
/* bottom half = colorbuffer 0 */
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glPixelStorei(GL_PACK_ROW_LENGTH, Width);
|
||||
glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
|
||||
glReadPixels(0, 0, Width / 2, Height, GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
glReadPixels(0, 0, Width, Height / 2, GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
buffer);
|
||||
|
||||
/* right half = colorbuffer 1 */
|
||||
/* top half = colorbuffer 1 */
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT1_EXT);
|
||||
glPixelStorei(GL_PACK_SKIP_PIXELS, Width / 2);
|
||||
glReadPixels(Width / 2, 0, Width - Width / 2, Height,
|
||||
glReadPixels(0, Height/2, Width, Height - Height / 2,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
buffer);
|
||||
buffer + Width * (Height / 2) * 4);
|
||||
|
||||
/* draw to window */
|
||||
glUseProgram_func(0);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
glWindowPos2iARB(0, 0);
|
||||
glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
|
||||
|
@@ -285,12 +285,6 @@ main(int argc, char** argv)
|
||||
glutInitWindowSize (600, 600);
|
||||
glutCreateWindow (argv[0]);
|
||||
glewInit();
|
||||
|
||||
if (!glutExtensionSupported("GL_EXT_texture_compression_s3tc")) {
|
||||
fprintf(stderr, "This test requires GL_EXT_texture_compression_s3tc.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
myInit();
|
||||
glutReshapeFunc (myReshape);
|
||||
glutDisplayFunc(display);
|
||||
|
@@ -257,11 +257,11 @@ RandomPrimitive(void)
|
||||
Vcount++;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
int k = RandomInt(9);
|
||||
Vbuffer[Vcount].v[0] = RandomFloat(-3, 3);
|
||||
Vbuffer[Vcount].v[1] = RandomFloat(-3, 3);
|
||||
Vbuffer[Vcount].v[2] = RandomFloat(-3, 3);
|
||||
Vbuffer[Vcount].v[3] = RandomFloat(-3, 3);
|
||||
int k = RandomInt(9);
|
||||
switch (k) {
|
||||
case 0:
|
||||
glVertex2fv(Vbuffer[Vcount].v);
|
||||
|
@@ -8,10 +8,6 @@
|
||||
#include <GL/glew.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
#ifndef APIENTRY
|
||||
#define APIENTRY
|
||||
#endif
|
||||
|
||||
static void assert_test(const char *file, int line, int cond, const char *msg)
|
||||
{
|
||||
if (!cond)
|
||||
@@ -46,7 +42,7 @@ static void assert_error_test(const char *file, int line, GLenum expect)
|
||||
|
||||
#define assert_error(err) assert_error_test(__FILE__, __LINE__, (err))
|
||||
|
||||
static void check_status(GLuint id, GLenum pname, void (APIENTRY *query)(GLuint, GLenum, GLint *))
|
||||
static void check_status(GLuint id, GLenum pname, void (*query)(GLuint, GLenum, GLint *))
|
||||
{
|
||||
GLint status;
|
||||
|
||||
|
@@ -149,7 +149,7 @@ static void Reshape( int width, int height )
|
||||
|
||||
static void ReInit( GLenum TC, TEXTURE *Tx )
|
||||
{
|
||||
GLint rv, v;
|
||||
GLint rv;
|
||||
|
||||
if ((Tx->TC == TC) && (Tx->cData != NULL)) {
|
||||
glCompressedTexImage2DARB(GL_TEXTURE_2D, /* target */
|
||||
@@ -170,12 +170,6 @@ static void ReInit( GLenum TC, TEXTURE *Tx )
|
||||
GL_UNSIGNED_BYTE, /* texture type */
|
||||
Tx->data); /* the texture */
|
||||
|
||||
|
||||
v = 0;
|
||||
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
|
||||
GL_TEXTURE_INTERNAL_FORMAT, &v);
|
||||
printf("Requested internal format = 0x%x, actual = 0x%x\n", TC, v);
|
||||
|
||||
/* okay, now cache the compressed texture */
|
||||
Tx->TC = TC;
|
||||
if (Tx->cData != NULL) {
|
||||
|
@@ -12,6 +12,7 @@
|
||||
#include <GL/glut.h>
|
||||
|
||||
static GLint WinWidth = 500, WinHeight = 500;
|
||||
static GLboolean Invert = GL_FALSE;
|
||||
|
||||
|
||||
static void Display(void)
|
||||
@@ -50,7 +51,15 @@ static void Display(void)
|
||||
glPixelZoom(4.0, 4.0);
|
||||
glColor4f(1, 0, 0, 0);
|
||||
glWindowPos2i(100, 0);
|
||||
if (Invert) {
|
||||
glPixelTransferf(GL_DEPTH_SCALE, -1.0);
|
||||
glPixelTransferf(GL_DEPTH_BIAS, 1.0);
|
||||
}
|
||||
glDrawPixels(100, 100, GL_DEPTH_COMPONENT, GL_FLOAT, depth);
|
||||
if (Invert) {
|
||||
glPixelTransferf(GL_DEPTH_SCALE, 1.0);
|
||||
glPixelTransferf(GL_DEPTH_BIAS, 0.0);
|
||||
}
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
@@ -77,6 +86,9 @@ static void Key(unsigned char key, int x, int y)
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (key) {
|
||||
case 'i':
|
||||
Invert = !Invert;
|
||||
break;
|
||||
case 27:
|
||||
exit(0);
|
||||
break;
|
||||
|
@@ -39,11 +39,6 @@ GLenum doubleBuffer;
|
||||
|
||||
static void Init(void)
|
||||
{
|
||||
if (!glutExtensionSupported("GL_ARB_occlusion_query")) {
|
||||
fprintf(stderr, "Sorry, this program requires GL_ARB_occlusion_query\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||
|
@@ -119,12 +119,6 @@ static void Init( void )
|
||||
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
|
||||
glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
sz, (const GLubyte *) buf);
|
||||
if (glGetError()) {
|
||||
printf("Program failed to compile:\n%s\n", buf);
|
||||
printf("Error: %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
exit(1);
|
||||
}
|
||||
assert(glIsProgramARB(prognum));
|
||||
}
|
||||
|
||||
|
@@ -95,7 +95,7 @@ enum sync_type {
|
||||
static void usage(char *name)
|
||||
{
|
||||
printf("usage: %s [-w <width>] [-h <height>] [-s<sync method>] "
|
||||
"[-v]\n", name);
|
||||
"[-vc]\n", name);
|
||||
printf("\t-s<sync method>:\n");
|
||||
printf("\t\tn: none\n");
|
||||
printf("\t\ts: SGI video sync extension\n");
|
||||
|
@@ -143,7 +143,7 @@ MakePbuffer( Display *dpy, int screen, int width, int height )
|
||||
|
||||
/* Create the pbuffer using first fbConfig in the list that works. */
|
||||
for (i=0;i<nConfigs;i++) {
|
||||
pBuffer = CreatePbuffer(dpy, screen, fbConfigs[i], width, height, largest, preserve);
|
||||
pBuffer = CreatePbuffer(dpy, screen, fbConfigs[i], width, height, preserve, largest);
|
||||
if (pBuffer) {
|
||||
gFBconfig = fbConfigs[i];
|
||||
gWidth = width;
|
||||
@@ -210,21 +210,6 @@ Setup(int width, int height)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Test drawable queries */
|
||||
{
|
||||
unsigned int v;
|
||||
glXQueryDrawable( gDpy, gPBuffer, GLX_WIDTH, &v);
|
||||
printf("GLX_WIDTH = %u\n", v);
|
||||
glXQueryDrawable( gDpy, gPBuffer, GLX_HEIGHT, &v);
|
||||
printf("GLX_HEIGHT = %u\n", v);
|
||||
glXQueryDrawable( gDpy, gPBuffer, GLX_PRESERVED_CONTENTS, &v);
|
||||
printf("GLX_PRESERVED_CONTENTS = %u\n", v);
|
||||
glXQueryDrawable( gDpy, gPBuffer, GLX_LARGEST_PBUFFER, &v);
|
||||
printf("GLX_LARGEST_PBUFFER = %u\n", v);
|
||||
glXQueryDrawable( gDpy, gPBuffer, GLX_FBCONFIG_ID, &v);
|
||||
printf("GLX_FBCONFIG_ID = %u\n", v);
|
||||
}
|
||||
|
||||
/* Get corresponding XVisualInfo */
|
||||
visInfo = GetVisualFromFBConfig(gDpy, gScreen, gFBconfig);
|
||||
if (!visInfo) {
|
||||
|
@@ -340,6 +340,7 @@ def generate(env):
|
||||
'-m32',
|
||||
#'-march=pentium4',
|
||||
'-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
|
||||
'-mstackrealign', # ensure stack is aligned -- do not enabled -msse without it!
|
||||
#'-mfpmath=sse',
|
||||
]
|
||||
if env['machine'] == 'x86_64':
|
||||
|
@@ -56,15 +56,17 @@ def generate(env):
|
||||
env.PrependENVPath('PATH', llvm_bin_dir)
|
||||
|
||||
if env.Detect('llvm-config'):
|
||||
try:
|
||||
env['LLVM_VERSION'] = env.backtick('llvm-config --version')
|
||||
except AttributeError:
|
||||
env['LLVM_VERSION'] = 'X.X'
|
||||
version = env.backtick('llvm-config --version').rstrip()
|
||||
|
||||
env.ParseConfig('llvm-config --cppflags')
|
||||
env.ParseConfig('llvm-config --libs jit interpreter nativecodegen bitwriter')
|
||||
env.ParseConfig('llvm-config --ldflags')
|
||||
env['LINK'] = env['CXX']
|
||||
try:
|
||||
env.ParseConfig('llvm-config --cppflags')
|
||||
env.ParseConfig('llvm-config --libs jit interpreter nativecodegen bitwriter')
|
||||
env.ParseConfig('llvm-config --ldflags')
|
||||
except OSError:
|
||||
print 'llvm-config version %s failed' % version
|
||||
else:
|
||||
env['LINK'] = env['CXX']
|
||||
env['LLVM_VERSION'] = version
|
||||
|
||||
def exists(env):
|
||||
return True
|
||||
|
1
src/Android.mk
Normal file
1
src/Android.mk
Normal file
@@ -0,0 +1 @@
|
||||
include $(call all-subdir-makefiles)
|
41
src/egl/Android.mk
Normal file
41
src/egl/Android.mk
Normal file
@@ -0,0 +1,41 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES := \
|
||||
main/eglapi.c \
|
||||
main/eglclient.c \
|
||||
main/eglconfig.c \
|
||||
main/eglconfigutil.c \
|
||||
main/eglcontext.c \
|
||||
main/eglcurrent.c \
|
||||
main/egldisplay.c \
|
||||
main/egldriver.c \
|
||||
main/eglglobals.c \
|
||||
main/eglimage.c \
|
||||
main/egllog.c \
|
||||
main/eglmisc.c \
|
||||
main/eglmode.c \
|
||||
main/eglscreen.c \
|
||||
main/eglstring.c \
|
||||
main/eglsurface.c
|
||||
|
||||
LOCAL_SRC_FILES += \
|
||||
drivers/android/egl_android.c \
|
||||
drivers/android/droid_loader.c \
|
||||
drivers/android/droid_ui.cpp \
|
||||
drivers/android/droid_intel.c
|
||||
|
||||
LOCAL_C_INCLUDES += \
|
||||
$(LOCAL_PATH)/main \
|
||||
external/mesa/include \
|
||||
external/mesa/src/mesa \
|
||||
external/drm/shared-core
|
||||
|
||||
LOCAL_CFLAGS += -DPTHREADS
|
||||
LOCAL_SHARED_LIBRARIES := libdl libui libutils
|
||||
LOCAL_STATIC_LIBRARIES := libes1api
|
||||
|
||||
LOCAL_MODULE := libhgl
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
136
src/egl/drivers/android/droid.h
Normal file
136
src/egl/drivers/android/droid.h
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Chia-I Wu <olvaffe@gmail.com>
|
||||
*
|
||||
* This is based on the work of eagle, by
|
||||
* Copyright © 2008, 2009 Kristian Høgsberg
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _DROID_H_
|
||||
#define _DROID_H_
|
||||
|
||||
#include "GL/gl.h"
|
||||
#include "GL/internal/dri_interface.h"
|
||||
|
||||
#include "eglcurrent.h"
|
||||
#include "egldisplay.h"
|
||||
#include "eglcontext.h"
|
||||
#include "eglsurface.h"
|
||||
#include "eglconfig.h"
|
||||
|
||||
/* opaque types */
|
||||
struct droid_loader;
|
||||
struct droid_context;
|
||||
struct droid_drawable;
|
||||
struct droid_image;
|
||||
struct droid_surface;
|
||||
|
||||
struct droid_backend {
|
||||
/* these are usually used by a loader */
|
||||
const char *driver_name;
|
||||
int (*initialize)(struct droid_backend *backend, int *fd, int *screen_number);
|
||||
int (*process_config)(struct droid_backend *backend, _EGLConfig *conf);
|
||||
void (*destroy)(struct droid_backend *backend);
|
||||
|
||||
__DRIbuffer *(*get_native_buffer)(struct droid_backend *backend,
|
||||
struct droid_surface *surf,
|
||||
int *width, int *height);
|
||||
__DRIbuffer *(*get_surface_buffers)(struct droid_backend *backend,
|
||||
struct droid_surface *surf,
|
||||
int *width, int *height,
|
||||
unsigned int *attachments, int count,
|
||||
int *out_count, int has_format);
|
||||
|
||||
/* public methods */
|
||||
struct droid_surface *(*create_window_surface)(struct droid_backend *backend,
|
||||
_EGLSurface *surf,
|
||||
NativeWindowType win);
|
||||
struct droid_surface *(*create_image_surface)(struct droid_backend *backend,
|
||||
NativePixmapType pix);
|
||||
void (*destroy_surface)(struct droid_backend *backend, struct droid_surface *surf);
|
||||
void (*swap_native_buffers)(struct droid_backend *backend,
|
||||
struct droid_surface *surf);
|
||||
|
||||
int (*match_pixmap)(struct droid_backend *backend, _EGLConfig *conf,
|
||||
NativePixmapType pix);
|
||||
};
|
||||
|
||||
struct droid_screen {
|
||||
struct droid_loader *loader;
|
||||
|
||||
__DRIscreen *dri_screen;
|
||||
__DRItexBufferExtension *tex_buffer;
|
||||
__DRIcopyBufferExtension *copy_buffer;
|
||||
|
||||
const __DRIconfig **dri_configs;
|
||||
int num_dri_configs;
|
||||
};
|
||||
|
||||
struct droid_backend *
|
||||
droid_backend_create_intel(const char *dev);
|
||||
|
||||
void
|
||||
droid_backend_destroy(struct droid_backend *backend);
|
||||
|
||||
struct droid_screen *
|
||||
droid_screen_create(struct droid_backend *backend);
|
||||
|
||||
void
|
||||
droid_screen_destroy(struct droid_screen *screen);
|
||||
|
||||
int
|
||||
droid_screen_convert_config(struct droid_screen *screen,
|
||||
const __DRIconfig *conf, _EGLConfig *egl_conf);
|
||||
|
||||
struct droid_context *
|
||||
droid_screen_create_context(struct droid_screen *screen,
|
||||
const __DRIconfig *conf,
|
||||
struct droid_context *shared);
|
||||
|
||||
void
|
||||
droid_screen_destroy_context(struct droid_screen *screen,
|
||||
struct droid_context *ctx);
|
||||
|
||||
struct droid_drawable *
|
||||
droid_screen_create_drawable(struct droid_screen *screen,
|
||||
const __DRIconfig *conf,
|
||||
struct droid_surface *surf);
|
||||
|
||||
void *
|
||||
droid_screen_get_drawable_data(struct droid_screen *screen,
|
||||
struct droid_drawable *drawable);
|
||||
|
||||
void
|
||||
droid_screen_destroy_drawable(struct droid_screen *screen,
|
||||
struct droid_drawable *drawable);
|
||||
|
||||
int
|
||||
droid_screen_bind_context(struct droid_screen *screen,
|
||||
struct droid_drawable *draw,
|
||||
struct droid_drawable *read,
|
||||
struct droid_context *ctx);
|
||||
|
||||
int
|
||||
droid_screen_swap_buffers(struct droid_screen *screen,
|
||||
struct droid_context *ctx,
|
||||
struct droid_drawable *drawable);
|
||||
|
||||
#endif /* _DROID_H_ */
|
648
src/egl/drivers/android/droid_intel.c
Normal file
648
src/egl/drivers/android/droid_intel.c
Normal file
@@ -0,0 +1,648 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Chia-I Wu <olvaffe@gmail.com>
|
||||
*
|
||||
* This is based on the work of eagle, by
|
||||
* Copyright © 2008, 2009 Kristian Høgsberg
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and its
|
||||
* documentation for any purpose is hereby granted without fee, provided that
|
||||
* the above copyright notice appear in all copies and that both that copyright
|
||||
* notice and this permission notice appear in supporting documentation, and
|
||||
* that the name of the copyright holders not be used in advertising or
|
||||
* publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. The copyright holders make no representations
|
||||
* about the suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
||||
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
||||
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "DROID-INTEL"
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <i915_drm.h>
|
||||
#include <GL/gl.h> /* dri_interface.h uses some GL integer types... */
|
||||
#include <GL/internal/dri_interface.h>
|
||||
#include <EGL/egl.h>
|
||||
|
||||
#include "droid.h"
|
||||
#include "droid_ui.h"
|
||||
|
||||
#define INTEL_IS_I965(x) ((x) & INTEL_GEN_4)
|
||||
#define INTEL_IS_I915(x) ((x) & INTEL_GEN_3)
|
||||
#define INTEL_IS_I9xx(x) ((x) & (INTEL_GEN_3 | INTEL_GEN_4))
|
||||
#define INTEL_IS_I8xx(x) ((x) & (INTEL_GEN_1 | INTEL_GEN_2))
|
||||
|
||||
#define INTEL_HAS_128_BYTE_Y_TILING(x) \
|
||||
(((x) & (INTEL_GEN_3 | INTEL_GEN_4 | INTEL_GEN_MINOR_MASK)) > INTEL_GEN_3)
|
||||
|
||||
enum {
|
||||
INTEL_SURFACE_TYPE_WINDOW,
|
||||
INTEL_SURFACE_TYPE_IMAGE,
|
||||
};
|
||||
|
||||
/* Look at xf86-video-intel/src/common.h for the full horror of device
|
||||
* identification.
|
||||
*/
|
||||
enum {
|
||||
INTEL_GEN_1 = 0x10,
|
||||
INTEL_GEN_2 = 0x20,
|
||||
INTEL_GEN_3 = 0x40,
|
||||
INTEL_GEN_31 = 0x41,
|
||||
INTEL_GEN_4 = 0x80,
|
||||
|
||||
INTEL_GEN_MAJOR_MASK = 0xf0,
|
||||
INTEL_GEN_MINOR_MASK = 0x0f,
|
||||
};
|
||||
|
||||
struct droid_backend_intel {
|
||||
struct droid_backend base;
|
||||
int fd;
|
||||
int screen_number;
|
||||
|
||||
uint32_t generation;
|
||||
int pitch_align;
|
||||
int enable_tiling;
|
||||
};
|
||||
|
||||
struct droid_surface_intel {
|
||||
int type;
|
||||
union {
|
||||
NativeWindowType win;
|
||||
NativePixmapType pix;
|
||||
} native;
|
||||
__DRIbuffer native_buffer;
|
||||
unsigned int native_width, native_height;
|
||||
int native_changed;
|
||||
|
||||
unsigned int attachments[20];
|
||||
__DRIbuffer buffers[10];
|
||||
uint32_t handles[10];
|
||||
int num_buffers;
|
||||
int depth_idx;
|
||||
|
||||
_EGLSurface *surf;
|
||||
};
|
||||
|
||||
static INLINE struct droid_backend_intel *
|
||||
lookup_backend(struct droid_backend *backend)
|
||||
{
|
||||
return (struct droid_backend_intel *) backend;
|
||||
}
|
||||
|
||||
static INLINE struct droid_surface_intel *
|
||||
lookup_surface(struct droid_surface *surface)
|
||||
{
|
||||
return (struct droid_surface_intel *) surface;
|
||||
}
|
||||
|
||||
static __DRIbuffer *
|
||||
intel_get_native_buffer(struct droid_backend *backend,
|
||||
struct droid_surface *surf,
|
||||
int *width, int *height)
|
||||
{
|
||||
struct droid_surface_intel *isurf = lookup_surface(surf);
|
||||
|
||||
/* non-window surface is single-buffered */
|
||||
if (isurf->type != INTEL_SURFACE_TYPE_WINDOW)
|
||||
return NULL;
|
||||
|
||||
if (!isurf->native_buffer.name)
|
||||
return NULL;
|
||||
|
||||
if (width)
|
||||
*width = isurf->native_width;
|
||||
if (height)
|
||||
*height = isurf->native_height;
|
||||
|
||||
return &isurf->native_buffer;
|
||||
}
|
||||
|
||||
static INLINE uint32_t
|
||||
align_to(uint32_t value, uint32_t align)
|
||||
{
|
||||
return (value + align - 1) & ~(align - 1);
|
||||
}
|
||||
|
||||
static INLINE int
|
||||
fence_pitch(struct droid_backend *backend, int pitch, int tiling)
|
||||
{
|
||||
struct droid_backend_intel *intel = lookup_backend(backend);
|
||||
int pitch_align, tile_width;
|
||||
|
||||
switch (tiling) {
|
||||
case I915_TILING_NONE:
|
||||
default:
|
||||
pitch_align = intel->pitch_align;
|
||||
tile_width = 1; /* not used */
|
||||
break;
|
||||
case I915_TILING_X:
|
||||
pitch_align = 512;
|
||||
tile_width = 512;
|
||||
break;
|
||||
case I915_TILING_Y:
|
||||
pitch_align = 512;
|
||||
tile_width =
|
||||
(INTEL_HAS_128_BYTE_Y_TILING(intel->generation)) ? 128 : 512;
|
||||
break;
|
||||
}
|
||||
|
||||
pitch = align_to(pitch, pitch_align);
|
||||
if (tiling == I915_TILING_NONE)
|
||||
return pitch;
|
||||
|
||||
/* 965+ just needs multiples of tile width */
|
||||
if (INTEL_IS_I965(intel->generation)) {
|
||||
pitch = align_to(pitch, tile_width);
|
||||
}
|
||||
else {
|
||||
/* Pre-965 needs power of two tile widths */
|
||||
while (tile_width < pitch)
|
||||
tile_width <<= 1;
|
||||
pitch = tile_width;
|
||||
}
|
||||
|
||||
return pitch;
|
||||
}
|
||||
|
||||
static INLINE uint32_t
|
||||
fence_size(struct droid_backend *backend, int height, int pitch, int tiling)
|
||||
{
|
||||
struct droid_backend_intel *intel = lookup_backend(backend);
|
||||
int height_align;
|
||||
uint32_t size;
|
||||
|
||||
switch (tiling) {
|
||||
case I915_TILING_NONE:
|
||||
default:
|
||||
/* Round the height up so that the GPU's access to a 2x2 aligned
|
||||
* subspan doesn't address an invalid page offset beyond the
|
||||
* end of the GTT.
|
||||
*/
|
||||
height_align = 2;
|
||||
break;
|
||||
case I915_TILING_X:
|
||||
height_align = 8;
|
||||
break;
|
||||
case I915_TILING_Y:
|
||||
height_align = 32;
|
||||
break;
|
||||
}
|
||||
|
||||
height = align_to(height, height_align);
|
||||
size = pitch * height;
|
||||
if (tiling == I915_TILING_NONE)
|
||||
return size;
|
||||
|
||||
/* The 965 can have fences at any page boundary. */
|
||||
if (INTEL_IS_I965(intel->generation)) {
|
||||
size = align_to(size, 4096);
|
||||
}
|
||||
else {
|
||||
uint32_t fence;
|
||||
|
||||
/* Align the size to a power of two greater than the smallest fence. */
|
||||
if (INTEL_IS_I9xx(intel->generation))
|
||||
fence = 1 << 20; /* 1 MiB */
|
||||
else
|
||||
fence = 1 << 19; /* 512 KiB */
|
||||
|
||||
while (fence < size)
|
||||
fence <<= 1;
|
||||
|
||||
size = fence;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static int
|
||||
create_buffer(struct droid_backend *backend, __DRIbuffer *buffer,
|
||||
int width, int height, int cpp, int tiling)
|
||||
{
|
||||
struct droid_backend_intel *intel = lookup_backend(backend);
|
||||
struct drm_i915_gem_create create;
|
||||
struct drm_gem_flink flink;
|
||||
|
||||
buffer->pitch = fence_pitch(backend, width * cpp, tiling);
|
||||
create.size = fence_size(backend, height, buffer->pitch, tiling);
|
||||
if (ioctl(intel->fd, DRM_IOCTL_I915_GEM_CREATE, &create)) {
|
||||
LOGE("failed to create buffer");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (tiling != I915_TILING_NONE) {
|
||||
struct drm_i915_gem_set_tiling set_tiling;
|
||||
|
||||
memset(&set_tiling, 0, sizeof(set_tiling));
|
||||
set_tiling.handle = create.handle;
|
||||
set_tiling.tiling_mode = tiling;
|
||||
set_tiling.stride = buffer->pitch;
|
||||
|
||||
if (ioctl(intel->fd, DRM_IOCTL_I915_GEM_SET_TILING, &set_tiling))
|
||||
LOGW("failed to enable tiling");
|
||||
}
|
||||
|
||||
flink.handle = create.handle;
|
||||
if (ioctl(intel->fd, DRM_IOCTL_GEM_FLINK, &flink) < 0) {
|
||||
LOGE("failed to flink buffer");
|
||||
return 0;
|
||||
}
|
||||
|
||||
buffer->name = flink.name;
|
||||
buffer->cpp = cpp;
|
||||
buffer->flags = 0;
|
||||
|
||||
return create.handle;
|
||||
}
|
||||
|
||||
static void
|
||||
delete_buffers(struct droid_backend *backend, struct droid_surface *surf)
|
||||
{
|
||||
struct droid_backend_intel *intel = lookup_backend(backend);
|
||||
struct droid_surface_intel *isurf = lookup_surface(surf);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < isurf->num_buffers; i++) {
|
||||
if (isurf->handles[i]) {
|
||||
struct drm_gem_close close;
|
||||
|
||||
close.handle = isurf->handles[i];
|
||||
if (ioctl(intel->fd, DRM_IOCTL_GEM_CLOSE, &close) < 0)
|
||||
LOGE("failed to close bo %d", close.handle);
|
||||
isurf->handles[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
isurf->num_buffers = 0;
|
||||
}
|
||||
|
||||
static __DRIbuffer *
|
||||
intel_get_surface_buffers(struct droid_backend *backend,
|
||||
struct droid_surface *surf,
|
||||
int *width, int *height,
|
||||
unsigned int *attachments, int count,
|
||||
int *out_count, int has_format)
|
||||
{
|
||||
struct droid_backend_intel *intel = lookup_backend(backend);
|
||||
struct droid_surface_intel *isurf = lookup_surface(surf);
|
||||
unsigned int att_size;
|
||||
__DRIbuffer buffers[10];
|
||||
uint32_t handles[10];
|
||||
int num = 0;
|
||||
|
||||
if (count > 10) {
|
||||
LOGW("too many buffers requested");
|
||||
count = 10;
|
||||
}
|
||||
|
||||
att_size = sizeof(attachments[0]) * count * ((has_format) ? 2 : 1);
|
||||
|
||||
if (isurf->native_changed) {
|
||||
delete_buffers(backend, surf);
|
||||
isurf->native_changed = 0;
|
||||
}
|
||||
|
||||
/* same buffers requested */
|
||||
if (isurf->num_buffers == count &&
|
||||
memcmp(isurf->attachments, attachments, att_size) == 0) {
|
||||
num = isurf->num_buffers;
|
||||
goto end;
|
||||
}
|
||||
memcpy(isurf->attachments, attachments, att_size);
|
||||
|
||||
while (count-- > 0) {
|
||||
unsigned int att = *attachments++;
|
||||
unsigned int format = (has_format) ? *attachments++ : 0;
|
||||
unsigned int cpp = (format) ? format / 8 : isurf->native_buffer.cpp;
|
||||
__DRIbuffer *buf = NULL;
|
||||
int reuse;
|
||||
|
||||
/* re-use buffer */
|
||||
for (reuse = 0; reuse < isurf->num_buffers; reuse++) {
|
||||
if (isurf->buffers[reuse].attachment == att) {
|
||||
if (isurf->buffers[reuse].cpp == cpp &&
|
||||
isurf->handles[reuse])
|
||||
buf = &isurf->buffers[reuse];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (0)
|
||||
LOGD("%s buffer %d: att %d cpp %d",
|
||||
(buf) ? "reuse" : "create", num, att, cpp);
|
||||
|
||||
if (buf) {
|
||||
buffers[num] = isurf->buffers[reuse];
|
||||
handles[num] = isurf->handles[reuse];
|
||||
isurf->handles[reuse] = 0;
|
||||
}
|
||||
else {
|
||||
int tiling =
|
||||
(intel->enable_tiling) ? I915_TILING_X : I915_TILING_NONE;
|
||||
|
||||
buffers[num].attachment = att;
|
||||
|
||||
if (isurf->type == INTEL_SURFACE_TYPE_IMAGE &&
|
||||
att == __DRI_BUFFER_FRONT_LEFT) {
|
||||
/* return native buffer */
|
||||
buffers[num] = isurf->native_buffer;
|
||||
buffers[num].attachment = att;
|
||||
handles[num] = 0;
|
||||
} else {
|
||||
buffers[num].attachment = att;
|
||||
handles[num] = create_buffer(backend, &buffers[num],
|
||||
isurf->native_width,
|
||||
isurf->native_height,
|
||||
cpp,
|
||||
tiling);
|
||||
}
|
||||
}
|
||||
num++;
|
||||
}
|
||||
|
||||
/* delete old buffers that are not re-used */
|
||||
delete_buffers(backend, surf);
|
||||
|
||||
memcpy(isurf->buffers, buffers, sizeof(buffers[0]) * num);
|
||||
memcpy(isurf->handles, handles, sizeof(handles[0]) * num);
|
||||
isurf->num_buffers = num;
|
||||
|
||||
end:
|
||||
*out_count = num;
|
||||
*width = isurf->native_width;
|
||||
*height = isurf->native_height;
|
||||
|
||||
return isurf->buffers;
|
||||
}
|
||||
|
||||
static void
|
||||
update_native_buffer(struct droid_surface *surf)
|
||||
{
|
||||
struct droid_surface_intel *isurf = lookup_surface(surf);
|
||||
__DRIbuffer *buf = &isurf->native_buffer;
|
||||
unsigned int name, cpp, pitch, width, height;
|
||||
|
||||
switch (isurf->type) {
|
||||
case INTEL_SURFACE_TYPE_WINDOW:
|
||||
/* oem[0] always point to the buffer that a client is drawing to */
|
||||
name = isurf->native.win->oem[0];
|
||||
cpp = ui_bytes_per_pixel(isurf->native.win->format);
|
||||
pitch = isurf->native.win->stride * cpp;
|
||||
width = isurf->native.win->width;
|
||||
height = isurf->native.win->height;
|
||||
break;
|
||||
case INTEL_SURFACE_TYPE_IMAGE:
|
||||
name = isurf->native.pix->reserved;
|
||||
cpp = ui_bytes_per_pixel(isurf->native.pix->format);
|
||||
pitch = isurf->native.pix->stride * cpp;
|
||||
width = isurf->native.pix->width;
|
||||
height = isurf->native.pix->height;
|
||||
break;
|
||||
default:
|
||||
name = cpp = pitch = width = height = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (buf->name != name || buf->cpp != cpp || buf->pitch != pitch ||
|
||||
isurf->native_width != width || isurf->native_height != height) {
|
||||
buf->attachment = __DRI_BUFFER_FRONT_LEFT;
|
||||
buf->name = name;
|
||||
buf->cpp = cpp;
|
||||
buf->pitch = pitch;
|
||||
buf->flags = 0;
|
||||
|
||||
isurf->native_width = width;
|
||||
isurf->native_height = height;
|
||||
|
||||
isurf->native_changed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static struct droid_surface *
|
||||
intel_create_window_surface(struct droid_backend *backend,
|
||||
_EGLSurface *surf,
|
||||
NativeWindowType win)
|
||||
{
|
||||
struct droid_surface_intel *isurf;
|
||||
|
||||
if (!win) {
|
||||
LOGE("invalid native window");
|
||||
_eglError(EGL_BAD_NATIVE_WINDOW, "eglCreateWindowSurface");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* TODO lift this limitation */
|
||||
if (!win->oem[0]) {
|
||||
LOGE("TODO support for non-gem based window");
|
||||
_eglError(EGL_BAD_NATIVE_WINDOW, "eglCreateWindowSurface");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
isurf = calloc(1, sizeof(*isurf));
|
||||
if (!isurf) {
|
||||
_eglError(EGL_BAD_ALLOC, "eglCreateWindowSurface");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
isurf->type = INTEL_SURFACE_TYPE_WINDOW;
|
||||
isurf->native.win = win;
|
||||
|
||||
surf->Width = win->width;
|
||||
surf->Height = win->height;
|
||||
/* always back buffer */
|
||||
surf->RenderBuffer = EGL_BACK_BUFFER;
|
||||
|
||||
isurf->surf = surf;
|
||||
|
||||
update_native_buffer((struct droid_surface *) isurf);
|
||||
|
||||
return (struct droid_surface *) isurf;
|
||||
}
|
||||
|
||||
static struct droid_surface *
|
||||
intel_create_image_surface(struct droid_backend *backend,
|
||||
NativePixmapType pix)
|
||||
{
|
||||
struct droid_surface_intel *isurf;
|
||||
int cpp;
|
||||
|
||||
if (!pix) {
|
||||
LOGE("invalid native pixmap");
|
||||
_eglError(EGL_BAD_NATIVE_PIXMAP, "eglCreateImage");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* TODO lift this limitation */
|
||||
if (!pix->reserved) {
|
||||
LOGE("TODO support for non-gem based pixmap");
|
||||
_eglError(EGL_BAD_NATIVE_PIXMAP, "eglCreateImage");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
isurf = calloc(1, sizeof(*isurf));
|
||||
if (!isurf) {
|
||||
_eglError(EGL_BAD_ALLOC, "eglCreateWindowSurface");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
isurf->type = INTEL_SURFACE_TYPE_IMAGE;
|
||||
isurf->native.pix = pix;
|
||||
|
||||
update_native_buffer((struct droid_surface *) isurf);
|
||||
|
||||
return (struct droid_surface *) isurf;
|
||||
}
|
||||
|
||||
static void
|
||||
intel_destroy_surface(struct droid_backend *backend, struct droid_surface *surf)
|
||||
{
|
||||
struct droid_surface_intel *isurf = lookup_surface(surf);
|
||||
delete_buffers(backend, surf);
|
||||
free(isurf);
|
||||
}
|
||||
|
||||
static void
|
||||
intel_swap_native_buffers(struct droid_backend *backend,
|
||||
struct droid_surface *surf)
|
||||
{
|
||||
struct droid_surface_intel *isurf = lookup_surface(surf);
|
||||
|
||||
if (isurf->type == INTEL_SURFACE_TYPE_WINDOW) {
|
||||
uint32_t flags;
|
||||
|
||||
flags = isurf->native.win->swapBuffers(isurf->native.win);
|
||||
if (flags & EGL_NATIVES_FLAG_SIZE_CHANGED) {
|
||||
update_native_buffer(surf);
|
||||
} else {
|
||||
/* oem[0] is changed after buffer swap */
|
||||
isurf->native_buffer.name = isurf->native.win->oem[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
intel_match_pixmap(struct droid_backend *backend, _EGLConfig *conf,
|
||||
NativePixmapType pix)
|
||||
{
|
||||
int val;
|
||||
val = GET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE);
|
||||
/* match the visual type */
|
||||
return (pix->format == val);
|
||||
}
|
||||
|
||||
static int
|
||||
intel_initialize(struct droid_backend *backend, int *fd, int *screen_number)
|
||||
{
|
||||
struct droid_backend_intel *intel = lookup_backend(backend);
|
||||
drm_auth_t auth;
|
||||
int err;
|
||||
|
||||
err = ioctl(intel->fd, DRM_IOCTL_GET_MAGIC, &auth);
|
||||
if (!err)
|
||||
err = ui_auth_gpu(auth.magic);
|
||||
|
||||
if (err) {
|
||||
LOGE("failed to authenticate");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (fd)
|
||||
*fd = intel->fd;
|
||||
if (screen_number)
|
||||
*screen_number = intel->screen_number;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#include <assert.h>
|
||||
static int
|
||||
intel_process_config(struct droid_backend *backend, _EGLConfig *conf)
|
||||
{
|
||||
int r, g, b, a;
|
||||
int surface_type;
|
||||
int format;
|
||||
|
||||
r = GET_CONFIG_ATTRIB(conf, EGL_RED_SIZE);
|
||||
g = GET_CONFIG_ATTRIB(conf, EGL_GREEN_SIZE);
|
||||
b = GET_CONFIG_ATTRIB(conf, EGL_BLUE_SIZE);
|
||||
a = GET_CONFIG_ATTRIB(conf, EGL_ALPHA_SIZE);
|
||||
format = ui_get_rgb_format(r, g, b, a);
|
||||
|
||||
if (format) {
|
||||
SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE, format);
|
||||
SET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE,
|
||||
EGL_WINDOW_BIT |
|
||||
EGL_PIXMAP_BIT |
|
||||
EGL_PBUFFER_BIT);
|
||||
}
|
||||
else {
|
||||
SET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE, EGL_PBUFFER_BIT);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
intel_destroy(struct droid_backend *backend)
|
||||
{
|
||||
struct droid_backend_intel *intel = lookup_backend(backend);
|
||||
close(intel->fd);
|
||||
free(intel);
|
||||
}
|
||||
|
||||
struct droid_backend *
|
||||
droid_backend_create_intel(const char *dev)
|
||||
{
|
||||
struct droid_backend_intel *intel;
|
||||
|
||||
intel = calloc(1, sizeof(*intel));
|
||||
if (!intel)
|
||||
return NULL;
|
||||
|
||||
intel->fd = open(dev, O_RDWR);
|
||||
if (intel->fd < 0) {
|
||||
LOGE("failed to open %s", dev);
|
||||
free(intel);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
intel->screen_number = 0;
|
||||
|
||||
/* XXX query using I915_GETPARAM + PARAM_CHIPSET_ID */
|
||||
intel->generation = INTEL_GEN_3;
|
||||
|
||||
intel->pitch_align = 64;
|
||||
intel->enable_tiling = 1;
|
||||
|
||||
intel->base.driver_name = "i915";
|
||||
intel->base.initialize = intel_initialize;
|
||||
intel->base.process_config = intel_process_config;
|
||||
intel->base.destroy = intel_destroy;
|
||||
|
||||
intel->base.get_native_buffer = intel_get_native_buffer;
|
||||
intel->base.get_surface_buffers = intel_get_surface_buffers;
|
||||
|
||||
intel->base.create_window_surface = intel_create_window_surface;
|
||||
intel->base.create_image_surface = intel_create_image_surface;
|
||||
intel->base.destroy_surface = intel_destroy_surface;
|
||||
intel->base.swap_native_buffers = intel_swap_native_buffers;
|
||||
|
||||
intel->base.match_pixmap = intel_match_pixmap;
|
||||
|
||||
return &intel->base;
|
||||
}
|
509
src/egl/drivers/android/droid_loader.c
Normal file
509
src/egl/drivers/android/droid_loader.c
Normal file
@@ -0,0 +1,509 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Chia-I Wu <olvaffe@gmail.com>
|
||||
*
|
||||
* This is based on the work of eagle, by
|
||||
* Copyright © 2008, 2009 Kristian Høgsberg
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "DROID-LOADER"
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <dlfcn.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "droid.h"
|
||||
#include "EGL/internal/eglimage_dri.h"
|
||||
|
||||
#ifndef DROID_DRIVER_PATH
|
||||
#define DROID_DRIVER_PATH "/system/lib"
|
||||
#endif
|
||||
|
||||
struct droid_loader {
|
||||
struct droid_backend *backend;
|
||||
|
||||
char *filename;
|
||||
void *handle;
|
||||
|
||||
__DRIcoreExtension *core;
|
||||
__DRIdri2Extension *dri2;
|
||||
};
|
||||
|
||||
struct droid_context {
|
||||
__DRIcontext *dri_context;
|
||||
};
|
||||
|
||||
struct droid_drawable {
|
||||
struct droid_loader *loader;
|
||||
struct droid_surface *surface;
|
||||
|
||||
__DRIdrawable *dri_drawable;
|
||||
const __DRIconfig *dri_config;
|
||||
__DRIEGLImage *dri_image;
|
||||
};
|
||||
|
||||
static __DRIbuffer *
|
||||
loader_ext_get_buffers_with_format(__DRIdrawable *driDrawable,
|
||||
int *width, int *height,
|
||||
unsigned int *attachments, int count,
|
||||
int *out_count, void *loaderPrivate)
|
||||
{
|
||||
struct droid_drawable *drawable = (struct droid_drawable *) loaderPrivate;
|
||||
struct droid_loader *loader = drawable->loader;
|
||||
__DRIbuffer *buffers;
|
||||
|
||||
buffers = loader->backend->get_surface_buffers(loader->backend,
|
||||
drawable->surface,
|
||||
width, height,
|
||||
attachments, count,
|
||||
out_count, 1);
|
||||
|
||||
return buffers;
|
||||
}
|
||||
|
||||
static const __DRIdri2LoaderExtension loader_ext_dri2_loader = {
|
||||
{ __DRI_DRI2_LOADER, __DRI_DRI2_LOADER_VERSION },
|
||||
NULL,
|
||||
NULL,
|
||||
loader_ext_get_buffers_with_format,
|
||||
};
|
||||
|
||||
static int
|
||||
loader_ext_get_ust(int64_t *ust)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
if (ust == NULL)
|
||||
return -EFAULT;
|
||||
|
||||
if (gettimeofday(&tv, NULL) == 0) {
|
||||
ust[0] = (tv.tv_sec * 1000000) + tv.tv_usec;
|
||||
return 0;
|
||||
} else {
|
||||
return -errno;
|
||||
}
|
||||
}
|
||||
|
||||
static const __DRIsystemTimeExtension loader_ext_system_time = {
|
||||
{ __DRI_SYSTEM_TIME, __DRI_SYSTEM_TIME_VERSION },
|
||||
loader_ext_get_ust,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const __DRIextension *loader_extensions[] = {
|
||||
&loader_ext_dri2_loader.base,
|
||||
&loader_ext_system_time.base,
|
||||
NULL
|
||||
};
|
||||
|
||||
static struct droid_loader *
|
||||
loader_create(struct droid_backend *backend)
|
||||
{
|
||||
struct droid_loader *loader;
|
||||
|
||||
loader = calloc(1, sizeof(*loader));
|
||||
if (!loader)
|
||||
return NULL;
|
||||
|
||||
loader->backend = backend;
|
||||
|
||||
return loader;
|
||||
}
|
||||
|
||||
static void
|
||||
loader_destroy(struct droid_loader *loader)
|
||||
{
|
||||
if (loader->filename)
|
||||
free(loader->filename);
|
||||
if (loader->handle)
|
||||
dlclose(loader->handle);
|
||||
free(loader);
|
||||
}
|
||||
|
||||
static int
|
||||
loader_load(struct droid_loader *loader, const char *filename)
|
||||
{
|
||||
const __DRIextension **extensions;
|
||||
const char *path = NULL;
|
||||
int i;
|
||||
|
||||
LOGD("Loading DRI driver %s", filename);
|
||||
|
||||
loader->handle = dlopen(filename, RTLD_NOW | RTLD_LOCAL);
|
||||
if (loader->handle == NULL) {
|
||||
LOGE("dlopen: %s", dlerror());
|
||||
return 0;
|
||||
}
|
||||
|
||||
extensions = dlsym(loader->handle, __DRI_DRIVER_EXTENSIONS);
|
||||
if (extensions == NULL) {
|
||||
LOGE("dlsym: %s", dlerror());
|
||||
dlclose(loader->handle);
|
||||
loader->handle = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; extensions[i]; i++) {
|
||||
if (strcmp(extensions[i]->name, __DRI_CORE) == 0 &&
|
||||
extensions[i]->version >= __DRI_CORE_VERSION) {
|
||||
loader->core = (__DRIcoreExtension *) extensions[i];
|
||||
}
|
||||
|
||||
if (strcmp(extensions[i]->name, __DRI_DRI2) == 0 &&
|
||||
extensions[i]->version >= __DRI_DRI2_VERSION) {
|
||||
loader->dri2 = (__DRIdri2Extension *) extensions[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (loader->core == NULL || loader->dri2 == NULL) {
|
||||
LOGE("missing required DRI extensions");
|
||||
dlclose(loader->handle);
|
||||
loader->handle = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
loader_init(struct droid_loader *loader)
|
||||
{
|
||||
char filename[1024];
|
||||
const char *path;
|
||||
|
||||
path = DROID_DRIVER_PATH;
|
||||
snprintf(filename, sizeof(filename), "%s/%s_dri.so",
|
||||
path, loader->backend->driver_name);
|
||||
|
||||
if (!loader_load(loader, filename))
|
||||
return 0;
|
||||
|
||||
loader->filename = strdup(filename);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
droid_backend_destroy(struct droid_backend *backend)
|
||||
{
|
||||
backend->destroy(backend);
|
||||
}
|
||||
|
||||
struct droid_screen *
|
||||
droid_screen_create(struct droid_backend *backend)
|
||||
{
|
||||
struct droid_screen *screen = NULL;
|
||||
struct droid_loader *loader;
|
||||
const __DRIextension **extensions;
|
||||
int fd, screen_number;
|
||||
int i;
|
||||
|
||||
loader = loader_create(backend);
|
||||
if (!loader || !loader_init(loader)) {
|
||||
LOGE("failed to initialize loader");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
screen = calloc(1, sizeof(*screen));
|
||||
if (!screen) {
|
||||
LOGE("failed to allocate new screen");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!loader->backend->initialize(loader->backend, &fd, &screen_number)) {
|
||||
LOGE("failed to initialize backend");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
screen->loader = loader;
|
||||
screen->dri_screen =
|
||||
loader->dri2->createNewScreen(screen_number, fd,
|
||||
loader_extensions,
|
||||
&screen->dri_configs, NULL);
|
||||
if (!screen->dri_screen) {
|
||||
LOGE("failed to create DRI screen");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
extensions = loader->core->getExtensions(screen->dri_screen);
|
||||
|
||||
for (i = 0; extensions && extensions[i]; i++) {
|
||||
if (strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0 &&
|
||||
extensions[i]->version >= __DRI_TEX_BUFFER_VERSION)
|
||||
screen->tex_buffer = (__DRItexBufferExtension *) extensions[i];
|
||||
|
||||
if (strcmp(extensions[i]->name, __DRI_COPY_BUFFER) == 0 &&
|
||||
extensions[i]->version >= __DRI_COPY_BUFFER_VERSION)
|
||||
screen->copy_buffer = (__DRIcopyBufferExtension *) extensions[i];
|
||||
}
|
||||
|
||||
if (!screen->tex_buffer) {
|
||||
LOGE("DRI driver has no TexBuffer extension");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!screen->tex_buffer) {
|
||||
LOGE("DRI driver has no CopyBuffer extension");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
for (i = 0; screen->dri_configs[i]; i++)
|
||||
;
|
||||
screen->num_dri_configs = i;
|
||||
|
||||
return screen;
|
||||
|
||||
fail:
|
||||
if (screen)
|
||||
droid_screen_destroy(screen);
|
||||
if (loader)
|
||||
loader_destroy(loader);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
droid_screen_destroy(struct droid_screen *screen)
|
||||
{
|
||||
struct droid_loader *loader = screen->loader;
|
||||
if (screen->dri_screen)
|
||||
loader->core->destroyScreen(screen->dri_screen);
|
||||
free(screen);
|
||||
}
|
||||
|
||||
static const struct {
|
||||
EGLenum egl_attrib;
|
||||
unsigned int dri_attrib;
|
||||
} droid_attrib_map[] = {
|
||||
{ EGL_BUFFER_SIZE, __DRI_ATTRIB_BUFFER_SIZE },
|
||||
{ EGL_RED_SIZE, __DRI_ATTRIB_RED_SIZE },
|
||||
{ EGL_GREEN_SIZE, __DRI_ATTRIB_GREEN_SIZE },
|
||||
{ EGL_BLUE_SIZE, __DRI_ATTRIB_BLUE_SIZE },
|
||||
{ EGL_ALPHA_SIZE, __DRI_ATTRIB_ALPHA_SIZE },
|
||||
{ EGL_BIND_TO_TEXTURE_RGB, __DRI_ATTRIB_BIND_TO_TEXTURE_RGB },
|
||||
{ EGL_BIND_TO_TEXTURE_RGBA, __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA },
|
||||
{ EGL_CONFIG_CAVEAT, __DRI_ATTRIB_CONFIG_CAVEAT },
|
||||
{ EGL_DEPTH_SIZE, __DRI_ATTRIB_DEPTH_SIZE },
|
||||
{ EGL_LEVEL, __DRI_ATTRIB_LEVEL },
|
||||
{ EGL_MAX_PBUFFER_WIDTH, __DRI_ATTRIB_MAX_PBUFFER_WIDTH },
|
||||
{ EGL_MAX_PBUFFER_HEIGHT, __DRI_ATTRIB_MAX_PBUFFER_HEIGHT },
|
||||
{ EGL_MAX_PBUFFER_PIXELS, __DRI_ATTRIB_MAX_PBUFFER_PIXELS },
|
||||
{ EGL_SAMPLE_BUFFERS, __DRI_ATTRIB_SAMPLE_BUFFERS },
|
||||
{ EGL_SAMPLES, __DRI_ATTRIB_SAMPLES },
|
||||
{ EGL_STENCIL_SIZE, __DRI_ATTRIB_STENCIL_SIZE },
|
||||
};
|
||||
|
||||
int
|
||||
droid_screen_convert_config(struct droid_screen *screen,
|
||||
const __DRIconfig *conf, _EGLConfig *egl_conf)
|
||||
{
|
||||
struct droid_loader *loader = screen->loader;
|
||||
const int num_attrs =
|
||||
sizeof(droid_attrib_map) / sizeof(droid_attrib_map[0]);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < num_attrs; i++) {
|
||||
unsigned int dri_attrib = droid_attrib_map[i].dri_attrib;
|
||||
unsigned int dri_value;
|
||||
EGLenum egl_attrib = droid_attrib_map[i].egl_attrib;
|
||||
EGLint egl_value;
|
||||
|
||||
if (!loader->core->getConfigAttrib(conf, dri_attrib, &dri_value)) {
|
||||
LOGE("failed to get attribute %02d for %p", dri_attrib, conf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (egl_attrib) {
|
||||
case EGL_CONFIG_CAVEAT:
|
||||
if (dri_value & __DRI_ATTRIB_SLOW_BIT)
|
||||
egl_value = EGL_SLOW_CONFIG;
|
||||
else if (dri_value & __DRI_ATTRIB_NON_CONFORMANT_CONFIG)
|
||||
egl_value = EGL_NON_CONFORMANT_CONFIG;
|
||||
else
|
||||
egl_value = EGL_NONE;
|
||||
break;
|
||||
default:
|
||||
egl_value = (EGLint) dri_value;
|
||||
break;
|
||||
}
|
||||
SET_CONFIG_ATTRIB(egl_conf, egl_attrib, egl_value);
|
||||
}
|
||||
|
||||
return loader->backend->process_config(loader->backend, egl_conf);
|
||||
}
|
||||
|
||||
struct droid_context *
|
||||
droid_screen_create_context(struct droid_screen *screen,
|
||||
const __DRIconfig *conf,
|
||||
struct droid_context *shared)
|
||||
{
|
||||
struct droid_loader *loader = screen->loader;
|
||||
struct droid_context *ctx;
|
||||
|
||||
ctx = calloc(1, sizeof(*ctx));
|
||||
if (!ctx) {
|
||||
LOGE("failed to allocate context");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ctx->dri_context =
|
||||
loader->dri2->createNewContext(screen->dri_screen, conf,
|
||||
(shared) ? shared->dri_context : NULL,
|
||||
NULL);
|
||||
if (!ctx->dri_context) {
|
||||
LOGE("failed to create DRI context");
|
||||
free(ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
void
|
||||
droid_screen_destroy_context(struct droid_screen *screen,
|
||||
struct droid_context *ctx)
|
||||
{
|
||||
struct droid_loader *loader = screen->loader;
|
||||
loader->core->destroyContext(ctx->dri_context);
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
struct droid_drawable *
|
||||
droid_screen_create_drawable(struct droid_screen *screen,
|
||||
const __DRIconfig *conf,
|
||||
struct droid_surface *surf)
|
||||
{
|
||||
struct droid_loader *loader = screen->loader;
|
||||
struct droid_drawable *drawable;
|
||||
|
||||
drawable = calloc(1, sizeof(*drawable));
|
||||
if (!drawable) {
|
||||
LOGE("failed to allocate drawable");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* needed in GetBuffers */
|
||||
drawable->loader = loader;
|
||||
drawable->surface = surf;
|
||||
drawable->dri_config = conf;
|
||||
|
||||
drawable->dri_drawable =
|
||||
loader->dri2->createNewDrawable(screen->dri_screen,
|
||||
conf, (void *) drawable);
|
||||
if (!drawable->dri_drawable) {
|
||||
LOGE("failed to create DRI drawable");
|
||||
free(drawable);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return drawable;
|
||||
}
|
||||
|
||||
void *
|
||||
droid_screen_get_drawable_data(struct droid_screen *screen,
|
||||
struct droid_drawable *drawable)
|
||||
{
|
||||
struct droid_loader *loader = screen->loader;
|
||||
__DRIEGLImage *img = drawable->dri_image;
|
||||
|
||||
if (!img) {
|
||||
unsigned int val;
|
||||
|
||||
img = calloc(1, sizeof(__DRIEGLImage));
|
||||
if (!img)
|
||||
return NULL;
|
||||
|
||||
img->magic = __DRI_EGL_IMAGE_MAGIC;
|
||||
img->drawable = drawable->dri_drawable;
|
||||
img->level = 0;
|
||||
if (loader->core->getConfigAttrib(drawable->dri_config,
|
||||
__DRI_ATTRIB_ALPHA_SIZE, &val))
|
||||
img->texture_format_rgba = (val > 0);
|
||||
|
||||
drawable->dri_image = img;
|
||||
}
|
||||
|
||||
return (void *) img;
|
||||
}
|
||||
|
||||
void
|
||||
droid_screen_destroy_drawable(struct droid_screen *screen,
|
||||
struct droid_drawable *drawable)
|
||||
{
|
||||
struct droid_loader *loader = screen->loader;
|
||||
if (drawable->dri_image)
|
||||
free(drawable->dri_image);
|
||||
loader->core->destroyDrawable(drawable->dri_drawable);
|
||||
free(drawable);
|
||||
}
|
||||
|
||||
int
|
||||
droid_screen_bind_context(struct droid_screen *screen,
|
||||
struct droid_drawable *draw,
|
||||
struct droid_drawable *read,
|
||||
struct droid_context *ctx)
|
||||
{
|
||||
struct droid_loader *loader = screen->loader;
|
||||
int ret = 0;
|
||||
|
||||
if (ctx) {
|
||||
if (draw && read)
|
||||
ret = loader->core->bindContext(ctx->dri_context,
|
||||
draw->dri_drawable,
|
||||
read->dri_drawable);
|
||||
else if (!draw && !read)
|
||||
ret = loader->core->unbindContext(ctx->dri_context);
|
||||
}
|
||||
|
||||
if (!ret)
|
||||
LOGE("failed to bind context %p", ctx);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
droid_screen_swap_buffers(struct droid_screen *screen,
|
||||
struct droid_context *ctx,
|
||||
struct droid_drawable *drawable)
|
||||
{
|
||||
struct droid_loader *loader = screen->loader;
|
||||
__DRIbuffer *native;
|
||||
int width, height;
|
||||
int err = 0;
|
||||
|
||||
native = loader->backend->get_native_buffer(loader->backend,
|
||||
drawable->surface,
|
||||
&width, &height);
|
||||
|
||||
/* copy from front buffer to native buffer */
|
||||
if (native)
|
||||
err = screen->copy_buffer->copyBuffer(ctx->dri_context, native, 0, 0,
|
||||
drawable->dri_drawable,
|
||||
__DRI_BUFFER_FRONT_LEFT, 0, 0,
|
||||
width, height);
|
||||
|
||||
if (!err)
|
||||
loader->backend->swap_native_buffers(loader->backend, drawable->surface);
|
||||
|
||||
return (!err);
|
||||
}
|
81
src/egl/drivers/android/droid_ui.cpp
Normal file
81
src/egl/drivers/android/droid_ui.cpp
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Chia-I Wu <olvaffe@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <ui/PixelFormat.h>
|
||||
#include <ui/ISurfaceComposer.h>
|
||||
|
||||
#include "droid_ui.h"
|
||||
|
||||
using namespace android;
|
||||
|
||||
namespace android {
|
||||
const sp<ISurfaceComposer>& _get_surface_manager();
|
||||
};
|
||||
|
||||
int
|
||||
ui_auth_gpu(drm_magic_t magic)
|
||||
{
|
||||
/*
|
||||
* surface flinger itself or root; we might want something like
|
||||
* getSurfaceFlinger() from libEGL
|
||||
*/
|
||||
if (getuid() == 1000 || getuid() == 0)
|
||||
return 0;
|
||||
|
||||
sp<ISurfaceComposer> sm(_get_surface_manager());
|
||||
if (sm == NULL)
|
||||
return -ENODEV;
|
||||
return sm->authGPU(magic);
|
||||
}
|
||||
|
||||
int ui_bytes_per_pixel(int format)
|
||||
{
|
||||
return bytesPerPixel(format);
|
||||
}
|
||||
|
||||
int ui_get_rgb_format(int red, int green, int blue, int alpha)
|
||||
{
|
||||
PixelFormatInfo info;
|
||||
PixelFormat fmt;
|
||||
|
||||
/* look in the RGB range */
|
||||
for (fmt = 1; fmt < PIXEL_FORMAT_YCbCr_422_SP; fmt++) {
|
||||
status_t err = getPixelFormatInfo(fmt, &info);
|
||||
if (err)
|
||||
return -1;
|
||||
/* bpp must be equal to depth */
|
||||
if (info.bytesPerPixel * 8 != info.bitsPerPixel)
|
||||
continue;
|
||||
|
||||
if ((info.h_red - info.l_red != red) ||
|
||||
(info.h_green - info.l_green != green) ||
|
||||
(info.h_blue - info.l_blue != blue) ||
|
||||
(info.h_alpha - info.l_alpha != alpha))
|
||||
continue;
|
||||
|
||||
/* mask? */
|
||||
return fmt;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
41
src/egl/drivers/android/droid_ui.h
Normal file
41
src/egl/drivers/android/droid_ui.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Chia-I Wu <olvaffe@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _DROID_UI_H
|
||||
#define _DROID_UI_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /*__cplusplus */
|
||||
|
||||
#include <drm.h>
|
||||
|
||||
int ui_auth_gpu(drm_magic_t magic);
|
||||
int ui_bytes_per_pixel(int format);
|
||||
int ui_get_rgb_format(int red, int green, int blue, int alpha);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /*__cplusplus */
|
||||
|
||||
#endif /* _DROID_UI_H */
|
596
src/egl/drivers/android/egl_android.c
Normal file
596
src/egl/drivers/android/egl_android.c
Normal file
@@ -0,0 +1,596 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Chia-I Wu <olvaffe@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "DROID-EGL"
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include "glapi/glapi.h"
|
||||
|
||||
#include "eglconfig.h"
|
||||
#include "eglcontext.h"
|
||||
#include "egldisplay.h"
|
||||
#include "egldriver.h"
|
||||
#include "eglglobals.h"
|
||||
#include "egllog.h"
|
||||
#include "eglsurface.h"
|
||||
#include "eglimage.h"
|
||||
|
||||
#include "droid.h"
|
||||
|
||||
#ifndef DROID_DEVICE_PATH
|
||||
#define DROID_DEVICE_PATH "/dev/dri/card0"
|
||||
#endif
|
||||
|
||||
struct droid_egl_driver
|
||||
{
|
||||
_EGLDriver base;
|
||||
|
||||
/* EGL_DEFAULT_DISPLAY */
|
||||
struct droid_egl_display *default_display;
|
||||
void (*flush_current)(void);
|
||||
void (*finish_current)(void);
|
||||
};
|
||||
|
||||
struct droid_egl_display
|
||||
{
|
||||
EGLint refcnt;
|
||||
|
||||
EGLint apis;
|
||||
EGLint major;
|
||||
EGLint minor;
|
||||
|
||||
struct droid_backend *backend;
|
||||
struct droid_screen *screen;
|
||||
};
|
||||
|
||||
struct droid_egl_context {
|
||||
_EGLContext base;
|
||||
struct droid_context *context;
|
||||
};
|
||||
|
||||
struct droid_egl_surface {
|
||||
_EGLSurface base;
|
||||
struct droid_drawable *drawable;
|
||||
struct droid_surface *surface;
|
||||
};
|
||||
|
||||
struct droid_egl_image {
|
||||
_EGLImage base;
|
||||
struct droid_drawable *drawable;
|
||||
struct droid_surface *surface;
|
||||
};
|
||||
|
||||
struct droid_egl_config {
|
||||
_EGLConfig base;
|
||||
const __DRIconfig *config;
|
||||
};
|
||||
|
||||
static INLINE struct droid_egl_driver *
|
||||
lookup_driver(_EGLDriver *drv)
|
||||
{
|
||||
return (struct droid_egl_driver *) drv;
|
||||
}
|
||||
|
||||
static INLINE struct droid_egl_display *
|
||||
lookup_display(_EGLDisplay *dpy)
|
||||
{
|
||||
return (struct droid_egl_display *) dpy->DriverData;
|
||||
}
|
||||
|
||||
static INLINE struct droid_egl_context *
|
||||
lookup_context(_EGLContext *context)
|
||||
{
|
||||
return (struct droid_egl_context *) context;
|
||||
}
|
||||
|
||||
static INLINE struct droid_egl_surface *
|
||||
lookup_surface(_EGLSurface *surface)
|
||||
{
|
||||
return (struct droid_egl_surface *) surface;
|
||||
}
|
||||
|
||||
static INLINE struct droid_egl_image *
|
||||
lookup_image(_EGLImage *image)
|
||||
{
|
||||
return (struct droid_egl_image *) image;
|
||||
}
|
||||
|
||||
static INLINE struct droid_egl_config *
|
||||
lookup_config(_EGLConfig *conf)
|
||||
{
|
||||
return (struct droid_egl_config *) conf;
|
||||
}
|
||||
|
||||
static void
|
||||
droid_create_configs(_EGLDisplay *dpy, struct droid_egl_display *droid_dpy,
|
||||
const __DRIconfig **configs, EGLint num_configs)
|
||||
{
|
||||
EGLint i;
|
||||
EGLint id = 1;
|
||||
|
||||
for (i = 0; i < num_configs; i++) {
|
||||
struct droid_egl_config *droid_conf = calloc(1, sizeof(*droid_conf));
|
||||
EGLint val;
|
||||
|
||||
if (!droid_conf)
|
||||
break;
|
||||
|
||||
_eglInitConfig(&droid_conf->base, id);
|
||||
droid_conf->config = configs[i];
|
||||
if (!droid_screen_convert_config(droid_dpy->screen, droid_conf->config,
|
||||
&droid_conf->base)) {
|
||||
free(droid_conf);
|
||||
continue;
|
||||
}
|
||||
|
||||
val = GET_CONFIG_ATTRIB(&droid_conf->base, EGL_CONFIG_CAVEAT);
|
||||
/* we do not want slow configs */
|
||||
if (val == EGL_SLOW_CONFIG) {
|
||||
free(droid_conf);
|
||||
} else {
|
||||
_eglAddConfig(dpy, &droid_conf->base);
|
||||
id++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static EGLBoolean
|
||||
droid_initialize_display(struct droid_egl_display *droid_dpy)
|
||||
{
|
||||
const char *path = DROID_DEVICE_PATH;
|
||||
|
||||
droid_dpy->backend = droid_backend_create_intel(path);
|
||||
if (!droid_dpy->backend)
|
||||
return EGL_FALSE;
|
||||
|
||||
droid_dpy->screen = droid_screen_create(droid_dpy->backend);
|
||||
if (!droid_dpy->screen) {
|
||||
free(droid_dpy->backend);
|
||||
droid_dpy->backend = NULL;
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
droid_dpy->apis = EGL_OPENGL_ES_BIT;
|
||||
droid_dpy->major = 1;
|
||||
droid_dpy->major = 4;
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
static EGLBoolean
|
||||
droid_eglInitialize(_EGLDriver *drv, _EGLDisplay *dpy,
|
||||
EGLint *major, EGLint *minor)
|
||||
{
|
||||
struct droid_egl_driver *droid_drv = lookup_driver(drv);
|
||||
struct droid_egl_display *droid_dpy;
|
||||
|
||||
if (dpy->NativeDisplay != EGL_DEFAULT_DISPLAY)
|
||||
return _eglError(EGL_NOT_INITIALIZED, "eglInitialize");
|
||||
|
||||
/* the default display */
|
||||
droid_dpy = droid_drv->default_display;
|
||||
if (!droid_dpy) {
|
||||
droid_dpy = calloc(1, sizeof(*droid_dpy));
|
||||
if (!droid_dpy)
|
||||
return _eglError(EGL_BAD_ALLOC, "eglInitialize");
|
||||
if (!droid_initialize_display(droid_dpy))
|
||||
return _eglError(EGL_NOT_INITIALIZED, "eglInitialize");
|
||||
|
||||
droid_create_configs(dpy, droid_dpy, droid_dpy->screen->dri_configs,
|
||||
droid_dpy->screen->num_dri_configs);
|
||||
|
||||
#if EGL_KHR_image_base
|
||||
if (droid_dpy->backend->create_image_surface) {
|
||||
dpy->Extensions.KHR_image = EGL_TRUE;
|
||||
dpy->Extensions.KHR_image_base = EGL_TRUE;
|
||||
dpy->Extensions.KHR_image_pixmap = EGL_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
droid_drv->default_display = droid_dpy;
|
||||
}
|
||||
|
||||
dpy->DriverData = (void *) droid_dpy;
|
||||
droid_dpy->refcnt++;
|
||||
|
||||
*major = droid_dpy->major;
|
||||
*minor = droid_dpy->minor;
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
static EGLBoolean
|
||||
droid_eglTerminate(_EGLDriver *drv, _EGLDisplay *dpy)
|
||||
{
|
||||
struct droid_egl_driver *droid_drv = lookup_driver(drv);
|
||||
struct droid_egl_display *droid_dpy = lookup_display(dpy);
|
||||
|
||||
dpy->DriverData = NULL;
|
||||
droid_dpy->refcnt--;
|
||||
if (!droid_dpy->refcnt) {
|
||||
_eglReleaseDisplayResources(drv, dpy);
|
||||
_eglCleanupDisplay(dpy);
|
||||
|
||||
free(droid_dpy);
|
||||
droid_drv->default_display = NULL;
|
||||
}
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
static _EGLProc
|
||||
droid_eglGetProcAddress(const char *procname)
|
||||
{
|
||||
return (_EGLProc) _glapi_get_proc_address(procname);
|
||||
}
|
||||
|
||||
static _EGLContext *
|
||||
droid_eglCreateContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
|
||||
_EGLContext *share_list, const EGLint *attrib_list)
|
||||
{
|
||||
struct droid_egl_display *droid_dpy = lookup_display(dpy);
|
||||
struct droid_egl_config *droid_conf = lookup_config(conf);
|
||||
struct droid_egl_context *shared = lookup_context(share_list);
|
||||
struct droid_egl_context *ctx;
|
||||
|
||||
ctx = calloc(1, sizeof(*ctx));
|
||||
if (!ctx) {
|
||||
_eglError(EGL_BAD_ALLOC, "eglCreateContext");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!_eglInitContext(drv, &ctx->base, &droid_conf->base, attrib_list)) {
|
||||
free(ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ctx->context =
|
||||
droid_screen_create_context(droid_dpy->screen, droid_conf->config,
|
||||
(shared) ? shared->context : NULL);
|
||||
if (!ctx->context) {
|
||||
free(ctx);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &ctx->base;
|
||||
}
|
||||
|
||||
static EGLBoolean
|
||||
droid_eglDestroyContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx)
|
||||
{
|
||||
struct droid_egl_display *droid_dpy = lookup_display(dpy);
|
||||
struct droid_egl_context *droid_ctx = lookup_context(ctx);
|
||||
|
||||
if (!_eglIsContextBound(ctx))
|
||||
droid_screen_destroy_context(droid_dpy->screen, droid_ctx->context);
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
static EGLBoolean
|
||||
droid_eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *d,
|
||||
_EGLSurface *r, _EGLContext *ctx)
|
||||
{
|
||||
struct droid_egl_driver *droid_drv = lookup_driver(drv);
|
||||
struct droid_egl_display *droid_dpy = lookup_display(dpy);
|
||||
struct droid_egl_surface *draw = lookup_surface(d);
|
||||
struct droid_egl_surface *read = lookup_surface(r);
|
||||
struct droid_egl_context *droid_ctx = lookup_context(ctx);
|
||||
_EGLContext *old;
|
||||
struct droid_egl_context *droid_old;
|
||||
|
||||
old = _eglGetCurrentContext();
|
||||
/* an unlinked context will be invalid after context switch */
|
||||
if (!_eglIsContextLinked(old))
|
||||
old = NULL;
|
||||
|
||||
droid_old = lookup_context(old);
|
||||
|
||||
if (!_eglMakeCurrent(drv, dpy, d, r, ctx))
|
||||
return EGL_FALSE;
|
||||
|
||||
if (droid_old && droid_old != droid_ctx && droid_drv->flush_current)
|
||||
droid_drv->flush_current();
|
||||
|
||||
_glapi_check_multithread();
|
||||
|
||||
/* bind new context or unbind old one */
|
||||
if (droid_ctx)
|
||||
droid_screen_bind_context(droid_dpy->screen,
|
||||
draw->drawable, read->drawable,
|
||||
droid_ctx->context);
|
||||
else if (droid_old)
|
||||
droid_screen_bind_context(droid_dpy->screen,
|
||||
NULL, NULL,
|
||||
droid_old->context);
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
static _EGLSurface *
|
||||
droid_eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
|
||||
NativeWindowType window, const EGLint *attrib_list)
|
||||
{
|
||||
struct droid_egl_display *droid_dpy = lookup_display(dpy);
|
||||
struct droid_egl_config *droid_conf = lookup_config(conf);
|
||||
struct droid_egl_surface *surf;
|
||||
|
||||
surf = calloc(1, sizeof(*surf));
|
||||
if (!surf) {
|
||||
_eglError(EGL_BAD_ALLOC, "eglCreateWindowSurface");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!_eglInitSurface(drv, &surf->base, EGL_WINDOW_BIT, &droid_conf->base, attrib_list)) {
|
||||
free(surf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
surf->surface =
|
||||
droid_dpy->backend->create_window_surface(droid_dpy->backend,
|
||||
&surf->base, window);
|
||||
if (!surf->surface) {
|
||||
free(surf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
surf->drawable = droid_screen_create_drawable(droid_dpy->screen,
|
||||
droid_conf->config,
|
||||
surf->surface);
|
||||
if (!surf->drawable) {
|
||||
droid_dpy->backend->destroy_surface(droid_dpy->backend, surf->surface);
|
||||
free(surf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &surf->base;
|
||||
}
|
||||
|
||||
static EGLBoolean
|
||||
droid_eglDestroySurface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf)
|
||||
{
|
||||
struct droid_egl_display *droid_dpy = lookup_display(dpy);
|
||||
struct droid_egl_surface *droid_surf = lookup_surface(surf);
|
||||
|
||||
if (_eglIsSurfaceBound(&droid_surf->base))
|
||||
return EGL_TRUE;
|
||||
|
||||
droid_screen_destroy_drawable(droid_dpy->screen, droid_surf->drawable);
|
||||
droid_dpy->backend->destroy_surface(droid_dpy->backend, droid_surf->surface);
|
||||
free(droid_surf);
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
static EGLBoolean
|
||||
droid_eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf)
|
||||
{
|
||||
struct droid_egl_driver *droid_drv = lookup_driver(drv);
|
||||
struct droid_egl_display *droid_dpy = lookup_display(dpy);
|
||||
struct droid_egl_surface *droid_surf = lookup_surface(surf);
|
||||
_EGLContext *ctx = _eglGetCurrentContext();
|
||||
struct droid_egl_context *droid_ctx = lookup_context(ctx);
|
||||
|
||||
if (droid_ctx) {
|
||||
if (droid_drv->flush_current)
|
||||
droid_drv->flush_current();
|
||||
|
||||
droid_screen_swap_buffers(droid_dpy->screen,
|
||||
droid_ctx->context,
|
||||
droid_surf->drawable);
|
||||
}
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
#if EGL_KHR_image_base
|
||||
|
||||
static _EGLImage *
|
||||
droid_eglCreateImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
|
||||
EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list)
|
||||
{
|
||||
struct droid_egl_display *droid_dpy = lookup_display(dpy);
|
||||
struct droid_egl_image *droid_img;
|
||||
struct droid_egl_config *droid_conf;
|
||||
_EGLConfig *conf;
|
||||
EGLint val, i;
|
||||
|
||||
/* only EGL_KHR_image_pixmap is supported */
|
||||
if (target != EGL_NATIVE_PIXMAP_KHR || ctx) {
|
||||
_eglError(EGL_BAD_PARAMETER, "eglCreateImageKHR");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < dpy->NumConfigs; i++) {
|
||||
conf = dpy->Configs[i];
|
||||
if (droid_dpy->backend->match_pixmap(droid_dpy->backend, conf,
|
||||
(NativePixmapType) buffer)) {
|
||||
EGLint val;
|
||||
val = GET_CONFIG_ATTRIB(conf, EGL_BIND_TO_TEXTURE_RGB);
|
||||
val |= GET_CONFIG_ATTRIB(conf, EGL_BIND_TO_TEXTURE_RGBA);
|
||||
if (val)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i >= dpy->NumConfigs)
|
||||
return NULL;
|
||||
|
||||
droid_img = calloc(1, sizeof(*droid_img));
|
||||
if (!droid_img) {
|
||||
_eglError(EGL_BAD_ALLOC, "eglCreateImageKHR");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!_eglInitImage(drv, &droid_img->base, attr_list)) {
|
||||
free(droid_img);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
droid_img->surface =
|
||||
droid_dpy->backend->create_image_surface(droid_dpy->backend,
|
||||
(NativePixmapType) buffer);
|
||||
if (!droid_img->surface) {
|
||||
free(droid_img);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
droid_conf = lookup_config(conf);
|
||||
droid_img->drawable =
|
||||
droid_screen_create_drawable(droid_dpy->screen, droid_conf->config,
|
||||
droid_img->surface);
|
||||
|
||||
if (!droid_img->drawable) {
|
||||
droid_dpy->backend->destroy_surface(droid_dpy->backend,
|
||||
droid_img->surface);
|
||||
free(droid_img);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
droid_img->base.ClientData =
|
||||
droid_screen_get_drawable_data(droid_dpy->screen, droid_img->drawable);
|
||||
|
||||
return &droid_img->base;
|
||||
}
|
||||
|
||||
|
||||
static EGLBoolean
|
||||
droid_eglDestroyImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *img)
|
||||
{
|
||||
struct droid_egl_display *droid_dpy = lookup_display(dpy);
|
||||
struct droid_egl_image *droid_img = lookup_image(img);
|
||||
|
||||
droid_screen_destroy_drawable(droid_dpy->screen, droid_img->drawable);
|
||||
droid_dpy->backend->destroy_surface(droid_dpy->backend, droid_img->surface);
|
||||
free(droid_img);
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
#endif /* EGL_KHR_image_base */
|
||||
|
||||
static EGLBoolean
|
||||
droid_eglWaitClient(_EGLDriver *drv, _EGLDisplay *dpy)
|
||||
{
|
||||
struct droid_egl_driver *droid_drv = lookup_driver(drv);
|
||||
_EGLContext *ctx = _eglGetCurrentContext();
|
||||
|
||||
if (!ctx || !droid_drv->finish_current)
|
||||
return EGL_TRUE;
|
||||
|
||||
if (!_eglIsSurfaceLinked(ctx->DrawSurface))
|
||||
return _eglError(EGL_BAD_CURRENT_SURFACE, "eglWaitClient");
|
||||
|
||||
droid_drv->finish_current();
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
static EGLBoolean
|
||||
droid_eglWaitNative(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine)
|
||||
{
|
||||
struct droid_egl_display *droid_dpy = lookup_display(dpy);
|
||||
_EGLContext *ctx = _eglGetCurrentContext();
|
||||
struct droid_egl_surface *droid_surf;
|
||||
|
||||
if (engine != EGL_CORE_NATIVE_ENGINE)
|
||||
return _eglError(EGL_BAD_PARAMETER, "eglWaitNative");
|
||||
|
||||
if (!ctx)
|
||||
return EGL_TRUE;
|
||||
|
||||
if (!_eglIsSurfaceLinked(ctx->DrawSurface))
|
||||
return _eglError(EGL_BAD_CURRENT_SURFACE, "eglWaitNative");
|
||||
|
||||
droid_surf = lookup_surface(ctx->DrawSurface);
|
||||
droid_dpy->backend->swap_native_buffers(droid_dpy->backend,
|
||||
droid_surf->surface);
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
droid_Unload(_EGLDriver *drv)
|
||||
{
|
||||
struct droid_egl_driver *droid_drv = lookup_driver(drv);
|
||||
free(droid_drv);
|
||||
}
|
||||
|
||||
static void
|
||||
droid_Log(EGLint level, const char *msg)
|
||||
{
|
||||
switch (level) {
|
||||
case _EGL_DEBUG:
|
||||
LOGD(msg);
|
||||
break;
|
||||
case _EGL_INFO:
|
||||
LOGI(msg);
|
||||
break;
|
||||
case _EGL_WARNING:
|
||||
LOGW(msg);
|
||||
break;
|
||||
case _EGL_FATAL:
|
||||
LOGE(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_EGLDriver *
|
||||
_eglMain(const char *args)
|
||||
{
|
||||
struct droid_egl_driver *droid_drv = calloc(1, sizeof(*droid_drv));
|
||||
if (!droid_drv)
|
||||
return NULL;
|
||||
|
||||
_eglInitDriverFallbacks(&droid_drv->base);
|
||||
droid_drv->base.API.Initialize = droid_eglInitialize;
|
||||
droid_drv->base.API.Terminate = droid_eglTerminate;
|
||||
|
||||
droid_drv->base.API.GetProcAddress = droid_eglGetProcAddress;
|
||||
|
||||
droid_drv->base.API.CreateContext = droid_eglCreateContext;
|
||||
droid_drv->base.API.DestroyContext = droid_eglDestroyContext;
|
||||
droid_drv->base.API.MakeCurrent = droid_eglMakeCurrent;
|
||||
droid_drv->base.API.CreateWindowSurface = droid_eglCreateWindowSurface;
|
||||
droid_drv->base.API.DestroySurface = droid_eglDestroySurface;
|
||||
droid_drv->base.API.SwapBuffers = droid_eglSwapBuffers;
|
||||
#if EGL_KHR_image_base
|
||||
droid_drv->base.API.CreateImageKHR = droid_eglCreateImageKHR;
|
||||
droid_drv->base.API.DestroyImageKHR = droid_eglDestroyImageKHR;
|
||||
#endif /* EGL_KHR_image_base */
|
||||
droid_drv->base.API.WaitClient = droid_eglWaitClient;
|
||||
droid_drv->base.API.WaitNative = droid_eglWaitNative;
|
||||
|
||||
droid_drv->base.Name = "Android/i915";
|
||||
droid_drv->base.Unload = droid_Unload;
|
||||
|
||||
/* we need a way to flush commands */
|
||||
droid_drv->flush_current =
|
||||
(void (*)(void)) droid_eglGetProcAddress("glFlush");
|
||||
droid_drv->finish_current =
|
||||
(void (*)(void)) droid_eglGetProcAddress("glFinish");
|
||||
|
||||
_eglSetLogProc(droid_Log);
|
||||
|
||||
return &droid_drv->base;
|
||||
}
|
@@ -54,13 +54,18 @@
|
||||
#include "eglglobals.h"
|
||||
#include "egllog.h"
|
||||
#include "eglsurface.h"
|
||||
#include "eglimage.h"
|
||||
|
||||
#include "EGL/internal/eglimage_dri.h"
|
||||
|
||||
#define MAX_DEPTH 32
|
||||
#define CALLOC_STRUCT(T) (struct T *) calloc(1, sizeof(struct T))
|
||||
|
||||
/** subclass of _EGLDriver */
|
||||
struct xdri_egl_driver
|
||||
{
|
||||
_EGLDriver Base; /**< base class */
|
||||
void (*FlushCurrentContext)(void);
|
||||
};
|
||||
|
||||
|
||||
@@ -73,6 +78,8 @@ struct xdri_egl_display
|
||||
|
||||
__GLXscreenConfigs *psc;
|
||||
EGLint scr;
|
||||
|
||||
const __GLcontextModes *imageConfigs[MAX_DEPTH + 1];
|
||||
};
|
||||
|
||||
|
||||
@@ -98,6 +105,16 @@ struct xdri_egl_surface
|
||||
};
|
||||
|
||||
|
||||
/** subclass of _EGLImage */
|
||||
struct xdri_egl_image
|
||||
{
|
||||
_EGLImage Base; /**< base class */
|
||||
|
||||
Drawable pixmap;
|
||||
__GLXDRIdrawable *driDrawable;
|
||||
};
|
||||
|
||||
|
||||
/** subclass of _EGLConfig */
|
||||
struct xdri_egl_config
|
||||
{
|
||||
@@ -147,6 +164,14 @@ lookup_config(_EGLConfig *conf)
|
||||
}
|
||||
|
||||
|
||||
/** Map EGLImage handle to xdri_egl_image object */
|
||||
static INLINE struct xdri_egl_image *
|
||||
lookup_image(_EGLImage *img)
|
||||
{
|
||||
return (struct xdri_egl_image *) img;
|
||||
}
|
||||
|
||||
|
||||
/** Get size of given window */
|
||||
static Status
|
||||
get_drawable_size(Display *dpy, Drawable d, uint *width, uint *height)
|
||||
@@ -162,6 +187,62 @@ get_drawable_size(Display *dpy, Drawable d, uint *width, uint *height)
|
||||
}
|
||||
|
||||
|
||||
#if EGL_KHR_image_base
|
||||
/** Get depth of given window */
|
||||
static Status
|
||||
get_drawable_depth(Display *dpy, Drawable d, uint *depth_ret)
|
||||
{
|
||||
Window root;
|
||||
Status stat;
|
||||
int xpos, ypos;
|
||||
unsigned int w, h, bw, depth;
|
||||
stat = XGetGeometry(dpy, d, &root, &xpos, &ypos, &w, &h, &bw, &depth);
|
||||
*depth_ret = depth;
|
||||
return stat;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The config of a pixmap must be guessed from its depth. Do the guess once
|
||||
* for all depths.
|
||||
*/
|
||||
static void
|
||||
find_image_configs(_EGLDisplay *dpy, const __GLcontextModes *modes)
|
||||
{
|
||||
struct xdri_egl_display *xdri_dpy = lookup_display(dpy);
|
||||
EGLint depth;
|
||||
|
||||
for (depth = 0; depth < MAX_DEPTH + 1; depth++) {
|
||||
const __GLcontextModes *m;
|
||||
|
||||
for (m = modes; m; m = m->next) {
|
||||
/* the depth of a pixmap might not include alpha */
|
||||
if (m->rgbBits != depth && (m->rgbBits - m->alphaBits) != depth)
|
||||
continue;
|
||||
if (!m->visualID)
|
||||
continue;
|
||||
|
||||
if (depth == 32) {
|
||||
if (m->bindToTextureRgba) {
|
||||
xdri_dpy->imageConfigs[depth] = m;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m->bindToTextureRgb) {
|
||||
xdri_dpy->imageConfigs[depth] = m;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m)
|
||||
_eglLog(_EGL_DEBUG, "Use mode 0x%02x for depth %d",
|
||||
m->visualID, depth);
|
||||
}
|
||||
}
|
||||
#endif /* EGL_KHR_image_base */
|
||||
|
||||
|
||||
/**
|
||||
* Produce a set of EGL configs.
|
||||
*/
|
||||
@@ -275,6 +356,15 @@ xdri_eglInitialize(_EGLDriver *drv, _EGLDisplay *dpy,
|
||||
EGL_OPENGL_ES2_BIT |
|
||||
EGL_OPENVG_BIT);
|
||||
|
||||
#if EGL_KHR_image_base
|
||||
/* must be called after DriverData is set */
|
||||
find_image_configs(dpy, psc->configs);
|
||||
|
||||
dpy->Extensions.KHR_image = EGL_TRUE;
|
||||
dpy->Extensions.KHR_image_base = EGL_TRUE;
|
||||
dpy->Extensions.KHR_image_pixmap = EGL_TRUE;
|
||||
#endif
|
||||
|
||||
/* we're supporting EGL 1.4 */
|
||||
*minor = 1;
|
||||
*major = 4;
|
||||
@@ -406,13 +496,23 @@ static EGLBoolean
|
||||
xdri_eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *d,
|
||||
_EGLSurface *r, _EGLContext *context)
|
||||
{
|
||||
struct xdri_egl_driver *xdri_driver = xdri_egl_driver(drv);
|
||||
struct xdri_egl_context *xdri_ctx = lookup_context(context);
|
||||
struct xdri_egl_surface *draw = lookup_surface(d);
|
||||
struct xdri_egl_surface *read = lookup_surface(r);
|
||||
_EGLContext *old = _eglGetCurrentContext();
|
||||
|
||||
/* an unlinked context will be invalid after context switch */
|
||||
if (!_eglIsContextLinked(old))
|
||||
old = NULL;
|
||||
|
||||
if (!_eglMakeCurrent(drv, dpy, d, r, context))
|
||||
return EGL_FALSE;
|
||||
|
||||
/* flush before context switch */
|
||||
if (old && old != context && xdri_driver->FlushCurrentContext)
|
||||
xdri_driver->FlushCurrentContext();
|
||||
|
||||
/* the symbol is defined in libGL.so */
|
||||
_glapi_check_multithread();
|
||||
|
||||
@@ -423,12 +523,9 @@ xdri_eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *d,
|
||||
return EGL_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_EGLContext *old = _eglGetCurrentContext();
|
||||
if (old) {
|
||||
xdri_ctx = lookup_context(old);
|
||||
xdri_ctx->driContext->unbindContext(xdri_ctx->driContext);
|
||||
}
|
||||
else if (old) {
|
||||
xdri_ctx = lookup_context(old);
|
||||
xdri_ctx->driContext->unbindContext(xdri_ctx->driContext);
|
||||
}
|
||||
|
||||
return EGL_TRUE;
|
||||
@@ -524,15 +621,119 @@ xdri_eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
|
||||
static EGLBoolean
|
||||
xdri_eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw)
|
||||
{
|
||||
struct xdri_egl_driver *xdri_driver = xdri_egl_driver(drv);
|
||||
struct xdri_egl_display *xdri_dpy = lookup_display(dpy);
|
||||
struct xdri_egl_surface *xdri_surf = lookup_surface(draw);
|
||||
|
||||
/* swapBuffers does not flush commands */
|
||||
if (draw == _eglGetCurrentSurface(EGL_DRAW) &&
|
||||
xdri_driver->FlushCurrentContext)
|
||||
xdri_driver->FlushCurrentContext();
|
||||
|
||||
xdri_dpy->psc->driScreen->swapBuffers(xdri_surf->driDrawable);
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
#if EGL_KHR_image_base
|
||||
|
||||
|
||||
static _EGLImage *
|
||||
xdri_eglCreateImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
|
||||
EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list)
|
||||
{
|
||||
struct xdri_egl_display *xdri_dpy = lookup_display(dpy);
|
||||
struct xdri_egl_image *xdri_img;
|
||||
__DRIEGLImage *driImage;
|
||||
EGLint err = EGL_SUCCESS;
|
||||
const __GLcontextModes *mode;
|
||||
uint depth;
|
||||
|
||||
xdri_img = CALLOC_STRUCT(xdri_egl_image);
|
||||
if (!xdri_img) {
|
||||
_eglError(EGL_BAD_ALLOC, "eglCreateImageKHR");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (target) {
|
||||
case EGL_NATIVE_PIXMAP_KHR:
|
||||
if (ctx) {
|
||||
err = EGL_BAD_PARAMETER;
|
||||
break;
|
||||
}
|
||||
xdri_img->pixmap = (Pixmap) buffer;
|
||||
break;
|
||||
default:
|
||||
err = EGL_BAD_PARAMETER;
|
||||
break;
|
||||
}
|
||||
|
||||
if (err != EGL_SUCCESS) {
|
||||
_eglError(EGL_BAD_PARAMETER, "eglCreateImageKHR");
|
||||
free(xdri_img);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!_eglInitImage(drv, &xdri_img->Base, attr_list)) {
|
||||
free(xdri_img);
|
||||
return NULL;
|
||||
}
|
||||
if (!get_drawable_depth(xdri_dpy->dpy, xdri_img->pixmap, &depth) ||
|
||||
depth > MAX_DEPTH) {
|
||||
free(xdri_img);
|
||||
return NULL;
|
||||
}
|
||||
mode = xdri_dpy->imageConfigs[depth];
|
||||
if (!mode) {
|
||||
free(xdri_img);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
driImage = CALLOC_STRUCT(__DRIEGLImageRec);
|
||||
if (!driImage) {
|
||||
_eglError(EGL_BAD_ALLOC, "eglCreateImageKHR");
|
||||
free(xdri_img);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
xdri_img->driDrawable =
|
||||
xdri_dpy->psc->driScreen->createDrawable(xdri_dpy->psc,
|
||||
(XID) xdri_img->pixmap,
|
||||
(GLXDrawable) xdri_img->pixmap,
|
||||
mode);
|
||||
if (!xdri_img->driDrawable) {
|
||||
free(driImage);
|
||||
free(xdri_img);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
driImage->magic = __DRI_EGL_IMAGE_MAGIC;
|
||||
driImage->drawable = xdri_img->driDrawable->driDrawable;
|
||||
driImage->texture_format_rgba = (depth == 32 && mode->bindToTextureRgba);
|
||||
driImage->level = 0;
|
||||
|
||||
xdri_img->Base.ClientData = (void *) driImage;
|
||||
|
||||
return &xdri_img->Base;
|
||||
}
|
||||
|
||||
|
||||
static EGLBoolean
|
||||
xdri_eglDestroyImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *img)
|
||||
{
|
||||
struct xdri_egl_image *xdri_img = lookup_image(img);
|
||||
|
||||
free(xdri_img->Base.ClientData);
|
||||
xdri_img->driDrawable->destroyDrawable(xdri_img->driDrawable);
|
||||
free(xdri_img);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
#endif /* EGL_KHR_image_base */
|
||||
|
||||
|
||||
static void
|
||||
xdri_Unload(_EGLDriver *drv)
|
||||
{
|
||||
@@ -567,9 +768,17 @@ _eglMain(const char *args)
|
||||
xdri_drv->Base.API.BindTexImage = xdri_eglBindTexImage;
|
||||
xdri_drv->Base.API.ReleaseTexImage = xdri_eglReleaseTexImage;
|
||||
xdri_drv->Base.API.SwapBuffers = xdri_eglSwapBuffers;
|
||||
#if EGL_KHR_image_base
|
||||
xdri_drv->Base.API.CreateImageKHR = xdri_eglCreateImageKHR;
|
||||
xdri_drv->Base.API.DestroyImageKHR = xdri_eglDestroyImageKHR;
|
||||
#endif /* EGL_KHR_image_base */
|
||||
|
||||
xdri_drv->Base.Name = "X/DRI";
|
||||
xdri_drv->Base.Unload = xdri_Unload;
|
||||
|
||||
/* we need a way to flush commands */
|
||||
xdri_drv->FlushCurrentContext =
|
||||
(void (*)(void)) xdri_eglGetProcAddress("glFlush");
|
||||
|
||||
return &xdri_drv->Base;
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@ include $(TOP)/configs/current
|
||||
INCLUDE_DIRS = -I$(TOP)/include -I$(TOP)/src/mesa/glapi $(X11_INCLUDES)
|
||||
|
||||
HEADERS = \
|
||||
eglclient.h \
|
||||
eglcompiler.h \
|
||||
eglconfig.h \
|
||||
eglconfigutil.h \
|
||||
@@ -16,6 +17,7 @@ HEADERS = \
|
||||
egldisplay.h \
|
||||
egldriver.h \
|
||||
eglglobals.h \
|
||||
eglimage.h \
|
||||
egllog.h \
|
||||
eglmisc.h \
|
||||
eglmode.h \
|
||||
@@ -26,6 +28,7 @@ HEADERS = \
|
||||
|
||||
SOURCES = \
|
||||
eglapi.c \
|
||||
eglclient.c \
|
||||
eglconfig.c \
|
||||
eglconfigutil.c \
|
||||
eglcontext.c \
|
||||
@@ -33,6 +36,7 @@ SOURCES = \
|
||||
egldisplay.c \
|
||||
egldriver.c \
|
||||
eglglobals.c \
|
||||
eglimage.c \
|
||||
egllog.c \
|
||||
eglmisc.c \
|
||||
eglmode.c \
|
||||
|
@@ -41,6 +41,7 @@
|
||||
#include "eglconfig.h"
|
||||
#include "eglscreen.h"
|
||||
#include "eglmode.h"
|
||||
#include "eglimage.h"
|
||||
|
||||
|
||||
/**
|
||||
@@ -92,8 +93,8 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
|
||||
snprintf(disp->Version, sizeof(disp->Version),
|
||||
"%d.%d (%s)", major_int, minor_int, drv->Name);
|
||||
|
||||
/* update the global notion of supported APIs */
|
||||
_eglGlobal.ClientAPIsMask |= disp->ClientAPIsMask;
|
||||
/* limit to APIs supported by core */
|
||||
disp->ClientAPIsMask &= _EGL_API_ALL_BITS;
|
||||
|
||||
disp->Driver = drv;
|
||||
} else {
|
||||
@@ -644,6 +645,10 @@ void (* EGLAPIENTRY eglGetProcAddress(const char *procname))()
|
||||
{ "eglReleaseThread", (_EGLProc) eglReleaseThread },
|
||||
{ "eglWaitClient", (_EGLProc) eglWaitClient },
|
||||
#endif /* EGL_VERSION_1_2 */
|
||||
#ifdef EGL_KHR_image_base
|
||||
{ "eglCreateImageKHR", (_EGLProc) eglCreateImageKHR },
|
||||
{ "eglDestroyImageKHR", (_EGLProc) eglDestroyImageKHR },
|
||||
#endif /* EGL_KHR_image_base */
|
||||
{ NULL, NULL }
|
||||
};
|
||||
EGLint i;
|
||||
@@ -653,6 +658,10 @@ void (* EGLAPIENTRY eglGetProcAddress(const char *procname))()
|
||||
}
|
||||
}
|
||||
|
||||
/* preload a driver if there isn't one */
|
||||
if (!_eglGlobal.NumDrivers)
|
||||
_eglPreloadDriver(NULL);
|
||||
|
||||
/* now loop over drivers to query their procs */
|
||||
for (i = 0; i < _eglGlobal.NumDrivers; i++) {
|
||||
_EGLProc p = _eglGlobal.Drivers[i]->API.GetProcAddress(procname);
|
||||
@@ -867,33 +876,7 @@ eglBindAPI(EGLenum api)
|
||||
if (!_eglIsApiValid(api))
|
||||
return _eglError(EGL_BAD_PARAMETER, "eglBindAPI");
|
||||
|
||||
switch (api) {
|
||||
#ifdef EGL_VERSION_1_4
|
||||
case EGL_OPENGL_API:
|
||||
if (_eglGlobal.ClientAPIsMask & EGL_OPENGL_BIT) {
|
||||
t->CurrentAPIIndex = _eglConvertApiToIndex(api);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
_eglError(EGL_BAD_PARAMETER, "eglBindAPI");
|
||||
return EGL_FALSE;
|
||||
#endif
|
||||
case EGL_OPENGL_ES_API:
|
||||
if (_eglGlobal.ClientAPIsMask & (EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT)) {
|
||||
t->CurrentAPIIndex = _eglConvertApiToIndex(api);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
_eglError(EGL_BAD_PARAMETER, "eglBindAPI");
|
||||
return EGL_FALSE;
|
||||
case EGL_OPENVG_API:
|
||||
if (_eglGlobal.ClientAPIsMask & EGL_OPENVG_BIT) {
|
||||
t->CurrentAPIIndex = _eglConvertApiToIndex(api);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
_eglError(EGL_BAD_PARAMETER, "eglBindAPI");
|
||||
return EGL_FALSE;
|
||||
default:
|
||||
return EGL_FALSE;
|
||||
}
|
||||
t->CurrentAPIIndex = _eglConvertApiToIndex(api);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
@@ -968,3 +951,50 @@ eglWaitClient(void)
|
||||
|
||||
|
||||
#endif /* EGL_VERSION_1_2 */
|
||||
|
||||
|
||||
#ifdef EGL_KHR_image_base
|
||||
|
||||
|
||||
EGLImageKHR
|
||||
eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list)
|
||||
{
|
||||
_EGLDisplay *disp = _eglLookupDisplay(dpy);
|
||||
_EGLContext *context = _eglLookupContext(ctx, disp);
|
||||
_EGLDriver *drv;
|
||||
_EGLImage *img;
|
||||
|
||||
drv = _eglCheckDisplay(disp, __FUNCTION__);
|
||||
if (!drv)
|
||||
return EGL_NO_IMAGE_KHR;
|
||||
if (!context && ctx != EGL_NO_CONTEXT) {
|
||||
_eglError(EGL_BAD_CONTEXT, __FUNCTION__);
|
||||
return EGL_NO_IMAGE_KHR;
|
||||
}
|
||||
|
||||
img = drv->API.CreateImageKHR(drv, disp, context, target, buffer, attr_list);
|
||||
if (img)
|
||||
return _eglLinkImage(img, disp);
|
||||
else
|
||||
return EGL_NO_IMAGE_KHR;
|
||||
}
|
||||
|
||||
|
||||
EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image)
|
||||
{
|
||||
_EGLDisplay *disp = _eglLookupDisplay(dpy);
|
||||
_EGLImage *img = _eglLookupImage(image, disp);
|
||||
_EGLDriver *drv;
|
||||
|
||||
drv = _eglCheckDisplay(disp, __FUNCTION__);
|
||||
if (!drv)
|
||||
return EGL_FALSE;
|
||||
if (!img)
|
||||
return _eglError(EGL_BAD_PARAMETER, __FUNCTION__);
|
||||
|
||||
_eglUnlinkImage(img);
|
||||
return drv->API.DestroyImageKHR(drv, disp, img);
|
||||
}
|
||||
|
||||
|
||||
#endif /* EGL_KHR_image_base */
|
||||
|
@@ -70,6 +70,11 @@ typedef _EGLSurface *(*CreatePbufferFromClientBuffer_t)(_EGLDriver *drv, _EGLDis
|
||||
#endif /* EGL_VERSION_1_2 */
|
||||
|
||||
|
||||
#ifdef EGL_KHR_image_base
|
||||
typedef _EGLImage *(*CreateImageKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list);
|
||||
typedef EGLBoolean (*DestroyImageKHR_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image);
|
||||
#endif /* EGL_KHR_image_base */
|
||||
|
||||
|
||||
/**
|
||||
* The API dispatcher jumps through these functions
|
||||
@@ -105,7 +110,7 @@ struct _egl_api
|
||||
WaitNative_t WaitNative;
|
||||
GetProcAddress_t GetProcAddress;
|
||||
|
||||
/* EGL_MESA_screen extension */
|
||||
#ifdef EGL_MESA_screen_surface
|
||||
ChooseModeMESA_t ChooseModeMESA;
|
||||
GetModesMESA_t GetModesMESA;
|
||||
GetModeAttribMESA_t GetModeAttribMESA;
|
||||
@@ -118,11 +123,17 @@ struct _egl_api
|
||||
QueryScreenSurfaceMESA_t QueryScreenSurfaceMESA;
|
||||
QueryScreenModeMESA_t QueryScreenModeMESA;
|
||||
QueryModeStringMESA_t QueryModeStringMESA;
|
||||
#endif /* EGL_MESA_screen_surface */
|
||||
|
||||
#ifdef EGL_VERSION_1_2
|
||||
WaitClient_t WaitClient;
|
||||
CreatePbufferFromClientBuffer_t CreatePbufferFromClientBuffer;
|
||||
#endif
|
||||
|
||||
#ifdef EGL_KHR_image_base
|
||||
CreateImageKHR_t CreateImageKHR;
|
||||
DestroyImageKHR_t DestroyImageKHR;
|
||||
#endif /* EGL_KHR_image_base */
|
||||
};
|
||||
|
||||
#endif /* EGLAPI_INCLUDED */
|
||||
|
21
src/egl/main/eglclient.c
Normal file
21
src/egl/main/eglclient.c
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Functions that client APIs can call.
|
||||
*/
|
||||
|
||||
|
||||
#include "eglcurrent.h"
|
||||
#include "egldisplay.h"
|
||||
#include "eglimage.h"
|
||||
#include "eglclient.h"
|
||||
|
||||
|
||||
/**
|
||||
* Return the opaque client data of an image.
|
||||
*/
|
||||
void *
|
||||
_eglClientGetImageData(EGLImageKHR image)
|
||||
{
|
||||
_EGLDisplay *dpy = _eglGetCurrentDisplay();
|
||||
_EGLImage *img = _eglLookupImage(image, dpy);
|
||||
return (img) ? img->ClientData : NULL;
|
||||
}
|
12
src/egl/main/eglclient.h
Normal file
12
src/egl/main/eglclient.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef EGLCLIENT_INCLUDED
|
||||
#define EGLCLIENT_INCLUDED
|
||||
|
||||
|
||||
#include "egltypedefs.h"
|
||||
|
||||
|
||||
extern void *
|
||||
_eglClientGetImageData(EGLImageKHR image);
|
||||
|
||||
|
||||
#endif /* EGLCLIENT_INCLUDED */
|
@@ -9,7 +9,7 @@
|
||||
|
||||
/* This should be kept in sync with _eglInitThreadInfo() */
|
||||
#define _EGL_THREAD_INFO_INITIALIZER \
|
||||
{ EGL_SUCCESS, { NULL }, 1 }
|
||||
{ EGL_SUCCESS, { NULL }, 0 }
|
||||
|
||||
/* a fallback thread info to guarantee that every thread always has one */
|
||||
static _EGLThreadInfo dummy_thread = _EGL_THREAD_INFO_INITIALIZER;
|
||||
|
@@ -4,8 +4,16 @@
|
||||
#include "egltypedefs.h"
|
||||
|
||||
|
||||
#define _EGL_API_NUM_INDICES \
|
||||
(EGL_OPENGL_API - EGL_OPENGL_ES_API + 2) /* idx 0 is for EGL_NONE */
|
||||
#define _EGL_API_ALL_BITS \
|
||||
(EGL_OPENGL_ES_BIT | \
|
||||
EGL_OPENVG_BIT | \
|
||||
EGL_OPENGL_ES2_BIT | \
|
||||
EGL_OPENGL_BIT)
|
||||
|
||||
|
||||
#define _EGL_API_FIRST_API EGL_OPENGL_ES_API
|
||||
#define _EGL_API_LAST_API EGL_OPENGL_API
|
||||
#define _EGL_API_NUM_APIS (_EGL_API_LAST_API - _EGL_API_FIRST_API + 1)
|
||||
|
||||
|
||||
/**
|
||||
@@ -14,20 +22,19 @@
|
||||
struct _egl_thread_info
|
||||
{
|
||||
EGLint LastError;
|
||||
_EGLContext *CurrentContexts[_EGL_API_NUM_INDICES];
|
||||
_EGLContext *CurrentContexts[_EGL_API_NUM_APIS];
|
||||
/* use index for fast access to current context */
|
||||
EGLint CurrentAPIIndex;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Return true if a client API enum can be converted to an index.
|
||||
* Return true if a client API enum is recognized.
|
||||
*/
|
||||
static INLINE EGLBoolean
|
||||
_eglIsApiValid(EGLenum api)
|
||||
{
|
||||
return ((api >= EGL_OPENGL_ES_API && api <= EGL_OPENGL_API) ||
|
||||
api == EGL_NONE);
|
||||
return (api >= _EGL_API_FIRST_API && api <= _EGL_API_LAST_API);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +45,7 @@ _eglIsApiValid(EGLenum api)
|
||||
static INLINE EGLint
|
||||
_eglConvertApiToIndex(EGLenum api)
|
||||
{
|
||||
return (api != EGL_NONE) ? api - EGL_OPENGL_ES_API + 1 : 0;
|
||||
return api - _EGL_API_FIRST_API;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +56,7 @@ _eglConvertApiToIndex(EGLenum api)
|
||||
static INLINE EGLenum
|
||||
_eglConvertApiFromIndex(EGLint idx)
|
||||
{
|
||||
return (idx) ? EGL_OPENGL_ES_API + idx - 1 : EGL_NONE;
|
||||
return _EGL_API_FIRST_API + idx;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -14,6 +14,9 @@ struct _egl_extensions
|
||||
{
|
||||
EGLBoolean MESA_screen_surface;
|
||||
EGLBoolean MESA_copy_context;
|
||||
EGLBoolean KHR_image;
|
||||
EGLBoolean KHR_image_base;
|
||||
EGLBoolean KHR_image_pixmap;
|
||||
|
||||
char String[_EGL_MAX_EXTENSIONS_LEN];
|
||||
};
|
||||
@@ -50,6 +53,8 @@ struct _egl_display
|
||||
/* lists of linked contexts and surface */
|
||||
_EGLContext *ContextList;
|
||||
_EGLSurface *SurfaceList;
|
||||
|
||||
_EGLImage *ImageList;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -19,62 +19,74 @@
|
||||
#include "eglscreen.h"
|
||||
#include "eglstring.h"
|
||||
#include "eglsurface.h"
|
||||
#include "eglimage.h"
|
||||
|
||||
#if defined(_EGL_PLATFORM_X)
|
||||
#include <dlfcn.h>
|
||||
#elif defined(_EGL_PLATFORM_WINDOWS)
|
||||
/* Use static linking on Windows for now */
|
||||
#define WINDOWS_STATIC_LINK
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Wrappers for dlopen/dlclose()
|
||||
*/
|
||||
#if defined(_EGL_PLATFORM_WINDOWS)
|
||||
#ifdef WINDOWS_STATIC_LINK
|
||||
static const char *DefaultDriverName = "Windows EGL Static Library";
|
||||
#else
|
||||
/* XXX Need to decide how to do dynamic name lookup on Windows */
|
||||
static const char *DefaultDriverName = "TBD";
|
||||
#endif
|
||||
typedef HMODULE lib_handle;
|
||||
|
||||
static HMODULE
|
||||
open_library(const char *filename)
|
||||
{
|
||||
#ifdef WINDOWS_STATIC_LINK
|
||||
return 0;
|
||||
#else
|
||||
return LoadLibrary(filename);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
close_library(HMODULE lib)
|
||||
{
|
||||
#ifdef WINDOWS_STATIC_LINK
|
||||
#else
|
||||
FreeLibrary(lib);
|
||||
#endif
|
||||
}
|
||||
/* XXX Need to decide how to do dynamic name lookup on Windows */
|
||||
static const char DefaultDriverName[] = "TBD";
|
||||
|
||||
typedef HMODULE lib_handle;
|
||||
|
||||
static HMODULE
|
||||
open_library(const char *filename)
|
||||
{
|
||||
return LoadLibrary(filename);
|
||||
}
|
||||
|
||||
static void
|
||||
close_library(HMODULE lib)
|
||||
{
|
||||
FreeLibrary(lib);
|
||||
}
|
||||
|
||||
|
||||
#elif defined(_EGL_PLATFORM_X)
|
||||
static const char *DefaultDriverName = "egl_softpipe";
|
||||
|
||||
typedef void * lib_handle;
|
||||
|
||||
static void *
|
||||
open_library(const char *filename)
|
||||
{
|
||||
return dlopen(filename, RTLD_LAZY);
|
||||
}
|
||||
static const char DefaultDriverName[] = "egl_softpipe";
|
||||
|
||||
typedef void * lib_handle;
|
||||
|
||||
static void *
|
||||
open_library(const char *filename)
|
||||
{
|
||||
return dlopen(filename, RTLD_LAZY);
|
||||
}
|
||||
|
||||
static void
|
||||
close_library(void *lib)
|
||||
{
|
||||
dlclose(lib);
|
||||
}
|
||||
|
||||
#else /* _EGL_PLATFORM_NO_OS */
|
||||
|
||||
static const char DefaultDriverName[] = "builtin";
|
||||
|
||||
typedef void *lib_handle;
|
||||
|
||||
static INLINE void *
|
||||
open_library(const char *filename)
|
||||
{
|
||||
return (void *) filename;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
close_library(void *lib)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
close_library(void *lib)
|
||||
{
|
||||
dlclose(lib);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -95,14 +107,22 @@ _eglChooseDriver(_EGLDisplay *dpy, char **argsRet)
|
||||
path = _eglstrdup(path);
|
||||
|
||||
#if defined(_EGL_PLATFORM_X)
|
||||
if (!path && dpy->NativeDisplay) {
|
||||
if (!path && dpy && dpy->NativeDisplay) {
|
||||
/* assume (wrongly!) that the native display is a display string */
|
||||
path = _eglSplitDisplayString((const char *) dpy->NativeDisplay, &args);
|
||||
}
|
||||
suffix = "so";
|
||||
#elif defined(_EGL_PLATFORM_WINDOWS)
|
||||
suffix = "dll";
|
||||
#endif /* _EGL_PLATFORM_X */
|
||||
#else /* _EGL_PLATFORM_NO_OS */
|
||||
if (path) {
|
||||
/* force the use of the default driver */
|
||||
_eglLog(_EGL_DEBUG, "ignore EGL_DRIVER");
|
||||
free(path);
|
||||
path = NULL;
|
||||
}
|
||||
suffix = NULL;
|
||||
#endif
|
||||
|
||||
if (!path)
|
||||
path = _eglstrdup(DefaultDriverName);
|
||||
@@ -136,43 +156,48 @@ _eglChooseDriver(_EGLDisplay *dpy, char **argsRet)
|
||||
static _EGLMain_t
|
||||
_eglOpenLibrary(const char *driverPath, lib_handle *handle)
|
||||
{
|
||||
_EGLMain_t mainFunc;
|
||||
lib_handle lib;
|
||||
_EGLMain_t mainFunc = NULL;
|
||||
const char *error = "unknown error";
|
||||
|
||||
assert(driverPath);
|
||||
|
||||
_eglLog(_EGL_DEBUG, "dlopen(%s)", driverPath);
|
||||
lib = open_library(driverPath);
|
||||
|
||||
#if defined(_EGL_PLATFORM_WINDOWS)
|
||||
/* Use static linking on Windows for now */
|
||||
#ifdef WINDOWS_STATIC_LINK
|
||||
lib = 0;
|
||||
mainFunc = (_EGLMain_t)_eglMain;
|
||||
#else
|
||||
/* XXX untested */
|
||||
_eglLog(_EGL_DEBUG, "dlopen(%s)", driverPath);
|
||||
lib = open_library(driverPath);
|
||||
if (!lib) {
|
||||
_eglLog(_EGL_WARNING, "Could not open %s",
|
||||
driverPath);
|
||||
return NULL;
|
||||
}
|
||||
mainFunc = (_EGLMain_t) GetProcAddress(lib, "_eglMain");
|
||||
#endif
|
||||
if (lib)
|
||||
mainFunc = (_EGLMain_t) GetProcAddress(lib, "_eglMain");
|
||||
#elif defined(_EGL_PLATFORM_X)
|
||||
_eglLog(_EGL_DEBUG, "dlopen(%s)", driverPath);
|
||||
lib = open_library(driverPath);
|
||||
if (lib) {
|
||||
mainFunc = (_EGLMain_t) dlsym(lib, "_eglMain");
|
||||
if (!mainFunc)
|
||||
error = dlerror();
|
||||
}
|
||||
else {
|
||||
error = dlerror();
|
||||
}
|
||||
#else /* _EGL_PLATFORM_NO_OS */
|
||||
/* must be the default driver name */
|
||||
if (strcmp(driverPath, DefaultDriverName) == 0)
|
||||
mainFunc = (_EGLMain_t) _eglMain;
|
||||
else
|
||||
error = "not builtin driver";
|
||||
#endif
|
||||
|
||||
if (!lib) {
|
||||
_eglLog(_EGL_WARNING, "Could not open %s (%s)",
|
||||
driverPath, dlerror());
|
||||
_eglLog(_EGL_WARNING, "Could not open driver %s (%s)",
|
||||
driverPath, error);
|
||||
if (!getenv("EGL_DRIVER"))
|
||||
_eglLog(_EGL_WARNING,
|
||||
"The driver can be overridden by setting EGL_DRIVER");
|
||||
return NULL;
|
||||
}
|
||||
mainFunc = (_EGLMain_t) dlsym(lib, "_eglMain");
|
||||
#endif
|
||||
|
||||
if (!mainFunc) {
|
||||
_eglLog(_EGL_WARNING, "_eglMain not found in %s", driverPath);
|
||||
_eglLog(_EGL_WARNING, "_eglMain not found in %s (%s)",
|
||||
driverPath, error);
|
||||
if (lib)
|
||||
close_library(lib);
|
||||
return NULL;
|
||||
@@ -404,6 +429,11 @@ _eglInitDriverFallbacks(_EGLDriver *drv)
|
||||
#ifdef EGL_VERSION_1_2
|
||||
drv->API.CreatePbufferFromClientBuffer = _eglCreatePbufferFromClientBuffer;
|
||||
#endif /* EGL_VERSION_1_2 */
|
||||
|
||||
#ifdef EGL_KHR_image_base
|
||||
drv->API.CreateImageKHR = _eglCreateImageKHR;
|
||||
drv->API.DestroyImageKHR = _eglDestroyImageKHR;
|
||||
#endif /* EGL_KHR_image_base */
|
||||
}
|
||||
|
||||
|
||||
@@ -428,6 +458,11 @@ _eglFindAPIs(void)
|
||||
const char *es2_libname = "libGLESv2.so";
|
||||
const char *gl_libname = "libGL.so";
|
||||
const char *vg_libname = "libOpenVG.so";
|
||||
#else /* _EGL_PLATFORM_NO_OS */
|
||||
const char *es1_libname = NULL;
|
||||
const char *es2_libname = NULL;
|
||||
const char *gl_libname = NULL;
|
||||
const char *vg_libname = NULL;
|
||||
#endif
|
||||
|
||||
if ((lib = open_library(es1_libname))) {
|
||||
|
@@ -15,13 +15,13 @@ struct _egl_global _eglGlobal =
|
||||
&_eglGlobalMutex, /* Mutex */
|
||||
NULL, /* DisplayList */
|
||||
1, /* FreeScreenHandle */
|
||||
0x0, /* ClientAPIsMask */
|
||||
0, /* NumDrivers */
|
||||
{ NULL }, /* Drivers */
|
||||
2, /* NumAtExitCalls */
|
||||
{ /* AtExitCalls */
|
||||
_eglFiniDisplay,
|
||||
_eglUnloadDrivers
|
||||
{
|
||||
/* default AtExitCalls, called in reverse order */
|
||||
_eglUnloadDrivers, /* always called last */
|
||||
_eglFiniDisplay
|
||||
},
|
||||
};
|
||||
|
||||
|
@@ -19,9 +19,6 @@ struct _egl_global
|
||||
|
||||
EGLScreenMESA FreeScreenHandle;
|
||||
|
||||
/* bitmaks of supported APIs (supported by _some_ driver) */
|
||||
EGLint ClientAPIsMask;
|
||||
|
||||
EGLint NumDrivers;
|
||||
_EGLDriver *Drivers[10];
|
||||
|
||||
|
104
src/egl/main/eglimage.c
Normal file
104
src/egl/main/eglimage.c
Normal file
@@ -0,0 +1,104 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "eglimage.h"
|
||||
#include "egldisplay.h"
|
||||
|
||||
EGLBoolean
|
||||
_eglInitImage(_EGLDriver *drv, _EGLImage *img, const EGLint *attrib_list)
|
||||
{
|
||||
EGLint i;
|
||||
|
||||
img->Preserved = EGL_FALSE;
|
||||
|
||||
for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) {
|
||||
switch (attrib_list[i]) {
|
||||
case EGL_IMAGE_PRESERVED_KHR:
|
||||
i++;
|
||||
img->Preserved = attrib_list[i];
|
||||
break;
|
||||
default:
|
||||
/* not an error */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
_EGLImage *
|
||||
_eglCreateImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
|
||||
EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list)
|
||||
{
|
||||
/* driver should override this function */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
EGLBoolean
|
||||
_eglDestroyImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image)
|
||||
{
|
||||
/* driver should override this function */
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
EGLImageKHR
|
||||
_eglLinkImage(_EGLImage *img, _EGLDisplay *dpy)
|
||||
{
|
||||
img->Display = dpy;
|
||||
img->Next = dpy->ImageList;
|
||||
dpy->ImageList = img;
|
||||
return (EGLImageKHR) img;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_eglUnlinkImage(_EGLImage *img)
|
||||
{
|
||||
_EGLImage *prev;
|
||||
|
||||
prev = img->Display->ImageList;
|
||||
if (prev != img) {
|
||||
while (prev) {
|
||||
if (prev->Next == img)
|
||||
break;
|
||||
prev = prev->Next;
|
||||
}
|
||||
assert(prev);
|
||||
prev->Next = img->Next;
|
||||
}
|
||||
else {
|
||||
img->Display->ImageList = img->Next;
|
||||
}
|
||||
|
||||
img->Next = NULL;
|
||||
img->Display = NULL;
|
||||
}
|
||||
|
||||
|
||||
#ifndef _EGL_SKIP_HANDLE_CHECK
|
||||
|
||||
|
||||
/**
|
||||
* Return EGL_TRUE if the given handle is a valid handle to an image.
|
||||
*/
|
||||
EGLBoolean
|
||||
_eglCheckImageHandle(EGLImageKHR img, _EGLDisplay *dpy)
|
||||
{
|
||||
_EGLImage *cur = NULL;
|
||||
|
||||
if (dpy)
|
||||
cur = dpy->ImageList;
|
||||
while (cur) {
|
||||
if (cur == (_EGLImage *) img) {
|
||||
assert(cur->Display == dpy);
|
||||
break;
|
||||
}
|
||||
cur = cur->Next;
|
||||
}
|
||||
return (cur != NULL);
|
||||
}
|
||||
|
||||
|
||||
#endif /* _EGL_SKIP_HANDLE_CHECK */
|
93
src/egl/main/eglimage.h
Normal file
93
src/egl/main/eglimage.h
Normal file
@@ -0,0 +1,93 @@
|
||||
#ifndef EGLIMAGE_INCLUDED
|
||||
#define EGLIMAGE_INCLUDED
|
||||
|
||||
|
||||
#include "egltypedefs.h"
|
||||
|
||||
|
||||
/**
|
||||
* "Base" class for device driver images.
|
||||
*/
|
||||
struct _egl_image
|
||||
{
|
||||
/* Client data that client APIs and the driver agree on */
|
||||
void *ClientData;
|
||||
|
||||
/* Managed by EGLDisplay for linking */
|
||||
_EGLDisplay *Display;
|
||||
_EGLImage *Next;
|
||||
|
||||
EGLBoolean Preserved;
|
||||
};
|
||||
|
||||
|
||||
extern EGLBoolean
|
||||
_eglInitImage(_EGLDriver *drv, _EGLImage *img, const EGLint *attrib_list);
|
||||
|
||||
|
||||
extern _EGLImage *
|
||||
_eglCreateImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
|
||||
EGLenum target, EGLClientBuffer buffer, const EGLint *attr_list);
|
||||
|
||||
|
||||
extern EGLBoolean
|
||||
_eglDestroyImageKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image);
|
||||
|
||||
|
||||
extern EGLImageKHR
|
||||
_eglLinkImage(_EGLImage *img, _EGLDisplay *dpy);
|
||||
|
||||
|
||||
extern void
|
||||
_eglUnlinkImage(_EGLImage *img);
|
||||
|
||||
|
||||
#ifndef _EGL_SKIP_HANDLE_CHECK
|
||||
|
||||
|
||||
extern EGLBoolean
|
||||
_eglCheckImageHandle(EGLImageKHR img, _EGLDisplay *dpy);
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
/**
|
||||
* Perform a quick check on the handle.
|
||||
*/
|
||||
static INLINE EGLBoolean
|
||||
_eglCheckImageHandle(EGLImageKHR img, _EGLDisplay *dpy)
|
||||
{
|
||||
_EGLImage *i = (_EGLImage *) img;
|
||||
return (dpy && i && i->Display == dpy);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Lookup a handle to find the linked image.
|
||||
* Return NULL if the handle has no corresponding linked image.
|
||||
*/
|
||||
static INLINE _EGLImage *
|
||||
_eglLookupImage(EGLImageKHR image, _EGLDisplay *dpy)
|
||||
{
|
||||
_EGLImage *img = (_EGLImage *) image;
|
||||
if (!_eglCheckImageHandle(img, dpy))
|
||||
img = NULL;
|
||||
return img;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the handle of a linked image.
|
||||
*/
|
||||
static INLINE EGLImageKHR
|
||||
_eglGetImageHandle(_EGLImage *img)
|
||||
{
|
||||
return (EGLImageKHR) ((img && img->Display) ? img : EGL_NO_IMAGE_KHR);
|
||||
}
|
||||
|
||||
|
||||
#endif /* EGLIMAGE_INCLUDED */
|
@@ -9,51 +9,140 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "egllog.h"
|
||||
#include "eglmutex.h"
|
||||
|
||||
#define MAXSTRING 1000
|
||||
#define FALLBACK_LOG_LEVEL _EGL_WARNING
|
||||
#define FALLBACK_LOG_LEVEL_STR "warning"
|
||||
|
||||
static EGLint ReportingLevel = -1;
|
||||
#define FALLBACK_LOG_LEVEL _EGL_WARNING
|
||||
|
||||
|
||||
static void
|
||||
log_level_initialize(void)
|
||||
static struct {
|
||||
_EGLMutex mutex;
|
||||
|
||||
EGLBoolean initialized;
|
||||
EGLint level;
|
||||
_EGLLogProc logger;
|
||||
EGLint num_messages;
|
||||
} logging = {
|
||||
_EGL_MUTEX_INITIALIZER,
|
||||
EGL_FALSE,
|
||||
FALLBACK_LOG_LEVEL,
|
||||
NULL,
|
||||
0
|
||||
};
|
||||
|
||||
static const char *level_strings[] = {
|
||||
/* the order is important */
|
||||
"fatal",
|
||||
"warning",
|
||||
"info",
|
||||
"debug",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the function to be called when there is a message to log.
|
||||
* Note that the function will be called with an internal lock held.
|
||||
* Recursive logging is not allowed.
|
||||
*/
|
||||
void
|
||||
_eglSetLogProc(_EGLLogProc logger)
|
||||
{
|
||||
#if defined(_EGL_PLATFORM_X)
|
||||
char *log_env = getenv("EGL_LOG_LEVEL");
|
||||
#else
|
||||
char *log_env = NULL;
|
||||
#endif
|
||||
EGLint num_messages = 0;
|
||||
|
||||
if (log_env == NULL) {
|
||||
ReportingLevel = FALLBACK_LOG_LEVEL;
|
||||
_eglLockMutex(&logging.mutex);
|
||||
|
||||
if (logging.logger != logger) {
|
||||
logging.logger = logger;
|
||||
|
||||
num_messages = logging.num_messages;
|
||||
logging.num_messages = 0;
|
||||
}
|
||||
else if (strcasecmp(log_env, "fatal") == 0) {
|
||||
ReportingLevel = _EGL_FATAL;
|
||||
}
|
||||
else if (strcasecmp(log_env, "warning") == 0) {
|
||||
ReportingLevel = _EGL_WARNING;
|
||||
}
|
||||
else if (strcasecmp(log_env, "info") == 0) {
|
||||
ReportingLevel = _EGL_INFO;
|
||||
}
|
||||
else if (strcasecmp(log_env, "debug") == 0) {
|
||||
ReportingLevel = _EGL_DEBUG;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Unrecognized EGL_LOG_LEVEL environment variable value. "
|
||||
"Expected one of \"fatal\", \"warning\", \"info\", \"debug\". "
|
||||
"Got \"%s\". Falling back to \"%s\".\n",
|
||||
log_env, FALLBACK_LOG_LEVEL_STR);
|
||||
ReportingLevel = FALLBACK_LOG_LEVEL;
|
||||
|
||||
_eglUnlockMutex(&logging.mutex);
|
||||
|
||||
if (num_messages)
|
||||
_eglLog(_EGL_DEBUG,
|
||||
"New logger installed. "
|
||||
"Messages before the new logger might not be available.");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the log reporting level.
|
||||
*/
|
||||
void
|
||||
_eglSetLogLevel(EGLint level)
|
||||
{
|
||||
switch (level) {
|
||||
case _EGL_FATAL:
|
||||
case _EGL_WARNING:
|
||||
case _EGL_INFO:
|
||||
case _EGL_DEBUG:
|
||||
_eglLockMutex(&logging.mutex);
|
||||
logging.level = level;
|
||||
_eglUnlockMutex(&logging.mutex);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Log a message to stderr.
|
||||
* The default logger. It prints the message to stderr.
|
||||
*/
|
||||
static void
|
||||
_eglDefaultLogger(EGLint level, const char *msg)
|
||||
{
|
||||
fprintf(stderr, "libEGL %s: %s\n", level_strings[level], msg);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the logging facility.
|
||||
*/
|
||||
static void
|
||||
_eglInitLogger(void)
|
||||
{
|
||||
const char *log_env;
|
||||
EGLint i, level = -1;
|
||||
|
||||
if (logging.initialized)
|
||||
return;
|
||||
|
||||
log_env = getenv("EGL_LOG_LEVEL");
|
||||
if (log_env) {
|
||||
for (i = 0; level_strings[i]; i++) {
|
||||
if (strcasecmp(log_env, level_strings[i]) == 0) {
|
||||
level = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
level = FALLBACK_LOG_LEVEL;
|
||||
}
|
||||
|
||||
logging.logger = _eglDefaultLogger;
|
||||
logging.level = (level >= 0) ? level : FALLBACK_LOG_LEVEL;
|
||||
logging.initialized = EGL_TRUE;
|
||||
|
||||
/* it is fine to call _eglLog now */
|
||||
if (log_env && level < 0) {
|
||||
_eglLog(_EGL_WARNING,
|
||||
"Unrecognized EGL_LOG_LEVEL environment variable value. "
|
||||
"Expected one of \"fatal\", \"warning\", \"info\", \"debug\". "
|
||||
"Got \"%s\". Falling back to \"%s\".",
|
||||
log_env, level_strings[FALLBACK_LOG_LEVEL]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Log a message with message logger.
|
||||
* \param level one of _EGL_FATAL, _EGL_WARNING, _EGL_INFO, _EGL_DEBUG.
|
||||
*/
|
||||
void
|
||||
@@ -61,40 +150,26 @@ _eglLog(EGLint level, const char *fmtStr, ...)
|
||||
{
|
||||
va_list args;
|
||||
char msg[MAXSTRING];
|
||||
const char *levelStr;
|
||||
static int log_level_initialized = 0;
|
||||
|
||||
if (!log_level_initialized) {
|
||||
log_level_initialize();
|
||||
log_level_initialized = 1;
|
||||
}
|
||||
/* one-time initialization; a little race here is fine */
|
||||
if (!logging.initialized)
|
||||
_eglInitLogger();
|
||||
if (level > logging.level || level < 0)
|
||||
return;
|
||||
|
||||
if (level <= ReportingLevel) {
|
||||
switch (level) {
|
||||
case _EGL_FATAL:
|
||||
levelStr = "Fatal";
|
||||
break;
|
||||
case _EGL_WARNING:
|
||||
levelStr = "Warning";
|
||||
break;
|
||||
case _EGL_INFO:
|
||||
levelStr = "Info";
|
||||
break;
|
||||
case _EGL_DEBUG:
|
||||
levelStr = "Debug";
|
||||
break;
|
||||
default:
|
||||
levelStr = "";
|
||||
}
|
||||
_eglLockMutex(&logging.mutex);
|
||||
|
||||
if (logging.logger) {
|
||||
va_start(args, fmtStr);
|
||||
vsnprintf(msg, MAXSTRING, fmtStr, args);
|
||||
va_end(args);
|
||||
|
||||
fprintf(stderr, "libEGL %s: %s\n", levelStr, msg);
|
||||
|
||||
if (level == _EGL_FATAL) {
|
||||
exit(1); /* or abort()? */
|
||||
}
|
||||
logging.logger(level, msg);
|
||||
logging.num_messages++;
|
||||
}
|
||||
|
||||
_eglUnlockMutex(&logging.mutex);
|
||||
|
||||
if (level == _EGL_FATAL)
|
||||
exit(1); /* or abort()? */
|
||||
}
|
||||
|
@@ -9,6 +9,17 @@
|
||||
#define _EGL_DEBUG 3 /* useful info for debugging */
|
||||
|
||||
|
||||
typedef void (*_EGLLogProc)(EGLint level, const char *msg);
|
||||
|
||||
|
||||
extern void
|
||||
_eglSetLogProc(_EGLLogProc logger);
|
||||
|
||||
|
||||
extern void
|
||||
_eglSetLogLevel(EGLint level);
|
||||
|
||||
|
||||
extern void
|
||||
_eglLog(EGLint level, const char *fmtStr, ...);
|
||||
|
||||
|
@@ -54,6 +54,12 @@ _eglUpdateExtensionsString(_EGLDisplay *dpy)
|
||||
strcat(exts, "EGL_MESA_screen_surface ");
|
||||
if (dpy->Extensions.MESA_copy_context)
|
||||
strcat(exts, "EGL_MESA_copy_context ");
|
||||
if (dpy->Extensions.KHR_image)
|
||||
strcat(exts, "EGL_KHR_image ");
|
||||
if (dpy->Extensions.KHR_image_base)
|
||||
strcat(exts, "EGL_KHR_image_base ");
|
||||
if (dpy->Extensions.KHR_image_pixmap)
|
||||
strcat(exts, "EGL_KHR_image_pixmap ");
|
||||
assert(strlen(exts) < _EGL_MAX_EXTENSIONS_LEN);
|
||||
}
|
||||
|
||||
|
@@ -6,6 +6,62 @@
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
|
||||
#ifndef EGL_MESA_screen_surface
|
||||
#define EGL_MESA_screen_surface 1
|
||||
|
||||
#define EGL_BAD_SCREEN_MESA 0x4000
|
||||
#define EGL_BAD_MODE_MESA 0x4001
|
||||
#define EGL_SCREEN_COUNT_MESA 0x4002
|
||||
#define EGL_SCREEN_POSITION_MESA 0x4003
|
||||
#define EGL_SCREEN_POSITION_GRANULARITY_MESA 0x4004
|
||||
#define EGL_MODE_ID_MESA 0x4005
|
||||
#define EGL_REFRESH_RATE_MESA 0x4006
|
||||
#define EGL_OPTIMAL_MESA 0x4007
|
||||
#define EGL_INTERLACED_MESA 0x4008
|
||||
#define EGL_SCREEN_BIT_MESA 0x08
|
||||
|
||||
typedef uint32_t EGLScreenMESA;
|
||||
typedef uint32_t EGLModeMESA;
|
||||
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglChooseModeMESA(EGLDisplay dpy, EGLScreenMESA screen, const EGLint *attrib_list, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglGetModesMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglGetModeAttribMESA(EGLDisplay dpy, EGLModeMESA mode, EGLint attribute, EGLint *value);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglGetScreensMESA(EGLDisplay dpy, EGLScreenMESA *screens, EGLint max_screens, EGLint *num_screens);
|
||||
EGLAPI EGLSurface EGLAPIENTRY eglCreateScreenSurfaceMESA(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglShowScreenSurfaceMESA(EGLDisplay dpy, EGLint screen, EGLSurface surface, EGLModeMESA mode);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglScreenPositionMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLint x, EGLint y);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglQueryScreenMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLint attribute, EGLint *value);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglQueryScreenSurfaceMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLSurface *surface);
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglQueryScreenModeMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *mode);
|
||||
EGLAPI const char * EGLAPIENTRY eglQueryModeStringMESA(EGLDisplay dpy, EGLModeMESA mode);
|
||||
#endif /* EGL_EGLEXT_PROTOTYPES */
|
||||
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLCHOOSEMODEMESA) (EGLDisplay dpy, EGLScreenMESA screen, const EGLint *attrib_list, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETMODESMESA) (EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGetModeATTRIBMESA) (EGLDisplay dpy, EGLModeMESA mode, EGLint attribute, EGLint *value);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSCRREENSMESA) (EGLDisplay dpy, EGLScreenMESA *screens, EGLint max_screens, EGLint *num_screens);
|
||||
typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESCREENSURFACEMESA) (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSHOWSCREENSURFACEMESA) (EGLDisplay dpy, EGLint screen, EGLSurface surface, EGLModeMESA mode);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLSCREENPOSIITONMESA) (EGLDisplay dpy, EGLScreenMESA screen, EGLint x, EGLint y);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSCREENMESA) (EGLDisplay dpy, EGLScreenMESA screen, EGLint attribute, EGLint *value);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSCREENSURFACEMESA) (EGLDisplay dpy, EGLScreenMESA screen, EGLSurface *surface);
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSCREENMODEMESA) (EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *mode);
|
||||
typedef const char * (EGLAPIENTRYP PFNEGLQUERYMODESTRINGMESA) (EGLDisplay dpy, EGLModeMESA mode);
|
||||
|
||||
#endif /* EGL_MESA_screen_surface */
|
||||
|
||||
#ifndef EGL_MESA_copy_context
|
||||
#define EGL_MESA_copy_context 1
|
||||
|
||||
#ifdef EGL_EGLEXT_PROTOTYPES
|
||||
EGLAPI EGLBoolean EGLAPIENTRY eglCopyContextMESA(EGLDisplay dpy, EGLContext source, EGLContext dest, EGLint mask);
|
||||
#endif /* EGL_EGLEXT_PROTOTYPES */
|
||||
|
||||
typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOPYCONTEXTMESA) (EGLDisplay dpy, EGLContext source, EGLContext dest, EGLint mask);
|
||||
|
||||
#endif /* EGL_MESA_copy_context */
|
||||
|
||||
#include "eglcompiler.h"
|
||||
|
||||
typedef struct _egl_api _EGLAPI;
|
||||
@@ -28,6 +84,8 @@ typedef struct _egl_surface _EGLSurface;
|
||||
|
||||
typedef struct _egl_thread_info _EGLThreadInfo;
|
||||
|
||||
typedef struct _egl_image _EGLImage;
|
||||
|
||||
|
||||
typedef _EGLDriver *(*_EGLMain_t)(const char *args);
|
||||
|
||||
|
@@ -268,7 +268,7 @@ void cso_release_all( struct cso_context *ctx )
|
||||
void cso_destroy_context( struct cso_context *ctx )
|
||||
{
|
||||
if (ctx) {
|
||||
/*cso_release_all( ctx );*/
|
||||
//cso_release_all( ctx );
|
||||
FREE( ctx );
|
||||
}
|
||||
}
|
||||
|
@@ -212,10 +212,17 @@ static void fse_prepare( struct draw_pt_middle_end *middle,
|
||||
struct draw_vertex_shader *vs = draw->vs.vertex_shader;
|
||||
vs->prepare(vs, draw);
|
||||
}
|
||||
|
||||
|
||||
//return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void fse_run_linear( struct draw_pt_middle_end *middle,
|
||||
unsigned start,
|
||||
unsigned count )
|
||||
|
@@ -210,7 +210,7 @@ void draw_pt_post_vs_prepare( struct pt_post_vs *pvs,
|
||||
pvs->run = post_vs_viewport;
|
||||
}
|
||||
else {
|
||||
/* if (opengl) */
|
||||
//if (opengl)
|
||||
pvs->run = post_vs_cliptest_viewport_gl;
|
||||
}
|
||||
}
|
||||
|
@@ -394,7 +394,6 @@ vcache_check_run( struct draw_pt_front_end *frontend,
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
FREE(storage);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -423,7 +422,6 @@ vcache_check_run( struct draw_pt_front_end *frontend,
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
FREE(storage);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@@ -891,7 +891,7 @@ static void x87_emit_ex2( struct aos_compilation *cp )
|
||||
struct x86_reg st1 = x86_make_reg(file_x87, 1);
|
||||
int stack = cp->func->x87_stack;
|
||||
|
||||
/* set_fpu_round_neg_inf( cp ); */
|
||||
// set_fpu_round_neg_inf( cp );
|
||||
|
||||
x87_fld(cp->func, st0); /* a a */
|
||||
x87_fprndint( cp->func ); /* int(a) a*/
|
||||
@@ -1759,14 +1759,14 @@ emit_instruction( struct aos_compilation *cp,
|
||||
return emit_SUB(cp, inst);
|
||||
|
||||
case TGSI_OPCODE_LRP:
|
||||
/*return emit_LERP(cp, inst);*/
|
||||
// return emit_LERP(cp, inst);
|
||||
return FALSE;
|
||||
|
||||
case TGSI_OPCODE_FRC:
|
||||
return emit_FRC(cp, inst);
|
||||
|
||||
case TGSI_OPCODE_CLAMP:
|
||||
/*return emit_CLAMP(cp, inst);*/
|
||||
// return emit_CLAMP(cp, inst);
|
||||
return FALSE;
|
||||
|
||||
case TGSI_OPCODE_FLR:
|
||||
|
@@ -584,7 +584,7 @@ fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list)
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
/*assert(!fenced_list->numUnfenced);*/
|
||||
//assert(!fenced_list->numUnfenced);
|
||||
#endif
|
||||
|
||||
pipe_mutex_unlock(fenced_list->mutex);
|
||||
|
@@ -1431,11 +1431,11 @@ fetch_texel( struct tgsi_sampler **sampler,
|
||||
{
|
||||
float rgba[NUM_CHANNELS][QUAD_SIZE];
|
||||
(*sampler)->get_samples(*sampler,
|
||||
&store[0], /* s */
|
||||
&store[4], /* t */
|
||||
&store[8], /* r */
|
||||
store[12], /* lodbias */
|
||||
rgba); /* results */
|
||||
&store[0],
|
||||
&store[4],
|
||||
&store[8],
|
||||
0.0f, /*store[12], lodbias */
|
||||
rgba);
|
||||
|
||||
memcpy( store, rgba, 16 * sizeof(float));
|
||||
}
|
||||
|
@@ -217,7 +217,7 @@ ATTRIB( R8G8_SNORM, 2, char, FROM_8_SNORM, TO_8_SNORM )
|
||||
ATTRIB( R8_SNORM, 1, char, FROM_8_SNORM, TO_8_SNORM )
|
||||
|
||||
ATTRIB( A8R8G8B8_UNORM, 4, ubyte, FROM_8_UNORM, TO_8_UNORM )
|
||||
/*ATTRIB( R8G8B8A8_UNORM, 4, ubyte, FROM_8_UNORM, TO_8_UNORM )*/
|
||||
//ATTRIB( R8G8B8A8_UNORM, 4, ubyte, FROM_8_UNORM, TO_8_UNORM )
|
||||
|
||||
ATTRIB( R32G32B32A32_FIXED, 4, int, FROM_32_FIXED, TO_32_FIXED )
|
||||
ATTRIB( R32G32B32_FIXED, 3, int, FROM_32_FIXED, TO_32_FIXED )
|
||||
|
@@ -268,7 +268,7 @@ static void check_os_katmai_support(void)
|
||||
* and therefore to be safe I'm going to leave this test in here.
|
||||
*/
|
||||
if (__cpu_detect_caps.hasSSE) {
|
||||
/* test_os_katmai_exception_support(); */
|
||||
// test_os_katmai_exception_support();
|
||||
}
|
||||
|
||||
/* Restore the original signal handlers.
|
||||
|
@@ -254,7 +254,7 @@ debug_profile_start(void)
|
||||
{
|
||||
WCHAR *p;
|
||||
|
||||
/* increment starting from the less significant digit */
|
||||
// increment starting from the less significant digit
|
||||
p = &wFileName[14];
|
||||
while(1) {
|
||||
if(*p == '9') {
|
||||
|
@@ -214,7 +214,7 @@ debug_symbol_print_imagehlp(const void *addr)
|
||||
HANDLE hProcess;
|
||||
BYTE symbolBuffer[1024];
|
||||
PIMAGEHLP_SYMBOL pSymbol = (PIMAGEHLP_SYMBOL) symbolBuffer;
|
||||
DWORD dwDisplacement = 0; /* Displacement of the input address, relative to the start of the symbol */
|
||||
DWORD dwDisplacement = 0; // Displacement of the input address, relative to the start of the symbol
|
||||
|
||||
hProcess = GetCurrentProcess();
|
||||
|
||||
|
94
src/gallium/auxiliary/util/u_fifo.h
Normal file
94
src/gallium/auxiliary/util/u_fifo.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright © 2009 Jakob Bornecrantz
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef U_FIFO_H
|
||||
#define U_FIFO_H
|
||||
|
||||
#include "util/u_memory.h"
|
||||
|
||||
struct util_fifo
|
||||
{
|
||||
size_t head;
|
||||
size_t tail;
|
||||
size_t num;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
static INLINE struct util_fifo *
|
||||
u_fifo_create(size_t size)
|
||||
{
|
||||
struct util_fifo *fifo;
|
||||
fifo = MALLOC(sizeof(*fifo) + size * sizeof(void*));
|
||||
|
||||
fifo->head = 0;
|
||||
fifo->tail = 0;
|
||||
fifo->num = 0;
|
||||
fifo->size = size;
|
||||
|
||||
return fifo;
|
||||
}
|
||||
|
||||
static INLINE boolean
|
||||
u_fifo_add(struct util_fifo *fifo, void *ptr)
|
||||
{
|
||||
void **array = (void**)&fifo[1];
|
||||
if (fifo->num >= fifo->size)
|
||||
return FALSE;
|
||||
|
||||
if (++fifo->head >= fifo->size)
|
||||
fifo->head = 0;
|
||||
|
||||
array[fifo->head] = ptr;
|
||||
|
||||
++fifo->num;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static INLINE boolean
|
||||
u_fifo_pop(struct util_fifo *fifo, void **ptr)
|
||||
{
|
||||
void **array = (void**)&fifo[1];
|
||||
|
||||
if (!fifo->num)
|
||||
return FALSE;
|
||||
|
||||
if (++fifo->tail >= fifo->size)
|
||||
fifo->tail = 0;
|
||||
|
||||
*ptr = array[fifo->tail];
|
||||
|
||||
++fifo->num;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
u_fifo_destroy(struct util_fifo *fifo)
|
||||
{
|
||||
FREE(fifo);
|
||||
}
|
||||
|
||||
#endif
|
@@ -14,10 +14,10 @@ PIPE_FORMAT_L16_UNORM , arith , 1, 1, un16, , , , xxx1,
|
||||
PIPE_FORMAT_Z16_UNORM , array , 1, 1, un16, , , , x___, zs
|
||||
PIPE_FORMAT_Z32_UNORM , array , 1, 1, un32, , , , x___, zs
|
||||
PIPE_FORMAT_Z32_FLOAT , array , 1, 1, f32 , , , , x___, zs
|
||||
PIPE_FORMAT_S8Z24_UNORM , arith , 1, 1, un8 , un24, , , yx__, zs
|
||||
PIPE_FORMAT_Z24S8_UNORM , arith , 1, 1, un24, un8 , , , xy__, zs
|
||||
PIPE_FORMAT_X8Z24_UNORM , arith , 1, 1, un8 , un24, , , y___, zs
|
||||
PIPE_FORMAT_Z24X8_UNORM , arith , 1, 1, un24, un8 , , , x___, zs
|
||||
PIPE_FORMAT_S8Z24_UNORM , arith , 1, 1, un24, un8 , , , xy__, zs
|
||||
PIPE_FORMAT_Z24S8_UNORM , arith , 1, 1, un8 , un24, , , yx__, zs
|
||||
PIPE_FORMAT_X8Z24_UNORM , arith , 1, 1, un24, un8 , , , x___, zs
|
||||
PIPE_FORMAT_Z24X8_UNORM , arith , 1, 1, un8 , un24, , , y___, zs
|
||||
PIPE_FORMAT_S8_UNORM , array , 1, 1, un8 , , , , _x__, zs
|
||||
PIPE_FORMAT_R64_FLOAT , array , 1, 1, f64 , , , , x001, rgb
|
||||
PIPE_FORMAT_R64G64_FLOAT , array , 1, 1, f64 , f64 , , , xy01, rgb
|
||||
|
|
@@ -1427,7 +1427,6 @@ set_vertex_data(struct gen_mipmap_state *ctx,
|
||||
rz = -1.0f;
|
||||
break;
|
||||
default:
|
||||
rx = ry = rz = 0.0f;
|
||||
assert(0);
|
||||
}
|
||||
|
||||
@@ -1516,17 +1515,6 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
|
||||
uint zslice = 0;
|
||||
uint offset;
|
||||
|
||||
/* The texture object should have room for the levels which we're
|
||||
* about to generate.
|
||||
*/
|
||||
assert(lastLevel <= pt->last_level);
|
||||
|
||||
/* If this fails, why are we here? */
|
||||
assert(lastLevel > baseLevel);
|
||||
|
||||
assert(filter == PIPE_TEX_FILTER_LINEAR ||
|
||||
filter == PIPE_TEX_FILTER_NEAREST);
|
||||
|
||||
/* check if we can render in the texture's format */
|
||||
if (!screen->is_format_supported(screen, pt->format, PIPE_TEXTURE_2D,
|
||||
PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {
|
||||
|
@@ -340,6 +340,16 @@ util_is_inf_or_nan(float x)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test whether x is a power of two.
|
||||
*/
|
||||
static INLINE boolean
|
||||
util_is_pot(unsigned x)
|
||||
{
|
||||
return (x & (x - 1)) == 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Find first bit set in word. Least significant bit is 1.
|
||||
* Return 0 if no bits set.
|
||||
|
@@ -52,8 +52,7 @@ pass_user_buffer_create(struct pipe_screen *screen,
|
||||
unsigned bytes)
|
||||
{
|
||||
struct pipe_buffer *buffer =
|
||||
screen->winsys->user_buffer_create(screen->winsys,
|
||||
ptr, bytes);
|
||||
screen->winsys->user_buffer_create(screen->winsys, ptr, bytes);
|
||||
|
||||
buffer->screen = screen;
|
||||
|
||||
@@ -69,9 +68,8 @@ pass_surface_buffer_create(struct pipe_screen *screen,
|
||||
unsigned *stride)
|
||||
{
|
||||
struct pipe_buffer *buffer =
|
||||
screen->winsys->surface_buffer_create(screen->winsys,
|
||||
width, height,
|
||||
format, usage, tex_usage, stride);
|
||||
screen->winsys->surface_buffer_create(screen->winsys, width, height,
|
||||
format, usage, tex_usage, stride);
|
||||
|
||||
buffer->screen = screen;
|
||||
|
||||
@@ -83,8 +81,7 @@ pass_buffer_map(struct pipe_screen *screen,
|
||||
struct pipe_buffer *buf,
|
||||
unsigned usage)
|
||||
{
|
||||
return screen->winsys->buffer_map(screen->winsys,
|
||||
buf, usage);
|
||||
return screen->winsys->buffer_map(screen->winsys, buf, usage);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -106,8 +103,7 @@ pass_flush_frontbuffer(struct pipe_screen *screen,
|
||||
struct pipe_surface *surf,
|
||||
void *context_private)
|
||||
{
|
||||
screen->winsys->flush_frontbuffer(screen->winsys,
|
||||
surf, context_private);
|
||||
screen->winsys->flush_frontbuffer(screen->winsys, surf, context_private);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -115,8 +111,7 @@ pass_fence_reference(struct pipe_screen *screen,
|
||||
struct pipe_fence_handle **ptr,
|
||||
struct pipe_fence_handle *fence)
|
||||
{
|
||||
screen->winsys->fence_reference(screen->winsys,
|
||||
ptr, fence);
|
||||
screen->winsys->fence_reference(screen->winsys, ptr, fence);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -124,8 +119,7 @@ pass_fence_signalled(struct pipe_screen *screen,
|
||||
struct pipe_fence_handle *fence,
|
||||
unsigned flag)
|
||||
{
|
||||
return screen->winsys->fence_signalled(screen->winsys,
|
||||
fence, flag);
|
||||
return screen->winsys->fence_signalled(screen->winsys, fence, flag);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -133,11 +127,11 @@ pass_fence_finish(struct pipe_screen *screen,
|
||||
struct pipe_fence_handle *fence,
|
||||
unsigned flag)
|
||||
{
|
||||
return screen->winsys->fence_finish(screen->winsys,
|
||||
fence, flag);
|
||||
return screen->winsys->fence_finish(screen->winsys, fence, flag);
|
||||
}
|
||||
|
||||
void u_simple_screen_init(struct pipe_screen *screen)
|
||||
void
|
||||
u_simple_screen_init(struct pipe_screen *screen)
|
||||
{
|
||||
screen->buffer_create = pass_buffer_create;
|
||||
screen->user_buffer_create = pass_user_buffer_create;
|
||||
@@ -152,7 +146,8 @@ void u_simple_screen_init(struct pipe_screen *screen)
|
||||
screen->fence_finish = pass_fence_finish;
|
||||
}
|
||||
|
||||
const char* u_simple_screen_winsys_name(struct pipe_screen *screen)
|
||||
const char *
|
||||
u_simple_screen_winsys_name(struct pipe_screen *screen)
|
||||
{
|
||||
return screen->winsys->get_name(screen->winsys);
|
||||
}
|
||||
|
@@ -34,14 +34,8 @@
|
||||
|
||||
|
||||
#include "pipe/p_context.h"
|
||||
#include "util/u_debug.h"
|
||||
#include "pipe/p_defines.h"
|
||||
#include "pipe/p_screen.h"
|
||||
#include "pipe/p_shader_tokens.h"
|
||||
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_simple_shaders.h"
|
||||
|
||||
#include "tgsi/tgsi_ureg.h"
|
||||
|
||||
|
||||
|
@@ -170,7 +170,7 @@ x8r8g8b8_get_tile_rgba(const unsigned *src,
|
||||
pRow[0] = ubyte_to_float((pixel >> 16) & 0xff);
|
||||
pRow[1] = ubyte_to_float((pixel >> 8) & 0xff);
|
||||
pRow[2] = ubyte_to_float((pixel >> 0) & 0xff);
|
||||
pRow[3] = ubyte_to_float(0xff);
|
||||
pRow[3] = 1.0F;
|
||||
}
|
||||
p += dst_stride;
|
||||
}
|
||||
@@ -394,6 +394,52 @@ r5g6b5_put_tile_rgba(ushort *dst,
|
||||
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_R8G8B8_UNORM ***/
|
||||
|
||||
static void
|
||||
r8g8b8_get_tile_rgba(const ubyte *src,
|
||||
unsigned w, unsigned h,
|
||||
float *p,
|
||||
unsigned dst_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
pRow[0] = ubyte_to_float(src[0]);
|
||||
pRow[1] = ubyte_to_float(src[1]);
|
||||
pRow[2] = ubyte_to_float(src[2]);
|
||||
pRow[3] = 1.0f;
|
||||
src += 3;
|
||||
}
|
||||
p += dst_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
r8g8b8_put_tile_rgba(ubyte *dst,
|
||||
unsigned w, unsigned h,
|
||||
const float *p,
|
||||
unsigned src_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
const float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
dst[0] = float_to_ubyte(pRow[0]);
|
||||
dst[1] = float_to_ubyte(pRow[1]);
|
||||
dst[2] = float_to_ubyte(pRow[2]);
|
||||
dst += 3;
|
||||
}
|
||||
p += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_Z16_UNORM ***/
|
||||
|
||||
/**
|
||||
@@ -1106,6 +1152,9 @@ pipe_tile_raw_to_rgba(enum pipe_format format,
|
||||
case PIPE_FORMAT_R5G6B5_UNORM:
|
||||
r5g6b5_get_tile_rgba((ushort *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_R8G8B8_UNORM:
|
||||
r8g8b8_get_tile_rgba((ubyte *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_L8_UNORM:
|
||||
l8_get_tile_rgba((ubyte *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
@@ -1222,6 +1271,9 @@ pipe_put_tile_rgba(struct pipe_transfer *pt,
|
||||
case PIPE_FORMAT_R5G6B5_UNORM:
|
||||
r5g6b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_R8G8B8_UNORM:
|
||||
r8g8b8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_R8G8B8A8_UNORM:
|
||||
assert(0);
|
||||
break;
|
||||
|
@@ -674,7 +674,7 @@ emit_MAD(struct codegen *gen, const struct tgsi_full_instruction *inst)
|
||||
* Emit linear interpolate. See emit_ADD for comments.
|
||||
*/
|
||||
static boolean
|
||||
emit_LRP(struct codegen *gen, const struct tgsi_full_instruction *inst)
|
||||
emit_LERP(struct codegen *gen, const struct tgsi_full_instruction *inst)
|
||||
{
|
||||
int ch, s1_reg[4], s2_reg[4], s3_reg[4], d_reg[4], tmp_reg[4];
|
||||
|
||||
@@ -1766,7 +1766,7 @@ emit_instruction(struct codegen *gen,
|
||||
return emit_binop(gen, inst);
|
||||
case TGSI_OPCODE_MAD:
|
||||
return emit_MAD(gen, inst);
|
||||
case TGSI_OPCODE_LRP:
|
||||
case TGSI_OPCODE_LERP:
|
||||
return emit_LRP(gen, inst);
|
||||
case TGSI_OPCODE_DP3:
|
||||
return emit_DP3(gen, inst);
|
||||
|
@@ -44,6 +44,7 @@
|
||||
#include "pipe/p_inlines.h"
|
||||
#include "util/u_math.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_fifo.h"
|
||||
|
||||
#include "i915_context.h"
|
||||
#include "i915_reg.h"
|
||||
@@ -76,8 +77,13 @@ struct i915_vbuf_render {
|
||||
size_t vbo_size;
|
||||
size_t vbo_offset;
|
||||
void *vbo_ptr;
|
||||
size_t vbo_alloc_size;
|
||||
size_t vbo_max_used;
|
||||
|
||||
/* stuff for the pool */
|
||||
struct util_fifo *pool_fifo;
|
||||
unsigned pool_used;
|
||||
unsigned pool_buffer_size;
|
||||
boolean pool_not_used;
|
||||
};
|
||||
|
||||
|
||||
@@ -105,6 +111,55 @@ i915_vbuf_render_get_vertex_info(struct vbuf_render *render)
|
||||
return &i915->current.vertex_info;
|
||||
}
|
||||
|
||||
static boolean
|
||||
i915_vbuf_render_reserve(struct i915_vbuf_render *i915_render, size_t size)
|
||||
{
|
||||
struct i915_context *i915 = i915_render->i915;
|
||||
|
||||
if (i915_render->vbo_size < size + i915_render->vbo_offset)
|
||||
return FALSE;
|
||||
|
||||
if (i915->vbo_flushed)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
i915_vbuf_render_new_buf(struct i915_vbuf_render *i915_render, size_t size)
|
||||
{
|
||||
struct i915_context *i915 = i915_render->i915;
|
||||
struct intel_winsys *iws = i915->iws;
|
||||
|
||||
if (i915_render->vbo) {
|
||||
if (i915_render->pool_not_used)
|
||||
iws->buffer_destroy(iws, i915_render->vbo);
|
||||
else
|
||||
u_fifo_add(i915_render->pool_fifo, i915_render->vbo);
|
||||
i915_render->vbo = NULL;
|
||||
}
|
||||
|
||||
i915->vbo_flushed = 0;
|
||||
|
||||
i915_render->vbo_size = MAX2(size, i915_render->pool_buffer_size);
|
||||
i915_render->vbo_offset = 0;
|
||||
|
||||
if (i915_render->vbo_size != i915_render->pool_buffer_size) {
|
||||
i915_render->pool_not_used = TRUE;
|
||||
i915_render->vbo = iws->buffer_create(iws, i915_render->vbo_size, 64,
|
||||
INTEL_NEW_VERTEX);
|
||||
} else {
|
||||
i915_render->pool_not_used = FALSE;
|
||||
|
||||
if (i915_render->pool_used >= 2) {
|
||||
FLUSH_BATCH(NULL);
|
||||
i915->vbo_flushed = 0;
|
||||
i915_render->pool_used = 0;
|
||||
}
|
||||
u_fifo_pop(i915_render->pool_fifo, (void**)&i915_render->vbo);
|
||||
}
|
||||
}
|
||||
|
||||
static boolean
|
||||
i915_vbuf_render_allocate_vertices(struct vbuf_render *render,
|
||||
ushort vertex_size,
|
||||
@@ -112,27 +167,17 @@ i915_vbuf_render_allocate_vertices(struct vbuf_render *render,
|
||||
{
|
||||
struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
|
||||
struct i915_context *i915 = i915_render->i915;
|
||||
struct intel_winsys *iws = i915->iws;
|
||||
size_t size = (size_t)vertex_size * (size_t)nr_vertices;
|
||||
|
||||
/* FIXME: handle failure */
|
||||
assert(!i915->vbo);
|
||||
|
||||
if (i915_render->vbo_size > size + i915_render->vbo_offset && !i915->vbo_flushed) {
|
||||
} else {
|
||||
i915->vbo_flushed = 0;
|
||||
if (i915_render->vbo) {
|
||||
iws->buffer_destroy(iws, i915_render->vbo);
|
||||
i915_render->vbo = NULL;
|
||||
}
|
||||
}
|
||||
if (!i915_vbuf_render_reserve(i915_render, size)) {
|
||||
|
||||
if (!i915_render->vbo) {
|
||||
i915_render->vbo_size = MAX2(size, i915_render->vbo_alloc_size);
|
||||
i915_render->vbo_offset = 0;
|
||||
i915_render->vbo = iws->buffer_create(iws, i915_render->vbo_size, 64,
|
||||
INTEL_NEW_VERTEX);
|
||||
if (i915->vbo_flushed)
|
||||
i915_render->pool_used = 0;
|
||||
|
||||
i915_vbuf_render_new_buf(i915_render, size);
|
||||
}
|
||||
|
||||
i915_render->vertex_size = vertex_size;
|
||||
@@ -504,6 +549,7 @@ i915_vbuf_render_create(struct i915_context *i915)
|
||||
{
|
||||
struct i915_vbuf_render *i915_render = CALLOC_STRUCT(i915_vbuf_render);
|
||||
struct intel_winsys *iws = i915->iws;
|
||||
int i;
|
||||
|
||||
i915_render->i915 = i915;
|
||||
|
||||
@@ -524,14 +570,24 @@ i915_vbuf_render_create(struct i915_context *i915)
|
||||
i915_render->base.release_vertices = i915_vbuf_render_release_vertices;
|
||||
i915_render->base.destroy = i915_vbuf_render_destroy;
|
||||
|
||||
i915_render->vbo_alloc_size = 128 * 4096;
|
||||
i915_render->vbo_size = i915_render->vbo_alloc_size;
|
||||
|
||||
i915_render->vbo = NULL;
|
||||
i915_render->vbo_size = 0;
|
||||
i915_render->vbo_offset = 0;
|
||||
i915_render->vbo = iws->buffer_create(iws, i915_render->vbo_size, 64,
|
||||
INTEL_NEW_VERTEX);
|
||||
|
||||
i915_render->pool_used = FALSE;
|
||||
i915_render->pool_buffer_size = 128 * 4096;
|
||||
i915_render->pool_fifo = u_fifo_create(6);
|
||||
for (i = 0; i < 6; i++)
|
||||
u_fifo_add(i915_render->pool_fifo,
|
||||
iws->buffer_create(iws, i915_render->pool_buffer_size, 64,
|
||||
INTEL_NEW_VERTEX));
|
||||
|
||||
#if 0
|
||||
/* TODO JB: is this realy needed? */
|
||||
i915_render->vbo_ptr = iws->buffer_map(iws, i915_render->vbo, TRUE);
|
||||
iws->buffer_unmap(iws, i915_render->vbo);
|
||||
#endif
|
||||
|
||||
return &i915_render->base;
|
||||
}
|
||||
|
@@ -150,6 +150,17 @@ struct intel_winsys {
|
||||
void (*buffer_unmap)(struct intel_winsys *iws,
|
||||
struct intel_buffer *buffer);
|
||||
|
||||
/**
|
||||
* Write to a buffer.
|
||||
*
|
||||
* Arguments follows pwrite(2)
|
||||
*/
|
||||
int (*buffer_write)(struct intel_winsys *iws,
|
||||
struct intel_buffer *dst,
|
||||
const void *src,
|
||||
size_t size,
|
||||
size_t offset);
|
||||
|
||||
void (*buffer_destroy)(struct intel_winsys *iws,
|
||||
struct intel_buffer *buffer);
|
||||
/*@}*/
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user