aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--X11/extensions/randrproto.txt14
-rw-r--r--X11/xtrans/Xtrans.c111
-rw-r--r--X11/xtrans/Xtrans.h4
-rw-r--r--X11/xtrans/Xtransint.h1
-rw-r--r--fontconfig/configure.ac6
-rw-r--r--libxcb/src/c_client.py28
-rw-r--r--libxcb/xcb-proto/src/xcb.xsd3
-rw-r--r--libxcb/xcb-proto/src/xkb.xml60
-rw-r--r--libxcb/xcb-proto/xcbgen/state.py1
-rw-r--r--libxcb/xcb-proto/xcbgen/xtypes.py16
-rw-r--r--mesalib/configure.ac2
-rw-r--r--mesalib/docs/GL3.txt4
-rw-r--r--mesalib/docs/README.CYGWIN256
-rw-r--r--mesalib/docs/README.MITS102
-rw-r--r--mesalib/docs/README.QUAKE207
-rw-r--r--mesalib/docs/README.THREADS52
-rw-r--r--mesalib/docs/license.html3
-rw-r--r--mesalib/docs/relnotes/10.1.html2
-rw-r--r--mesalib/include/GLES2/gl2.h581
-rw-r--r--mesalib/include/GLES2/gl2ext.h2607
-rw-r--r--mesalib/include/GLES3/gl3.h1922
-rw-r--r--mesalib/include/c11/threads.h79
-rw-r--r--mesalib/include/c11/threads_posix.h373
-rw-r--r--mesalib/include/c11/threads_win32.h609
-rw-r--r--mesalib/src/gallium/auxiliary/hud/hud_context.c2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format.h3
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_upload_mgr.c16
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_upload_mgr.h10
-rw-r--r--mesalib/src/glsl/Makefile.sources1
-rw-r--r--mesalib/src/glsl/ast.h102
-rw-r--r--mesalib/src/glsl/ast_array_index.cpp13
-rw-r--r--mesalib/src/glsl/ast_function.cpp8
-rw-r--r--mesalib/src/glsl/ast_to_hir.cpp231
-rw-r--r--mesalib/src/glsl/ast_type.cpp10
-rw-r--r--mesalib/src/glsl/builtin_functions.cpp137
-rw-r--r--mesalib/src/glsl/builtin_variables.cpp2
-rw-r--r--mesalib/src/glsl/glcpp/glcpp-parse.y301
-rw-r--r--mesalib/src/glsl/glcpp/glcpp.c1
-rw-r--r--mesalib/src/glsl/glcpp/glcpp.h7
-rw-r--r--mesalib/src/glsl/glcpp/pp.c4
-rw-r--r--mesalib/src/glsl/glsl_parser.yy173
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.cpp173
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.h4
-rw-r--r--mesalib/src/glsl/glsl_types.cpp83
-rw-r--r--mesalib/src/glsl/glsl_types.h7
-rw-r--r--mesalib/src/glsl/ir.h14
-rw-r--r--mesalib/src/glsl/ir_equals.cpp60
-rw-r--r--mesalib/src/glsl/ir_optimization.h1
-rw-r--r--mesalib/src/glsl/link_atomics.cpp3
-rw-r--r--mesalib/src/glsl/linker.cpp120
-rw-r--r--mesalib/src/glsl/opt_algebraic.cpp52
-rw-r--r--mesalib/src/glsl/opt_vectorize.cpp319
-rw-r--r--mesalib/src/glsl/standalone_scaffolding.cpp1
-rw-r--r--mesalib/src/mapi/glapi/gen/ARB_viewport_array.xml79
-rw-r--r--mesalib/src/mapi/glapi/gen/Makefile.am1
-rw-r--r--mesalib/src/mapi/glapi/gen/gl_API.xml2
-rw-r--r--mesalib/src/mapi/u_thread.h165
-rw-r--r--mesalib/src/mesa/drivers/common/driverfuncs.c2
-rw-r--r--mesalib/src/mesa/drivers/common/meta.c90
-rw-r--r--mesalib/src/mesa/drivers/dri/common/xmlpool/.gitignore1
-rw-r--r--mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am2
-rw-r--r--mesalib/src/mesa/drivers/dri/common/xmlpool/ca.po321
-rw-r--r--mesalib/src/mesa/drivers/dri/common/xmlpool/de.po235
-rw-r--r--mesalib/src/mesa/drivers/dri/common/xmlpool/es.po234
-rw-r--r--mesalib/src/mesa/drivers/dri/common/xmlpool/fr.po199
-rw-r--r--mesalib/src/mesa/drivers/dri/common/xmlpool/nl.po197
-rw-r--r--mesalib/src/mesa/drivers/dri/common/xmlpool/sv.po216
-rw-r--r--mesalib/src/mesa/main/api_validate.c10
-rw-r--r--mesalib/src/mesa/main/attrib.c40
-rw-r--r--mesalib/src/mesa/main/config.h5
-rw-r--r--mesalib/src/mesa/main/context.c72
-rw-r--r--mesalib/src/mesa/main/dlist.c1
-rw-r--r--mesalib/src/mesa/main/enable.c36
-rw-r--r--mesalib/src/mesa/main/extensions.c2
-rw-r--r--mesalib/src/mesa/main/fbobject.c2
-rw-r--r--mesalib/src/mesa/main/ff_fragment_shader.cpp8
-rw-r--r--mesalib/src/mesa/main/ffvertex_prog.c2
-rw-r--r--mesalib/src/mesa/main/formats.c12
-rw-r--r--mesalib/src/mesa/main/framebuffer.c86
-rw-r--r--mesalib/src/mesa/main/framebuffer.h5
-rw-r--r--mesalib/src/mesa/main/get.c229
-rw-r--r--mesalib/src/mesa/main/get.h6
-rw-r--r--mesalib/src/mesa/main/get_hash_params.py13
-rw-r--r--mesalib/src/mesa/main/glformats.c130
-rw-r--r--mesalib/src/mesa/main/macros.h2
-rw-r--r--mesalib/src/mesa/main/mtypes.h46
-rw-r--r--mesalib/src/mesa/main/rastpos.c5
-rw-r--r--mesalib/src/mesa/main/scissor.c161
-rw-r--r--mesalib/src/mesa/main/scissor.h10
-rw-r--r--mesalib/src/mesa/main/shaderapi.c62
-rw-r--r--mesalib/src/mesa/main/shaderapi.h3
-rw-r--r--mesalib/src/mesa/main/shaderobj.c4
-rw-r--r--mesalib/src/mesa/main/shared.c4
-rw-r--r--mesalib/src/mesa/main/state.c24
-rw-r--r--mesalib/src/mesa/main/texobj.c8
-rw-r--r--mesalib/src/mesa/main/texstate.c75
-rw-r--r--mesalib/src/mesa/main/texstorage.c40
-rw-r--r--mesalib/src/mesa/main/transformfeedback.c51
-rw-r--r--mesalib/src/mesa/main/viewport.c347
-rw-r--r--mesalib/src/mesa/main/viewport.h21
-rw-r--r--mesalib/src/mesa/math/m_matrix.c13
-rw-r--r--mesalib/src/mesa/math/m_matrix.h4
-rw-r--r--mesalib/src/mesa/program/ir_to_mesa.cpp2
-rw-r--r--mesalib/src/mesa/program/prog_print.c10
-rw-r--r--mesalib/src/mesa/program/prog_statevars.c6
-rw-r--r--mesalib/src/mesa/program/program.c5
-rw-r--r--mesalib/src/mesa/program/program.h22
-rw-r--r--mesalib/src/mesa/program/programopt.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_clip.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_constbuf.c9
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_rasterizer.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_scissor.c14
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_viewport.c12
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_bitmap.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_clear.c10
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_drawpixels.c4
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_fbo.c9
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_draw.c6
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp2
-rw-r--r--mesalib/src/mesa/state_tracker/st_program.c6
-rw-r--r--mesalib/src/mesa/swrast/s_context.c10
-rw-r--r--mesalib/src/mesa/swrast/s_depth.c10
-rw-r--r--mesalib/src/mesa/swrast/s_fragprog.c2
-rw-r--r--mesalib/src/mesa/swrast_setup/ss_context.c4
-rw-r--r--mesalib/src/mesa/tnl/t_rasterpos.c16
-rw-r--r--mesalib/src/mesa/x86/read_rgba_span_x86.h56
-rw-r--r--xorg-server/Makefile.am2
-rw-r--r--xorg-server/Xi/exevents.c19
-rw-r--r--xorg-server/Xi/grabdev.c2
-rw-r--r--xorg-server/composite/compwindow.c1
-rw-r--r--xorg-server/configure.ac40
-rw-r--r--xorg-server/dix/dispatch.c6
-rw-r--r--xorg-server/dix/events.c6
-rw-r--r--xorg-server/dix/grabs.c11
-rw-r--r--xorg-server/exa/exa_accel.c1
-rw-r--r--xorg-server/exa/exa_render.c6
-rw-r--r--xorg-server/glamor/Makefile.am71
-rw-r--r--xorg-server/glamor/compat-api.h107
-rw-r--r--xorg-server/glamor/compiler.h59
-rw-r--r--xorg-server/glamor/glamor.c628
-rw-r--r--xorg-server/glamor/glamor.h432
-rw-r--r--xorg-server/glamor/glamor_addtraps.c65
-rw-r--r--xorg-server/glamor/glamor_compositerects.c278
-rw-r--r--xorg-server/glamor/glamor_copyarea.c676
-rw-r--r--xorg-server/glamor/glamor_copyplane.c72
-rw-r--r--xorg-server/glamor/glamor_copywindow.c58
-rw-r--r--xorg-server/glamor/glamor_core.c612
-rw-r--r--xorg-server/glamor/glamor_debug.h116
-rw-r--r--xorg-server/glamor/glamor_egl.c860
-rw-r--r--xorg-server/glamor/glamor_eglmodule.c52
-rw-r--r--xorg-server/glamor/glamor_fbo.c590
-rw-r--r--xorg-server/glamor/glamor_fill.c364
-rw-r--r--xorg-server/glamor/glamor_fillspans.c113
-rw-r--r--xorg-server/glamor/glamor_getimage.c101
-rw-r--r--xorg-server/glamor/glamor_getspans.c95
-rw-r--r--xorg-server/glamor/glamor_gl_dispatch.c118
-rw-r--r--xorg-server/glamor/glamor_gl_dispatch.h138
-rw-r--r--xorg-server/glamor/glamor_glext.h64
-rw-r--r--xorg-server/glamor/glamor_glyphblt.c118
-rw-r--r--xorg-server/glamor/glamor_glyphs.c1806
-rw-r--r--xorg-server/glamor/glamor_gradient.c1584
-rw-r--r--xorg-server/glamor/glamor_largepixmap.c1324
-rw-r--r--xorg-server/glamor/glamor_picture.c131
-rw-r--r--xorg-server/glamor/glamor_pixmap.c1433
-rw-r--r--xorg-server/glamor/glamor_polyfillrect.c127
-rw-r--r--xorg-server/glamor/glamor_polylines.c135
-rw-r--r--xorg-server/glamor/glamor_polyops.c85
-rw-r--r--xorg-server/glamor/glamor_priv.h1047
-rw-r--r--xorg-server/glamor/glamor_putimage.c363
-rw-r--r--xorg-server/glamor/glamor_render.c2135
-rw-r--r--xorg-server/glamor/glamor_setspans.c111
-rw-r--r--xorg-server/glamor/glamor_tile.c325
-rw-r--r--xorg-server/glamor/glamor_trapezoid.c1819
-rw-r--r--xorg-server/glamor/glamor_triangles.c80
-rw-r--r--xorg-server/glamor/glamor_utils.h1835
-rw-r--r--xorg-server/glamor/glamor_window.c103
-rw-r--r--xorg-server/glamor/glamor_xv.c645
-rw-r--r--xorg-server/glamor/glapi.h121
-rw-r--r--xorg-server/glx/glxdri2.c59
-rw-r--r--xorg-server/glx/glxdriswrast.c25
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyr.c27
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrdriext.c1
-rw-r--r--xorg-server/hw/kdrive/src/kinput.c4
-rw-r--r--xorg-server/hw/kdrive/src/kxv.c4
-rw-r--r--xorg-server/hw/vfb/InitOutput.c18
-rw-r--r--xorg-server/hw/xfree86/common/xf86Config.c4
-rw-r--r--xorg-server/hw/xfree86/common/xf86Configure.c47
-rw-r--r--xorg-server/hw/xfree86/common/xf86Helper.c1
-rw-r--r--xorg-server/hw/xfree86/common/xf86Init.c4
-rw-r--r--xorg-server/hw/xfree86/common/xf86fbman.c3
-rw-r--r--xorg-server/hw/xfree86/ddc/interpret_edid.c137
-rw-r--r--xorg-server/hw/xfree86/ddc/xf86DDC.h2
-rw-r--r--xorg-server/hw/xfree86/dri/dri.c12
-rw-r--r--xorg-server/hw/xfree86/modes/xf86Crtc.c41
-rw-r--r--xorg-server/hw/xfree86/modes/xf86EdidModes.c4
-rw-r--r--xorg-server/hw/xfree86/modes/xf86RandR12.c1
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/lnx_init.c1
-rw-r--r--xorg-server/hw/xfree86/parser/Configint.h2
-rw-r--r--xorg-server/hw/xfree86/parser/DRI.c13
-rw-r--r--xorg-server/hw/xfree86/parser/Device.c45
-rw-r--r--xorg-server/hw/xfree86/parser/Extensions.c3
-rw-r--r--xorg-server/hw/xfree86/parser/Files.c15
-rw-r--r--xorg-server/hw/xfree86/parser/Flags.c15
-rw-r--r--xorg-server/hw/xfree86/parser/Input.c11
-rw-r--r--xorg-server/hw/xfree86/parser/InputClass.c71
-rw-r--r--xorg-server/hw/xfree86/parser/Layout.c33
-rw-r--r--xorg-server/hw/xfree86/parser/Module.c15
-rw-r--r--xorg-server/hw/xfree86/parser/Monitor.c87
-rw-r--r--xorg-server/hw/xfree86/parser/Pointer.c35
-rw-r--r--xorg-server/hw/xfree86/parser/Screen.c63
-rw-r--r--xorg-server/hw/xfree86/parser/Vendor.c9
-rw-r--r--xorg-server/hw/xfree86/parser/Video.c17
-rw-r--r--xorg-server/hw/xfree86/parser/read.c103
-rw-r--r--xorg-server/hw/xfree86/parser/scan.c24
-rw-r--r--xorg-server/hw/xfree86/x86emu/ops.c168
-rw-r--r--xorg-server/hw/xnest/Events.c6
-rw-r--r--xorg-server/hw/xnest/GCOps.c4
-rw-r--r--xorg-server/hw/xnest/Init.c22
-rw-r--r--xorg-server/hw/xnest/Window.c2
-rw-r--r--xorg-server/hw/xquartz/GL/indirect.c4
-rw-r--r--xorg-server/hw/xquartz/X11Application.m13
-rw-r--r--xorg-server/hw/xquartz/X11Controller.m2
-rw-r--r--xorg-server/hw/xquartz/applewm.c16
-rw-r--r--xorg-server/hw/xquartz/darwinfb.h2
-rw-r--r--xorg-server/hw/xquartz/mach-startup/stub.c4
-rw-r--r--xorg-server/hw/xquartz/quartz.c3
-rw-r--r--xorg-server/hw/xquartz/xpr/appledri.c10
-rw-r--r--xorg-server/hw/xquartz/xpr/x-hook.c27
-rw-r--r--xorg-server/include/dix-config.h.in3
-rw-r--r--xorg-server/include/dixfontstubs.h2
-rw-r--r--xorg-server/include/dixstruct.h1
-rw-r--r--xorg-server/include/xorg-server.h.in3
-rw-r--r--xorg-server/m4/xorg-tls.m44
-rw-r--r--xorg-server/os/io.c11
-rw-r--r--xorg-server/os/log.c2
-rw-r--r--xorg-server/os/utils.c27
-rw-r--r--xorg-server/os/xdmauth.c18
-rw-r--r--xorg-server/os/xdmcp.c28
-rw-r--r--xorg-server/randr/rrcrtc.c17
-rw-r--r--xorg-server/test/hashtabletest.c6
-rw-r--r--xorg-server/test/signal-logging.c7
-rw-r--r--xorg-server/test/xi2/protocol-common.c66
-rw-r--r--xorg-server/test/xi2/protocol-common.h2
-rw-r--r--xorg-server/test/xi2/protocol-xipassivegrabdevice.c8
-rw-r--r--xorg-server/test/xi2/protocol-xiquerydevice.c2
-rw-r--r--xorg-server/test/xi2/protocol-xiqueryversion.c4
247 files changed, 28786 insertions, 6163 deletions
diff --git a/X11/extensions/randrproto.txt b/X11/extensions/randrproto.txt
index 2123e7eda..864268e5d 100644
--- a/X11/extensions/randrproto.txt
+++ b/X11/extensions/randrproto.txt
@@ -406,19 +406,19 @@ The name of this extension is "RANDR".
New for version 1.2:
- If 'enable' contains RRCrtcChangeMask, RRCrtcChangeNotify events
- will be sent when a the configuration for a CRTC associated with the
+ If 'enable' contains RRCrtcChangeNotifyMask, RRCrtcChangeNotify events
+ will be sent when the configuration for a CRTC associated with the
screen changes, either through this protocol extension or due to
detected external changes. RRCrtcChangeNotify may also be sent when
this request executes if the CRTC configuration has changed since
the client connected, to avoid race conditions.
- If 'enable' contains RROutputChangeMask, RROutputChangeNotify events
- will be sent when a the configuration for an output associated with
+ If 'enable' contains RROutputChangeNotifyMask, RROutputChangeNotify
+ events will be sent when the configuration for an output associated with
the screen changes, either through this protocol extension or due to
- detected external changes. RROutputChangeNotify may also be sent
- when this request executes if the output configuration has changed
- since the client connected, to avoid race conditions.
+ detected external changes. RROutputChangeNotify may also be sent when
+ this request executes if the output configuration has changed since the
+ client connected, to avoid race conditions.
If 'enable' contains RROutputPropertyNotifyMask,
RROutputPropertyNotify events will be sent when properties change on
diff --git a/X11/xtrans/Xtrans.c b/X11/xtrans/Xtrans.c
index 735d7b87f..225f4c88c 100644
--- a/X11/xtrans/Xtrans.c
+++ b/X11/xtrans/Xtrans.c
@@ -48,6 +48,10 @@ from The Open Group.
*/
#include <ctype.h>
+#ifdef HAVE_SYSTEMD_DAEMON
+#include <string.h>
+#include <systemd/sd-daemon.h>
+#endif
/*
* The transport table contains a definition for every transport (protocol)
@@ -744,6 +748,34 @@ TRANS(CreateListener) (XtransConnInfo ciptr, char *port, unsigned int flags)
}
int
+TRANS(Received) (const char * protocol)
+
+{
+ Xtransport *trans;
+ int i = 0, ret = 0;
+
+ prmsg (5, "Received(%s)\n", protocol);
+
+ if ((trans = TRANS(SelectTransport)(protocol)) == NULL)
+ {
+ prmsg (1,"Received: unable to find transport: %s\n",
+ protocol);
+
+ return -1;
+ }
+ if (trans->flags & TRANS_ALIAS) {
+ if (trans->nolisten)
+ while (trans->nolisten[i]) {
+ ret |= TRANS(Received)(trans->nolisten[i]);
+ i++;
+ }
+ }
+
+ trans->flags |= TRANS_RECEIVED;
+ return ret;
+}
+
+int
TRANS(NoListen) (const char * protocol)
{
@@ -1023,6 +1055,79 @@ complete_network_count (void)
}
+static int
+receive_listening_fds(char* port, XtransConnInfo* temp_ciptrs, int* count_ret)
+
+{
+#ifdef HAVE_SYSTEMD_DAEMON
+ XtransConnInfo ciptr;
+ int i, systemd_listen_fds;
+
+ systemd_listen_fds = sd_listen_fds(1);
+ if (systemd_listen_fds < 0)
+ {
+ prmsg (1, "receive_listening_fds: sd_listen_fds error: %s\n",
+ strerror(-systemd_listen_fds));
+ return -1;
+ }
+
+ for (i = 0; i < systemd_listen_fds && *count_ret < NUMTRANS; i++)
+ {
+ struct sockaddr_storage a;
+ int ti;
+ const char* tn;
+ socklen_t al;
+
+ al = sizeof(a);
+ if (getsockname(i + SD_LISTEN_FDS_START, (struct sockaddr*)&a, &al) < 0) {
+ prmsg (1, "receive_listening_fds: getsockname error: %s\n",
+ strerror(errno));
+ return -1;
+ }
+
+ switch (a.ss_family)
+ {
+ case AF_UNIX:
+ ti = TRANS_SOCKET_UNIX_INDEX;
+ if (*((struct sockaddr_un*)&a)->sun_path == '\0' &&
+ al > sizeof(sa_family_t))
+ tn = "local";
+ else
+ tn = "unix";
+ break;
+ case AF_INET:
+ ti = TRANS_SOCKET_INET_INDEX;
+ tn = "inet";
+ break;
+#if defined(IPv6) && defined(AF_INET6)
+ case AF_INET6:
+ ti = TRANS_SOCKET_INET6_INDEX;
+ tn = "inet6";
+ break;
+#endif /* IPv6 */
+ default:
+ prmsg (1, "receive_listening_fds:"
+ "Got unknown socket address family\n");
+ return -1;
+ }
+
+ ciptr = TRANS(ReopenCOTSServer)(ti, i + SD_LISTEN_FDS_START, port);
+ if (!ciptr)
+ {
+ prmsg (1, "receive_listening_fds:"
+ "Got NULL while trying to reopen socket received from systemd.\n");
+ return -1;
+ }
+
+ prmsg (5, "receive_listening_fds: received listener for %s, %d\n",
+ tn, ciptr->fd);
+ temp_ciptrs[(*count_ret)++] = ciptr;
+ TRANS(Received)(tn);
+ }
+#endif /* HAVE_SYSTEMD_DAEMON */
+ return 0;
+}
+
#ifdef XQUARTZ_EXPORTS_LAUNCHD_FD
extern int xquartz_launchd_fd;
#endif
@@ -1055,12 +1160,16 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret,
}
#endif
+ if (receive_listening_fds(port, temp_ciptrs, count_ret) < 0)
+ return -1;
+
for (i = 0; i < NUMTRANS; i++)
{
Xtransport *trans = Xtransports[i].transport;
unsigned int flags = 0;
- if (trans->flags&TRANS_ALIAS || trans->flags&TRANS_NOLISTEN)
+ if (trans->flags&TRANS_ALIAS || trans->flags&TRANS_NOLISTEN ||
+ trans->flags&TRANS_RECEIVED)
continue;
snprintf(buffer, sizeof(buffer), "%s/:%s",
diff --git a/X11/xtrans/Xtrans.h b/X11/xtrans/Xtrans.h
index 69accd780..1754720c9 100644
--- a/X11/xtrans/Xtrans.h
+++ b/X11/xtrans/Xtrans.h
@@ -303,6 +303,10 @@ int TRANS(CreateListener)(
unsigned int /* flags */
);
+int TRANS(Received) (
+ const char* /* protocol*/
+);
+
int TRANS(NoListen) (
const char* /* protocol*/
);
diff --git a/X11/xtrans/Xtransint.h b/X11/xtrans/Xtransint.h
index ec5a77203..4c670b88a 100644
--- a/X11/xtrans/Xtransint.h
+++ b/X11/xtrans/Xtransint.h
@@ -331,6 +331,7 @@ typedef struct _Xtransport_table {
#define TRANS_NOUNLINK (1<<4) /* Don't unlink transport endpoints */
#define TRANS_ABSTRACT (1<<5) /* Use abstract sockets if available */
#define TRANS_NOXAUTH (1<<6) /* Don't verify authentication (because it's secure some other way at the OS layer) */
+#define TRANS_RECEIVED (1<<7) /* The fd for this has already been opened by someone else. */
/* Flags to preserve when setting others */
#define TRANS_KEEPFLAGS (TRANS_NOUNLINK|TRANS_ABSTRACT)
diff --git a/fontconfig/configure.ac b/fontconfig/configure.ac
index 728a55099..89fe117ca 100644
--- a/fontconfig/configure.ac
+++ b/fontconfig/configure.ac
@@ -37,6 +37,10 @@ AC_INIT([fontconfig], [2.11.0], [https://bugs.freedesktop.org/enter_bug.cgi?prod
AM_INIT_AUTOMAKE([1.11 parallel-tests dist-bzip2])
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
+dnl Initialize libtool
+LT_PREREQ([2.2])
+LT_INIT([disable-static win32-dll])
+
dnl libtool versioning
dnl bump revision when fixing bugs
@@ -67,8 +71,6 @@ AC_USE_SYSTEM_EXTENSIONS
AC_SYS_LARGEFILE
AC_PROG_INSTALL
AC_PROG_LN_S
-AC_LIBTOOL_WIN32_DLL
-AM_PROG_LIBTOOL
AC_PROG_MAKE_SET
PKG_PROG_PKG_CONFIG
m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], AC_SUBST([pkgconfigdir], ${libdir}/pkgconfig))
diff --git a/libxcb/src/c_client.py b/libxcb/src/c_client.py
index 45de54413..161cbf59d 100644
--- a/libxcb/src/c_client.py
+++ b/libxcb/src/c_client.py
@@ -981,15 +981,22 @@ def _c_serialize_helper_fields(context, self,
# fields with variable size
else:
- # switch/bitcase: always calculate padding before and after variable sized fields
- if need_padding or is_bitcase:
+ if field.type.is_pad:
+ # Variable length pad is <pad align= />
+ code_lines.append('%s xcb_align_to = %d;' % (space, field.type.align))
count += _c_serialize_helper_insert_padding(context, code_lines, space,
+ self.var_followed_by_fixed_fields)
+ continue
+ else:
+ # switch/bitcase: always calculate padding before and after variable sized fields
+ if need_padding or is_bitcase:
+ count += _c_serialize_helper_insert_padding(context, code_lines, space,
self.var_followed_by_fixed_fields)
- value, length = _c_serialize_helper_fields_variable_size(context, self, field,
- code_lines, temp_vars,
- space, prefix)
- prev_field_was_variable = True
+ value, length = _c_serialize_helper_fields_variable_size(context, self, field,
+ code_lines, temp_vars,
+ space, prefix)
+ prev_field_was_variable = True
# save (un)serialization C code
if '' != value:
@@ -1740,10 +1747,11 @@ def _c_accessors(self, name, base):
# else:
if True:
for field in self.fields:
- if field.type.is_list and not field.type.fixed_size():
- _c_accessors_list(self, field)
- elif field.prev_varsized_field is not None or not field.type.fixed_size():
- _c_accessors_field(self, field)
+ if not field.type.is_pad:
+ if field.type.is_list and not field.type.fixed_size():
+ _c_accessors_list(self, field)
+ elif field.prev_varsized_field is not None or not field.type.fixed_size():
+ _c_accessors_field(self, field)
def c_simple(self, name):
'''
diff --git a/libxcb/xcb-proto/src/xcb.xsd b/libxcb/xcb-proto/src/xcb.xsd
index 73dbf8a77..580d2588d 100644
--- a/libxcb/xcb-proto/src/xcb.xsd
+++ b/libxcb/xcb-proto/src/xcb.xsd
@@ -42,7 +42,8 @@ authorization from the authors.
<!-- Padding -->
<xsd:element name="pad">
<xsd:complexType>
- <xsd:attribute name="bytes" type="xsd:integer" use="required" />
+ <xsd:attribute name="bytes" type="xsd:integer" use="optional" />
+ <xsd:attribute name="align" type="xsd:integer" use="optional" />
</xsd:complexType>
</xsd:element>
diff --git a/libxcb/xcb-proto/src/xkb.xml b/libxcb/xcb-proto/src/xkb.xml
index 1df0771e1..9ef4402ec 100644
--- a/libxcb/xcb-proto/src/xkb.xml
+++ b/libxcb/xcb-proto/src/xkb.xml
@@ -1351,20 +1351,7 @@ authorization from the authors.
<list name="acts_rtrn_count" type="CARD8">
<fieldref>nKeyActions</fieldref>
</list>
- <list type="CARD8" name="alignment_pad">
- <op op="-">
- <op op="&amp;">
- <op op="+">
- <fieldref>nKeyActions</fieldref>
- <value>3</value>
- </op>
- <unop op="~">
- <value>3</value>
- </unop>
- </op>
- <fieldref>nKeyActions</fieldref>
- </op>
- </list>
+ <pad align="4" />
<list name="acts_rtrn_acts" type="Action">
<fieldref>totalActions</fieldref>
</list>
@@ -1380,60 +1367,21 @@ authorization from the authors.
<list name="vmods_rtrn" type="CARD8" mask="ModMask">
<popcount><fieldref>virtualMods</fieldref></popcount>
</list>
- <list type="CARD8" name="alignment_pad2">
- <op op="-">
- <op op="&amp;">
- <op op="+">
- <popcount><fieldref>virtualMods</fieldref></popcount>
- <value>3</value>
- </op>
- <unop op="~">
- <value>3</value>
- </unop>
- </op>
- <popcount><fieldref>virtualMods</fieldref></popcount>
- </op>
- </list>
+ <pad align="4" />
</bitcase>
<bitcase>
<enumref ref="MapPart">ExplicitComponents</enumref>
<list name="explicit_rtrn" type="SetExplicit">
<fieldref>totalKeyExplicit</fieldref>
</list>
- <list type="CARD16" name="alignment_pad3">
- <op op="-">
- <op op="&amp;">
- <op op="+">
- <fieldref>totalKeyExplicit</fieldref>
- <value>1</value>
- </op>
- <unop op="~">
- <value>1</value>
- </unop>
- </op>
- <fieldref>totalKeyExplicit</fieldref>
- </op>
- </list>
+ <pad align="4" />
</bitcase>
<bitcase>
<enumref ref="MapPart">ModifierMap</enumref>
<list name="modmap_rtrn" type="KeyModMap">
<fieldref>totalModMapKeys</fieldref>
</list>
- <list type="CARD16" name="alignment_pad4">
- <op op="-">
- <op op="&amp;">
- <op op="+">
- <fieldref>totalModMapKeys</fieldref>
- <value>1</value>
- </op>
- <unop op="~">
- <value>1</value>
- </unop>
- </op>
- <fieldref>totalModMapKeys</fieldref>
- </op>
- </list>
+ <pad align="4" />
</bitcase>
<bitcase>
<enumref ref="MapPart">VirtualModMap</enumref>
diff --git a/libxcb/xcb-proto/xcbgen/state.py b/libxcb/xcb-proto/xcbgen/state.py
index 10a8722ea..52b8d8da7 100644
--- a/libxcb/xcb-proto/xcbgen/state.py
+++ b/libxcb/xcb-proto/xcbgen/state.py
@@ -93,6 +93,7 @@ class Module(object):
# Recursively resolve all types
def resolve(self):
for (name, item) in self.all:
+ self.pads = 0
item.resolve(self)
# Call all the output methods
diff --git a/libxcb/xcb-proto/xcbgen/xtypes.py b/libxcb/xcb-proto/xcbgen/xtypes.py
index 5f45723ce..3cd90320e 100644
--- a/libxcb/xcb-proto/xcbgen/xtypes.py
+++ b/libxcb/xcb-proto/xcbgen/xtypes.py
@@ -267,13 +267,17 @@ class PadType(Type):
Type.__init__(self, tcard8.name)
self.is_pad = True
self.size = 1
- self.nmemb = 1 if (elt == None) else int(elt.get('bytes'), 0)
+ self.nmemb = 1
+ self.align = 1
+ if elt != None:
+ self.nmemb = int(elt.get('bytes', "1"), 0)
+ self.align = int(elt.get('align', "1"), 0)
def resolve(self, module):
self.resolved = True
def fixed_size(self):
- return True
+ return self.align <= 1
class ComplexType(Type):
@@ -296,16 +300,15 @@ class ComplexType(Type):
def resolve(self, module):
if self.resolved:
return
- pads = 0
enum = None
# Resolve all of our field datatypes.
for child in list(self.elt):
if child.tag == 'pad':
- field_name = 'pad' + str(pads)
+ field_name = 'pad' + str(module.pads)
fkey = 'CARD8'
type = PadType(child)
- pads = pads + 1
+ module.pads = module.pads + 1
visible = False
elif child.tag == 'field':
field_name = child.get('name')
@@ -397,7 +400,6 @@ class SwitchType(ComplexType):
def resolve(self, module):
if self.resolved:
return
-# pads = 0
parents = list(self.parents) + [self]
@@ -560,6 +562,8 @@ class Reply(ComplexType):
def resolve(self, module):
if self.resolved:
return
+ # Reset pads count
+ module.pads = 0
# Add the automatic protocol fields
self.fields.append(Field(tcard8, tcard8.name, 'response_type', False, True, True))
self.fields.append(_placeholder_byte)
diff --git a/mesalib/configure.ac b/mesalib/configure.ac
index d9e18968c..33ac92259 100644
--- a/mesalib/configure.ac
+++ b/mesalib/configure.ac
@@ -29,7 +29,7 @@ AC_SUBST([OSMESA_VERSION])
dnl Versions for external dependencies
LIBDRM_REQUIRED=2.4.24
LIBDRM_RADEON_REQUIRED=2.4.50
-LIBDRM_INTEL_REQUIRED=2.4.49
+LIBDRM_INTEL_REQUIRED=2.4.52
LIBDRM_NVVIEUX_REQUIRED=2.4.33
LIBDRM_NOUVEAU_REQUIRED="2.4.33 libdrm >= 2.4.41"
LIBDRM_FREEDRENO_REQUIRED=2.4.51
diff --git a/mesalib/docs/GL3.txt b/mesalib/docs/GL3.txt
index 0672ec708..799db4bc0 100644
--- a/mesalib/docs/GL3.txt
+++ b/mesalib/docs/GL3.txt
@@ -120,7 +120,7 @@ GL 4.1:
GL_ARB_separate_shader_objects some infrastructure done
GL_ARB_shader_precision not started
GL_ARB_vertex_attrib_64bit not started
- GL_ARB_viewport_array not started
+ GL_ARB_viewport_array DONE (i965)
GL 4.2:
@@ -142,7 +142,7 @@ GL 4.2:
GL 4.3:
GLSL 4.3 not started
- GL_ARB_arrays_of_arrays not started
+ GL_ARB_arrays_of_arrays started
GL_ARB_ES3_compatibility DONE (i965)
GL_ARB_clear_buffer_object not started
GL_ARB_compute_shader not started
diff --git a/mesalib/docs/README.CYGWIN b/mesalib/docs/README.CYGWIN
deleted file mode 100644
index 58d5af3e2..000000000
--- a/mesalib/docs/README.CYGWIN
+++ /dev/null
@@ -1,256 +0,0 @@
-
- Mesa Cygwin/X11 Information
-
-
-WARNING
-=======
-
-If you installed X11 (packages xorg-x11-devel and xorg-x11-bin-dlls ) with the
-latest setup.exe from Cygwin the GL (Mesa) libraries and include are already
-installed in /usr/X11R6.
-
-The following will explain how to "replace" them.
-
-Installation
-============
-
-How to compile Mesa on Cygwin/X11 systems:
-
-1. Shared libs:
- type 'make cygwin-sl'.
-
- When finished, the Mesa DLL will be in the Mesa-x.y/lib/ and
- Mesa-x.y/bin directories.
-
-
-2. Static libs:
- type 'make cygwin-static'.
- When finished, the Mesa libraries will be in the Mesa-x.y/lib/ directory.
-
-Header and library files:
- After you've compiled Mesa and tried the demos I recommend the following
- procedure for "installing" Mesa.
-
- Copy the Mesa include/GL directory to /usr/X11R6/include:
- cp -a include/GL /usr/X11R6/include
-
- Copy the Mesa library files to /usr/X11R6/lib:
- cp -a lib/* /usr/X11R6ocal/lib
-
- Copy the Mesa bin files (used by the DLL stuff) to /usr/X11R6/bin:
- cp -a lib/cyg* /usr/X11R6/bin
-
-Xt/Motif widgets:
- If you want to use Mesa or OpenGL in your Xt/Motif program you can build
- the widgets found in either the widgets-mesa or widgets-sgi directories.
- The former were written for Mesa and the later are the original SGI
- widgets. Look in those directories for more information.
- For the Motif widgets you must have downloaded the lesstif package.
-
-
-Using the library
-=================
-
-Configuration options:
- The file src/mesa/main/config.h has many parameters which you can adjust
- such as maximum number of lights, clipping planes, maximum texture size,
- etc. In particular, you may want to change DEPTH_BITS from 16 to 32
- if a 16-bit depth buffer isn't precise enough for your application.
-
-
-Shared libraries:
- If you compile shared libraries (Win32 DLLS) you may have to set an
- environment variable to specify where the Mesa libraries are located.
- Set the PATH variable to include /your-dir/Mesa-2.6/bin.
- Otherwise, when you try to run a demo it may fail with a message saying
- that one or more DLL couldn't be found.
-
-
-Xt/Motif Widgets:
- Two versions of the Xt/Motif OpenGL drawing area widgets are included:
-
- widgets-sgi/ SGI's stock widgets
- widgets-mesa/ Mesa-tuned widgets
-
- Look in those directories for details
-
-
-Togl:
- Togl is an OpenGL/Mesa widget for Tcl/Tk.
- See http://togl.sourceforge.net for more information.
-
-
-
-X Display Modes:
- Mesa supports RGB(A) rendering into almost any X visual type and depth.
-
- The glXChooseVisual function tries its best to pick an appropriate visual
- for the given attribute list. However, if this doesn't suit your needs
- you can force Mesa to use any X visual you want (any supported by your
- X server that is) by setting the MESA_RGB_VISUAL and MESA_CI_VISUAL
- environment variables. When an RGB visual is requested, glXChooseVisual
- will first look if the MESA_RGB_VISUAL variable is defined. If so, it
- will try to use the specified visual. Similarly, when a color index
- visual is requested, glXChooseVisual will look for the MESA_CI_VISUAL
- variable.
-
- The format of accepted values is: <visual-class> <depth>
- Here are some examples:
-
- using the C-shell:
- % setenv MESA_RGB_VISUAL "TrueColor 8" // 8-bit TrueColor
- % setenv MESA_CI_VISUAL "PseudoColor 12" // 12-bit PseudoColor
- % setenv MESA_RGB_VISUAL "PseudoColor 8" // 8-bit PseudoColor
-
- using the KornShell:
- $ export MESA_RGB_VISUAL="TrueColor 8"
- $ export MESA_CI_VISUAL="PseudoColor 12"
- $ export MESA_RGB_VISUAL="PseudoColor 8"
-
-
-Double buffering:
- Mesa can use either an X Pixmap or XImage as the backbuffer when in
- double buffer mode. Using GLX, the default is to use an XImage. The
- MESA_BACK_BUFFER environment variable can override this. The valid
- values for MESA_BACK_BUFFER are: Pixmap and XImage (only the first
- letter is checked, case doesn't matter).
-
- A pixmap is faster when drawing simple lines and polygons while an
- XImage is faster when Mesa has to do pixel-by-pixel rendering. If you
- need depth buffering the XImage will almost surely be faster. Exper-
- iment with the MESA_BACK_BUFFER variable to see which is faster for
- your application.
-
-
-Colormaps:
- When using Mesa directly or with GLX, it's up to the application writer
- to create a window with an appropriate colormap. The aux, tk, and GLUT
- toolkits try to minimize colormap "flashing" by sharing colormaps when
- possible. Specifically, if the visual and depth of the window matches
- that of the root window, the root window's colormap will be shared by
- the Mesa window. Otherwise, a new, private colormap will be allocated.
-
- When sharing the root colormap, Mesa may be unable to allocate the colors
- it needs, resulting in poor color quality. This can happen when a
- large number of colorcells in the root colormap are already allocated.
- To prevent colormap sharing in aux, tk and GLUT, define the environment
- variable MESA_PRIVATE_CMAP. The value isn't significant.
-
-
-Gamma correction:
- To compensate for the nonlinear relationship between pixel values
- and displayed intensities, there is a gamma correction feature in
- Mesa. Some systems, such as Silicon Graphics, support gamma
- correction in hardware (man gamma) so you won't need to use Mesa's
- gamma facility. Other systems, however, may need gamma adjustment
- to produce images which look correct. If in the past you thought
- Mesa's images were too dim, read on.
-
- Gamma correction is controlled with the MESA_GAMMA environment
- variable. Its value is of the form "Gr Gg Gb" or just "G" where
- Gr is the red gamma value, Gg is the green gamma value, Gb is the
- blue gamma value and G is one gamma value to use for all three
- channels. Each value is a positive real number typically in the
- range 1.0 to 2.5. The defaults are all 1.0, effectively disabling
- gamma correction. Examples using csh:
-
- % setenv MESA_GAMMA "2.3 2.2 2.4" // separate R,G,B values
- % setenv MESA_GAMMA "2.0" // same gamma for R,G,B
-
- The demos/gamma.c program may help you to determine reasonable gamma
- value for your display. With correct gamma values, the color intensities
- displayed in the top row (drawn by dithering) should nearly match those
- in the bottom row (drawn as grays).
-
- Alex De Bruyn reports that gamma values of 1.6, 1.6 and 1.9 work well
- on HP displays using the HP-ColorRecovery technology.
-
- Mesa implements gamma correction with a lookup table which translates
- a "linear" pixel value to a gamma-corrected pixel value. There is a
- small performance penalty. Gamma correction only works in RGB mode.
- Also be aware that pixel values read back from the frame buffer will
- not be "un-corrected" so glReadPixels may not return the same data
- drawn with glDrawPixels.
-
- For more information about gamma correction see:
- http://www.inforamp.net/~poynton/notes/colour_and_gamma/GammaFAQ.html
-
-
-Overlay Planes
-
- Overlay planes in the frame buffer are supported by Mesa but require
- hardware and X server support. To determine if your X server has
- overlay support you can test for the SERVER_OVERLAY_VISUALS property:
-
- xprop -root | grep SERVER_OVERLAY_VISUALS
-
-
-HPCR glClear(GL_COLOR_BUFFER_BIT) dithering
-
- If you set the MESA_HPCR_CLEAR environment variable then dithering
- will be used when clearing the color buffer. This is only applicable
- to HP systems with the HPCR (Color Recovery) system.
-
-
-Extensions
-==========
- There are three Mesa-specific GLX extensions at this time.
-
- GLX_MESA_pixmap_colormap
-
- This extension adds the GLX function:
-
- GLXPixmap glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visual,
- Pixmap pixmap, Colormap cmap )
-
- It is an alternative to the standard glXCreateGLXPixmap() function.
- Since Mesa supports RGB rendering into any X visual, not just True-
- Color or DirectColor, Mesa needs colormap information to convert RGB
- values into pixel values. An X window carries this information but a
- pixmap does not. This function associates a colormap to a GLX pixmap.
- See the xdemos/glxpixmap.c file for an example of how to use this
- extension.
-
- GLX_MESA_release_buffers
-
- Mesa associates a set of ancillary (depth, accumulation, stencil and
- alpha) buffers with each X window it draws into. These ancillary
- buffers are allocated for each X window the first time the X window
- is passed to glXMakeCurrent(). Mesa, however, can't detect when an
- X window has been destroyed in order to free the ancillary buffers.
-
- The best it can do is to check for recently destroyed windows whenever
- the client calls the glXCreateContext() or glXDestroyContext()
- functions. This may not be sufficient in all situations though.
-
- The GLX_MESA_release_buffers extension allows a client to explicitly
- deallocate the ancillary buffers by calling glxReleaseBuffersMESA()
- just before an X window is destroyed. For example:
-
- #ifdef GLX_MESA_release_buffers
- glXReleaseBuffersMESA( dpy, window );
- #endif
- XDestroyWindow( dpy, window );
-
- This extension is new in Mesa 2.0.
-
- GLX_MESA_copy_sub_buffer
-
- This extension adds the glXCopySubBufferMESA() function. It works
- like glXSwapBuffers() but only copies a sub-region of the window
- instead of the whole window.
-
- This extension is new in Mesa version 2.6
-
-
-
-Summary of X-related environment variables:
- MESA_RGB_VISUAL - specifies the X visual and depth for RGB mode (X only)
- MESA_CI_VISUAL - specifies the X visual and depth for CI mode (X only)
- MESA_BACK_BUFFER - specifies how to implement the back color buffer (X only)
- MESA_PRIVATE_CMAP - force aux/tk libraries to use private colormaps (X only)
- MESA_GAMMA - gamma correction coefficients (X only)
-
-
-----------------------------------------------------------------------
-README.CYGWIN - lassauge April 2004 - based on README.X11
diff --git a/mesalib/docs/README.MITS b/mesalib/docs/README.MITS
deleted file mode 100644
index a89176a62..000000000
--- a/mesalib/docs/README.MITS
+++ /dev/null
@@ -1,102 +0,0 @@
-
- Mesa 3.0 MITS Information
-
-
-This software is distributed under the terms of the GNU Library
-General Public License, see the LICENSE file for details.
-
-
-This document is a preliminary introduction to help you get
-started. For more detaile information consult the web page.
-
-http://10-dencies.zkm.de/~mesa/
-
-
-
-Version 0.1 (Yes it's very alpha code so be warned!)
-Contributors:
- Emil Briggs (briggs@bucky.physics.ncsu.edu)
- David Bucciarelli (tech.hmw@plus.it)
- Andreas Schiffler (schiffler@zkm.de)
-
-
-
-1. Requirements:
- Mesa 3.0.
- An SMP capable machine running Linux 2.x
- libpthread installed on your machine.
-
-
-2. What does MITS stand for?
- MITS stands for Mesa Internal Threading System. By adding
- internal threading to Mesa it should be possible to improve
- performance of OpenGL applications on SMP machines.
-
-
-3. Do applications have to be recoded to take advantage of MITS?
- No. The threading is internal to Mesa and transparent to
- applications.
-
-
-4. Will all applications benefit from the current implementation of MITS?
- No. This implementation splits the processing of the vertex buffer
- over two threads. There is a certain amount of overhead involved
- with the thread synchronization and if there is not enough work
- to be done the extra overhead outweighs any speedup from using
- dual processors. You will not for example see any speedup when
- running Quake because it uses GL_POLYGON and there is only one
- polygon for each vertex buffer processed. Test results on a
- dual 200 Mhz. Pentium Pro system show that one needs around
- 100-200 vertices in the vertex buffer before any there is any
- appreciable benefit from the threading.
-
-
-5. Are there any parameters that I can tune to try to improve performance.
- Yes. You can try to vary the size of the vertex buffer which is
- define in VB_MAX located in the file src/vb.h from your top level
- Mesa distribution. The number needs to be a multiple of 12 and
- the optimum value will probably depend on the capabilities of
- your machine and the particular application you are running.
-
-
-6. Are there any ways I can modify the application to improve its
- performance with the MITS?
- Yes. Try to use as many vertices between each Begin/End pair
- as possbile. This will reduce the thread synchronization
- overhead.
-
-
-7. What sort of speedups can I expect?
- On some benchmarks performance gains of up to 30% have been
- observerd. Others may see no gain at all and in a few rare
- cases even some degradation.
-
-
-8. What still needs to be done?
- Lots of testing and benchmarking.
- A portable implementation that works within the Mesa thread API.
- Threading of additional areas of Mesa to improve performance
- even more.
-
-
-
-Installation:
-
- 1. This assumes that you already have a working Mesa 3.0 installation
- from source.
- 2. Place the tarball MITS.tar.gz in your top level Mesa directory.
- 3. Unzip it and untar it. It will replace the following files in
- your Mesa source tree so back them up if you want to save them.
-
-
- README.MITS
- Make-config
- Makefile
- mklib.glide
- src/vbxform.c
- src/vb.h
-
- 4. Rebuild Mesa using the command
-
- make linux-386-glide-mits
-
diff --git a/mesalib/docs/README.QUAKE b/mesalib/docs/README.QUAKE
deleted file mode 100644
index e90c76a08..000000000
--- a/mesalib/docs/README.QUAKE
+++ /dev/null
@@ -1,207 +0,0 @@
-
- Info on using Mesa 3.0 with Linux Quake I and Quake II
-
-
-
-Disclaimer
-----------
-
-I am _not_ a Quake expert by any means. I pretty much only run it to
-test Mesa. There have been a lot of questions about Linux Quake and
-Mesa so I'm trying to provide some useful info here. If this file
-doesn't help you then you should look elsewhere for help. The Mesa
-mailing list or the news://news.3dfx.com/3dfx.linux.glide newsgroup
-might be good.
-
-Again, all the information I have is in this file. Please don't email
-me with questions.
-
-If you have information to contribute to this file please send it to
-me at brianp@elastic.avid.com
-
-
-
-Linux Quake
------------
-
-You can get Linux Quake from http://www.idsoftware.com/
-
-Quake I and II for Linux were tested with, and include, Mesa 2.6. You
-shouldn't have too many problems if you simply follow the instructions
-in the Quake distribution.
-
-
-
-RedHat 5.0 Linux problems
--------------------------
-
-RedHat Linux 5.x uses the GNU C library ("glibc" or "libc6") whereas
-previous RedHat and other Linux distributions use "libc5" for its
-runtime C library.
-
-Linux Quake I and II were compiled for libc5. If you compile Mesa
-on a RedHat 5.x system the resulting libMesaGL.so file will not work
-with Linux Quake because of the different C runtime libraries.
-The symptom of this is a segmentation fault soon after starting Quake.
-
-If you want to use a newer version of Mesa (like 3.x) with Quake on
-RedHat 5.x then read on.
-
-The solution to the C library problem is to force Mesa to use libc5.
-libc5 is in /usr/i486-linux-libc5/lib on RedHat 5.x systems.
-
-Emil Briggs (briggs@tick.physics.ncsu.edu) nicely gave me the following
-info:
-
-> I only know what works on a RedHat 5.0 distribution. RH5 includes
-> a full set of libraries for both libc5 and glibc. The loader ld.so
-> uses the libc5 libraries in /usr/i486-linux-libc5/lib for programs
-> linked against libc5 while it uses the glibc libraries in /lib and
-> /usr/lib for programs linked against glibc.
->
-> Anyway I changed line 41 of mklib.glide to
-> GLIDELIBS="-L/usr/local/glide/lib -lglide2x -L/usr/i486-linux-libc5/lib"
->
-> And I started quake2 up with a script like this
-> #!/bin/csh
-> setenv LD_LIBRARY_PATH /usr/i486-linux-libc5/lib
-> setenv MESA_GLX_FX f
-> ./quake2 +set vid_ref gl
-> kbd_mode -a
-> reset
-
-
-I've already patched the mklib.glide file. You'll have to start Quake
-with the script shown above though.
-
-
-
-**********************
-
-Daryll Strauss writes:
-
-Here's my thoughts on the problem. On a RH 5.x system, you can NOT build
-a libc5 executable or library. Red Hat just doesn't include the right
-stuff to do it.
-
-Since Quake is a libc5 based application, you are in trouble. You need
-libc5 libraries.
-
-What can you do about it? Well there's a package called gcc5 that does
-MOST of the right stuff to compile with libc5. (It brings back older
-header files, makes appropriate symbolic links for libraries, and sets
-up the compiler to use the correct directories) You can find gcc5 here:
-ftp://ecg.mit.edu/pub/linux/gcc5-1.0-1.i386.rpm
-
-No, this isn't quite enough. There are still a few tricks to getting
-Mesa to compile as a libc5 application. First you have to make sure that
-every compile uses gcc5 instead of gcc. Second, in some cases the link
-line actually lists -L/usr/lib which breaks gcc5 (because it forces you
-to use the glibc version of things)
-
-If you get all the stuff correctly compiled with gcc5 it should work.
-I've run Mesa 3.0B6 and its demos in a window with my Rush on a Red Hat
-5.1 system. It is a big hassle, but it can be done. I've only made Quake
-segfault, but I think that's from my libRush using the wrong libc.
-
-Yes, mixing libc5 and glibc is a major pain. I've been working to get
-all my libraries compiling correctly with this setup. Someone should
-make an RPM out of it and feed changes back to Brian once they get it
-all working. If no one else has done so by the time I get the rest of my
-stuff straightened out, I'll try to do it myself.
-
- - |Daryll
-
-
-
-*********************
-
-David Bucciarelli (tech.hmw@plus.it) writes:
-
-I'm using the Mesa-3.0beta7 and the RedHat 5.1 and QuakeII is
-working fine for me. I had only to make a small change to the
-Mesa-3.0/mklib.glide file, from:
-
-
- GLIDELIBS="-L/usr/local/glide/lib -lglide2x
--L/usr/i486-linux-libc5/lib -lm"
-
-to:
-
- GLIDELIBS="-L/usr/i486-linux-libc5/lib -lglide2x"
-
-and to make two symbolic links:
-
-[david@localhost Mesa]$ ln -s libMesaGL.so libMesaGL.so.2
-[david@localhost Mesa]$ ln -s libMesaGLU.so libMesaGLU.so.2
-
-I'm using the Daryll's Linux glide rpm for the Voodoo2 and glibc (it
-includes also the Glide for the libc5). I'm not using the /dev/3Dfx and
-running QuakeII as root with the following env. var:
-
-export
-LD_LIBRARY_PATH=/dsk1/home/david/src/gl/Mesa/lib:/usr/i486-linux-libc5/lib
-
-I think that all problems are related to the glibc, Quake will never
-work if you get the following output:
-
-[david@localhost Mesa]$ ldd lib/libMesaGL.so
- libglide2x.so => /usr/lib/libglide2x.so (0x400f8000)
- libm.so.6 => /lib/libm.so.6 (0x40244000)
- libc.so.6 => /lib/libc.so.6 (0x4025d000)
- /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00000000)
-
-You must get the following outputs:
-
-[david@localhost Mesa]# ldd lib/libMesaGL.so
- libglide2x.so => /usr/i486-linux-libc5/lib/libglide2x.so
-(0x400f3000)
-
-[root@localhost quake2]# ldd quake2
- libdl.so.1 => /lib/libdl.so.1 (0x40005000)
- libm.so.5 => /usr/i486-linux-libc5/lib/libm.so.5 (0x40008000)
- libc.so.5 => /usr/i486-linux-libc5/lib/libc.so.5 (0x40010000)
-
-[root@localhost quake2]# ldd ref_gl.so
- libMesaGL.so.2 =>
-/dsk1/home/david/src/gl/Mesa/lib/libMesaGL.so.2 (0x400eb000)
- libglide2x.so => /usr/i486-linux-libc5/lib/libglide2x.so
-(0x401d9000)
- libX11.so.6 => /usr/i486-linux-libc5/lib/libX11.so.6
-(0x40324000)
- libXext.so.6 => /usr/i486-linux-libc5/lib/libXext.so.6
-(0x403b7000)
- libvga.so.1 => /usr/i486-linux-libc5/lib/libvga.so.1
-(0x403c1000)
- libm.so.5 => /usr/i486-linux-libc5/lib/libm.so.5 (0x403f5000)
- libc.so.5 => /usr/i486-linux-libc5/lib/libc.so.5 (0x403fd000)
-
-
-***********************
-
-Steve Davies (steve@one47.demon.co.uk) writes:
-
-
-Try using:
-
- export LD_LIBRARY_PATH=/usr/i486-linux-libc5/lib
- ./quake2 +set vid_ref gl
-
-to start the game... Works for me, but assumes that you have the
-compatability libc5 RPMs installed.
-
-
-***************************
-
-WWW resources - you may find additional Linux Quake help at these URLs:
-
-
-http://quake.medina.net/howto
-
-http://webpages.mr.net/bobz
-
-http://www.linuxgames.com/quake2/
-
-
-
-----------------------------------------------------------------------
diff --git a/mesalib/docs/README.THREADS b/mesalib/docs/README.THREADS
deleted file mode 100644
index fb6e0ff3d..000000000
--- a/mesalib/docs/README.THREADS
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-Mesa Threads README
--------------------
-
-Thread safety was introduced in Mesa 2.6 by John Stone and
-Christoph Poliwoda.
-
-It was redesigned in Mesa 3.3 so that thread safety is
-supported by default (on systems which support threads,
-that is). There is no measurable penalty on single
-threaded applications.
-
-NOTE that the only _driver_ which is thread safe at this time
-is the OS/Mesa driver!
-
-
-At present the mthreads code supports three thread APIS:
- 1) POSIX threads (aka pthreads).
- 2) Solaris / Unix International threads.
- 3) Win32 threads (Win 95/NT).
-
-Support for other thread libraries can be added src/glthread.[ch]
-
-
-In order to guarantee proper operation, it is
-necessary for both Mesa and application code to use the same threads API.
-So, if your application uses Sun's thread API, then you should build Mesa
-using one of the targets for Sun threads.
-
-The mtdemos directory contains some example programs which use
-multiple threads to render to osmesa rendering context(s).
-
-Linux users should be aware that there exist many different POSIX
-threads packages. The best solution is the linuxthreads package
-(http://pauillac.inria.fr/~xleroy/linuxthreads/) as this package is the
-only one that really supports multiprocessor machines (AFAIK). See
-http://pauillac.inria.fr/~xleroy/linuxthreads/README for further
-information about the usage of linuxthreads.
-
-If you are interested in helping with thread safety work in Mesa
-join the Mesa developers mailing list and post your proposal.
-
-
-Regards,
- John Stone -- j.stone@acm.org johns@cs.umr.edu
- Christoph Poliwoda -- poliwoda@volumegraphics.com
-
-
-Version info:
- Mesa 2.6 - initial thread support.
- Mesa 3.3 - thread support mostly rewritten (Brian Paul)
diff --git a/mesalib/docs/license.html b/mesalib/docs/license.html
index 80bb60400..d56823f6d 100644
--- a/mesalib/docs/license.html
+++ b/mesalib/docs/license.html
@@ -103,6 +103,9 @@ Device drivers src/mesa/drivers/* MIT, generally
Ext headers include/GL/glext.h Khronos
include/GL/glxext.h
+
+C11 thread include/c11/threads*.h Boost (permissive)
+emulation
</pre>
<p>
diff --git a/mesalib/docs/relnotes/10.1.html b/mesalib/docs/relnotes/10.1.html
index 1089c7199..14b635f24 100644
--- a/mesalib/docs/relnotes/10.1.html
+++ b/mesalib/docs/relnotes/10.1.html
@@ -46,7 +46,9 @@ Note: some of the new features are only available with certain drivers.
<ul>
<li>GL_ARB_draw_indirect on i965.</li>
<li>GL_ARB_clear_buffer_object</li>
+<li>GL_ARB_viewport_array on i965.</li>
<li>GL_AMD_shader_trinary_minmax.</li>
+<li>Reduced memory usage for display lists.</li>
</ul>
diff --git a/mesalib/include/GLES2/gl2.h b/mesalib/include/GLES2/gl2.h
index c2d835726..665f6c338 100644
--- a/mesalib/include/GLES2/gl2.h
+++ b/mesalib/include/GLES2/gl2.h
@@ -1,56 +1,83 @@
#ifndef __gl2_h_
-#define __gl2_h_
-
-/* $Revision: 20555 $ on $Date:: 2013-02-12 14:32:47 -0800 #$ */
-
-#include <GLES2/gl2platform.h>
+#define __gl2_h_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
- * This document is licensed under the SGI Free Software B License Version
- * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
- */
-
-/*-------------------------------------------------------------------------
- * Data type definitions
- *-----------------------------------------------------------------------*/
+** Copyright (c) 2013 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
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are 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 Materials.
+**
+** THE MATERIALS ARE 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
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+/*
+** This header is generated from the Khronos OpenGL / OpenGL ES XML
+** API Registry. The current version of the Registry, generator scripts
+** used to make the header, and the header can be found at
+** http://www.opengl.org/registry/
+**
+** Khronos $Revision: 24614 $ on $Date: 2013-12-30 04:44:46 -0800 (Mon, 30 Dec 2013) $
+*/
-typedef void GLvoid;
-typedef char GLchar;
-typedef unsigned int GLenum;
-typedef unsigned char GLboolean;
-typedef unsigned int GLbitfield;
-typedef khronos_int8_t GLbyte;
-typedef short GLshort;
-typedef int GLint;
-typedef int GLsizei;
-typedef khronos_uint8_t GLubyte;
-typedef unsigned short GLushort;
-typedef unsigned int GLuint;
-typedef khronos_float_t GLfloat;
-typedef khronos_float_t GLclampf;
-typedef khronos_int32_t GLfixed;
+#include <GLES2/gl2platform.h>
-/* GL types for handling large vertex buffer objects */
-typedef khronos_intptr_t GLintptr;
-typedef khronos_ssize_t GLsizeiptr;
+/* Generated on date 20131230 */
-/* OpenGL ES core versions */
-#define GL_ES_VERSION_2_0 1
+/* Generated C header for:
+ * API: gles2
+ * Profile: common
+ * Versions considered: 2\.[0-9]
+ * Versions emitted: .*
+ * Default extensions included: None
+ * Additional extensions included: _nomatch_^
+ * Extensions removed: _nomatch_^
+ */
-/* ClearBufferMask */
+#ifndef GL_ES_VERSION_2_0
+#define GL_ES_VERSION_2_0 1
+#include <KHR/khrplatform.h>
+typedef khronos_int8_t GLbyte;
+typedef khronos_float_t GLclampf;
+typedef khronos_int32_t GLfixed;
+typedef short GLshort;
+typedef unsigned short GLushort;
+typedef void GLvoid;
+typedef struct __GLsync *GLsync;
+typedef khronos_int64_t GLint64;
+typedef khronos_uint64_t GLuint64;
+typedef unsigned int GLenum;
+typedef unsigned int GLuint;
+typedef char GLchar;
+typedef khronos_float_t GLfloat;
+typedef khronos_ssize_t GLsizeiptr;
+typedef khronos_intptr_t GLintptr;
+typedef unsigned int GLbitfield;
+typedef int GLint;
+typedef unsigned char GLboolean;
+typedef int GLsizei;
+typedef khronos_uint8_t GLubyte;
#define GL_DEPTH_BUFFER_BIT 0x00000100
#define GL_STENCIL_BUFFER_BIT 0x00000400
#define GL_COLOR_BUFFER_BIT 0x00004000
-
-/* Boolean */
#define GL_FALSE 0
#define GL_TRUE 1
-
-/* BeginMode */
#define GL_POINTS 0x0000
#define GL_LINES 0x0001
#define GL_LINE_LOOP 0x0002
@@ -58,18 +85,6 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_TRIANGLES 0x0004
#define GL_TRIANGLE_STRIP 0x0005
#define GL_TRIANGLE_FAN 0x0006
-
-/* AlphaFunction (not supported in ES20) */
-/* GL_NEVER */
-/* GL_LESS */
-/* GL_EQUAL */
-/* GL_LEQUAL */
-/* GL_GREATER */
-/* GL_NOTEQUAL */
-/* GL_GEQUAL */
-/* GL_ALWAYS */
-
-/* BlendingFactorDest */
#define GL_ZERO 0
#define GL_ONE 1
#define GL_SRC_COLOR 0x0300
@@ -78,29 +93,15 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_ONE_MINUS_SRC_ALPHA 0x0303
#define GL_DST_ALPHA 0x0304
#define GL_ONE_MINUS_DST_ALPHA 0x0305
-
-/* BlendingFactorSrc */
-/* GL_ZERO */
-/* GL_ONE */
#define GL_DST_COLOR 0x0306
#define GL_ONE_MINUS_DST_COLOR 0x0307
#define GL_SRC_ALPHA_SATURATE 0x0308
-/* GL_SRC_ALPHA */
-/* GL_ONE_MINUS_SRC_ALPHA */
-/* GL_DST_ALPHA */
-/* GL_ONE_MINUS_DST_ALPHA */
-
-/* BlendEquationSeparate */
#define GL_FUNC_ADD 0x8006
#define GL_BLEND_EQUATION 0x8009
-#define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */
+#define GL_BLEND_EQUATION_RGB 0x8009
#define GL_BLEND_EQUATION_ALPHA 0x883D
-
-/* BlendSubtract */
#define GL_FUNC_SUBTRACT 0x800A
#define GL_FUNC_REVERSE_SUBTRACT 0x800B
-
-/* Separate Blend Functions */
#define GL_BLEND_DST_RGB 0x80C8
#define GL_BLEND_SRC_RGB 0x80C9
#define GL_BLEND_DST_ALPHA 0x80CA
@@ -110,38 +111,19 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_CONSTANT_ALPHA 0x8003
#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
#define GL_BLEND_COLOR 0x8005
-
-/* Buffer Objects */
#define GL_ARRAY_BUFFER 0x8892
#define GL_ELEMENT_ARRAY_BUFFER 0x8893
#define GL_ARRAY_BUFFER_BINDING 0x8894
#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
-
#define GL_STREAM_DRAW 0x88E0
#define GL_STATIC_DRAW 0x88E4
#define GL_DYNAMIC_DRAW 0x88E8
-
#define GL_BUFFER_SIZE 0x8764
#define GL_BUFFER_USAGE 0x8765
-
#define GL_CURRENT_VERTEX_ATTRIB 0x8626
-
-/* CullFaceMode */
#define GL_FRONT 0x0404
#define GL_BACK 0x0405
#define GL_FRONT_AND_BACK 0x0408
-
-/* DepthFunction */
-/* GL_NEVER */
-/* GL_LESS */
-/* GL_EQUAL */
-/* GL_LEQUAL */
-/* GL_GREATER */
-/* GL_NOTEQUAL */
-/* GL_GEQUAL */
-/* GL_ALWAYS */
-
-/* EnableCap */
#define GL_TEXTURE_2D 0x0DE1
#define GL_CULL_FACE 0x0B44
#define GL_BLEND 0x0BE2
@@ -152,19 +134,13 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_POLYGON_OFFSET_FILL 0x8037
#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
#define GL_SAMPLE_COVERAGE 0x80A0
-
-/* ErrorCode */
#define GL_NO_ERROR 0
#define GL_INVALID_ENUM 0x0500
#define GL_INVALID_VALUE 0x0501
#define GL_INVALID_OPERATION 0x0502
#define GL_OUT_OF_MEMORY 0x0505
-
-/* FrontFaceDirection */
#define GL_CW 0x0900
#define GL_CCW 0x0901
-
-/* GetPName */
#define GL_LINE_WIDTH 0x0B21
#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
@@ -191,7 +167,6 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
#define GL_VIEWPORT 0x0BA2
#define GL_SCISSOR_BOX 0x0C10
-/* GL_SCISSOR_TEST */
#define GL_COLOR_CLEAR_VALUE 0x0C22
#define GL_COLOR_WRITEMASK 0x0C23
#define GL_UNPACK_ALIGNMENT 0x0CF5
@@ -206,32 +181,18 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_DEPTH_BITS 0x0D56
#define GL_STENCIL_BITS 0x0D57
#define GL_POLYGON_OFFSET_UNITS 0x2A00
-/* GL_POLYGON_OFFSET_FILL */
#define GL_POLYGON_OFFSET_FACTOR 0x8038
#define GL_TEXTURE_BINDING_2D 0x8069
#define GL_SAMPLE_BUFFERS 0x80A8
#define GL_SAMPLES 0x80A9
#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
-
-/* GetTextureParameter */
-/* GL_TEXTURE_MAG_FILTER */
-/* GL_TEXTURE_MIN_FILTER */
-/* GL_TEXTURE_WRAP_S */
-/* GL_TEXTURE_WRAP_T */
-
#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
-
-/* HintMode */
#define GL_DONT_CARE 0x1100
#define GL_FASTEST 0x1101
#define GL_NICEST 0x1102
-
-/* HintTarget */
-#define GL_GENERATE_MIPMAP_HINT 0x8192
-
-/* DataType */
+#define GL_GENERATE_MIPMAP_HINT 0x8192
#define GL_BYTE 0x1400
#define GL_UNSIGNED_BYTE 0x1401
#define GL_SHORT 0x1402
@@ -240,44 +201,35 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_UNSIGNED_INT 0x1405
#define GL_FLOAT 0x1406
#define GL_FIXED 0x140C
-
-/* PixelFormat */
#define GL_DEPTH_COMPONENT 0x1902
#define GL_ALPHA 0x1906
#define GL_RGB 0x1907
#define GL_RGBA 0x1908
#define GL_LUMINANCE 0x1909
#define GL_LUMINANCE_ALPHA 0x190A
-
-/* PixelType */
-/* GL_UNSIGNED_BYTE */
#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
#define GL_UNSIGNED_SHORT_5_6_5 0x8363
-
-/* Shaders */
-#define GL_FRAGMENT_SHADER 0x8B30
-#define GL_VERTEX_SHADER 0x8B31
-#define GL_MAX_VERTEX_ATTRIBS 0x8869
-#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
-#define GL_MAX_VARYING_VECTORS 0x8DFC
+#define GL_FRAGMENT_SHADER 0x8B30
+#define GL_VERTEX_SHADER 0x8B31
+#define GL_MAX_VERTEX_ATTRIBS 0x8869
+#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
+#define GL_MAX_VARYING_VECTORS 0x8DFC
#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
-#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
-#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
-#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
-#define GL_SHADER_TYPE 0x8B4F
-#define GL_DELETE_STATUS 0x8B80
-#define GL_LINK_STATUS 0x8B82
-#define GL_VALIDATE_STATUS 0x8B83
-#define GL_ATTACHED_SHADERS 0x8B85
-#define GL_ACTIVE_UNIFORMS 0x8B86
-#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
-#define GL_ACTIVE_ATTRIBUTES 0x8B89
-#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
-#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
-#define GL_CURRENT_PROGRAM 0x8B8D
-
-/* StencilFunction */
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
+#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
+#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
+#define GL_SHADER_TYPE 0x8B4F
+#define GL_DELETE_STATUS 0x8B80
+#define GL_LINK_STATUS 0x8B82
+#define GL_VALIDATE_STATUS 0x8B83
+#define GL_ATTACHED_SHADERS 0x8B85
+#define GL_ACTIVE_UNIFORMS 0x8B86
+#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
+#define GL_ACTIVE_ATTRIBUTES 0x8B89
+#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
+#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
+#define GL_CURRENT_PROGRAM 0x8B8D
#define GL_NEVER 0x0200
#define GL_LESS 0x0201
#define GL_EQUAL 0x0202
@@ -286,9 +238,6 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_NOTEQUAL 0x0205
#define GL_GEQUAL 0x0206
#define GL_ALWAYS 0x0207
-
-/* StencilOp */
-/* GL_ZERO */
#define GL_KEEP 0x1E00
#define GL_REPLACE 0x1E01
#define GL_INCR 0x1E02
@@ -296,35 +245,21 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_INVERT 0x150A
#define GL_INCR_WRAP 0x8507
#define GL_DECR_WRAP 0x8508
-
-/* StringName */
#define GL_VENDOR 0x1F00
#define GL_RENDERER 0x1F01
#define GL_VERSION 0x1F02
#define GL_EXTENSIONS 0x1F03
-
-/* TextureMagFilter */
#define GL_NEAREST 0x2600
#define GL_LINEAR 0x2601
-
-/* TextureMinFilter */
-/* GL_NEAREST */
-/* GL_LINEAR */
#define GL_NEAREST_MIPMAP_NEAREST 0x2700
#define GL_LINEAR_MIPMAP_NEAREST 0x2701
#define GL_NEAREST_MIPMAP_LINEAR 0x2702
#define GL_LINEAR_MIPMAP_LINEAR 0x2703
-
-/* TextureParameterName */
#define GL_TEXTURE_MAG_FILTER 0x2800
#define GL_TEXTURE_MIN_FILTER 0x2801
#define GL_TEXTURE_WRAP_S 0x2802
#define GL_TEXTURE_WRAP_T 0x2803
-
-/* TextureTarget */
-/* GL_TEXTURE_2D */
#define GL_TEXTURE 0x1702
-
#define GL_TEXTURE_CUBE_MAP 0x8513
#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
@@ -334,8 +269,6 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
-
-/* TextureUnit */
#define GL_TEXTURE0 0x84C0
#define GL_TEXTURE1 0x84C1
#define GL_TEXTURE2 0x84C2
@@ -369,13 +302,9 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_TEXTURE30 0x84DE
#define GL_TEXTURE31 0x84DF
#define GL_ACTIVE_TEXTURE 0x84E0
-
-/* TextureWrapMode */
#define GL_REPEAT 0x2901
#define GL_CLAMP_TO_EDGE 0x812F
#define GL_MIRRORED_REPEAT 0x8370
-
-/* Uniform Types */
#define GL_FLOAT_VEC2 0x8B50
#define GL_FLOAT_VEC3 0x8B51
#define GL_FLOAT_VEC4 0x8B52
@@ -391,48 +320,34 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_FLOAT_MAT4 0x8B5C
#define GL_SAMPLER_2D 0x8B5E
#define GL_SAMPLER_CUBE 0x8B60
-
-/* Vertex Arrays */
-#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
-#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
-#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
-#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
-#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
-#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
-
-/* Read Format */
-#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
-
-/* Shader Source */
#define GL_COMPILE_STATUS 0x8B81
#define GL_INFO_LOG_LENGTH 0x8B84
#define GL_SHADER_SOURCE_LENGTH 0x8B88
#define GL_SHADER_COMPILER 0x8DFA
-
-/* Shader Binary */
#define GL_SHADER_BINARY_FORMATS 0x8DF8
#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
-
-/* Shader Precision-Specified Types */
#define GL_LOW_FLOAT 0x8DF0
#define GL_MEDIUM_FLOAT 0x8DF1
#define GL_HIGH_FLOAT 0x8DF2
#define GL_LOW_INT 0x8DF3
#define GL_MEDIUM_INT 0x8DF4
#define GL_HIGH_INT 0x8DF5
-
-/* Framebuffer Object. */
#define GL_FRAMEBUFFER 0x8D40
#define GL_RENDERBUFFER 0x8D41
-
#define GL_RGBA4 0x8056
#define GL_RGB5_A1 0x8057
#define GL_RGB565 0x8D62
#define GL_DEPTH_COMPONENT16 0x81A5
#define GL_STENCIL_INDEX8 0x8D48
-
#define GL_RENDERBUFFER_WIDTH 0x8D42
#define GL_RENDERBUFFER_HEIGHT 0x8D43
#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
@@ -442,179 +357,169 @@ typedef khronos_ssize_t GLsizeiptr;
#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
-
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
-
#define GL_COLOR_ATTACHMENT0 0x8CE0
#define GL_DEPTH_ATTACHMENT 0x8D00
#define GL_STENCIL_ATTACHMENT 0x8D20
-
#define GL_NONE 0
-
-#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
-#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
+#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
-#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
-#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
-
+#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
+#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
#define GL_FRAMEBUFFER_BINDING 0x8CA6
#define GL_RENDERBUFFER_BINDING 0x8CA7
#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
-
#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
-
-/*-------------------------------------------------------------------------
- * GL core functions.
- *-----------------------------------------------------------------------*/
-
-GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture);
-GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader);
-GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar* name);
-GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer);
-GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer);
-GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer);
-GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture);
-GL_APICALL void GL_APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
-GL_APICALL void GL_APIENTRY glBlendEquation ( GLenum mode );
-GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha);
-GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);
-GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
-GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage);
-GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data);
-GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target);
-GL_APICALL void GL_APIENTRY glClear (GLbitfield mask);
-GL_APICALL void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
-GL_APICALL void GL_APIENTRY glClearDepthf (GLclampf depth);
-GL_APICALL void GL_APIENTRY glClearStencil (GLint s);
-GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
-GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader);
-GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data);
-GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data);
-GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
-GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-GL_APICALL GLuint GL_APIENTRY glCreateProgram (void);
-GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type);
-GL_APICALL void GL_APIENTRY glCullFace (GLenum mode);
-GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers);
-GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers);
-GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program);
-GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers);
-GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader);
-GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures);
-GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func);
-GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag);
-GL_APICALL void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar);
-GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader);
-GL_APICALL void GL_APIENTRY glDisable (GLenum cap);
-GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index);
-GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count);
-GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices);
-GL_APICALL void GL_APIENTRY glEnable (GLenum cap);
-GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index);
-GL_APICALL void GL_APIENTRY glFinish (void);
-GL_APICALL void GL_APIENTRY glFlush (void);
-GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
-GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode);
-GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers);
-GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target);
-GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers);
-GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers);
-GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures);
-GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
-GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
-GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
-GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name);
-GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params);
-GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params);
-GL_APICALL GLenum GL_APIENTRY glGetError (void);
-GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params);
-GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params);
-GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint* params);
-GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint* params);
-GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog);
-GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params);
-GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint* params);
-GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog);
-GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
-GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);
-GL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenum name);
-GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params);
-GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params);
-GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params);
-GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params);
-GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name);
-GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params);
-GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params);
-GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer);
-GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode);
-GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer);
-GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap);
-GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer);
-GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program);
-GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer);
-GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader);
-GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture);
-GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width);
-GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program);
-GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param);
-GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units);
-GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);
-GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void);
-GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
-GL_APICALL void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert);
-GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
-GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length);
-GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length);
-GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);
-GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask);
-GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask);
-GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask);
-GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
-GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
-GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
-GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param);
-GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params);
-GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);
-GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint* params);
-GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels);
-GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat x);
-GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v);
-GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint x);
-GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* v);
-GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat x, GLfloat y);
-GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat* v);
-GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint x, GLint y);
-GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint* v);
-GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z);
-GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat* v);
-GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint x, GLint y, GLint z);
-GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint* v);
-GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* v);
-GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w);
-GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* v);
-GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GL_APICALL void GL_APIENTRY glUseProgram (GLuint program);
-GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program);
-GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x);
-GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values);
-GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y);
-GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint indx, const GLfloat* values);
-GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z);
-GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint indx, const GLfloat* values);
-GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint indx, const GLfloat* values);
-GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr);
-GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture);
+GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader);
+GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name);
+GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer);
+GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer);
+GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer);
+GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture);
+GL_APICALL void GL_APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+GL_APICALL void GL_APIENTRY glBlendEquation (GLenum mode);
+GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha);
+GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);
+GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage);
+GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data);
+GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target);
+GL_APICALL void GL_APIENTRY glClear (GLbitfield mask);
+GL_APICALL void GL_APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+GL_APICALL void GL_APIENTRY glClearDepthf (GLfloat d);
+GL_APICALL void GL_APIENTRY glClearStencil (GLint s);
+GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader);
+GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data);
+GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data);
+GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GL_APICALL GLuint GL_APIENTRY glCreateProgram (void);
+GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type);
+GL_APICALL void GL_APIENTRY glCullFace (GLenum mode);
+GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers);
+GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers);
+GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program);
+GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers);
+GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader);
+GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures);
+GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func);
+GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag);
+GL_APICALL void GL_APIENTRY glDepthRangef (GLfloat n, GLfloat f);
+GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader);
+GL_APICALL void GL_APIENTRY glDisable (GLenum cap);
+GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index);
+GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count);
+GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices);
+GL_APICALL void GL_APIENTRY glEnable (GLenum cap);
+GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index);
+GL_APICALL void GL_APIENTRY glFinish (void);
+GL_APICALL void GL_APIENTRY glFlush (void);
+GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode);
+GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint *buffers);
+GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target);
+GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers);
+GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers);
+GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint *textures);
+GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders);
+GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar *name);
+GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *data);
+GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params);
+GL_APICALL GLenum GL_APIENTRY glGetError (void);
+GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat *data);
+GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint *data);
+GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision);
+GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
+GL_APICALL const GLubyte *GL_APIENTRY glGetString (GLenum name);
+GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params);
+GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params);
+GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params);
+GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar *name);
+GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params);
+GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer);
+GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode);
+GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer);
+GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap);
+GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer);
+GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program);
+GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer);
+GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader);
+GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture);
+GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width);
+GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program);
+GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param);
+GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units);
+GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels);
+GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void);
+GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glSampleCoverage (GLfloat value, GLboolean invert);
+GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length);
+GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length);
+GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);
+GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask);
+GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask);
+GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask);
+GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
+GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels);
+GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param);
+GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params);
+GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);
+GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params);
+GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);
+GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat v0);
+GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint v0);
+GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1);
+GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint v0, GLint v1);
+GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2);
+GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUseProgram (GLuint program);
+GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program);
+GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint index, GLfloat x);
+GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y);
+GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);
+GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
+#endif /* GL_ES_VERSION_2_0 */
#ifdef __cplusplus
}
#endif
-#endif /* __gl2_h_ */
+#endif
diff --git a/mesalib/include/GLES2/gl2ext.h b/mesalib/include/GLES2/gl2ext.h
index 4ac971a68..2a84c4d81 100644
--- a/mesalib/include/GLES2/gl2ext.h
+++ b/mesalib/include/GLES2/gl2ext.h
@@ -1,1381 +1,582 @@
#ifndef __gl2ext_h_
-#define __gl2ext_h_
-
-/* $Revision: 22161 $ on $Date:: 2013-06-25 08:17:27 -0700 #$ */
+#define __gl2ext_h_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
- * This document is licensed under the SGI Free Software B License Version
- * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ .
- */
+** Copyright (c) 2013 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
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are 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 Materials.
+**
+** THE MATERIALS ARE 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
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+/*
+** This header is generated from the Khronos OpenGL / OpenGL ES XML
+** API Registry. The current version of the Registry, generator scripts
+** used to make the header, and the header can be found at
+** http://www.opengl.org/registry/
+**
+** Khronos $Revision: 24614 $ on $Date: 2013-12-30 04:44:46 -0800 (Mon, 30 Dec 2013) $
+*/
#ifndef GL_APIENTRYP
-# define GL_APIENTRYP GL_APIENTRY*
+#define GL_APIENTRYP GL_APIENTRY*
#endif
-/* New types shared by several extensions */
+/* Generated on date 20131230 */
-#ifndef __gl3_h_
-/* These are defined with respect to <inttypes.h> in the
- * Apple extension spec, but they are also used by non-APPLE
- * extensions, and in the Khronos header we use the Khronos
- * portable types in khrplatform.h, which must be defined.
+/* Generated C header for:
+ * API: gles2
+ * Profile: common
+ * Versions considered: 2\.[0-9]
+ * Versions emitted: _nomatch_^
+ * Default extensions included: gles2
+ * Additional extensions included: _nomatch_^
+ * Extensions removed: _nomatch_^
*/
-typedef khronos_int64_t GLint64;
-typedef khronos_uint64_t GLuint64;
-typedef struct __GLsync *GLsync;
-#endif
-
-
-/*------------------------------------------------------------------------*
- * OES extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_OES_compressed_ETC1_RGB8_texture */
-#ifndef GL_OES_compressed_ETC1_RGB8_texture
-#define GL_ETC1_RGB8_OES 0x8D64
-#endif
-
-/* GL_OES_compressed_paletted_texture */
-#ifndef GL_OES_compressed_paletted_texture
-#define GL_PALETTE4_RGB8_OES 0x8B90
-#define GL_PALETTE4_RGBA8_OES 0x8B91
-#define GL_PALETTE4_R5_G6_B5_OES 0x8B92
-#define GL_PALETTE4_RGBA4_OES 0x8B93
-#define GL_PALETTE4_RGB5_A1_OES 0x8B94
-#define GL_PALETTE8_RGB8_OES 0x8B95
-#define GL_PALETTE8_RGBA8_OES 0x8B96
-#define GL_PALETTE8_R5_G6_B5_OES 0x8B97
-#define GL_PALETTE8_RGBA4_OES 0x8B98
-#define GL_PALETTE8_RGB5_A1_OES 0x8B99
-#endif
-
-/* GL_OES_depth24 */
-#ifndef GL_OES_depth24
-#define GL_DEPTH_COMPONENT24_OES 0x81A6
-#endif
-
-/* GL_OES_depth32 */
-#ifndef GL_OES_depth32
-#define GL_DEPTH_COMPONENT32_OES 0x81A7
-#endif
-
-/* GL_OES_depth_texture */
-/* No new tokens introduced by this extension. */
-
-/* GL_OES_EGL_image */
-#ifndef GL_OES_EGL_image
-typedef void* GLeglImageOES;
-#endif
-
-/* GL_OES_EGL_image_external */
-#ifndef GL_OES_EGL_image_external
-/* GLeglImageOES defined in GL_OES_EGL_image already. */
-#define GL_TEXTURE_EXTERNAL_OES 0x8D65
-#define GL_SAMPLER_EXTERNAL_OES 0x8D66
-#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67
-#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68
-#endif
-
-/* GL_OES_element_index_uint */
-#ifndef GL_OES_element_index_uint
-#define GL_UNSIGNED_INT 0x1405
-#endif
-
-/* GL_OES_get_program_binary */
-#ifndef GL_OES_get_program_binary
-#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741
-#define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE
-#define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF
-#endif
-
-/* GL_OES_mapbuffer */
-#ifndef GL_OES_mapbuffer
-#define GL_WRITE_ONLY_OES 0x88B9
-#define GL_BUFFER_ACCESS_OES 0x88BB
-#define GL_BUFFER_MAPPED_OES 0x88BC
-#define GL_BUFFER_MAP_POINTER_OES 0x88BD
-#endif
-
-/* GL_OES_packed_depth_stencil */
-#ifndef GL_OES_packed_depth_stencil
-#define GL_DEPTH_STENCIL_OES 0x84F9
-#define GL_UNSIGNED_INT_24_8_OES 0x84FA
-#define GL_DEPTH24_STENCIL8_OES 0x88F0
-#endif
-
-/* GL_OES_required_internalformat */
-#ifndef GL_OES_required_internalformat
-#define GL_ALPHA8_OES 0x803C
-#define GL_DEPTH_COMPONENT16_OES 0x81A5
-/* reuse GL_DEPTH_COMPONENT24_OES */
-/* reuse GL_DEPTH24_STENCIL8_OES */
-/* reuse GL_DEPTH_COMPONENT32_OES */
-#define GL_LUMINANCE4_ALPHA4_OES 0x8043
-#define GL_LUMINANCE8_ALPHA8_OES 0x8045
-#define GL_LUMINANCE8_OES 0x8040
-#define GL_RGBA4_OES 0x8056
-#define GL_RGB5_A1_OES 0x8057
-#define GL_RGB565_OES 0x8D62
-/* reuse GL_RGB8_OES */
-/* reuse GL_RGBA8_OES */
-/* reuse GL_RGB10_EXT */
-/* reuse GL_RGB10_A2_EXT */
-#endif
-
-/* GL_OES_rgb8_rgba8 */
-#ifndef GL_OES_rgb8_rgba8
-#define GL_RGB8_OES 0x8051
-#define GL_RGBA8_OES 0x8058
-#endif
-
-/* GL_OES_standard_derivatives */
-#ifndef GL_OES_standard_derivatives
-#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B
-#endif
-
-/* GL_OES_stencil1 */
-#ifndef GL_OES_stencil1
-#define GL_STENCIL_INDEX1_OES 0x8D46
-#endif
-
-/* GL_OES_stencil4 */
-#ifndef GL_OES_stencil4
-#define GL_STENCIL_INDEX4_OES 0x8D47
-#endif
-
-#ifndef GL_OES_surfaceless_context
-#define GL_FRAMEBUFFER_UNDEFINED_OES 0x8219
-#endif
-
-/* GL_OES_texture_3D */
-#ifndef GL_OES_texture_3D
-#define GL_TEXTURE_WRAP_R_OES 0x8072
-#define GL_TEXTURE_3D_OES 0x806F
-#define GL_TEXTURE_BINDING_3D_OES 0x806A
-#define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073
-#define GL_SAMPLER_3D_OES 0x8B5F
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4
-#endif
-
-/* GL_OES_texture_float */
-/* No new tokens introduced by this extension. */
-
-/* GL_OES_texture_float_linear */
-/* No new tokens introduced by this extension. */
-
-/* GL_OES_texture_half_float */
-#ifndef GL_OES_texture_half_float
-#define GL_HALF_FLOAT_OES 0x8D61
-#endif
-
-/* GL_OES_texture_half_float_linear */
-/* No new tokens introduced by this extension. */
-
-/* GL_OES_texture_npot */
-/* No new tokens introduced by this extension. */
-
-/* GL_OES_vertex_array_object */
-#ifndef GL_OES_vertex_array_object
-#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5
-#endif
-
-/* GL_OES_vertex_half_float */
-/* GL_HALF_FLOAT_OES defined in GL_OES_texture_half_float already. */
-
-/* GL_OES_vertex_type_10_10_10_2 */
-#ifndef GL_OES_vertex_type_10_10_10_2
-#define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6
-#define GL_INT_10_10_10_2_OES 0x8DF7
-#endif
-
-/*------------------------------------------------------------------------*
- * KHR extension tokens
- *------------------------------------------------------------------------*/
#ifndef GL_KHR_debug
-typedef void (GL_APIENTRYP GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const GLvoid *userParam);
-#define GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR 0x8242
-#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR 0x8243
-#define GL_DEBUG_CALLBACK_FUNCTION_KHR 0x8244
-#define GL_DEBUG_CALLBACK_USER_PARAM_KHR 0x8245
-#define GL_DEBUG_SOURCE_API_KHR 0x8246
-#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR 0x8247
-#define GL_DEBUG_SOURCE_SHADER_COMPILER_KHR 0x8248
-#define GL_DEBUG_SOURCE_THIRD_PARTY_KHR 0x8249
-#define GL_DEBUG_SOURCE_APPLICATION_KHR 0x824A
-#define GL_DEBUG_SOURCE_OTHER_KHR 0x824B
-#define GL_DEBUG_TYPE_ERROR_KHR 0x824C
-#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR 0x824D
-#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR 0x824E
-#define GL_DEBUG_TYPE_PORTABILITY_KHR 0x824F
-#define GL_DEBUG_TYPE_PERFORMANCE_KHR 0x8250
-#define GL_DEBUG_TYPE_OTHER_KHR 0x8251
-#define GL_DEBUG_TYPE_MARKER_KHR 0x8268
-#define GL_DEBUG_TYPE_PUSH_GROUP_KHR 0x8269
-#define GL_DEBUG_TYPE_POP_GROUP_KHR 0x826A
-#define GL_DEBUG_SEVERITY_NOTIFICATION_KHR 0x826B
-#define GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR 0x826C
-#define GL_DEBUG_GROUP_STACK_DEPTH_KHR 0x826D
-#define GL_BUFFER_KHR 0x82E0
-#define GL_SHADER_KHR 0x82E1
-#define GL_PROGRAM_KHR 0x82E2
-#define GL_QUERY_KHR 0x82E3
-/* PROGRAM_PIPELINE only in GL */
-#define GL_SAMPLER_KHR 0x82E6
-/* DISPLAY_LIST only in GL */
-#define GL_MAX_LABEL_LENGTH_KHR 0x82E8
-#define GL_MAX_DEBUG_MESSAGE_LENGTH_KHR 0x9143
-#define GL_MAX_DEBUG_LOGGED_MESSAGES_KHR 0x9144
-#define GL_DEBUG_LOGGED_MESSAGES_KHR 0x9145
-#define GL_DEBUG_SEVERITY_HIGH_KHR 0x9146
-#define GL_DEBUG_SEVERITY_MEDIUM_KHR 0x9147
-#define GL_DEBUG_SEVERITY_LOW_KHR 0x9148
-#define GL_DEBUG_OUTPUT_KHR 0x92E0
-#define GL_CONTEXT_FLAG_DEBUG_BIT_KHR 0x00000002
-#define GL_STACK_OVERFLOW_KHR 0x0503
-#define GL_STACK_UNDERFLOW_KHR 0x0504
+#define GL_KHR_debug 1
+typedef void (GL_APIENTRY *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
+#define GL_SAMPLER 0x82E6
+#define GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR 0x8242
+#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR 0x8243
+#define GL_DEBUG_CALLBACK_FUNCTION_KHR 0x8244
+#define GL_DEBUG_CALLBACK_USER_PARAM_KHR 0x8245
+#define GL_DEBUG_SOURCE_API_KHR 0x8246
+#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR 0x8247
+#define GL_DEBUG_SOURCE_SHADER_COMPILER_KHR 0x8248
+#define GL_DEBUG_SOURCE_THIRD_PARTY_KHR 0x8249
+#define GL_DEBUG_SOURCE_APPLICATION_KHR 0x824A
+#define GL_DEBUG_SOURCE_OTHER_KHR 0x824B
+#define GL_DEBUG_TYPE_ERROR_KHR 0x824C
+#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR 0x824D
+#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR 0x824E
+#define GL_DEBUG_TYPE_PORTABILITY_KHR 0x824F
+#define GL_DEBUG_TYPE_PERFORMANCE_KHR 0x8250
+#define GL_DEBUG_TYPE_OTHER_KHR 0x8251
+#define GL_DEBUG_TYPE_MARKER_KHR 0x8268
+#define GL_DEBUG_TYPE_PUSH_GROUP_KHR 0x8269
+#define GL_DEBUG_TYPE_POP_GROUP_KHR 0x826A
+#define GL_DEBUG_SEVERITY_NOTIFICATION_KHR 0x826B
+#define GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR 0x826C
+#define GL_DEBUG_GROUP_STACK_DEPTH_KHR 0x826D
+#define GL_BUFFER_KHR 0x82E0
+#define GL_SHADER_KHR 0x82E1
+#define GL_PROGRAM_KHR 0x82E2
+#define GL_VERTEX_ARRAY_KHR 0x8074
+#define GL_QUERY_KHR 0x82E3
+#define GL_SAMPLER_KHR 0x82E6
+#define GL_MAX_LABEL_LENGTH_KHR 0x82E8
+#define GL_MAX_DEBUG_MESSAGE_LENGTH_KHR 0x9143
+#define GL_MAX_DEBUG_LOGGED_MESSAGES_KHR 0x9144
+#define GL_DEBUG_LOGGED_MESSAGES_KHR 0x9145
+#define GL_DEBUG_SEVERITY_HIGH_KHR 0x9146
+#define GL_DEBUG_SEVERITY_MEDIUM_KHR 0x9147
+#define GL_DEBUG_SEVERITY_LOW_KHR 0x9148
+#define GL_DEBUG_OUTPUT_KHR 0x92E0
+#define GL_CONTEXT_FLAG_DEBUG_BIT_KHR 0x00000002
+#define GL_STACK_OVERFLOW_KHR 0x0503
+#define GL_STACK_UNDERFLOW_KHR 0x0504
+typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLKHRPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
+typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTKHRPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
+typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKKHRPROC) (GLDEBUGPROCKHR callback, const void *userParam);
+typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
+typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPKHRPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message);
+typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPKHRPROC) (void);
+typedef void (GL_APIENTRYP PFNGLOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
+typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
+typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei length, const GLchar *label);
+typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
+typedef void (GL_APIENTRYP PFNGLGETPOINTERVKHRPROC) (GLenum pname, void **params);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDebugMessageControlKHR (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
+GL_APICALL void GL_APIENTRY glDebugMessageInsertKHR (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
+GL_APICALL void GL_APIENTRY glDebugMessageCallbackKHR (GLDEBUGPROCKHR callback, const void *userParam);
+GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLogKHR (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
+GL_APICALL void GL_APIENTRY glPushDebugGroupKHR (GLenum source, GLuint id, GLsizei length, const GLchar *message);
+GL_APICALL void GL_APIENTRY glPopDebugGroupKHR (void);
+GL_APICALL void GL_APIENTRY glObjectLabelKHR (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
+GL_APICALL void GL_APIENTRY glGetObjectLabelKHR (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
+GL_APICALL void GL_APIENTRY glObjectPtrLabelKHR (const void *ptr, GLsizei length, const GLchar *label);
+GL_APICALL void GL_APIENTRY glGetObjectPtrLabelKHR (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
+GL_APICALL void GL_APIENTRY glGetPointervKHR (GLenum pname, void **params);
#endif
+#endif /* GL_KHR_debug */
+
+#ifndef GL_KHR_texture_compression_astc_hdr
+#define GL_KHR_texture_compression_astc_hdr 1
+#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0
+#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1
+#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2
+#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3
+#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4
+#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5
+#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6
+#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7
+#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8
+#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9
+#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA
+#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB
+#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC
+#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD
+#endif /* GL_KHR_texture_compression_astc_hdr */
#ifndef GL_KHR_texture_compression_astc_ldr
-#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0
-#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1
-#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2
-#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3
-#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4
-#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5
-#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6
-#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7
-#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8
-#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9
-#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA
-#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB
-#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC
-#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC
-#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD
-#endif
-
-/*------------------------------------------------------------------------*
- * AMD extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_AMD_compressed_3DC_texture */
-#ifndef GL_AMD_compressed_3DC_texture
-#define GL_3DC_X_AMD 0x87F9
-#define GL_3DC_XY_AMD 0x87FA
-#endif
-
-/* GL_AMD_compressed_ATC_texture */
-#ifndef GL_AMD_compressed_ATC_texture
-#define GL_ATC_RGB_AMD 0x8C92
-#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93
-#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE
-#endif
-
-/* GL_AMD_performance_monitor */
-#ifndef GL_AMD_performance_monitor
-#define GL_COUNTER_TYPE_AMD 0x8BC0
-#define GL_COUNTER_RANGE_AMD 0x8BC1
-#define GL_UNSIGNED_INT64_AMD 0x8BC2
-#define GL_PERCENTAGE_AMD 0x8BC3
-#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4
-#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5
-#define GL_PERFMON_RESULT_AMD 0x8BC6
-#endif
-
-/* GL_AMD_program_binary_Z400 */
-#ifndef GL_AMD_program_binary_Z400
-#define GL_Z400_BINARY_AMD 0x8740
-#endif
-
-/*------------------------------------------------------------------------*
- * ANGLE extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_ANGLE_depth_texture */
-#ifndef GL_ANGLE_depth_texture
-#define GL_DEPTH_COMPONENT 0x1902
-#define GL_DEPTH_STENCIL_OES 0x84F9
-#define GL_UNSIGNED_SHORT 0x1403
-#define GL_UNSIGNED_INT 0x1405
-#define GL_UNSIGNED_INT_24_8_OES 0x84FA
-#define GL_DEPTH_COMPONENT16 0x81A5
-#define GL_DEPTH_COMPONENT32_OES 0x81A7
-#define GL_DEPTH24_STENCIL8_OES 0x88F0
-#endif
-
-/* GL_ANGLE_framebuffer_blit */
-#ifndef GL_ANGLE_framebuffer_blit
-#define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8
-#define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9
-#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6
-#define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA
-#endif
-
-/* GL_ANGLE_framebuffer_multisample */
-#ifndef GL_ANGLE_framebuffer_multisample
-#define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56
-#define GL_MAX_SAMPLES_ANGLE 0x8D57
-#endif
-
-/* GL_ANGLE_instanced_arrays */
-#ifndef GL_ANGLE_instanced_arrays
-#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE
-#endif
-
-/* GL_ANGLE_pack_reverse_row_order */
-#ifndef GL_ANGLE_pack_reverse_row_order
-#define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4
-#endif
-
-/* GL_ANGLE_program_binary */
-#ifndef GL_ANGLE_program_binary
-#define GL_PROGRAM_BINARY_ANGLE 0x93A6
-#endif
-
-/* GL_ANGLE_texture_compression_dxt3 */
-#ifndef GL_ANGLE_texture_compression_dxt3
-#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2
-#endif
-
-/* GL_ANGLE_texture_compression_dxt5 */
-#ifndef GL_ANGLE_texture_compression_dxt5
-#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3
-#endif
-
-/* GL_ANGLE_texture_usage */
-#ifndef GL_ANGLE_texture_usage
-#define GL_TEXTURE_USAGE_ANGLE 0x93A2
-#define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3
-#endif
-
-/* GL_ANGLE_translated_shader_source */
-#ifndef GL_ANGLE_translated_shader_source
-#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0
-#endif
-
-/*------------------------------------------------------------------------*
- * APPLE extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_APPLE_copy_texture_levels */
-/* No new tokens introduced by this extension. */
-
-/* GL_APPLE_framebuffer_multisample */
-#ifndef GL_APPLE_framebuffer_multisample
-#define GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE 0x8D56
-#define GL_MAX_SAMPLES_APPLE 0x8D57
-#define GL_READ_FRAMEBUFFER_APPLE 0x8CA8
-#define GL_DRAW_FRAMEBUFFER_APPLE 0x8CA9
-#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE 0x8CA6
-#define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA
-#endif
-
-/* GL_APPLE_rgb_422 */
-#ifndef GL_APPLE_rgb_422
-#define GL_RGB_422_APPLE 0x8A1F
-#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA
-#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB
-#endif
-
-/* GL_APPLE_sync */
-#ifndef GL_APPLE_sync
-
-#define GL_SYNC_OBJECT_APPLE 0x8A53
-#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111
-#define GL_OBJECT_TYPE_APPLE 0x9112
-#define GL_SYNC_CONDITION_APPLE 0x9113
-#define GL_SYNC_STATUS_APPLE 0x9114
-#define GL_SYNC_FLAGS_APPLE 0x9115
-#define GL_SYNC_FENCE_APPLE 0x9116
-#define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117
-#define GL_UNSIGNALED_APPLE 0x9118
-#define GL_SIGNALED_APPLE 0x9119
-#define GL_ALREADY_SIGNALED_APPLE 0x911A
-#define GL_TIMEOUT_EXPIRED_APPLE 0x911B
-#define GL_CONDITION_SATISFIED_APPLE 0x911C
-#define GL_WAIT_FAILED_APPLE 0x911D
-#define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001
-#define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull
-#endif
-
-/* GL_APPLE_texture_format_BGRA8888 */
-#ifndef GL_APPLE_texture_format_BGRA8888
-#define GL_BGRA_EXT 0x80E1
-#endif
-
-/* GL_APPLE_texture_max_level */
-#ifndef GL_APPLE_texture_max_level
-#define GL_TEXTURE_MAX_LEVEL_APPLE 0x813D
-#endif
-
-/*------------------------------------------------------------------------*
- * ARM extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_ARM_mali_program_binary */
-#ifndef GL_ARM_mali_program_binary
-#define GL_MALI_PROGRAM_BINARY_ARM 0x8F61
-#endif
-
-/* GL_ARM_mali_shader_binary */
-#ifndef GL_ARM_mali_shader_binary
-#define GL_MALI_SHADER_BINARY_ARM 0x8F60
-#endif
-
-/* GL_ARM_rgba8 */
-/* No new tokens introduced by this extension. */
-
-/*------------------------------------------------------------------------*
- * EXT extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_EXT_blend_minmax */
-#ifndef GL_EXT_blend_minmax
-#define GL_MIN_EXT 0x8007
-#define GL_MAX_EXT 0x8008
-#endif
-
-/* GL_EXT_color_buffer_half_float */
-#ifndef GL_EXT_color_buffer_half_float
-#define GL_RGBA16F_EXT 0x881A
-#define GL_RGB16F_EXT 0x881B
-#define GL_RG16F_EXT 0x822F
-#define GL_R16F_EXT 0x822D
-#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT 0x8211
-#define GL_UNSIGNED_NORMALIZED_EXT 0x8C17
-#endif
-
-/* GL_EXT_debug_label */
-#ifndef GL_EXT_debug_label
-#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F
-#define GL_PROGRAM_OBJECT_EXT 0x8B40
-#define GL_SHADER_OBJECT_EXT 0x8B48
-#define GL_BUFFER_OBJECT_EXT 0x9151
-#define GL_QUERY_OBJECT_EXT 0x9153
-#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154
-#endif
-
-/* GL_EXT_debug_marker */
-/* No new tokens introduced by this extension. */
-
-/* GL_EXT_discard_framebuffer */
-#ifndef GL_EXT_discard_framebuffer
-#define GL_COLOR_EXT 0x1800
-#define GL_DEPTH_EXT 0x1801
-#define GL_STENCIL_EXT 0x1802
-#endif
-
-#ifndef GL_EXT_disjoint_timer_query
-#define GL_QUERY_COUNTER_BITS_EXT 0x8864
-#define GL_CURRENT_QUERY_EXT 0x8865
-#define GL_QUERY_RESULT_EXT 0x8866
-#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867
-#define GL_TIME_ELAPSED_EXT 0x88BF
-#define GL_TIMESTAMP_EXT 0x8E28
-#define GL_GPU_DISJOINT_EXT 0x8FBB
-#endif
-
-#ifndef GL_EXT_draw_buffers
-#define GL_EXT_draw_buffers 1
-#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF
-#define GL_MAX_DRAW_BUFFERS_EXT 0x8824
-#define GL_DRAW_BUFFER0_EXT 0x8825
-#define GL_DRAW_BUFFER1_EXT 0x8826
-#define GL_DRAW_BUFFER2_EXT 0x8827
-#define GL_DRAW_BUFFER3_EXT 0x8828
-#define GL_DRAW_BUFFER4_EXT 0x8829
-#define GL_DRAW_BUFFER5_EXT 0x882A
-#define GL_DRAW_BUFFER6_EXT 0x882B
-#define GL_DRAW_BUFFER7_EXT 0x882C
-#define GL_DRAW_BUFFER8_EXT 0x882D
-#define GL_DRAW_BUFFER9_EXT 0x882E
-#define GL_DRAW_BUFFER10_EXT 0x882F
-#define GL_DRAW_BUFFER11_EXT 0x8830
-#define GL_DRAW_BUFFER12_EXT 0x8831
-#define GL_DRAW_BUFFER13_EXT 0x8832
-#define GL_DRAW_BUFFER14_EXT 0x8833
-#define GL_DRAW_BUFFER15_EXT 0x8834
-#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
-#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1
-#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2
-#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3
-#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4
-#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5
-#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6
-#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7
-#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8
-#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9
-#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA
-#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB
-#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC
-#define GL_COLOR_ATTACHMENT13_EXT 0x8CED
-#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE
-#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF
-#endif
-
-/* GL_EXT_map_buffer_range */
-#ifndef GL_EXT_map_buffer_range
-#define GL_MAP_READ_BIT_EXT 0x0001
-#define GL_MAP_WRITE_BIT_EXT 0x0002
-#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004
-#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008
-#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010
-#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020
-#endif
-
-/* GL_EXT_multisampled_render_to_texture */
-#ifndef GL_EXT_multisampled_render_to_texture
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C
-/* reuse values from GL_EXT_framebuffer_multisample (desktop extension) */
-#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
-#define GL_MAX_SAMPLES_EXT 0x8D57
-#endif
-
-/* GL_EXT_multiview_draw_buffers */
-#ifndef GL_EXT_multiview_draw_buffers
-#define GL_COLOR_ATTACHMENT_EXT 0x90F0
-#define GL_MULTIVIEW_EXT 0x90F1
-#define GL_DRAW_BUFFER_EXT 0x0C01
-#define GL_READ_BUFFER_EXT 0x0C02
-#define GL_MAX_MULTIVIEW_BUFFERS_EXT 0x90F2
-#endif
-
-/* GL_EXT_multi_draw_arrays */
-/* No new tokens introduced by this extension. */
-
-/* GL_EXT_occlusion_query_boolean */
-#ifndef GL_EXT_occlusion_query_boolean
-#define GL_ANY_SAMPLES_PASSED_EXT 0x8C2F
-#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A
-#define GL_CURRENT_QUERY_EXT 0x8865
-#define GL_QUERY_RESULT_EXT 0x8866
-#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867
-#endif
-
-/* GL_EXT_read_format_bgra */
-#ifndef GL_EXT_read_format_bgra
-#define GL_BGRA_EXT 0x80E1
-#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365
-#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366
-#endif
-
-/* GL_EXT_robustness */
-#ifndef GL_EXT_robustness
-/* reuse GL_NO_ERROR */
-#define GL_GUILTY_CONTEXT_RESET_EXT 0x8253
-#define GL_INNOCENT_CONTEXT_RESET_EXT 0x8254
-#define GL_UNKNOWN_CONTEXT_RESET_EXT 0x8255
-#define GL_CONTEXT_ROBUST_ACCESS_EXT 0x90F3
-#define GL_RESET_NOTIFICATION_STRATEGY_EXT 0x8256
-#define GL_LOSE_CONTEXT_ON_RESET_EXT 0x8252
-#define GL_NO_RESET_NOTIFICATION_EXT 0x8261
-#endif
-
-/* GL_EXT_separate_shader_objects */
-#ifndef GL_EXT_separate_shader_objects
-#define GL_VERTEX_SHADER_BIT_EXT 0x00000001
-#define GL_FRAGMENT_SHADER_BIT_EXT 0x00000002
-#define GL_ALL_SHADER_BITS_EXT 0xFFFFFFFF
-#define GL_PROGRAM_SEPARABLE_EXT 0x8258
-#define GL_ACTIVE_PROGRAM_EXT 0x8259
-#define GL_PROGRAM_PIPELINE_BINDING_EXT 0x825A
-#endif
-
-/* GL_EXT_shader_framebuffer_fetch */
-#ifndef GL_EXT_shader_framebuffer_fetch
-#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52
-#endif
-
-/* GL_EXT_shader_texture_lod */
-/* No new tokens introduced by this extension. */
-
-/* GL_EXT_shadow_samplers */
-#ifndef GL_EXT_shadow_samplers
-#define GL_TEXTURE_COMPARE_MODE_EXT 0x884C
-#define GL_TEXTURE_COMPARE_FUNC_EXT 0x884D
-#define GL_COMPARE_REF_TO_TEXTURE_EXT 0x884E
-#define GL_SAMPLER_2D_SHADOW_EXT 0x8B62
-#endif
-
-/* GL_EXT_sRGB */
-#ifndef GL_EXT_sRGB
-#define GL_SRGB_EXT 0x8C40
-#define GL_SRGB_ALPHA_EXT 0x8C42
-#define GL_SRGB8_ALPHA8_EXT 0x8C43
-#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210
-#endif
-
-/* GL_EXT_texture_compression_dxt1 */
-#ifndef GL_EXT_texture_compression_dxt1
-#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
-#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
-#endif
-
-/* GL_EXT_texture_filter_anisotropic */
-#ifndef GL_EXT_texture_filter_anisotropic
-#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
-#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
-#endif
-
-/* GL_EXT_texture_format_BGRA8888 */
-#ifndef GL_EXT_texture_format_BGRA8888
-#define GL_BGRA_EXT 0x80E1
-#endif
-
-/* GL_EXT_texture_rg */
-#ifndef GL_EXT_texture_rg
-#define GL_RED_EXT 0x1903
-#define GL_RG_EXT 0x8227
-#define GL_R8_EXT 0x8229
-#define GL_RG8_EXT 0x822B
-#endif
-
-/* GL_EXT_texture_storage */
-#ifndef GL_EXT_texture_storage
-#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F
-#define GL_ALPHA8_EXT 0x803C
-#define GL_LUMINANCE8_EXT 0x8040
-#define GL_LUMINANCE8_ALPHA8_EXT 0x8045
-#define GL_RGBA32F_EXT 0x8814
-#define GL_RGB32F_EXT 0x8815
-#define GL_ALPHA32F_EXT 0x8816
-#define GL_LUMINANCE32F_EXT 0x8818
-#define GL_LUMINANCE_ALPHA32F_EXT 0x8819
-/* reuse GL_RGBA16F_EXT */
-/* reuse GL_RGB16F_EXT */
-#define GL_ALPHA16F_EXT 0x881C
-#define GL_LUMINANCE16F_EXT 0x881E
-#define GL_LUMINANCE_ALPHA16F_EXT 0x881F
-#define GL_RGB10_A2_EXT 0x8059
-#define GL_RGB10_EXT 0x8052
-#define GL_BGRA8_EXT 0x93A1
-#define GL_R8_EXT 0x8229
-#define GL_RG8_EXT 0x822B
-#define GL_R32F_EXT 0x822E
-#define GL_RG32F_EXT 0x8230
-#define GL_R16F_EXT 0x822D
-#define GL_RG16F_EXT 0x822F
-#endif
-
-/* GL_EXT_texture_type_2_10_10_10_REV */
-#ifndef GL_EXT_texture_type_2_10_10_10_REV
-#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368
-#endif
-
-/* GL_EXT_unpack_subimage */
-#ifndef GL_EXT_unpack_subimage
-#define GL_UNPACK_ROW_LENGTH_EXT 0x0CF2
-#define GL_UNPACK_SKIP_ROWS_EXT 0x0CF3
-#define GL_UNPACK_SKIP_PIXELS_EXT 0x0CF4
-#endif
-
-/*------------------------------------------------------------------------*
- * DMP extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_DMP_shader_binary */
-#ifndef GL_DMP_shader_binary
-#define GL_SHADER_BINARY_DMP 0x9250
-#endif
-
-/*------------------------------------------------------------------------*
- * FJ extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_FJ_shader_binary_GCCSO */
-#ifndef GL_FJ_shader_binary_GCCSO
-#define GL_GCCSO_SHADER_BINARY_FJ 0x9260
-#endif
-
-/*------------------------------------------------------------------------*
- * IMG extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_IMG_program_binary */
-#ifndef GL_IMG_program_binary
-#define GL_SGX_PROGRAM_BINARY_IMG 0x9130
-#endif
-
-/* GL_IMG_read_format */
-#ifndef GL_IMG_read_format
-#define GL_BGRA_IMG 0x80E1
-#define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG 0x8365
-#endif
-
-/* GL_IMG_shader_binary */
-#ifndef GL_IMG_shader_binary
-#define GL_SGX_BINARY_IMG 0x8C0A
-#endif
-
-/* GL_IMG_texture_compression_pvrtc */
-#ifndef GL_IMG_texture_compression_pvrtc
-#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
-#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01
-#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
-#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
-#endif
-
-/* GL_IMG_texture_compression_pvrtc2 */
-#ifndef GL_IMG_texture_compression_pvrtc2
-#define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137
-#define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138
-#endif
-
-/* GL_IMG_multisampled_render_to_texture */
-#ifndef GL_IMG_multisampled_render_to_texture
-#define GL_RENDERBUFFER_SAMPLES_IMG 0x9133
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134
-#define GL_MAX_SAMPLES_IMG 0x9135
-#define GL_TEXTURE_SAMPLES_IMG 0x9136
-#endif
-
-/*------------------------------------------------------------------------*
- * NV extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_NV_coverage_sample */
-#ifndef GL_NV_coverage_sample
-#define GL_COVERAGE_COMPONENT_NV 0x8ED0
-#define GL_COVERAGE_COMPONENT4_NV 0x8ED1
-#define GL_COVERAGE_ATTACHMENT_NV 0x8ED2
-#define GL_COVERAGE_BUFFERS_NV 0x8ED3
-#define GL_COVERAGE_SAMPLES_NV 0x8ED4
-#define GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5
-#define GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6
-#define GL_COVERAGE_AUTOMATIC_NV 0x8ED7
-#define GL_COVERAGE_BUFFER_BIT_NV 0x00008000
-#endif
-
-/* GL_NV_depth_nonlinear */
-#ifndef GL_NV_depth_nonlinear
-#define GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C
-#endif
-
-/* GL_NV_draw_buffers */
-#ifndef GL_NV_draw_buffers
-#define GL_MAX_DRAW_BUFFERS_NV 0x8824
-#define GL_DRAW_BUFFER0_NV 0x8825
-#define GL_DRAW_BUFFER1_NV 0x8826
-#define GL_DRAW_BUFFER2_NV 0x8827
-#define GL_DRAW_BUFFER3_NV 0x8828
-#define GL_DRAW_BUFFER4_NV 0x8829
-#define GL_DRAW_BUFFER5_NV 0x882A
-#define GL_DRAW_BUFFER6_NV 0x882B
-#define GL_DRAW_BUFFER7_NV 0x882C
-#define GL_DRAW_BUFFER8_NV 0x882D
-#define GL_DRAW_BUFFER9_NV 0x882E
-#define GL_DRAW_BUFFER10_NV 0x882F
-#define GL_DRAW_BUFFER11_NV 0x8830
-#define GL_DRAW_BUFFER12_NV 0x8831
-#define GL_DRAW_BUFFER13_NV 0x8832
-#define GL_DRAW_BUFFER14_NV 0x8833
-#define GL_DRAW_BUFFER15_NV 0x8834
-#define GL_COLOR_ATTACHMENT0_NV 0x8CE0
-#define GL_COLOR_ATTACHMENT1_NV 0x8CE1
-#define GL_COLOR_ATTACHMENT2_NV 0x8CE2
-#define GL_COLOR_ATTACHMENT3_NV 0x8CE3
-#define GL_COLOR_ATTACHMENT4_NV 0x8CE4
-#define GL_COLOR_ATTACHMENT5_NV 0x8CE5
-#define GL_COLOR_ATTACHMENT6_NV 0x8CE6
-#define GL_COLOR_ATTACHMENT7_NV 0x8CE7
-#define GL_COLOR_ATTACHMENT8_NV 0x8CE8
-#define GL_COLOR_ATTACHMENT9_NV 0x8CE9
-#define GL_COLOR_ATTACHMENT10_NV 0x8CEA
-#define GL_COLOR_ATTACHMENT11_NV 0x8CEB
-#define GL_COLOR_ATTACHMENT12_NV 0x8CEC
-#define GL_COLOR_ATTACHMENT13_NV 0x8CED
-#define GL_COLOR_ATTACHMENT14_NV 0x8CEE
-#define GL_COLOR_ATTACHMENT15_NV 0x8CEF
-#endif
-
-/* GL_NV_draw_instanced */
-/* No new tokens introduced by this extension. */
-
-/* GL_NV_fbo_color_attachments */
-#ifndef GL_NV_fbo_color_attachments
-#define GL_MAX_COLOR_ATTACHMENTS_NV 0x8CDF
-/* GL_COLOR_ATTACHMENT{0-15}_NV defined in GL_NV_draw_buffers already. */
-#endif
-
-/* GL_NV_fence */
-#ifndef GL_NV_fence
-#define GL_ALL_COMPLETED_NV 0x84F2
-#define GL_FENCE_STATUS_NV 0x84F3
-#define GL_FENCE_CONDITION_NV 0x84F4
-#endif
-
-/* GL_NV_framebuffer_blit */
-#ifndef GL_NV_framebuffer_blit
-#define GL_READ_FRAMEBUFFER_NV 0x8CA8
-#define GL_DRAW_FRAMEBUFFER_NV 0x8CA9
-#define GL_DRAW_FRAMEBUFFER_BINDING_NV 0x8CA6
-#define GL_READ_FRAMEBUFFER_BINDING_NV 0x8CAA
-#endif
-
-/* GL_NV_framebuffer_multisample */
-#ifndef GL_NV_framebuffer_multisample
-#define GL_RENDERBUFFER_SAMPLES_NV 0x8CAB
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV 0x8D56
-#define GL_MAX_SAMPLES_NV 0x8D57
-#endif
-
-/* GL_NV_generate_mipmap_sRGB */
-/* No new tokens introduced by this extension. */
-
-/* GL_NV_instanced_arrays */
-#ifndef GL_NV_instanced_arrays
-#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_NV 0x88FE
-#endif
-
-/* GL_NV_read_buffer */
-#ifndef GL_NV_read_buffer
-#define GL_READ_BUFFER_NV 0x0C02
-#endif
-
-/* GL_NV_read_buffer_front */
-/* No new tokens introduced by this extension. */
-
-/* GL_NV_read_depth */
-/* No new tokens introduced by this extension. */
-
-/* GL_NV_read_depth_stencil */
-/* No new tokens introduced by this extension. */
-
-/* GL_NV_read_stencil */
-/* No new tokens introduced by this extension. */
-
-/* GL_NV_shadow_samplers_array */
-#ifndef GL_NV_shadow_samplers_array
-#define GL_SAMPLER_2D_ARRAY_SHADOW_NV 0x8DC4
-#endif
-
-/* GL_NV_shadow_samplers_cube */
-#ifndef GL_NV_shadow_samplers_cube
-#define GL_SAMPLER_CUBE_SHADOW_NV 0x8DC5
-#endif
-
-/* GL_NV_sRGB_formats */
-#ifndef GL_NV_sRGB_formats
-#define GL_SLUMINANCE_NV 0x8C46
-#define GL_SLUMINANCE_ALPHA_NV 0x8C44
-#define GL_SRGB8_NV 0x8C41
-#define GL_SLUMINANCE8_NV 0x8C47
-#define GL_SLUMINANCE8_ALPHA8_NV 0x8C45
-#define GL_COMPRESSED_SRGB_S3TC_DXT1_NV 0x8C4C
-#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV 0x8C4D
-#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV 0x8C4E
-#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV 0x8C4F
-#define GL_ETC1_SRGB8_NV 0x88EE
-#endif
-
-/* GL_NV_texture_border_clamp */
-#ifndef GL_NV_texture_border_clamp
-#define GL_TEXTURE_BORDER_COLOR_NV 0x1004
-#define GL_CLAMP_TO_BORDER_NV 0x812D
-#endif
-
-/* GL_NV_texture_compression_s3tc_update */
-/* No new tokens introduced by this extension. */
-
-/* GL_NV_texture_npot_2D_mipmap */
-/* No new tokens introduced by this extension. */
-
-/*------------------------------------------------------------------------*
- * QCOM extension tokens
- *------------------------------------------------------------------------*/
-
-/* GL_QCOM_alpha_test */
-#ifndef GL_QCOM_alpha_test
-#define GL_ALPHA_TEST_QCOM 0x0BC0
-#define GL_ALPHA_TEST_FUNC_QCOM 0x0BC1
-#define GL_ALPHA_TEST_REF_QCOM 0x0BC2
-#endif
-
-/* GL_QCOM_binning_control */
-#ifndef GL_QCOM_binning_control
-#define GL_BINNING_CONTROL_HINT_QCOM 0x8FB0
-#define GL_CPU_OPTIMIZED_QCOM 0x8FB1
-#define GL_GPU_OPTIMIZED_QCOM 0x8FB2
-#define GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM 0x8FB3
-#endif
-
-/* GL_QCOM_driver_control */
-/* No new tokens introduced by this extension. */
-
-/* GL_QCOM_extended_get */
-#ifndef GL_QCOM_extended_get
-#define GL_TEXTURE_WIDTH_QCOM 0x8BD2
-#define GL_TEXTURE_HEIGHT_QCOM 0x8BD3
-#define GL_TEXTURE_DEPTH_QCOM 0x8BD4
-#define GL_TEXTURE_INTERNAL_FORMAT_QCOM 0x8BD5
-#define GL_TEXTURE_FORMAT_QCOM 0x8BD6
-#define GL_TEXTURE_TYPE_QCOM 0x8BD7
-#define GL_TEXTURE_IMAGE_VALID_QCOM 0x8BD8
-#define GL_TEXTURE_NUM_LEVELS_QCOM 0x8BD9
-#define GL_TEXTURE_TARGET_QCOM 0x8BDA
-#define GL_TEXTURE_OBJECT_VALID_QCOM 0x8BDB
-#define GL_STATE_RESTORE 0x8BDC
-#endif
-
-/* GL_QCOM_extended_get2 */
-/* No new tokens introduced by this extension. */
-
-/* GL_QCOM_perfmon_global_mode */
-#ifndef GL_QCOM_perfmon_global_mode
-#define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0
-#endif
-
-/* GL_QCOM_writeonly_rendering */
-#ifndef GL_QCOM_writeonly_rendering
-#define GL_WRITEONLY_RENDERING_QCOM 0x8823
-#endif
-
-/* GL_QCOM_tiled_rendering */
-#ifndef GL_QCOM_tiled_rendering
-#define GL_COLOR_BUFFER_BIT0_QCOM 0x00000001
-#define GL_COLOR_BUFFER_BIT1_QCOM 0x00000002
-#define GL_COLOR_BUFFER_BIT2_QCOM 0x00000004
-#define GL_COLOR_BUFFER_BIT3_QCOM 0x00000008
-#define GL_COLOR_BUFFER_BIT4_QCOM 0x00000010
-#define GL_COLOR_BUFFER_BIT5_QCOM 0x00000020
-#define GL_COLOR_BUFFER_BIT6_QCOM 0x00000040
-#define GL_COLOR_BUFFER_BIT7_QCOM 0x00000080
-#define GL_DEPTH_BUFFER_BIT0_QCOM 0x00000100
-#define GL_DEPTH_BUFFER_BIT1_QCOM 0x00000200
-#define GL_DEPTH_BUFFER_BIT2_QCOM 0x00000400
-#define GL_DEPTH_BUFFER_BIT3_QCOM 0x00000800
-#define GL_DEPTH_BUFFER_BIT4_QCOM 0x00001000
-#define GL_DEPTH_BUFFER_BIT5_QCOM 0x00002000
-#define GL_DEPTH_BUFFER_BIT6_QCOM 0x00004000
-#define GL_DEPTH_BUFFER_BIT7_QCOM 0x00008000
-#define GL_STENCIL_BUFFER_BIT0_QCOM 0x00010000
-#define GL_STENCIL_BUFFER_BIT1_QCOM 0x00020000
-#define GL_STENCIL_BUFFER_BIT2_QCOM 0x00040000
-#define GL_STENCIL_BUFFER_BIT3_QCOM 0x00080000
-#define GL_STENCIL_BUFFER_BIT4_QCOM 0x00100000
-#define GL_STENCIL_BUFFER_BIT5_QCOM 0x00200000
-#define GL_STENCIL_BUFFER_BIT6_QCOM 0x00400000
-#define GL_STENCIL_BUFFER_BIT7_QCOM 0x00800000
-#define GL_MULTISAMPLE_BUFFER_BIT0_QCOM 0x01000000
-#define GL_MULTISAMPLE_BUFFER_BIT1_QCOM 0x02000000
-#define GL_MULTISAMPLE_BUFFER_BIT2_QCOM 0x04000000
-#define GL_MULTISAMPLE_BUFFER_BIT3_QCOM 0x08000000
-#define GL_MULTISAMPLE_BUFFER_BIT4_QCOM 0x10000000
-#define GL_MULTISAMPLE_BUFFER_BIT5_QCOM 0x20000000
-#define GL_MULTISAMPLE_BUFFER_BIT6_QCOM 0x40000000
-#define GL_MULTISAMPLE_BUFFER_BIT7_QCOM 0x80000000
-#endif
-
-/*------------------------------------------------------------------------*
- * VIV extension tokens
- *------------------------------------------------------------------------*/
+#define GL_KHR_texture_compression_astc_ldr 1
+#endif /* GL_KHR_texture_compression_astc_ldr */
-/* GL_VIV_shader_binary */
-#ifndef GL_VIV_shader_binary
-#define GL_SHADER_BINARY_VIV 0x8FC4
+#ifndef GL_OES_EGL_image
+#define GL_OES_EGL_image 1
+typedef void *GLeglImageOES;
+typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image);
+typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image);
+GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image);
#endif
+#endif /* GL_OES_EGL_image */
-/*------------------------------------------------------------------------*
- * End of extension tokens, start of corresponding extension functions
- *------------------------------------------------------------------------*/
-
-/*------------------------------------------------------------------------*
- * OES extension functions
- *------------------------------------------------------------------------*/
+#ifndef GL_OES_EGL_image_external
+#define GL_OES_EGL_image_external 1
+#define GL_TEXTURE_EXTERNAL_OES 0x8D65
+#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67
+#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68
+#define GL_SAMPLER_EXTERNAL_OES 0x8D66
+#endif /* GL_OES_EGL_image_external */
-/* GL_OES_compressed_ETC1_RGB8_texture */
#ifndef GL_OES_compressed_ETC1_RGB8_texture
#define GL_OES_compressed_ETC1_RGB8_texture 1
-#endif
+#define GL_ETC1_RGB8_OES 0x8D64
+#endif /* GL_OES_compressed_ETC1_RGB8_texture */
-/* GL_OES_compressed_paletted_texture */
#ifndef GL_OES_compressed_paletted_texture
#define GL_OES_compressed_paletted_texture 1
-#endif
+#define GL_PALETTE4_RGB8_OES 0x8B90
+#define GL_PALETTE4_RGBA8_OES 0x8B91
+#define GL_PALETTE4_R5_G6_B5_OES 0x8B92
+#define GL_PALETTE4_RGBA4_OES 0x8B93
+#define GL_PALETTE4_RGB5_A1_OES 0x8B94
+#define GL_PALETTE8_RGB8_OES 0x8B95
+#define GL_PALETTE8_RGBA8_OES 0x8B96
+#define GL_PALETTE8_R5_G6_B5_OES 0x8B97
+#define GL_PALETTE8_RGBA4_OES 0x8B98
+#define GL_PALETTE8_RGB5_A1_OES 0x8B99
+#endif /* GL_OES_compressed_paletted_texture */
-/* GL_OES_depth24 */
#ifndef GL_OES_depth24
#define GL_OES_depth24 1
-#endif
+#define GL_DEPTH_COMPONENT24_OES 0x81A6
+#endif /* GL_OES_depth24 */
-/* GL_OES_depth32 */
#ifndef GL_OES_depth32
#define GL_OES_depth32 1
-#endif
+#define GL_DEPTH_COMPONENT32_OES 0x81A7
+#endif /* GL_OES_depth32 */
-/* GL_OES_depth_texture */
#ifndef GL_OES_depth_texture
#define GL_OES_depth_texture 1
-#endif
+#endif /* GL_OES_depth_texture */
-/* GL_OES_EGL_image */
-#ifndef GL_OES_EGL_image
-#define GL_OES_EGL_image 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image);
-GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image);
-#endif
-typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image);
-typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image);
-#endif
-
-/* GL_OES_EGL_image_external */
-#ifndef GL_OES_EGL_image_external
-#define GL_OES_EGL_image_external 1
-/* glEGLImageTargetTexture2DOES defined in GL_OES_EGL_image already. */
-#endif
-
-/* GL_OES_element_index_uint */
#ifndef GL_OES_element_index_uint
#define GL_OES_element_index_uint 1
-#endif
+#endif /* GL_OES_element_index_uint */
-/* GL_OES_fbo_render_mipmap */
#ifndef GL_OES_fbo_render_mipmap
#define GL_OES_fbo_render_mipmap 1
-#endif
+#endif /* GL_OES_fbo_render_mipmap */
-/* GL_OES_fragment_precision_high */
#ifndef GL_OES_fragment_precision_high
#define GL_OES_fragment_precision_high 1
-#endif
+#endif /* GL_OES_fragment_precision_high */
-/* GL_OES_get_program_binary */
#ifndef GL_OES_get_program_binary
#define GL_OES_get_program_binary 1
+#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741
+#define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE
+#define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF
+typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary);
+typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLint length);
#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glGetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
-GL_APICALL void GL_APIENTRY glProgramBinaryOES (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length);
-#endif
-typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary);
-typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length);
+GL_APICALL void GL_APIENTRY glGetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary);
+GL_APICALL void GL_APIENTRY glProgramBinaryOES (GLuint program, GLenum binaryFormat, const void *binary, GLint length);
#endif
+#endif /* GL_OES_get_program_binary */
-/* GL_OES_mapbuffer */
#ifndef GL_OES_mapbuffer
#define GL_OES_mapbuffer 1
+#define GL_WRITE_ONLY_OES 0x88B9
+#define GL_BUFFER_ACCESS_OES 0x88BB
+#define GL_BUFFER_MAPPED_OES 0x88BC
+#define GL_BUFFER_MAP_POINTER_OES 0x88BD
+typedef void *(GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access);
+typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target);
+typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, void **params);
#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void* GL_APIENTRY glMapBufferOES (GLenum target, GLenum access);
+GL_APICALL void *GL_APIENTRY glMapBufferOES (GLenum target, GLenum access);
GL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target);
-GL_APICALL void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, GLvoid** params);
-#endif
-typedef void* (GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access);
-typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target);
-typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, GLvoid** params);
+GL_APICALL void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, void **params);
#endif
+#endif /* GL_OES_mapbuffer */
-/* GL_OES_packed_depth_stencil */
#ifndef GL_OES_packed_depth_stencil
#define GL_OES_packed_depth_stencil 1
-#endif
+#define GL_DEPTH_STENCIL_OES 0x84F9
+#define GL_UNSIGNED_INT_24_8_OES 0x84FA
+#define GL_DEPTH24_STENCIL8_OES 0x88F0
+#endif /* GL_OES_packed_depth_stencil */
-/* GL_OES_required_internalformat */
#ifndef GL_OES_required_internalformat
#define GL_OES_required_internalformat 1
-#endif
+#define GL_ALPHA8_OES 0x803C
+#define GL_DEPTH_COMPONENT16_OES 0x81A5
+#define GL_LUMINANCE4_ALPHA4_OES 0x8043
+#define GL_LUMINANCE8_ALPHA8_OES 0x8045
+#define GL_LUMINANCE8_OES 0x8040
+#define GL_RGBA4_OES 0x8056
+#define GL_RGB5_A1_OES 0x8057
+#define GL_RGB565_OES 0x8D62
+#define GL_RGB8_OES 0x8051
+#define GL_RGBA8_OES 0x8058
+#define GL_RGB10_EXT 0x8052
+#define GL_RGB10_A2_EXT 0x8059
+#endif /* GL_OES_required_internalformat */
-/* GL_OES_rgb8_rgba8 */
#ifndef GL_OES_rgb8_rgba8
#define GL_OES_rgb8_rgba8 1
-#endif
+#endif /* GL_OES_rgb8_rgba8 */
-/* GL_OES_standard_derivatives */
#ifndef GL_OES_standard_derivatives
#define GL_OES_standard_derivatives 1
-#endif
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B
+#endif /* GL_OES_standard_derivatives */
-/* GL_OES_stencil1 */
#ifndef GL_OES_stencil1
#define GL_OES_stencil1 1
-#endif
+#define GL_STENCIL_INDEX1_OES 0x8D46
+#endif /* GL_OES_stencil1 */
-/* GL_OES_stencil4 */
#ifndef GL_OES_stencil4
#define GL_OES_stencil4 1
-#endif
+#define GL_STENCIL_INDEX4_OES 0x8D47
+#endif /* GL_OES_stencil4 */
#ifndef GL_OES_surfaceless_context
#define GL_OES_surfaceless_context 1
-#endif
+#define GL_FRAMEBUFFER_UNDEFINED_OES 0x8219
+#endif /* GL_OES_surfaceless_context */
-/* GL_OES_texture_3D */
#ifndef GL_OES_texture_3D
#define GL_OES_texture_3D 1
+#define GL_TEXTURE_WRAP_R_OES 0x8072
+#define GL_TEXTURE_3D_OES 0x806F
+#define GL_TEXTURE_BINDING_3D_OES 0x806A
+#define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073
+#define GL_SAMPLER_3D_OES 0x8B5F
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4
+typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);
+typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);
+typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data);
+typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOESPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
-GL_APICALL void GL_APIENTRY glTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels);
+GL_APICALL void GL_APIENTRY glTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);
+GL_APICALL void GL_APIENTRY glTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);
GL_APICALL void GL_APIENTRY glCopyTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data);
-GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data);
+GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data);
+GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);
GL_APICALL void GL_APIENTRY glFramebufferTexture3DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
#endif
-typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
-typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels);
-typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data);
-typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) (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 (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOES) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
-#endif
+#endif /* GL_OES_texture_3D */
+
+#ifndef GL_OES_texture_compression_astc
+#define GL_OES_texture_compression_astc 1
+#define GL_COMPRESSED_RGBA_ASTC_3x3x3_OES 0x93C0
+#define GL_COMPRESSED_RGBA_ASTC_4x3x3_OES 0x93C1
+#define GL_COMPRESSED_RGBA_ASTC_4x4x3_OES 0x93C2
+#define GL_COMPRESSED_RGBA_ASTC_4x4x4_OES 0x93C3
+#define GL_COMPRESSED_RGBA_ASTC_5x4x4_OES 0x93C4
+#define GL_COMPRESSED_RGBA_ASTC_5x5x4_OES 0x93C5
+#define GL_COMPRESSED_RGBA_ASTC_5x5x5_OES 0x93C6
+#define GL_COMPRESSED_RGBA_ASTC_6x5x5_OES 0x93C7
+#define GL_COMPRESSED_RGBA_ASTC_6x6x5_OES 0x93C8
+#define GL_COMPRESSED_RGBA_ASTC_6x6x6_OES 0x93C9
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES 0x93E0
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES 0x93E1
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES 0x93E2
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES 0x93E3
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES 0x93E4
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES 0x93E5
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES 0x93E6
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES 0x93E7
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES 0x93E8
+#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES 0x93E9
+#endif /* GL_OES_texture_compression_astc */
-/* GL_OES_texture_float */
#ifndef GL_OES_texture_float
#define GL_OES_texture_float 1
-#endif
+#endif /* GL_OES_texture_float */
-/* GL_OES_texture_float_linear */
#ifndef GL_OES_texture_float_linear
#define GL_OES_texture_float_linear 1
-#endif
+#endif /* GL_OES_texture_float_linear */
-/* GL_OES_texture_half_float */
#ifndef GL_OES_texture_half_float
#define GL_OES_texture_half_float 1
-#endif
+#define GL_HALF_FLOAT_OES 0x8D61
+#endif /* GL_OES_texture_half_float */
-/* GL_OES_texture_half_float_linear */
#ifndef GL_OES_texture_half_float_linear
#define GL_OES_texture_half_float_linear 1
-#endif
+#endif /* GL_OES_texture_half_float_linear */
-/* GL_OES_texture_npot */
#ifndef GL_OES_texture_npot
#define GL_OES_texture_npot 1
-#endif
+#endif /* GL_OES_texture_npot */
-/* GL_OES_vertex_array_object */
#ifndef GL_OES_vertex_array_object
#define GL_OES_vertex_array_object 1
+#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5
+typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array);
+typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays);
+typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays);
+typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glBindVertexArrayOES (GLuint array);
GL_APICALL void GL_APIENTRY glDeleteVertexArraysOES (GLsizei n, const GLuint *arrays);
GL_APICALL void GL_APIENTRY glGenVertexArraysOES (GLsizei n, GLuint *arrays);
GL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES (GLuint array);
#endif
-typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array);
-typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays);
-typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays);
-typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array);
-#endif
+#endif /* GL_OES_vertex_array_object */
-/* GL_OES_vertex_half_float */
#ifndef GL_OES_vertex_half_float
#define GL_OES_vertex_half_float 1
-#endif
+#endif /* GL_OES_vertex_half_float */
-/* GL_OES_vertex_type_10_10_10_2 */
#ifndef GL_OES_vertex_type_10_10_10_2
#define GL_OES_vertex_type_10_10_10_2 1
-#endif
-
-/*------------------------------------------------------------------------*
- * KHR extension functions
- *------------------------------------------------------------------------*/
-
-#ifndef GL_KHR_debug
-#define GL_KHR_debug 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glDebugMessageControlKHR (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
-GL_APICALL void GL_APIENTRY glDebugMessageInsertKHR (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
-GL_APICALL void GL_APIENTRY glDebugMessageCallbackKHR (GLDEBUGPROCKHR callback, const void *userParam);
-GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLogKHR (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
-GL_APICALL void GL_APIENTRY glPushDebugGroupKHR (GLenum source, GLuint id, GLsizei length, const GLchar *message);
-GL_APICALL void GL_APIENTRY glPopDebugGroupKHR (void);
-GL_APICALL void GL_APIENTRY glObjectLabelKHR (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
-GL_APICALL void GL_APIENTRY glGetObjectLabelKHR (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
-GL_APICALL void GL_APIENTRY glObjectPtrLabelKHR (const void *ptr, GLsizei length, const GLchar *label);
-GL_APICALL void GL_APIENTRY glGetObjectPtrLabelKHR (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
-GL_APICALL void GL_APIENTRY glGetPointervKHR (GLenum pname, void **params);
-#endif
-typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLKHRPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
-typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTKHRPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
-typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKKHRPROC) (GLDEBUGPROCKHR callback, const void *userParam);
-typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
-typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPKHRPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message);
-typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPKHRPROC) (void);
-typedef void (GL_APIENTRYP PFNGLOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
-typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
-typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei length, const GLchar *label);
-typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
-typedef void (GL_APIENTRYP PFNGLGETPOINTERVKHRPROC) (GLenum pname, void **params);
-#endif
-
-#ifndef GL_KHR_texture_compression_astc_ldr
-#define GL_KHR_texture_compression_astc_ldr 1
-#endif
-
+#define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6
+#define GL_INT_10_10_10_2_OES 0x8DF7
+#endif /* GL_OES_vertex_type_10_10_10_2 */
-/*------------------------------------------------------------------------*
- * AMD extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_AMD_compressed_3DC_texture */
#ifndef GL_AMD_compressed_3DC_texture
#define GL_AMD_compressed_3DC_texture 1
-#endif
+#define GL_3DC_X_AMD 0x87F9
+#define GL_3DC_XY_AMD 0x87FA
+#endif /* GL_AMD_compressed_3DC_texture */
-/* GL_AMD_compressed_ATC_texture */
#ifndef GL_AMD_compressed_ATC_texture
#define GL_AMD_compressed_ATC_texture 1
-#endif
+#define GL_ATC_RGB_AMD 0x8C92
+#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93
+#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE
+#endif /* GL_AMD_compressed_ATC_texture */
-/* AMD_performance_monitor */
#ifndef GL_AMD_performance_monitor
#define GL_AMD_performance_monitor 1
+#define GL_COUNTER_TYPE_AMD 0x8BC0
+#define GL_COUNTER_RANGE_AMD 0x8BC1
+#define GL_UNSIGNED_INT64_AMD 0x8BC2
+#define GL_PERCENTAGE_AMD 0x8BC3
+#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4
+#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5
+#define GL_PERFMON_RESULT_AMD 0x8BC6
+typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups);
+typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);
+typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);
+typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);
+typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data);
+typedef void (GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);
+typedef void (GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);
+typedef void (GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList);
+typedef void (GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor);
+typedef void (GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor);
+typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups);
GL_APICALL void GL_APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);
GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);
GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);
-GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data);
+GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, void *data);
GL_APICALL void GL_APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors);
GL_APICALL void GL_APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors);
-GL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList);
+GL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList);
GL_APICALL void GL_APIENTRY glBeginPerfMonitorAMD (GLuint monitor);
GL_APICALL void GL_APIENTRY glEndPerfMonitorAMD (GLuint monitor);
GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);
#endif
-typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups);
-typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);
-typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);
-typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);
-typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data);
-typedef void (GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);
-typedef void (GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);
-typedef void (GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList);
-typedef void (GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor);
-typedef void (GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor);
-typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);
-#endif
+#endif /* GL_AMD_performance_monitor */
-/* GL_AMD_program_binary_Z400 */
#ifndef GL_AMD_program_binary_Z400
#define GL_AMD_program_binary_Z400 1
-#endif
-
-/*------------------------------------------------------------------------*
- * ANGLE extension functions
- *------------------------------------------------------------------------*/
+#define GL_Z400_BINARY_AMD 0x8740
+#endif /* GL_AMD_program_binary_Z400 */
-/* GL_ANGLE_depth_texture */
#ifndef GL_ANGLE_depth_texture
#define GL_ANGLE_depth_texture 1
-#endif
+#endif /* GL_ANGLE_depth_texture */
-/* GL_ANGLE_framebuffer_blit */
#ifndef GL_ANGLE_framebuffer_blit
#define GL_ANGLE_framebuffer_blit 1
+#define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8
+#define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9
+#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6
+#define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA
+typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
#endif
-typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
-#endif
+#endif /* GL_ANGLE_framebuffer_blit */
-/* GL_ANGLE_framebuffer_multisample */
#ifndef GL_ANGLE_framebuffer_multisample
#define GL_ANGLE_framebuffer_multisample 1
+#define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56
+#define GL_MAX_SAMPLES_ANGLE 0x8D57
+typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
#endif
-typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-#endif
+#endif /* GL_ANGLE_framebuffer_multisample */
#ifndef GL_ANGLE_instanced_arrays
#define GL_ANGLE_instanced_arrays 1
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE
+typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
+typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glDrawArraysInstancedANGLE (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE (GLuint index, GLuint divisor);
#endif
-typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
-typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
-typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor);
-#endif
+#endif /* GL_ANGLE_instanced_arrays */
-/* GL_ANGLE_pack_reverse_row_order */
#ifndef GL_ANGLE_pack_reverse_row_order
#define GL_ANGLE_pack_reverse_row_order 1
-#endif
+#define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4
+#endif /* GL_ANGLE_pack_reverse_row_order */
-/* GL_ANGLE_program_binary */
#ifndef GL_ANGLE_program_binary
#define GL_ANGLE_program_binary 1
-#endif
+#define GL_PROGRAM_BINARY_ANGLE 0x93A6
+#endif /* GL_ANGLE_program_binary */
-/* GL_ANGLE_texture_compression_dxt3 */
#ifndef GL_ANGLE_texture_compression_dxt3
#define GL_ANGLE_texture_compression_dxt3 1
-#endif
+#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2
+#endif /* GL_ANGLE_texture_compression_dxt3 */
-/* GL_ANGLE_texture_compression_dxt5 */
#ifndef GL_ANGLE_texture_compression_dxt5
#define GL_ANGLE_texture_compression_dxt5 1
-#endif
+#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3
+#endif /* GL_ANGLE_texture_compression_dxt5 */
-/* GL_ANGLE_texture_usage */
#ifndef GL_ANGLE_texture_usage
#define GL_ANGLE_texture_usage 1
-#endif
+#define GL_TEXTURE_USAGE_ANGLE 0x93A2
+#define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3
+#endif /* GL_ANGLE_texture_usage */
#ifndef GL_ANGLE_translated_shader_source
#define GL_ANGLE_translated_shader_source 1
+#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0
+typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source);
#endif
-typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source);
-#endif
-
-/*------------------------------------------------------------------------*
- * APPLE extension functions
- *------------------------------------------------------------------------*/
+#endif /* GL_ANGLE_translated_shader_source */
-/* GL_APPLE_copy_texture_levels */
#ifndef GL_APPLE_copy_texture_levels
#define GL_APPLE_copy_texture_levels 1
+typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glCopyTextureLevelsAPPLE (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount);
#endif
-typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount);
-#endif
+#endif /* GL_APPLE_copy_texture_levels */
-/* GL_APPLE_framebuffer_multisample */
#ifndef GL_APPLE_framebuffer_multisample
#define GL_APPLE_framebuffer_multisample 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
-GL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void);
-#endif /* GL_GLEXT_PROTOTYPES */
+#define GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE 0x8D56
+#define GL_MAX_SAMPLES_APPLE 0x8D57
+#define GL_READ_FRAMEBUFFER_APPLE 0x8CA8
+#define GL_DRAW_FRAMEBUFFER_APPLE 0x8CA9
+#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE 0x8CA6
+#define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void);
#endif
+#endif /* GL_APPLE_framebuffer_multisample */
-/* GL_APPLE_rgb_422 */
#ifndef GL_APPLE_rgb_422
#define GL_APPLE_rgb_422 1
-#endif
+#define GL_RGB_422_APPLE 0x8A1F
+#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA
+#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB
+#define GL_RGB_RAW_422_APPLE 0x8A51
+#endif /* GL_APPLE_rgb_422 */
-/* GL_APPLE_sync */
#ifndef GL_APPLE_sync
#define GL_APPLE_sync 1
+#define GL_SYNC_OBJECT_APPLE 0x8A53
+#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111
+#define GL_OBJECT_TYPE_APPLE 0x9112
+#define GL_SYNC_CONDITION_APPLE 0x9113
+#define GL_SYNC_STATUS_APPLE 0x9114
+#define GL_SYNC_FLAGS_APPLE 0x9115
+#define GL_SYNC_FENCE_APPLE 0x9116
+#define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117
+#define GL_UNSIGNALED_APPLE 0x9118
+#define GL_SIGNALED_APPLE 0x9119
+#define GL_ALREADY_SIGNALED_APPLE 0x911A
+#define GL_TIMEOUT_EXPIRED_APPLE 0x911B
+#define GL_CONDITION_SATISFIED_APPLE 0x911C
+#define GL_WAIT_FAILED_APPLE 0x911D
+#define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001
+#define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull
+typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags);
+typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync);
+typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync);
+typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
+typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
+typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params);
+typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL GLsync GL_APIENTRY glFenceSyncAPPLE (GLenum condition, GLbitfield flags);
GL_APICALL GLboolean GL_APIENTRY glIsSyncAPPLE (GLsync sync);
@@ -1385,93 +586,114 @@ GL_APICALL void GL_APIENTRY glWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLui
GL_APICALL void GL_APIENTRY glGetInteger64vAPPLE (GLenum pname, GLint64 *params);
GL_APICALL void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
#endif
-typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags);
-typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync);
-typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync);
-typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
-typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
-typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params);
-typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
-#endif
+#endif /* GL_APPLE_sync */
-/* GL_APPLE_texture_format_BGRA8888 */
#ifndef GL_APPLE_texture_format_BGRA8888
#define GL_APPLE_texture_format_BGRA8888 1
-#endif
+#define GL_BGRA_EXT 0x80E1
+#define GL_BGRA8_EXT 0x93A1
+#endif /* GL_APPLE_texture_format_BGRA8888 */
-/* GL_APPLE_texture_max_level */
#ifndef GL_APPLE_texture_max_level
#define GL_APPLE_texture_max_level 1
-#endif
-
-/*------------------------------------------------------------------------*
- * ARM extension functions
- *------------------------------------------------------------------------*/
+#define GL_TEXTURE_MAX_LEVEL_APPLE 0x813D
+#endif /* GL_APPLE_texture_max_level */
-/* GL_ARM_mali_program_binary */
#ifndef GL_ARM_mali_program_binary
#define GL_ARM_mali_program_binary 1
-#endif
+#define GL_MALI_PROGRAM_BINARY_ARM 0x8F61
+#endif /* GL_ARM_mali_program_binary */
-/* GL_ARM_mali_shader_binary */
#ifndef GL_ARM_mali_shader_binary
#define GL_ARM_mali_shader_binary 1
-#endif
+#define GL_MALI_SHADER_BINARY_ARM 0x8F60
+#endif /* GL_ARM_mali_shader_binary */
-/* GL_ARM_rgba8 */
#ifndef GL_ARM_rgba8
#define GL_ARM_rgba8 1
-#endif
+#endif /* GL_ARM_rgba8 */
-/*------------------------------------------------------------------------*
- * EXT extension functions
- *------------------------------------------------------------------------*/
+#ifndef GL_DMP_shader_binary
+#define GL_DMP_shader_binary 1
+#define GL_SHADER_BINARY_DMP 0x9250
+#endif /* GL_DMP_shader_binary */
-/* GL_EXT_blend_minmax */
#ifndef GL_EXT_blend_minmax
#define GL_EXT_blend_minmax 1
-#endif
+#define GL_MIN_EXT 0x8007
+#define GL_MAX_EXT 0x8008
+#endif /* GL_EXT_blend_minmax */
-/* GL_EXT_color_buffer_half_float */
#ifndef GL_EXT_color_buffer_half_float
#define GL_EXT_color_buffer_half_float 1
-#endif
+#define GL_RGBA16F_EXT 0x881A
+#define GL_RGB16F_EXT 0x881B
+#define GL_RG16F_EXT 0x822F
+#define GL_R16F_EXT 0x822D
+#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT 0x8211
+#define GL_UNSIGNED_NORMALIZED_EXT 0x8C17
+#endif /* GL_EXT_color_buffer_half_float */
-/* GL_EXT_debug_label */
#ifndef GL_EXT_debug_label
#define GL_EXT_debug_label 1
+#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F
+#define GL_PROGRAM_OBJECT_EXT 0x8B40
+#define GL_SHADER_OBJECT_EXT 0x8B48
+#define GL_BUFFER_OBJECT_EXT 0x9151
+#define GL_QUERY_OBJECT_EXT 0x9153
+#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154
+#define GL_TRANSFORM_FEEDBACK 0x8E22
+typedef void (GL_APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label);
+typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label);
GL_APICALL void GL_APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label);
#endif
-typedef void (GL_APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label);
-typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label);
-#endif
+#endif /* GL_EXT_debug_label */
-/* GL_EXT_debug_marker */
#ifndef GL_EXT_debug_marker
#define GL_EXT_debug_marker 1
+typedef void (GL_APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker);
+typedef void (GL_APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker);
+typedef void (GL_APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker);
GL_APICALL void GL_APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker);
GL_APICALL void GL_APIENTRY glPopGroupMarkerEXT (void);
#endif
-typedef void (GL_APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker);
-typedef void (GL_APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker);
-typedef void (GL_APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void);
-#endif
+#endif /* GL_EXT_debug_marker */
-/* GL_EXT_discard_framebuffer */
#ifndef GL_EXT_discard_framebuffer
#define GL_EXT_discard_framebuffer 1
+#define GL_COLOR_EXT 0x1800
+#define GL_DEPTH_EXT 0x1801
+#define GL_STENCIL_EXT 0x1802
+typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments);
#endif
-typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments);
-#endif
+#endif /* GL_EXT_discard_framebuffer */
#ifndef GL_EXT_disjoint_timer_query
#define GL_EXT_disjoint_timer_query 1
+#define GL_QUERY_COUNTER_BITS_EXT 0x8864
+#define GL_CURRENT_QUERY_EXT 0x8865
+#define GL_QUERY_RESULT_EXT 0x8866
+#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867
+#define GL_TIME_ELAPSED_EXT 0x88BF
+#define GL_TIMESTAMP_EXT 0x8E28
+#define GL_GPU_DISJOINT_EXT 0x8FBB
+typedef void (GL_APIENTRYP PFNGLGENQUERIESEXTPROC) (GLsizei n, GLuint *ids);
+typedef void (GL_APIENTRYP PFNGLDELETEQUERIESEXTPROC) (GLsizei n, const GLuint *ids);
+typedef GLboolean (GL_APIENTRYP PFNGLISQUERYEXTPROC) (GLuint id);
+typedef void (GL_APIENTRYP PFNGLBEGINQUERYEXTPROC) (GLenum target, GLuint id);
+typedef void (GL_APIENTRYP PFNGLENDQUERYEXTPROC) (GLenum target);
+typedef void (GL_APIENTRYP PFNGLQUERYCOUNTEREXTPROC) (GLuint id, GLenum target);
+typedef void (GL_APIENTRYP PFNGLGETQUERYIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTIVEXTPROC) (GLuint id, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVEXTPROC) (GLuint id, GLenum pname, GLuint *params);
+typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params);
+typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glGenQueriesEXT (GLsizei n, GLuint *ids);
GL_APICALL void GL_APIENTRY glDeleteQueriesEXT (GLsizei n, const GLuint *ids);
@@ -1485,223 +707,360 @@ GL_APICALL void GL_APIENTRY glGetQueryObjectuivEXT (GLuint id, GLenum pname, GLu
GL_APICALL void GL_APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params);
GL_APICALL void GL_APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params);
#endif
-typedef void (GL_APIENTRYP PFNGLGENQUERIESEXTPROC) (GLsizei n, GLuint *ids);
-typedef void (GL_APIENTRYP PFNGLDELETEQUERIESEXTPROC) (GLsizei n, const GLuint *ids);
-typedef GLboolean (GL_APIENTRYP PFNGLISQUERYEXTPROC) (GLuint id);
-typedef void (GL_APIENTRYP PFNGLBEGINQUERYEXTPROC) (GLenum target, GLuint id);
-typedef void (GL_APIENTRYP PFNGLENDQUERYEXTPROC) (GLenum target);
-typedef void (GL_APIENTRYP PFNGLQUERYCOUNTEREXTPROC) (GLuint id, GLenum target);
-typedef void (GL_APIENTRYP PFNGLGETQUERYIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTIVEXTPROC) (GLuint id, GLenum pname, GLint *params);
-typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVEXTPROC) (GLuint id, GLenum pname, GLuint *params);
-typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params);
-typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params);
#endif /* GL_EXT_disjoint_timer_query */
#ifndef GL_EXT_draw_buffers
#define GL_EXT_draw_buffers 1
+#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF
+#define GL_MAX_DRAW_BUFFERS_EXT 0x8824
+#define GL_DRAW_BUFFER0_EXT 0x8825
+#define GL_DRAW_BUFFER1_EXT 0x8826
+#define GL_DRAW_BUFFER2_EXT 0x8827
+#define GL_DRAW_BUFFER3_EXT 0x8828
+#define GL_DRAW_BUFFER4_EXT 0x8829
+#define GL_DRAW_BUFFER5_EXT 0x882A
+#define GL_DRAW_BUFFER6_EXT 0x882B
+#define GL_DRAW_BUFFER7_EXT 0x882C
+#define GL_DRAW_BUFFER8_EXT 0x882D
+#define GL_DRAW_BUFFER9_EXT 0x882E
+#define GL_DRAW_BUFFER10_EXT 0x882F
+#define GL_DRAW_BUFFER11_EXT 0x8830
+#define GL_DRAW_BUFFER12_EXT 0x8831
+#define GL_DRAW_BUFFER13_EXT 0x8832
+#define GL_DRAW_BUFFER14_EXT 0x8833
+#define GL_DRAW_BUFFER15_EXT 0x8834
+#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
+#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1
+#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2
+#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3
+#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4
+#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5
+#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6
+#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7
+#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8
+#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9
+#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA
+#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB
+#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC
+#define GL_COLOR_ATTACHMENT13_EXT 0x8CED
+#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE
+#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF
+typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSEXTPROC) (GLsizei n, const GLenum *bufs);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glDrawBuffersEXT (GLsizei n, const GLenum *bufs);
#endif
-typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSEXTPROC) (GLsizei n, const GLenum *bufs);
#endif /* GL_EXT_draw_buffers */
-/* GL_EXT_map_buffer_range */
+#ifndef GL_EXT_draw_instanced
+#define GL_EXT_draw_instanced 1
+typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount);
+typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount);
+GL_APICALL void GL_APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
+#endif
+#endif /* GL_EXT_draw_instanced */
+
+#ifndef GL_EXT_instanced_arrays
+#define GL_EXT_instanced_arrays 1
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_EXT 0x88FE
+typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISOREXTPROC) (GLuint index, GLuint divisor);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glVertexAttribDivisorEXT (GLuint index, GLuint divisor);
+#endif
+#endif /* GL_EXT_instanced_arrays */
+
#ifndef GL_EXT_map_buffer_range
#define GL_EXT_map_buffer_range 1
+#define GL_MAP_READ_BIT_EXT 0x0001
+#define GL_MAP_WRITE_BIT_EXT 0x0002
+#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004
+#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008
+#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010
+#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020
+typedef void *(GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length);
#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+GL_APICALL void *GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
GL_APICALL void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length);
#endif
-typedef void* (GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
-typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length);
+#endif /* GL_EXT_map_buffer_range */
+
+#ifndef GL_EXT_multi_draw_arrays
+#define GL_EXT_multi_draw_arrays 1
+typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
+typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
+GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount);
#endif
+#endif /* GL_EXT_multi_draw_arrays */
-/* GL_EXT_multisampled_render_to_texture */
#ifndef GL_EXT_multisampled_render_to_texture
#define GL_EXT_multisampled_render_to_texture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleEXT (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
-GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei);
-#endif
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C
+#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
+#define GL_MAX_SAMPLES_EXT 0x8D57
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
#endif
+#endif /* GL_EXT_multisampled_render_to_texture */
-/* GL_EXT_multiview_draw_buffers */
#ifndef GL_EXT_multiview_draw_buffers
#define GL_EXT_multiview_draw_buffers 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glReadBufferIndexedEXT (GLenum src, GLint index);
-GL_APICALL void GL_APIENTRY glDrawBuffersIndexedEXT (GLint n, const GLenum *location, const GLint *indices);
-GL_APICALL void GL_APIENTRY glGetIntegeri_vEXT (GLenum target, GLuint index, GLint *data);
-#endif
+#define GL_COLOR_ATTACHMENT_EXT 0x90F0
+#define GL_MULTIVIEW_EXT 0x90F1
+#define GL_DRAW_BUFFER_EXT 0x0C01
+#define GL_READ_BUFFER_EXT 0x0C02
+#define GL_MAX_MULTIVIEW_BUFFERS_EXT 0x90F2
typedef void (GL_APIENTRYP PFNGLREADBUFFERINDEXEDEXTPROC) (GLenum src, GLint index);
typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSINDEXEDEXTPROC) (GLint n, const GLenum *location, const GLint *indices);
typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VEXTPROC) (GLenum target, GLuint index, GLint *data);
-#endif
-
-#ifndef GL_EXT_multi_draw_arrays
-#define GL_EXT_multi_draw_arrays 1
#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum, const GLint *, const GLsizei *, GLsizei);
-GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
-typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
+GL_APICALL void GL_APIENTRY glReadBufferIndexedEXT (GLenum src, GLint index);
+GL_APICALL void GL_APIENTRY glDrawBuffersIndexedEXT (GLint n, const GLenum *location, const GLint *indices);
+GL_APICALL void GL_APIENTRY glGetIntegeri_vEXT (GLenum target, GLuint index, GLint *data);
#endif
+#endif /* GL_EXT_multiview_draw_buffers */
-/* GL_EXT_occlusion_query_boolean */
#ifndef GL_EXT_occlusion_query_boolean
#define GL_EXT_occlusion_query_boolean 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glGenQueriesEXT (GLsizei n, GLuint *ids);
-GL_APICALL void GL_APIENTRY glDeleteQueriesEXT (GLsizei n, const GLuint *ids);
-GL_APICALL GLboolean GL_APIENTRY glIsQueryEXT (GLuint id);
-GL_APICALL void GL_APIENTRY glBeginQueryEXT (GLenum target, GLuint id);
-GL_APICALL void GL_APIENTRY glEndQueryEXT (GLenum target);
-GL_APICALL void GL_APIENTRY glGetQueryivEXT (GLenum target, GLenum pname, GLint *params);
-GL_APICALL void GL_APIENTRY glGetQueryObjectuivEXT (GLuint id, GLenum pname, GLuint *params);
-#endif
-typedef void (GL_APIENTRYP PFNGLGENQUERIESEXTPROC) (GLsizei n, GLuint *ids);
-typedef void (GL_APIENTRYP PFNGLDELETEQUERIESEXTPROC) (GLsizei n, const GLuint *ids);
-typedef GLboolean (GL_APIENTRYP PFNGLISQUERYEXTPROC) (GLuint id);
-typedef void (GL_APIENTRYP PFNGLBEGINQUERYEXTPROC) (GLenum target, GLuint id);
-typedef void (GL_APIENTRYP PFNGLENDQUERYEXTPROC) (GLenum target);
-typedef void (GL_APIENTRYP PFNGLGETQUERYIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVEXTPROC) (GLuint id, GLenum pname, GLuint *params);
-#endif
+#define GL_ANY_SAMPLES_PASSED_EXT 0x8C2F
+#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A
+#endif /* GL_EXT_occlusion_query_boolean */
+
+#ifndef GL_EXT_pvrtc_sRGB
+#define GL_EXT_pvrtc_sRGB 1
+#define GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT 0x8A54
+#define GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT 0x8A55
+#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT 0x8A56
+#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT 0x8A57
+#endif /* GL_EXT_pvrtc_sRGB */
-/* GL_EXT_read_format_bgra */
#ifndef GL_EXT_read_format_bgra
#define GL_EXT_read_format_bgra 1
-#endif
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365
+#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366
+#endif /* GL_EXT_read_format_bgra */
-/* GL_EXT_robustness */
#ifndef GL_EXT_robustness
#define GL_EXT_robustness 1
+#define GL_GUILTY_CONTEXT_RESET_EXT 0x8253
+#define GL_INNOCENT_CONTEXT_RESET_EXT 0x8254
+#define GL_UNKNOWN_CONTEXT_RESET_EXT 0x8255
+#define GL_CONTEXT_ROBUST_ACCESS_EXT 0x90F3
+#define GL_RESET_NOTIFICATION_STRATEGY_EXT 0x8256
+#define GL_LOSE_CONTEXT_ON_RESET_EXT 0x8252
+#define GL_NO_RESET_NOTIFICATION_EXT 0x8261
+typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSEXTPROC) (void);
+typedef void (GL_APIENTRYP PFNGLREADNPIXELSEXTPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);
+typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params);
+typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatusEXT (void);
GL_APICALL void GL_APIENTRY glReadnPixelsEXT (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);
-GL_APICALL void GL_APIENTRY glGetnUniformfvEXT (GLuint program, GLint location, GLsizei bufSize, float *params);
+GL_APICALL void GL_APIENTRY glGetnUniformfvEXT (GLuint program, GLint location, GLsizei bufSize, GLfloat *params);
GL_APICALL void GL_APIENTRY glGetnUniformivEXT (GLuint program, GLint location, GLsizei bufSize, GLint *params);
#endif
-typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSEXTPROC) (void);
-typedef void (GL_APIENTRYP PFNGLREADNPIXELSEXTPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);
-typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, float *params);
-typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params);
-#endif
+#endif /* GL_EXT_robustness */
+
+#ifndef GL_EXT_sRGB
+#define GL_EXT_sRGB 1
+#define GL_SRGB_EXT 0x8C40
+#define GL_SRGB_ALPHA_EXT 0x8C42
+#define GL_SRGB8_ALPHA8_EXT 0x8C43
+#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210
+#endif /* GL_EXT_sRGB */
+
+#ifndef GL_EXT_sRGB_write_control
+#define GL_EXT_sRGB_write_control 1
+#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9
+#endif /* GL_EXT_sRGB_write_control */
-/* GL_EXT_separate_shader_objects */
#ifndef GL_EXT_separate_shader_objects
#define GL_EXT_separate_shader_objects 1
+#define GL_ACTIVE_PROGRAM_EXT 0x8259
+#define GL_VERTEX_SHADER_BIT_EXT 0x00000001
+#define GL_FRAGMENT_SHADER_BIT_EXT 0x00000002
+#define GL_ALL_SHADER_BITS_EXT 0xFFFFFFFF
+#define GL_PROGRAM_SEPARABLE_EXT 0x8258
+#define GL_PROGRAM_PIPELINE_BINDING_EXT 0x825A
+typedef void (GL_APIENTRYP PFNGLACTIVESHADERPROGRAMEXTPROC) (GLuint pipeline, GLuint program);
+typedef void (GL_APIENTRYP PFNGLBINDPROGRAMPIPELINEEXTPROC) (GLuint pipeline);
+typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROGRAMVEXTPROC) (GLenum type, GLsizei count, const GLchar **strings);
+typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPIPELINESEXTPROC) (GLsizei n, const GLuint *pipelines);
+typedef void (GL_APIENTRYP PFNGLGENPROGRAMPIPELINESEXTPROC) (GLsizei n, GLuint *pipelines);
+typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEIVEXTPROC) (GLuint pipeline, GLenum pname, GLint *params);
+typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPIPELINEEXTPROC) (GLuint pipeline);
+typedef void (GL_APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLUSEPROGRAMSTAGESEXTPROC) (GLuint pipeline, GLbitfield stages, GLuint program);
+typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEEXTPROC) (GLuint pipeline);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glUseProgramStagesEXT (GLuint pipeline, GLbitfield stages, GLuint program);
GL_APICALL void GL_APIENTRY glActiveShaderProgramEXT (GLuint pipeline, GLuint program);
-GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramvEXT (GLenum type, GLsizei count, const GLchar **strings);
GL_APICALL void GL_APIENTRY glBindProgramPipelineEXT (GLuint pipeline);
+GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramvEXT (GLenum type, GLsizei count, const GLchar **strings);
GL_APICALL void GL_APIENTRY glDeleteProgramPipelinesEXT (GLsizei n, const GLuint *pipelines);
GL_APICALL void GL_APIENTRY glGenProgramPipelinesEXT (GLsizei n, GLuint *pipelines);
+GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLogEXT (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+GL_APICALL void GL_APIENTRY glGetProgramPipelineivEXT (GLuint pipeline, GLenum pname, GLint *params);
GL_APICALL GLboolean GL_APIENTRY glIsProgramPipelineEXT (GLuint pipeline);
GL_APICALL void GL_APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value);
-GL_APICALL void GL_APIENTRY glGetProgramPipelineivEXT (GLuint pipeline, GLenum pname, GLint *params);
-GL_APICALL void GL_APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint x);
-GL_APICALL void GL_APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint x, GLint y);
-GL_APICALL void GL_APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint x, GLint y, GLint z);
-GL_APICALL void GL_APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w);
-GL_APICALL void GL_APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat x);
-GL_APICALL void GL_APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat x, GLfloat y);
-GL_APICALL void GL_APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z);
-GL_APICALL void GL_APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GL_APICALL void GL_APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
-GL_APICALL void GL_APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
-GL_APICALL void GL_APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
-GL_APICALL void GL_APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0);
GL_APICALL void GL_APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0);
+GL_APICALL void GL_APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1);
GL_APICALL void GL_APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1);
+GL_APICALL void GL_APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
GL_APICALL void GL_APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
+GL_APICALL void GL_APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
GL_APICALL void GL_APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+GL_APICALL void GL_APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value);
GL_APICALL void GL_APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
GL_APICALL void GL_APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
GL_APICALL void GL_APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUseProgramStagesEXT (GLuint pipeline, GLbitfield stages, GLuint program);
GL_APICALL void GL_APIENTRY glValidateProgramPipelineEXT (GLuint pipeline);
-GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLogEXT (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
-#endif
-typedef void (GL_APIENTRYP PFNGLUSEPROGRAMSTAGESEXTPROC) (GLuint pipeline, GLbitfield stages, GLuint program);
-typedef void (GL_APIENTRYP PFNGLACTIVESHADERPROGRAMEXTPROC) (GLuint pipeline, GLuint program);
-typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROGRAMVEXTPROC) (GLenum type, GLsizei count, const GLchar **strings);
-typedef void (GL_APIENTRYP PFNGLBINDPROGRAMPIPELINEEXTPROC) (GLuint pipeline);
-typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPIPELINESEXTPROC) (GLsizei n, const GLuint *pipelines);
-typedef void (GL_APIENTRYP PFNGLGENPROGRAMPIPELINESEXTPROC) (GLsizei n, GLuint *pipelines);
-typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPIPELINEEXTPROC) (GLuint pipeline);
-typedef void (GL_APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value);
-typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEIVEXTPROC) (GLuint pipeline, GLenum pname, GLint *params);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint x);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint x, GLint y);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint x, GLint y, GLint z, GLint w);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat x);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEEXTPROC) (GLuint pipeline);
-typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
-#endif
+GL_APICALL void GL_APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0);
+GL_APICALL void GL_APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1);
+GL_APICALL void GL_APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
+GL_APICALL void GL_APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+GL_APICALL void GL_APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GL_APICALL void GL_APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+#endif
+#endif /* GL_EXT_separate_shader_objects */
-/* GL_EXT_shader_framebuffer_fetch */
#ifndef GL_EXT_shader_framebuffer_fetch
#define GL_EXT_shader_framebuffer_fetch 1
-#endif
+#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52
+#endif /* GL_EXT_shader_framebuffer_fetch */
+
+#ifndef GL_EXT_shader_integer_mix
+#define GL_EXT_shader_integer_mix 1
+#endif /* GL_EXT_shader_integer_mix */
-/* GL_EXT_shader_texture_lod */
#ifndef GL_EXT_shader_texture_lod
#define GL_EXT_shader_texture_lod 1
-#endif
+#endif /* GL_EXT_shader_texture_lod */
-/* GL_EXT_shadow_samplers */
#ifndef GL_EXT_shadow_samplers
#define GL_EXT_shadow_samplers 1
-#endif
+#define GL_TEXTURE_COMPARE_MODE_EXT 0x884C
+#define GL_TEXTURE_COMPARE_FUNC_EXT 0x884D
+#define GL_COMPARE_REF_TO_TEXTURE_EXT 0x884E
+#define GL_SAMPLER_2D_SHADOW_EXT 0x8B62
+#endif /* GL_EXT_shadow_samplers */
-/* GL_EXT_sRGB */
-#ifndef GL_EXT_sRGB
-#define GL_EXT_sRGB 1
-#endif
-
-/* GL_EXT_texture_compression_dxt1 */
#ifndef GL_EXT_texture_compression_dxt1
#define GL_EXT_texture_compression_dxt1 1
-#endif
+#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
+#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
+#endif /* GL_EXT_texture_compression_dxt1 */
+
+#ifndef GL_EXT_texture_compression_s3tc
+#define GL_EXT_texture_compression_s3tc 1
+#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
+#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
+#endif /* GL_EXT_texture_compression_s3tc */
-/* GL_EXT_texture_filter_anisotropic */
#ifndef GL_EXT_texture_filter_anisotropic
#define GL_EXT_texture_filter_anisotropic 1
-#endif
+#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
+#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
+#endif /* GL_EXT_texture_filter_anisotropic */
-/* GL_EXT_texture_format_BGRA8888 */
#ifndef GL_EXT_texture_format_BGRA8888
#define GL_EXT_texture_format_BGRA8888 1
-#endif
+#endif /* GL_EXT_texture_format_BGRA8888 */
-/* GL_EXT_texture_rg */
#ifndef GL_EXT_texture_rg
#define GL_EXT_texture_rg 1
-#endif
+#define GL_RED_EXT 0x1903
+#define GL_RG_EXT 0x8227
+#define GL_R8_EXT 0x8229
+#define GL_RG8_EXT 0x822B
+#endif /* GL_EXT_texture_rg */
+
+#ifndef GL_EXT_texture_sRGB_decode
+#define GL_EXT_texture_sRGB_decode 1
+#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48
+#define GL_DECODE_EXT 0x8A49
+#define GL_SKIP_DECODE_EXT 0x8A4A
+#endif /* GL_EXT_texture_sRGB_decode */
-/* GL_EXT_texture_storage */
#ifndef GL_EXT_texture_storage
#define GL_EXT_texture_storage 1
+#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F
+#define GL_ALPHA8_EXT 0x803C
+#define GL_LUMINANCE8_EXT 0x8040
+#define GL_LUMINANCE8_ALPHA8_EXT 0x8045
+#define GL_RGBA32F_EXT 0x8814
+#define GL_RGB32F_EXT 0x8815
+#define GL_ALPHA32F_EXT 0x8816
+#define GL_LUMINANCE32F_EXT 0x8818
+#define GL_LUMINANCE_ALPHA32F_EXT 0x8819
+#define GL_ALPHA16F_EXT 0x881C
+#define GL_LUMINANCE16F_EXT 0x881E
+#define GL_LUMINANCE_ALPHA16F_EXT 0x881F
+#define GL_R32F_EXT 0x822E
+#define GL_RG32F_EXT 0x8230
+typedef void (GL_APIENTRYP PFNGLTEXSTORAGE1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glTexStorage1DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
GL_APICALL void GL_APIENTRY glTexStorage2DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
@@ -1710,139 +1069,278 @@ GL_APICALL void GL_APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target
GL_APICALL void GL_APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
GL_APICALL void GL_APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
#endif
-typedef void (GL_APIENTRYP PFNGLTEXSTORAGE1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
-typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
-typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
-typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
-#endif
+#endif /* GL_EXT_texture_storage */
-/* GL_EXT_texture_type_2_10_10_10_REV */
#ifndef GL_EXT_texture_type_2_10_10_10_REV
#define GL_EXT_texture_type_2_10_10_10_REV 1
-#endif
+#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368
+#endif /* GL_EXT_texture_type_2_10_10_10_REV */
-/* GL_EXT_unpack_subimage */
#ifndef GL_EXT_unpack_subimage
#define GL_EXT_unpack_subimage 1
-#endif
-
-/*------------------------------------------------------------------------*
- * DMP extension functions
- *------------------------------------------------------------------------*/
+#define GL_UNPACK_ROW_LENGTH_EXT 0x0CF2
+#define GL_UNPACK_SKIP_ROWS_EXT 0x0CF3
+#define GL_UNPACK_SKIP_PIXELS_EXT 0x0CF4
+#endif /* GL_EXT_unpack_subimage */
-/* GL_DMP_shader_binary */
-#ifndef GL_DMP_shader_binary
-#define GL_DMP_shader_binary 1
-#endif
-
-/*------------------------------------------------------------------------*
- * FJ extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_FJ_shader_binary_GCCSO */
#ifndef GL_FJ_shader_binary_GCCSO
#define GL_FJ_shader_binary_GCCSO 1
-#endif
+#define GL_GCCSO_SHADER_BINARY_FJ 0x9260
+#endif /* GL_FJ_shader_binary_GCCSO */
-/*------------------------------------------------------------------------*
- * IMG extension functions
- *------------------------------------------------------------------------*/
+#ifndef GL_IMG_multisampled_render_to_texture
+#define GL_IMG_multisampled_render_to_texture 1
+#define GL_RENDERBUFFER_SAMPLES_IMG 0x9133
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134
+#define GL_MAX_SAMPLES_IMG 0x9135
+#define GL_TEXTURE_SAMPLES_IMG 0x9136
+typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+#endif
+#endif /* GL_IMG_multisampled_render_to_texture */
-/* GL_IMG_program_binary */
#ifndef GL_IMG_program_binary
#define GL_IMG_program_binary 1
-#endif
+#define GL_SGX_PROGRAM_BINARY_IMG 0x9130
+#endif /* GL_IMG_program_binary */
-/* GL_IMG_read_format */
#ifndef GL_IMG_read_format
#define GL_IMG_read_format 1
-#endif
+#define GL_BGRA_IMG 0x80E1
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG 0x8365
+#endif /* GL_IMG_read_format */
-/* GL_IMG_shader_binary */
#ifndef GL_IMG_shader_binary
#define GL_IMG_shader_binary 1
-#endif
+#define GL_SGX_BINARY_IMG 0x8C0A
+#endif /* GL_IMG_shader_binary */
-/* GL_IMG_texture_compression_pvrtc */
#ifndef GL_IMG_texture_compression_pvrtc
#define GL_IMG_texture_compression_pvrtc 1
-#endif
+#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
+#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01
+#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
+#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
+#endif /* GL_IMG_texture_compression_pvrtc */
-/* GL_IMG_texture_compression_pvrtc2 */
#ifndef GL_IMG_texture_compression_pvrtc2
#define GL_IMG_texture_compression_pvrtc2 1
+#define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137
+#define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138
+#endif /* GL_IMG_texture_compression_pvrtc2 */
+
+#ifndef GL_INTEL_performance_query
+#define GL_INTEL_performance_query 1
+#define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000
+#define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001
+#define GL_PERFQUERY_WAIT_INTEL 0x83FB
+#define GL_PERFQUERY_FLUSH_INTEL 0x83FA
+#define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9
+#define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0
+#define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1
+#define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2
+#define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3
+#define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4
+#define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5
+#define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8
+#define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9
+#define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA
+#define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB
+#define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC
+#define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD
+#define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE
+#define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF
+#define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500
+typedef void (GL_APIENTRYP PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle);
+typedef void (GL_APIENTRYP PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint *queryHandle);
+typedef void (GL_APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle);
+typedef void (GL_APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle);
+typedef void (GL_APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId);
+typedef void (GL_APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId);
+typedef void (GL_APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue);
+typedef void (GL_APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten);
+typedef void (GL_APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId);
+typedef void (GL_APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glBeginPerfQueryINTEL (GLuint queryHandle);
+GL_APICALL void GL_APIENTRY glCreatePerfQueryINTEL (GLuint queryId, GLuint *queryHandle);
+GL_APICALL void GL_APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle);
+GL_APICALL void GL_APIENTRY glEndPerfQueryINTEL (GLuint queryHandle);
+GL_APICALL void GL_APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId);
+GL_APICALL void GL_APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId);
+GL_APICALL void GL_APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue);
+GL_APICALL void GL_APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten);
+GL_APICALL void GL_APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId);
+GL_APICALL void GL_APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask);
+#endif
+#endif /* GL_INTEL_performance_query */
+
+#ifndef GL_NV_blend_equation_advanced
+#define GL_NV_blend_equation_advanced 1
+#define GL_BLEND_OVERLAP_NV 0x9281
+#define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280
+#define GL_BLUE_NV 0x1905
+#define GL_COLORBURN_NV 0x929A
+#define GL_COLORDODGE_NV 0x9299
+#define GL_CONJOINT_NV 0x9284
+#define GL_CONTRAST_NV 0x92A1
+#define GL_DARKEN_NV 0x9297
+#define GL_DIFFERENCE_NV 0x929E
+#define GL_DISJOINT_NV 0x9283
+#define GL_DST_ATOP_NV 0x928F
+#define GL_DST_IN_NV 0x928B
+#define GL_DST_NV 0x9287
+#define GL_DST_OUT_NV 0x928D
+#define GL_DST_OVER_NV 0x9289
+#define GL_EXCLUSION_NV 0x92A0
+#define GL_GREEN_NV 0x1904
+#define GL_HARDLIGHT_NV 0x929B
+#define GL_HARDMIX_NV 0x92A9
+#define GL_HSL_COLOR_NV 0x92AF
+#define GL_HSL_HUE_NV 0x92AD
+#define GL_HSL_LUMINOSITY_NV 0x92B0
+#define GL_HSL_SATURATION_NV 0x92AE
+#define GL_INVERT_OVG_NV 0x92B4
+#define GL_INVERT_RGB_NV 0x92A3
+#define GL_LIGHTEN_NV 0x9298
+#define GL_LINEARBURN_NV 0x92A5
+#define GL_LINEARDODGE_NV 0x92A4
+#define GL_LINEARLIGHT_NV 0x92A7
+#define GL_MINUS_CLAMPED_NV 0x92B3
+#define GL_MINUS_NV 0x929F
+#define GL_MULTIPLY_NV 0x9294
+#define GL_OVERLAY_NV 0x9296
+#define GL_PINLIGHT_NV 0x92A8
+#define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2
+#define GL_PLUS_CLAMPED_NV 0x92B1
+#define GL_PLUS_DARKER_NV 0x9292
+#define GL_PLUS_NV 0x9291
+#define GL_RED_NV 0x1903
+#define GL_SCREEN_NV 0x9295
+#define GL_SOFTLIGHT_NV 0x929C
+#define GL_SRC_ATOP_NV 0x928E
+#define GL_SRC_IN_NV 0x928A
+#define GL_SRC_NV 0x9286
+#define GL_SRC_OUT_NV 0x928C
+#define GL_SRC_OVER_NV 0x9288
+#define GL_UNCORRELATED_NV 0x9282
+#define GL_VIVIDLIGHT_NV 0x92A6
+#define GL_XOR_NV 0x1506
+typedef void (GL_APIENTRYP PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value);
+typedef void (GL_APIENTRYP PFNGLBLENDBARRIERNVPROC) (void);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glBlendParameteriNV (GLenum pname, GLint value);
+GL_APICALL void GL_APIENTRY glBlendBarrierNV (void);
#endif
+#endif /* GL_NV_blend_equation_advanced */
-/* GL_IMG_multisampled_render_to_texture */
-#ifndef GL_IMG_multisampled_render_to_texture
-#define GL_IMG_multisampled_render_to_texture 1
+#ifndef GL_NV_blend_equation_advanced_coherent
+#define GL_NV_blend_equation_advanced_coherent 1
+#define GL_BLEND_ADVANCED_COHERENT_NV 0x9285
+#endif /* GL_NV_blend_equation_advanced_coherent */
+
+#ifndef GL_NV_copy_buffer
+#define GL_NV_copy_buffer 1
+#define GL_COPY_READ_BUFFER_NV 0x8F36
+#define GL_COPY_WRITE_BUFFER_NV 0x8F37
+typedef void (GL_APIENTRYP PFNGLCOPYBUFFERSUBDATANVPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
-GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei);
-#endif
-typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples);
+GL_APICALL void GL_APIENTRY glCopyBufferSubDataNV (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
#endif
+#endif /* GL_NV_copy_buffer */
-/*------------------------------------------------------------------------*
- * NV extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_NV_coverage_sample */
#ifndef GL_NV_coverage_sample
#define GL_NV_coverage_sample 1
+#define GL_COVERAGE_COMPONENT_NV 0x8ED0
+#define GL_COVERAGE_COMPONENT4_NV 0x8ED1
+#define GL_COVERAGE_ATTACHMENT_NV 0x8ED2
+#define GL_COVERAGE_BUFFERS_NV 0x8ED3
+#define GL_COVERAGE_SAMPLES_NV 0x8ED4
+#define GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5
+#define GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6
+#define GL_COVERAGE_AUTOMATIC_NV 0x8ED7
+#define GL_COVERAGE_BUFFER_BIT_NV 0x00008000
+typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask);
+typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glCoverageMaskNV (GLboolean mask);
GL_APICALL void GL_APIENTRY glCoverageOperationNV (GLenum operation);
#endif
-typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask);
-typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation);
-#endif
+#endif /* GL_NV_coverage_sample */
-/* GL_NV_depth_nonlinear */
#ifndef GL_NV_depth_nonlinear
#define GL_NV_depth_nonlinear 1
-#endif
+#define GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C
+#endif /* GL_NV_depth_nonlinear */
-/* GL_NV_draw_buffers */
#ifndef GL_NV_draw_buffers
#define GL_NV_draw_buffers 1
+#define GL_MAX_DRAW_BUFFERS_NV 0x8824
+#define GL_DRAW_BUFFER0_NV 0x8825
+#define GL_DRAW_BUFFER1_NV 0x8826
+#define GL_DRAW_BUFFER2_NV 0x8827
+#define GL_DRAW_BUFFER3_NV 0x8828
+#define GL_DRAW_BUFFER4_NV 0x8829
+#define GL_DRAW_BUFFER5_NV 0x882A
+#define GL_DRAW_BUFFER6_NV 0x882B
+#define GL_DRAW_BUFFER7_NV 0x882C
+#define GL_DRAW_BUFFER8_NV 0x882D
+#define GL_DRAW_BUFFER9_NV 0x882E
+#define GL_DRAW_BUFFER10_NV 0x882F
+#define GL_DRAW_BUFFER11_NV 0x8830
+#define GL_DRAW_BUFFER12_NV 0x8831
+#define GL_DRAW_BUFFER13_NV 0x8832
+#define GL_DRAW_BUFFER14_NV 0x8833
+#define GL_DRAW_BUFFER15_NV 0x8834
+#define GL_COLOR_ATTACHMENT0_NV 0x8CE0
+#define GL_COLOR_ATTACHMENT1_NV 0x8CE1
+#define GL_COLOR_ATTACHMENT2_NV 0x8CE2
+#define GL_COLOR_ATTACHMENT3_NV 0x8CE3
+#define GL_COLOR_ATTACHMENT4_NV 0x8CE4
+#define GL_COLOR_ATTACHMENT5_NV 0x8CE5
+#define GL_COLOR_ATTACHMENT6_NV 0x8CE6
+#define GL_COLOR_ATTACHMENT7_NV 0x8CE7
+#define GL_COLOR_ATTACHMENT8_NV 0x8CE8
+#define GL_COLOR_ATTACHMENT9_NV 0x8CE9
+#define GL_COLOR_ATTACHMENT10_NV 0x8CEA
+#define GL_COLOR_ATTACHMENT11_NV 0x8CEB
+#define GL_COLOR_ATTACHMENT12_NV 0x8CEC
+#define GL_COLOR_ATTACHMENT13_NV 0x8CED
+#define GL_COLOR_ATTACHMENT14_NV 0x8CEE
+#define GL_COLOR_ATTACHMENT15_NV 0x8CEF
+typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glDrawBuffersNV (GLsizei n, const GLenum *bufs);
#endif
-typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs);
-#endif
+#endif /* GL_NV_draw_buffers */
-/* GL_NV_draw_instanced */
#ifndef GL_NV_draw_instanced
#define GL_NV_draw_instanced 1
+typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDNVPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDNVPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glDrawArraysInstancedNV (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
-GL_APICALL void GL_APIENTRY glDrawElementsInstancedNV (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
-#endif
-typedef void (GL_APIENTRYP PFNDRAWARRAYSINSTANCEDNVPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
-typedef void (GL_APIENTRYP PFNDRAWELEMENTSINSTANCEDNVPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
+GL_APICALL void GL_APIENTRY glDrawElementsInstancedNV (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
#endif
+#endif /* GL_NV_draw_instanced */
+
+#ifndef GL_NV_explicit_attrib_location
+#define GL_NV_explicit_attrib_location 1
+#endif /* GL_NV_explicit_attrib_location */
-/* GL_NV_fbo_color_attachments */
#ifndef GL_NV_fbo_color_attachments
#define GL_NV_fbo_color_attachments 1
-#endif
+#define GL_MAX_COLOR_ATTACHMENTS_NV 0x8CDF
+#endif /* GL_NV_fbo_color_attachments */
-/* GL_NV_fence */
#ifndef GL_NV_fence
#define GL_NV_fence 1
-#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glDeleteFencesNV (GLsizei, const GLuint *);
-GL_APICALL void GL_APIENTRY glGenFencesNV (GLsizei, GLuint *);
-GL_APICALL GLboolean GL_APIENTRY glIsFenceNV (GLuint);
-GL_APICALL GLboolean GL_APIENTRY glTestFenceNV (GLuint);
-GL_APICALL void GL_APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *);
-GL_APICALL void GL_APIENTRY glFinishFenceNV (GLuint);
-GL_APICALL void GL_APIENTRY glSetFenceNV (GLuint, GLenum);
-#endif
+#define GL_ALL_COMPLETED_NV 0x84F2
+#define GL_FENCE_STATUS_NV 0x84F3
+#define GL_FENCE_CONDITION_NV 0x84F4
typedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences);
typedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences);
typedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC) (GLuint fence);
@@ -1850,135 +1348,194 @@ typedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence);
typedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params);
typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence);
typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences);
+GL_APICALL void GL_APIENTRY glGenFencesNV (GLsizei n, GLuint *fences);
+GL_APICALL GLboolean GL_APIENTRY glIsFenceNV (GLuint fence);
+GL_APICALL GLboolean GL_APIENTRY glTestFenceNV (GLuint fence);
+GL_APICALL void GL_APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glFinishFenceNV (GLuint fence);
+GL_APICALL void GL_APIENTRY glSetFenceNV (GLuint fence, GLenum condition);
#endif
+#endif /* GL_NV_fence */
-/* GL_NV_framebuffer_blit */
#ifndef GL_NV_framebuffer_blit
#define GL_NV_framebuffer_blit 1
+#define GL_READ_FRAMEBUFFER_NV 0x8CA8
+#define GL_DRAW_FRAMEBUFFER_NV 0x8CA9
+#define GL_DRAW_FRAMEBUFFER_BINDING_NV 0x8CA6
+#define GL_READ_FRAMEBUFFER_BINDING_NV 0x8CAA
+typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERNVPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glBlitFramebufferNV (int srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
-#endif
-typedef void (GL_APIENTRYP PFNBLITFRAMEBUFFERNVPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+GL_APICALL void GL_APIENTRY glBlitFramebufferNV (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
#endif
+#endif /* GL_NV_framebuffer_blit */
-/* GL_NV_framebuffer_multisample */
#ifndef GL_NV_framebuffer_multisample
#define GL_NV_framebuffer_multisample 1
+#define GL_RENDERBUFFER_SAMPLES_NV 0x8CAB
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV 0x8D56
+#define GL_MAX_SAMPLES_NV 0x8D57
+typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLENVPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
#ifdef GL_GLEXT_PROTOTYPES
-GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleNV ( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-#endif
-typedef void (GL_APIENTRYP PFNRENDERBUFFERSTORAGEMULTISAMPLENVPROC) ( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleNV (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
#endif
+#endif /* GL_NV_framebuffer_multisample */
-/* GL_NV_generate_mipmap_sRGB */
#ifndef GL_NV_generate_mipmap_sRGB
#define GL_NV_generate_mipmap_sRGB 1
-#endif
+#endif /* GL_NV_generate_mipmap_sRGB */
-/* GL_NV_instanced_arrays */
#ifndef GL_NV_instanced_arrays
#define GL_NV_instanced_arrays 1
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_NV 0x88FE
+typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORNVPROC) (GLuint index, GLuint divisor);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glVertexAttribDivisorNV (GLuint index, GLuint divisor);
#endif
-typedef void (GL_APIENTRYP PFNVERTEXATTRIBDIVISORNVPROC) (GLuint index, GLuint divisor);
+#endif /* GL_NV_instanced_arrays */
+
+#ifndef GL_NV_non_square_matrices
+#define GL_NV_non_square_matrices 1
+#define GL_FLOAT_MAT2x3_NV 0x8B65
+#define GL_FLOAT_MAT2x4_NV 0x8B66
+#define GL_FLOAT_MAT3x2_NV 0x8B67
+#define GL_FLOAT_MAT3x4_NV 0x8B68
+#define GL_FLOAT_MAT4x2_NV 0x8B69
+#define GL_FLOAT_MAT4x3_NV 0x8B6A
+typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X3FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X2FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X4FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X2FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X4FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X3FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+#ifdef GL_GLEXT_PROTOTYPES
+GL_APICALL void GL_APIENTRY glUniformMatrix2x3fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix3x2fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix2x4fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix4x2fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix3x4fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix4x3fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
#endif
+#endif /* GL_NV_non_square_matrices */
-/* GL_NV_read_buffer */
#ifndef GL_NV_read_buffer
#define GL_NV_read_buffer 1
+#define GL_READ_BUFFER_NV 0x0C02
+typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glReadBufferNV (GLenum mode);
#endif
-typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode);
-#endif
+#endif /* GL_NV_read_buffer */
-/* GL_NV_read_buffer_front */
#ifndef GL_NV_read_buffer_front
#define GL_NV_read_buffer_front 1
-#endif
+#endif /* GL_NV_read_buffer_front */
-/* GL_NV_read_depth */
#ifndef GL_NV_read_depth
#define GL_NV_read_depth 1
-#endif
+#endif /* GL_NV_read_depth */
-/* GL_NV_read_depth_stencil */
#ifndef GL_NV_read_depth_stencil
#define GL_NV_read_depth_stencil 1
-#endif
+#endif /* GL_NV_read_depth_stencil */
-/* GL_NV_read_stencil */
#ifndef GL_NV_read_stencil
#define GL_NV_read_stencil 1
-#endif
+#endif /* GL_NV_read_stencil */
+
+#ifndef GL_NV_sRGB_formats
+#define GL_NV_sRGB_formats 1
+#define GL_SLUMINANCE_NV 0x8C46
+#define GL_SLUMINANCE_ALPHA_NV 0x8C44
+#define GL_SRGB8_NV 0x8C41
+#define GL_SLUMINANCE8_NV 0x8C47
+#define GL_SLUMINANCE8_ALPHA8_NV 0x8C45
+#define GL_COMPRESSED_SRGB_S3TC_DXT1_NV 0x8C4C
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV 0x8C4D
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV 0x8C4E
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV 0x8C4F
+#define GL_ETC1_SRGB8_NV 0x88EE
+#endif /* GL_NV_sRGB_formats */
-/* GL_NV_shadow_samplers_array */
#ifndef GL_NV_shadow_samplers_array
#define GL_NV_shadow_samplers_array 1
-#endif
+#define GL_SAMPLER_2D_ARRAY_SHADOW_NV 0x8DC4
+#endif /* GL_NV_shadow_samplers_array */
-/* GL_NV_shadow_samplers_cube */
#ifndef GL_NV_shadow_samplers_cube
#define GL_NV_shadow_samplers_cube 1
-#endif
-
-/* GL_NV_sRGB_formats */
-#ifndef GL_NV_sRGB_formats
-#define GL_NV_sRGB_formats 1
-#endif
+#define GL_SAMPLER_CUBE_SHADOW_NV 0x8DC5
+#endif /* GL_NV_shadow_samplers_cube */
-/* GL_NV_texture_border_clamp */
#ifndef GL_NV_texture_border_clamp
#define GL_NV_texture_border_clamp 1
-#endif
+#define GL_TEXTURE_BORDER_COLOR_NV 0x1004
+#define GL_CLAMP_TO_BORDER_NV 0x812D
+#endif /* GL_NV_texture_border_clamp */
-/* GL_NV_texture_compression_s3tc_update */
#ifndef GL_NV_texture_compression_s3tc_update
#define GL_NV_texture_compression_s3tc_update 1
-#endif
+#endif /* GL_NV_texture_compression_s3tc_update */
-/* GL_NV_texture_npot_2D_mipmap */
#ifndef GL_NV_texture_npot_2D_mipmap
#define GL_NV_texture_npot_2D_mipmap 1
-#endif
+#endif /* GL_NV_texture_npot_2D_mipmap */
-/*------------------------------------------------------------------------*
- * QCOM extension functions
- *------------------------------------------------------------------------*/
-
-/* GL_QCOM_alpha_test */
#ifndef GL_QCOM_alpha_test
#define GL_QCOM_alpha_test 1
+#define GL_ALPHA_TEST_QCOM 0x0BC0
+#define GL_ALPHA_TEST_FUNC_QCOM 0x0BC1
+#define GL_ALPHA_TEST_REF_QCOM 0x0BC2
+typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glAlphaFuncQCOM (GLenum func, GLclampf ref);
#endif
-typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref);
-#endif
+#endif /* GL_QCOM_alpha_test */
-/* GL_QCOM_binning_control */
#ifndef GL_QCOM_binning_control
#define GL_QCOM_binning_control 1
-#endif
+#define GL_BINNING_CONTROL_HINT_QCOM 0x8FB0
+#define GL_CPU_OPTIMIZED_QCOM 0x8FB1
+#define GL_GPU_OPTIMIZED_QCOM 0x8FB2
+#define GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM 0x8FB3
+#endif /* GL_QCOM_binning_control */
-/* GL_QCOM_driver_control */
#ifndef GL_QCOM_driver_control
#define GL_QCOM_driver_control 1
+typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls);
+typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString);
+typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl);
+typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glGetDriverControlsQCOM (GLint *num, GLsizei size, GLuint *driverControls);
GL_APICALL void GL_APIENTRY glGetDriverControlStringQCOM (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString);
GL_APICALL void GL_APIENTRY glEnableDriverControlQCOM (GLuint driverControl);
GL_APICALL void GL_APIENTRY glDisableDriverControlQCOM (GLuint driverControl);
#endif
-typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls);
-typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString);
-typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl);
-typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl);
-#endif
+#endif /* GL_QCOM_driver_control */
-/* GL_QCOM_extended_get */
#ifndef GL_QCOM_extended_get
#define GL_QCOM_extended_get 1
+#define GL_TEXTURE_WIDTH_QCOM 0x8BD2
+#define GL_TEXTURE_HEIGHT_QCOM 0x8BD3
+#define GL_TEXTURE_DEPTH_QCOM 0x8BD4
+#define GL_TEXTURE_INTERNAL_FORMAT_QCOM 0x8BD5
+#define GL_TEXTURE_FORMAT_QCOM 0x8BD6
+#define GL_TEXTURE_TYPE_QCOM 0x8BD7
+#define GL_TEXTURE_IMAGE_VALID_QCOM 0x8BD8
+#define GL_TEXTURE_NUM_LEVELS_QCOM 0x8BD9
+#define GL_TEXTURE_TARGET_QCOM 0x8BDA
+#define GL_TEXTURE_OBJECT_VALID_QCOM 0x8BDB
+#define GL_STATE_RESTORE 0x8BDC
+typedef void (GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC) (GLuint *textures, GLint maxTextures, GLint *numTextures);
+typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC) (GLuint *buffers, GLint maxBuffers, GLint *numBuffers);
+typedef void (GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC) (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers);
+typedef void (GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC) (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers);
+typedef void (GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params);
+typedef void (GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC) (GLenum target, GLenum pname, GLint param);
+typedef void (GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, void *texels);
+typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, void **params);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glExtGetTexturesQCOM (GLuint *textures, GLint maxTextures, GLint *numTextures);
GL_APICALL void GL_APIENTRY glExtGetBuffersQCOM (GLuint *buffers, GLint maxBuffers, GLint *numBuffers);
@@ -1986,66 +1543,84 @@ GL_APICALL void GL_APIENTRY glExtGetRenderbuffersQCOM (GLuint *renderbuffers, GL
GL_APICALL void GL_APIENTRY glExtGetFramebuffersQCOM (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers);
GL_APICALL void GL_APIENTRY glExtGetTexLevelParameterivQCOM (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params);
GL_APICALL void GL_APIENTRY glExtTexObjectStateOverrideiQCOM (GLenum target, GLenum pname, GLint param);
-GL_APICALL void GL_APIENTRY glExtGetTexSubImageQCOM (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels);
-GL_APICALL void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, GLvoid **params);
-#endif
-typedef void (GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC) (GLuint *textures, GLint maxTextures, GLint *numTextures);
-typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC) (GLuint *buffers, GLint maxBuffers, GLint *numBuffers);
-typedef void (GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC) (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers);
-typedef void (GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC) (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers);
-typedef void (GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params);
-typedef void (GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC) (GLenum target, GLenum pname, GLint param);
-typedef void (GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels);
-typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, GLvoid **params);
+GL_APICALL void GL_APIENTRY glExtGetTexSubImageQCOM (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, void *texels);
+GL_APICALL void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, void **params);
#endif
+#endif /* GL_QCOM_extended_get */
-/* GL_QCOM_extended_get2 */
#ifndef GL_QCOM_extended_get2
#define GL_QCOM_extended_get2 1
+typedef void (GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC) (GLuint *shaders, GLint maxShaders, GLint *numShaders);
+typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC) (GLuint *programs, GLint maxPrograms, GLint *numPrograms);
+typedef GLboolean (GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC) (GLuint program);
+typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC) (GLuint program, GLenum shadertype, GLchar *source, GLint *length);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glExtGetShadersQCOM (GLuint *shaders, GLint maxShaders, GLint *numShaders);
GL_APICALL void GL_APIENTRY glExtGetProgramsQCOM (GLuint *programs, GLint maxPrograms, GLint *numPrograms);
GL_APICALL GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM (GLuint program);
GL_APICALL void GL_APIENTRY glExtGetProgramBinarySourceQCOM (GLuint program, GLenum shadertype, GLchar *source, GLint *length);
#endif
-typedef void (GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC) (GLuint *shaders, GLint maxShaders, GLint *numShaders);
-typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC) (GLuint *programs, GLint maxPrograms, GLint *numPrograms);
-typedef GLboolean (GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC) (GLuint program);
-typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC) (GLuint program, GLenum shadertype, GLchar *source, GLint *length);
-#endif
+#endif /* GL_QCOM_extended_get2 */
-/* GL_QCOM_perfmon_global_mode */
#ifndef GL_QCOM_perfmon_global_mode
#define GL_QCOM_perfmon_global_mode 1
-#endif
+#define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0
+#endif /* GL_QCOM_perfmon_global_mode */
-/* GL_QCOM_writeonly_rendering */
-#ifndef GL_QCOM_writeonly_rendering
-#define GL_QCOM_writeonly_rendering 1
-#endif
-
-/* GL_QCOM_tiled_rendering */
#ifndef GL_QCOM_tiled_rendering
#define GL_QCOM_tiled_rendering 1
+#define GL_COLOR_BUFFER_BIT0_QCOM 0x00000001
+#define GL_COLOR_BUFFER_BIT1_QCOM 0x00000002
+#define GL_COLOR_BUFFER_BIT2_QCOM 0x00000004
+#define GL_COLOR_BUFFER_BIT3_QCOM 0x00000008
+#define GL_COLOR_BUFFER_BIT4_QCOM 0x00000010
+#define GL_COLOR_BUFFER_BIT5_QCOM 0x00000020
+#define GL_COLOR_BUFFER_BIT6_QCOM 0x00000040
+#define GL_COLOR_BUFFER_BIT7_QCOM 0x00000080
+#define GL_DEPTH_BUFFER_BIT0_QCOM 0x00000100
+#define GL_DEPTH_BUFFER_BIT1_QCOM 0x00000200
+#define GL_DEPTH_BUFFER_BIT2_QCOM 0x00000400
+#define GL_DEPTH_BUFFER_BIT3_QCOM 0x00000800
+#define GL_DEPTH_BUFFER_BIT4_QCOM 0x00001000
+#define GL_DEPTH_BUFFER_BIT5_QCOM 0x00002000
+#define GL_DEPTH_BUFFER_BIT6_QCOM 0x00004000
+#define GL_DEPTH_BUFFER_BIT7_QCOM 0x00008000
+#define GL_STENCIL_BUFFER_BIT0_QCOM 0x00010000
+#define GL_STENCIL_BUFFER_BIT1_QCOM 0x00020000
+#define GL_STENCIL_BUFFER_BIT2_QCOM 0x00040000
+#define GL_STENCIL_BUFFER_BIT3_QCOM 0x00080000
+#define GL_STENCIL_BUFFER_BIT4_QCOM 0x00100000
+#define GL_STENCIL_BUFFER_BIT5_QCOM 0x00200000
+#define GL_STENCIL_BUFFER_BIT6_QCOM 0x00400000
+#define GL_STENCIL_BUFFER_BIT7_QCOM 0x00800000
+#define GL_MULTISAMPLE_BUFFER_BIT0_QCOM 0x01000000
+#define GL_MULTISAMPLE_BUFFER_BIT1_QCOM 0x02000000
+#define GL_MULTISAMPLE_BUFFER_BIT2_QCOM 0x04000000
+#define GL_MULTISAMPLE_BUFFER_BIT3_QCOM 0x08000000
+#define GL_MULTISAMPLE_BUFFER_BIT4_QCOM 0x10000000
+#define GL_MULTISAMPLE_BUFFER_BIT5_QCOM 0x20000000
+#define GL_MULTISAMPLE_BUFFER_BIT6_QCOM 0x40000000
+#define GL_MULTISAMPLE_BUFFER_BIT7_QCOM 0x80000000
+typedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);
+typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask);
#ifdef GL_GLEXT_PROTOTYPES
GL_APICALL void GL_APIENTRY glStartTilingQCOM (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);
GL_APICALL void GL_APIENTRY glEndTilingQCOM (GLbitfield preserveMask);
#endif
-typedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask);
-typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask);
-#endif
+#endif /* GL_QCOM_tiled_rendering */
-/*------------------------------------------------------------------------*
- * VIV extension tokens
- *------------------------------------------------------------------------*/
+#ifndef GL_QCOM_writeonly_rendering
+#define GL_QCOM_writeonly_rendering 1
+#define GL_WRITEONLY_RENDERING_QCOM 0x8823
+#endif /* GL_QCOM_writeonly_rendering */
-/* GL_VIV_shader_binary */
#ifndef GL_VIV_shader_binary
#define GL_VIV_shader_binary 1
-#endif
+#define GL_SHADER_BINARY_VIV 0x8FC4
+#endif /* GL_VIV_shader_binary */
#ifdef __cplusplus
}
#endif
-#endif /* __gl2ext_h_ */
+#endif
diff --git a/mesalib/include/GLES3/gl3.h b/mesalib/include/GLES3/gl3.h
index 9c79862c0..807fda8aa 100644
--- a/mesalib/include/GLES3/gl3.h
+++ b/mesalib/include/GLES3/gl3.h
@@ -1,18 +1,12 @@
#ifndef __gl3_h_
-#define __gl3_h_
-
-/*
- * gl3.h last updated on $Date: 2013-02-12 14:37:24 -0800 (Tue, 12 Feb 2013) $
- */
-
-#include <GLES3/gl3platform.h>
+#define __gl3_h_ 1
#ifdef __cplusplus
extern "C" {
#endif
/*
-** Copyright (c) 2007-2013 The Khronos Group Inc.
+** Copyright (c) 2013 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,1026 +27,910 @@ extern "C" {
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
+/*
+** This header is generated from the Khronos OpenGL / OpenGL ES XML
+** API Registry. The current version of the Registry, generator scripts
+** used to make the header, and the header can be found at
+** http://www.opengl.org/registry/
+**
+** Khronos $Revision: 24614 $ on $Date: 2013-12-30 04:44:46 -0800 (Mon, 30 Dec 2013) $
+*/
-/*-------------------------------------------------------------------------
- * Data type definitions
- *-----------------------------------------------------------------------*/
-
-/* OpenGL ES 2.0 */
+#include <GLES3/gl3platform.h>
-typedef void GLvoid;
-typedef char GLchar;
-typedef unsigned int GLenum;
-typedef unsigned char GLboolean;
-typedef unsigned int GLbitfield;
-typedef khronos_int8_t GLbyte;
-typedef short GLshort;
-typedef int GLint;
-typedef int GLsizei;
-typedef khronos_uint8_t GLubyte;
-typedef unsigned short GLushort;
-typedef unsigned int GLuint;
-typedef khronos_float_t GLfloat;
-typedef khronos_float_t GLclampf;
-typedef khronos_int32_t GLfixed;
-typedef khronos_intptr_t GLintptr;
-typedef khronos_ssize_t GLsizeiptr;
+/* Generated on date 20131230 */
-/* OpenGL ES 3.0 */
+/* Generated C header for:
+ * API: gles2
+ * Profile: common
+ * Versions considered: [23]\.[0-9]
+ * Versions emitted: .*
+ * Default extensions included: None
+ * Additional extensions included: _nomatch_^
+ * Extensions removed: _nomatch_^
+ */
-typedef unsigned short GLhalf;
-typedef khronos_int64_t GLint64;
-typedef khronos_uint64_t GLuint64;
+#ifndef GL_ES_VERSION_2_0
+#define GL_ES_VERSION_2_0 1
+#include <KHR/khrplatform.h>
+typedef khronos_int8_t GLbyte;
+typedef khronos_float_t GLclampf;
+typedef khronos_int32_t GLfixed;
+typedef short GLshort;
+typedef unsigned short GLushort;
+typedef void GLvoid;
typedef struct __GLsync *GLsync;
-
-/*-------------------------------------------------------------------------
- * Token definitions
- *-----------------------------------------------------------------------*/
-
-/* OpenGL ES core versions */
-#define GL_ES_VERSION_3_0 1
-#define GL_ES_VERSION_2_0 1
-
-/* OpenGL ES 2.0 */
-
-/* ClearBufferMask */
-#define GL_DEPTH_BUFFER_BIT 0x00000100
-#define GL_STENCIL_BUFFER_BIT 0x00000400
-#define GL_COLOR_BUFFER_BIT 0x00004000
-
-/* Boolean */
-#define GL_FALSE 0
-#define GL_TRUE 1
-
-/* BeginMode */
-#define GL_POINTS 0x0000
-#define GL_LINES 0x0001
-#define GL_LINE_LOOP 0x0002
-#define GL_LINE_STRIP 0x0003
-#define GL_TRIANGLES 0x0004
-#define GL_TRIANGLE_STRIP 0x0005
-#define GL_TRIANGLE_FAN 0x0006
-
-/* BlendingFactorDest */
-#define GL_ZERO 0
-#define GL_ONE 1
-#define GL_SRC_COLOR 0x0300
-#define GL_ONE_MINUS_SRC_COLOR 0x0301
-#define GL_SRC_ALPHA 0x0302
-#define GL_ONE_MINUS_SRC_ALPHA 0x0303
-#define GL_DST_ALPHA 0x0304
-#define GL_ONE_MINUS_DST_ALPHA 0x0305
-
-/* BlendingFactorSrc */
-/* GL_ZERO */
-/* GL_ONE */
-#define GL_DST_COLOR 0x0306
-#define GL_ONE_MINUS_DST_COLOR 0x0307
-#define GL_SRC_ALPHA_SATURATE 0x0308
-/* GL_SRC_ALPHA */
-/* GL_ONE_MINUS_SRC_ALPHA */
-/* GL_DST_ALPHA */
-/* GL_ONE_MINUS_DST_ALPHA */
-
-/* BlendEquationSeparate */
-#define GL_FUNC_ADD 0x8006
-#define GL_BLEND_EQUATION 0x8009
-#define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */
-#define GL_BLEND_EQUATION_ALPHA 0x883D
-
-/* BlendSubtract */
-#define GL_FUNC_SUBTRACT 0x800A
-#define GL_FUNC_REVERSE_SUBTRACT 0x800B
-
-/* Separate Blend Functions */
-#define GL_BLEND_DST_RGB 0x80C8
-#define GL_BLEND_SRC_RGB 0x80C9
-#define GL_BLEND_DST_ALPHA 0x80CA
-#define GL_BLEND_SRC_ALPHA 0x80CB
-#define GL_CONSTANT_COLOR 0x8001
-#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
-#define GL_CONSTANT_ALPHA 0x8003
-#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
-#define GL_BLEND_COLOR 0x8005
-
-/* Buffer Objects */
-#define GL_ARRAY_BUFFER 0x8892
-#define GL_ELEMENT_ARRAY_BUFFER 0x8893
-#define GL_ARRAY_BUFFER_BINDING 0x8894
-#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
-
-#define GL_STREAM_DRAW 0x88E0
-#define GL_STATIC_DRAW 0x88E4
-#define GL_DYNAMIC_DRAW 0x88E8
-
-#define GL_BUFFER_SIZE 0x8764
-#define GL_BUFFER_USAGE 0x8765
-
-#define GL_CURRENT_VERTEX_ATTRIB 0x8626
-
-/* CullFaceMode */
-#define GL_FRONT 0x0404
-#define GL_BACK 0x0405
-#define GL_FRONT_AND_BACK 0x0408
-
-/* DepthFunction */
-/* GL_NEVER */
-/* GL_LESS */
-/* GL_EQUAL */
-/* GL_LEQUAL */
-/* GL_GREATER */
-/* GL_NOTEQUAL */
-/* GL_GEQUAL */
-/* GL_ALWAYS */
-
-/* EnableCap */
-#define GL_TEXTURE_2D 0x0DE1
-#define GL_CULL_FACE 0x0B44
-#define GL_BLEND 0x0BE2
-#define GL_DITHER 0x0BD0
-#define GL_STENCIL_TEST 0x0B90
-#define GL_DEPTH_TEST 0x0B71
-#define GL_SCISSOR_TEST 0x0C11
-#define GL_POLYGON_OFFSET_FILL 0x8037
-#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
-#define GL_SAMPLE_COVERAGE 0x80A0
-
-/* ErrorCode */
-#define GL_NO_ERROR 0
-#define GL_INVALID_ENUM 0x0500
-#define GL_INVALID_VALUE 0x0501
-#define GL_INVALID_OPERATION 0x0502
-#define GL_OUT_OF_MEMORY 0x0505
-
-/* FrontFaceDirection */
-#define GL_CW 0x0900
-#define GL_CCW 0x0901
-
-/* GetPName */
-#define GL_LINE_WIDTH 0x0B21
-#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
-#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
-#define GL_CULL_FACE_MODE 0x0B45
-#define GL_FRONT_FACE 0x0B46
-#define GL_DEPTH_RANGE 0x0B70
-#define GL_DEPTH_WRITEMASK 0x0B72
-#define GL_DEPTH_CLEAR_VALUE 0x0B73
-#define GL_DEPTH_FUNC 0x0B74
-#define GL_STENCIL_CLEAR_VALUE 0x0B91
-#define GL_STENCIL_FUNC 0x0B92
-#define GL_STENCIL_FAIL 0x0B94
-#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
-#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
-#define GL_STENCIL_REF 0x0B97
-#define GL_STENCIL_VALUE_MASK 0x0B93
-#define GL_STENCIL_WRITEMASK 0x0B98
-#define GL_STENCIL_BACK_FUNC 0x8800
-#define GL_STENCIL_BACK_FAIL 0x8801
-#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
-#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
-#define GL_STENCIL_BACK_REF 0x8CA3
-#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
-#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
-#define GL_VIEWPORT 0x0BA2
-#define GL_SCISSOR_BOX 0x0C10
-/* GL_SCISSOR_TEST */
-#define GL_COLOR_CLEAR_VALUE 0x0C22
-#define GL_COLOR_WRITEMASK 0x0C23
-#define GL_UNPACK_ALIGNMENT 0x0CF5
-#define GL_PACK_ALIGNMENT 0x0D05
-#define GL_MAX_TEXTURE_SIZE 0x0D33
-#define GL_MAX_VIEWPORT_DIMS 0x0D3A
-#define GL_SUBPIXEL_BITS 0x0D50
-#define GL_RED_BITS 0x0D52
-#define GL_GREEN_BITS 0x0D53
-#define GL_BLUE_BITS 0x0D54
-#define GL_ALPHA_BITS 0x0D55
-#define GL_DEPTH_BITS 0x0D56
-#define GL_STENCIL_BITS 0x0D57
-#define GL_POLYGON_OFFSET_UNITS 0x2A00
-/* GL_POLYGON_OFFSET_FILL */
-#define GL_POLYGON_OFFSET_FACTOR 0x8038
-#define GL_TEXTURE_BINDING_2D 0x8069
-#define GL_SAMPLE_BUFFERS 0x80A8
-#define GL_SAMPLES 0x80A9
-#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
-#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
-
-/* GetTextureParameter */
-/* GL_TEXTURE_MAG_FILTER */
-/* GL_TEXTURE_MIN_FILTER */
-/* GL_TEXTURE_WRAP_S */
-/* GL_TEXTURE_WRAP_T */
-
-#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
-#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
-
-/* HintMode */
-#define GL_DONT_CARE 0x1100
-#define GL_FASTEST 0x1101
-#define GL_NICEST 0x1102
-
-/* HintTarget */
-#define GL_GENERATE_MIPMAP_HINT 0x8192
-
-/* DataType */
-#define GL_BYTE 0x1400
-#define GL_UNSIGNED_BYTE 0x1401
-#define GL_SHORT 0x1402
-#define GL_UNSIGNED_SHORT 0x1403
-#define GL_INT 0x1404
-#define GL_UNSIGNED_INT 0x1405
-#define GL_FLOAT 0x1406
-#define GL_FIXED 0x140C
-
-/* PixelFormat */
-#define GL_DEPTH_COMPONENT 0x1902
-#define GL_ALPHA 0x1906
-#define GL_RGB 0x1907
-#define GL_RGBA 0x1908
-#define GL_LUMINANCE 0x1909
-#define GL_LUMINANCE_ALPHA 0x190A
-
-/* PixelType */
-/* GL_UNSIGNED_BYTE */
-#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
-#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
-#define GL_UNSIGNED_SHORT_5_6_5 0x8363
-
-/* Shaders */
-#define GL_FRAGMENT_SHADER 0x8B30
-#define GL_VERTEX_SHADER 0x8B31
-#define GL_MAX_VERTEX_ATTRIBS 0x8869
-#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
-#define GL_MAX_VARYING_VECTORS 0x8DFC
-#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
-#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
-#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
-#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
-#define GL_SHADER_TYPE 0x8B4F
-#define GL_DELETE_STATUS 0x8B80
-#define GL_LINK_STATUS 0x8B82
-#define GL_VALIDATE_STATUS 0x8B83
-#define GL_ATTACHED_SHADERS 0x8B85
-#define GL_ACTIVE_UNIFORMS 0x8B86
-#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
-#define GL_ACTIVE_ATTRIBUTES 0x8B89
-#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
-#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
-#define GL_CURRENT_PROGRAM 0x8B8D
-
-/* StencilFunction */
-#define GL_NEVER 0x0200
-#define GL_LESS 0x0201
-#define GL_EQUAL 0x0202
-#define GL_LEQUAL 0x0203
-#define GL_GREATER 0x0204
-#define GL_NOTEQUAL 0x0205
-#define GL_GEQUAL 0x0206
-#define GL_ALWAYS 0x0207
-
-/* StencilOp */
-/* GL_ZERO */
-#define GL_KEEP 0x1E00
-#define GL_REPLACE 0x1E01
-#define GL_INCR 0x1E02
-#define GL_DECR 0x1E03
-#define GL_INVERT 0x150A
-#define GL_INCR_WRAP 0x8507
-#define GL_DECR_WRAP 0x8508
-
-/* StringName */
-#define GL_VENDOR 0x1F00
-#define GL_RENDERER 0x1F01
-#define GL_VERSION 0x1F02
-#define GL_EXTENSIONS 0x1F03
-
-/* TextureMagFilter */
-#define GL_NEAREST 0x2600
-#define GL_LINEAR 0x2601
-
-/* TextureMinFilter */
-/* GL_NEAREST */
-/* GL_LINEAR */
-#define GL_NEAREST_MIPMAP_NEAREST 0x2700
-#define GL_LINEAR_MIPMAP_NEAREST 0x2701
-#define GL_NEAREST_MIPMAP_LINEAR 0x2702
-#define GL_LINEAR_MIPMAP_LINEAR 0x2703
-
-/* TextureParameterName */
-#define GL_TEXTURE_MAG_FILTER 0x2800
-#define GL_TEXTURE_MIN_FILTER 0x2801
-#define GL_TEXTURE_WRAP_S 0x2802
-#define GL_TEXTURE_WRAP_T 0x2803
-
-/* TextureTarget */
-/* GL_TEXTURE_2D */
-#define GL_TEXTURE 0x1702
-
-#define GL_TEXTURE_CUBE_MAP 0x8513
-#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
-#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
-
-/* TextureUnit */
-#define GL_TEXTURE0 0x84C0
-#define GL_TEXTURE1 0x84C1
-#define GL_TEXTURE2 0x84C2
-#define GL_TEXTURE3 0x84C3
-#define GL_TEXTURE4 0x84C4
-#define GL_TEXTURE5 0x84C5
-#define GL_TEXTURE6 0x84C6
-#define GL_TEXTURE7 0x84C7
-#define GL_TEXTURE8 0x84C8
-#define GL_TEXTURE9 0x84C9
-#define GL_TEXTURE10 0x84CA
-#define GL_TEXTURE11 0x84CB
-#define GL_TEXTURE12 0x84CC
-#define GL_TEXTURE13 0x84CD
-#define GL_TEXTURE14 0x84CE
-#define GL_TEXTURE15 0x84CF
-#define GL_TEXTURE16 0x84D0
-#define GL_TEXTURE17 0x84D1
-#define GL_TEXTURE18 0x84D2
-#define GL_TEXTURE19 0x84D3
-#define GL_TEXTURE20 0x84D4
-#define GL_TEXTURE21 0x84D5
-#define GL_TEXTURE22 0x84D6
-#define GL_TEXTURE23 0x84D7
-#define GL_TEXTURE24 0x84D8
-#define GL_TEXTURE25 0x84D9
-#define GL_TEXTURE26 0x84DA
-#define GL_TEXTURE27 0x84DB
-#define GL_TEXTURE28 0x84DC
-#define GL_TEXTURE29 0x84DD
-#define GL_TEXTURE30 0x84DE
-#define GL_TEXTURE31 0x84DF
-#define GL_ACTIVE_TEXTURE 0x84E0
-
-/* TextureWrapMode */
-#define GL_REPEAT 0x2901
-#define GL_CLAMP_TO_EDGE 0x812F
-#define GL_MIRRORED_REPEAT 0x8370
-
-/* Uniform Types */
-#define GL_FLOAT_VEC2 0x8B50
-#define GL_FLOAT_VEC3 0x8B51
-#define GL_FLOAT_VEC4 0x8B52
-#define GL_INT_VEC2 0x8B53
-#define GL_INT_VEC3 0x8B54
-#define GL_INT_VEC4 0x8B55
-#define GL_BOOL 0x8B56
-#define GL_BOOL_VEC2 0x8B57
-#define GL_BOOL_VEC3 0x8B58
-#define GL_BOOL_VEC4 0x8B59
-#define GL_FLOAT_MAT2 0x8B5A
-#define GL_FLOAT_MAT3 0x8B5B
-#define GL_FLOAT_MAT4 0x8B5C
-#define GL_SAMPLER_2D 0x8B5E
-#define GL_SAMPLER_CUBE 0x8B60
-
-/* Vertex Arrays */
-#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
-#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
-#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
-#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
-#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
-#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
-#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
-
-/* Read Format */
-#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
-#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
-
-/* Shader Source */
-#define GL_COMPILE_STATUS 0x8B81
-#define GL_INFO_LOG_LENGTH 0x8B84
-#define GL_SHADER_SOURCE_LENGTH 0x8B88
-#define GL_SHADER_COMPILER 0x8DFA
-
-/* Shader Binary */
-#define GL_SHADER_BINARY_FORMATS 0x8DF8
-#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
-
-/* Shader Precision-Specified Types */
-#define GL_LOW_FLOAT 0x8DF0
-#define GL_MEDIUM_FLOAT 0x8DF1
-#define GL_HIGH_FLOAT 0x8DF2
-#define GL_LOW_INT 0x8DF3
-#define GL_MEDIUM_INT 0x8DF4
-#define GL_HIGH_INT 0x8DF5
-
-/* Framebuffer Object. */
-#define GL_FRAMEBUFFER 0x8D40
-#define GL_RENDERBUFFER 0x8D41
-
-#define GL_RGBA4 0x8056
-#define GL_RGB5_A1 0x8057
-#define GL_RGB565 0x8D62
-#define GL_DEPTH_COMPONENT16 0x81A5
-#define GL_STENCIL_INDEX8 0x8D48
-
-#define GL_RENDERBUFFER_WIDTH 0x8D42
-#define GL_RENDERBUFFER_HEIGHT 0x8D43
-#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
-#define GL_RENDERBUFFER_RED_SIZE 0x8D50
-#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
-#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
-#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
-#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
-#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
-
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
-
-#define GL_COLOR_ATTACHMENT0 0x8CE0
-#define GL_DEPTH_ATTACHMENT 0x8D00
-#define GL_STENCIL_ATTACHMENT 0x8D20
-
-#define GL_NONE 0
-
-#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
-#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
-#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
-#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
-#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
-
-#define GL_FRAMEBUFFER_BINDING 0x8CA6
-#define GL_RENDERBUFFER_BINDING 0x8CA7
-#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
-
-#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
-
-/* OpenGL ES 3.0 */
-
-#define GL_READ_BUFFER 0x0C02
-#define GL_UNPACK_ROW_LENGTH 0x0CF2
-#define GL_UNPACK_SKIP_ROWS 0x0CF3
-#define GL_UNPACK_SKIP_PIXELS 0x0CF4
-#define GL_PACK_ROW_LENGTH 0x0D02
-#define GL_PACK_SKIP_ROWS 0x0D03
-#define GL_PACK_SKIP_PIXELS 0x0D04
-#define GL_COLOR 0x1800
-#define GL_DEPTH 0x1801
-#define GL_STENCIL 0x1802
-#define GL_RED 0x1903
-#define GL_RGB8 0x8051
-#define GL_RGBA8 0x8058
-#define GL_RGB10_A2 0x8059
-#define GL_TEXTURE_BINDING_3D 0x806A
-#define GL_UNPACK_SKIP_IMAGES 0x806D
-#define GL_UNPACK_IMAGE_HEIGHT 0x806E
-#define GL_TEXTURE_3D 0x806F
-#define GL_TEXTURE_WRAP_R 0x8072
-#define GL_MAX_3D_TEXTURE_SIZE 0x8073
-#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
-#define GL_MAX_ELEMENTS_VERTICES 0x80E8
-#define GL_MAX_ELEMENTS_INDICES 0x80E9
-#define GL_TEXTURE_MIN_LOD 0x813A
-#define GL_TEXTURE_MAX_LOD 0x813B
-#define GL_TEXTURE_BASE_LEVEL 0x813C
-#define GL_TEXTURE_MAX_LEVEL 0x813D
-#define GL_MIN 0x8007
-#define GL_MAX 0x8008
-#define GL_DEPTH_COMPONENT24 0x81A6
-#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD
-#define GL_TEXTURE_COMPARE_MODE 0x884C
-#define GL_TEXTURE_COMPARE_FUNC 0x884D
-#define GL_CURRENT_QUERY 0x8865
-#define GL_QUERY_RESULT 0x8866
-#define GL_QUERY_RESULT_AVAILABLE 0x8867
-#define GL_BUFFER_MAPPED 0x88BC
-#define GL_BUFFER_MAP_POINTER 0x88BD
-#define GL_STREAM_READ 0x88E1
-#define GL_STREAM_COPY 0x88E2
-#define GL_STATIC_READ 0x88E5
-#define GL_STATIC_COPY 0x88E6
-#define GL_DYNAMIC_READ 0x88E9
-#define GL_DYNAMIC_COPY 0x88EA
-#define GL_MAX_DRAW_BUFFERS 0x8824
-#define GL_DRAW_BUFFER0 0x8825
-#define GL_DRAW_BUFFER1 0x8826
-#define GL_DRAW_BUFFER2 0x8827
-#define GL_DRAW_BUFFER3 0x8828
-#define GL_DRAW_BUFFER4 0x8829
-#define GL_DRAW_BUFFER5 0x882A
-#define GL_DRAW_BUFFER6 0x882B
-#define GL_DRAW_BUFFER7 0x882C
-#define GL_DRAW_BUFFER8 0x882D
-#define GL_DRAW_BUFFER9 0x882E
-#define GL_DRAW_BUFFER10 0x882F
-#define GL_DRAW_BUFFER11 0x8830
-#define GL_DRAW_BUFFER12 0x8831
-#define GL_DRAW_BUFFER13 0x8832
-#define GL_DRAW_BUFFER14 0x8833
-#define GL_DRAW_BUFFER15 0x8834
-#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
-#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
-#define GL_SAMPLER_3D 0x8B5F
-#define GL_SAMPLER_2D_SHADOW 0x8B62
-#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B
-#define GL_PIXEL_PACK_BUFFER 0x88EB
-#define GL_PIXEL_UNPACK_BUFFER 0x88EC
-#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED
-#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
-#define GL_FLOAT_MAT2x3 0x8B65
-#define GL_FLOAT_MAT2x4 0x8B66
-#define GL_FLOAT_MAT3x2 0x8B67
-#define GL_FLOAT_MAT3x4 0x8B68
-#define GL_FLOAT_MAT4x2 0x8B69
-#define GL_FLOAT_MAT4x3 0x8B6A
-#define GL_SRGB 0x8C40
-#define GL_SRGB8 0x8C41
-#define GL_SRGB8_ALPHA8 0x8C43
-#define GL_COMPARE_REF_TO_TEXTURE 0x884E
-#define GL_MAJOR_VERSION 0x821B
-#define GL_MINOR_VERSION 0x821C
-#define GL_NUM_EXTENSIONS 0x821D
-#define GL_RGBA32F 0x8814
-#define GL_RGB32F 0x8815
-#define GL_RGBA16F 0x881A
-#define GL_RGB16F 0x881B
-#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD
-#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF
-#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904
-#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905
-#define GL_MAX_VARYING_COMPONENTS 0x8B4B
-#define GL_TEXTURE_2D_ARRAY 0x8C1A
-#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D
-#define GL_R11F_G11F_B10F 0x8C3A
-#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B
-#define GL_RGB9_E5 0x8C3D
-#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E
-#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76
-#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F
-#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80
-#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83
-#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84
-#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85
-#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88
-#define GL_RASTERIZER_DISCARD 0x8C89
+typedef khronos_int64_t GLint64;
+typedef khronos_uint64_t GLuint64;
+typedef unsigned int GLenum;
+typedef unsigned int GLuint;
+typedef char GLchar;
+typedef khronos_float_t GLfloat;
+typedef khronos_ssize_t GLsizeiptr;
+typedef khronos_intptr_t GLintptr;
+typedef unsigned int GLbitfield;
+typedef int GLint;
+typedef unsigned char GLboolean;
+typedef int GLsizei;
+typedef khronos_uint8_t GLubyte;
+#define GL_DEPTH_BUFFER_BIT 0x00000100
+#define GL_STENCIL_BUFFER_BIT 0x00000400
+#define GL_COLOR_BUFFER_BIT 0x00004000
+#define GL_FALSE 0
+#define GL_TRUE 1
+#define GL_POINTS 0x0000
+#define GL_LINES 0x0001
+#define GL_LINE_LOOP 0x0002
+#define GL_LINE_STRIP 0x0003
+#define GL_TRIANGLES 0x0004
+#define GL_TRIANGLE_STRIP 0x0005
+#define GL_TRIANGLE_FAN 0x0006
+#define GL_ZERO 0
+#define GL_ONE 1
+#define GL_SRC_COLOR 0x0300
+#define GL_ONE_MINUS_SRC_COLOR 0x0301
+#define GL_SRC_ALPHA 0x0302
+#define GL_ONE_MINUS_SRC_ALPHA 0x0303
+#define GL_DST_ALPHA 0x0304
+#define GL_ONE_MINUS_DST_ALPHA 0x0305
+#define GL_DST_COLOR 0x0306
+#define GL_ONE_MINUS_DST_COLOR 0x0307
+#define GL_SRC_ALPHA_SATURATE 0x0308
+#define GL_FUNC_ADD 0x8006
+#define GL_BLEND_EQUATION 0x8009
+#define GL_BLEND_EQUATION_RGB 0x8009
+#define GL_BLEND_EQUATION_ALPHA 0x883D
+#define GL_FUNC_SUBTRACT 0x800A
+#define GL_FUNC_REVERSE_SUBTRACT 0x800B
+#define GL_BLEND_DST_RGB 0x80C8
+#define GL_BLEND_SRC_RGB 0x80C9
+#define GL_BLEND_DST_ALPHA 0x80CA
+#define GL_BLEND_SRC_ALPHA 0x80CB
+#define GL_CONSTANT_COLOR 0x8001
+#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
+#define GL_CONSTANT_ALPHA 0x8003
+#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
+#define GL_BLEND_COLOR 0x8005
+#define GL_ARRAY_BUFFER 0x8892
+#define GL_ELEMENT_ARRAY_BUFFER 0x8893
+#define GL_ARRAY_BUFFER_BINDING 0x8894
+#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
+#define GL_STREAM_DRAW 0x88E0
+#define GL_STATIC_DRAW 0x88E4
+#define GL_DYNAMIC_DRAW 0x88E8
+#define GL_BUFFER_SIZE 0x8764
+#define GL_BUFFER_USAGE 0x8765
+#define GL_CURRENT_VERTEX_ATTRIB 0x8626
+#define GL_FRONT 0x0404
+#define GL_BACK 0x0405
+#define GL_FRONT_AND_BACK 0x0408
+#define GL_TEXTURE_2D 0x0DE1
+#define GL_CULL_FACE 0x0B44
+#define GL_BLEND 0x0BE2
+#define GL_DITHER 0x0BD0
+#define GL_STENCIL_TEST 0x0B90
+#define GL_DEPTH_TEST 0x0B71
+#define GL_SCISSOR_TEST 0x0C11
+#define GL_POLYGON_OFFSET_FILL 0x8037
+#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
+#define GL_SAMPLE_COVERAGE 0x80A0
+#define GL_NO_ERROR 0
+#define GL_INVALID_ENUM 0x0500
+#define GL_INVALID_VALUE 0x0501
+#define GL_INVALID_OPERATION 0x0502
+#define GL_OUT_OF_MEMORY 0x0505
+#define GL_CW 0x0900
+#define GL_CCW 0x0901
+#define GL_LINE_WIDTH 0x0B21
+#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
+#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
+#define GL_CULL_FACE_MODE 0x0B45
+#define GL_FRONT_FACE 0x0B46
+#define GL_DEPTH_RANGE 0x0B70
+#define GL_DEPTH_WRITEMASK 0x0B72
+#define GL_DEPTH_CLEAR_VALUE 0x0B73
+#define GL_DEPTH_FUNC 0x0B74
+#define GL_STENCIL_CLEAR_VALUE 0x0B91
+#define GL_STENCIL_FUNC 0x0B92
+#define GL_STENCIL_FAIL 0x0B94
+#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
+#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
+#define GL_STENCIL_REF 0x0B97
+#define GL_STENCIL_VALUE_MASK 0x0B93
+#define GL_STENCIL_WRITEMASK 0x0B98
+#define GL_STENCIL_BACK_FUNC 0x8800
+#define GL_STENCIL_BACK_FAIL 0x8801
+#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
+#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
+#define GL_STENCIL_BACK_REF 0x8CA3
+#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
+#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
+#define GL_VIEWPORT 0x0BA2
+#define GL_SCISSOR_BOX 0x0C10
+#define GL_COLOR_CLEAR_VALUE 0x0C22
+#define GL_COLOR_WRITEMASK 0x0C23
+#define GL_UNPACK_ALIGNMENT 0x0CF5
+#define GL_PACK_ALIGNMENT 0x0D05
+#define GL_MAX_TEXTURE_SIZE 0x0D33
+#define GL_MAX_VIEWPORT_DIMS 0x0D3A
+#define GL_SUBPIXEL_BITS 0x0D50
+#define GL_RED_BITS 0x0D52
+#define GL_GREEN_BITS 0x0D53
+#define GL_BLUE_BITS 0x0D54
+#define GL_ALPHA_BITS 0x0D55
+#define GL_DEPTH_BITS 0x0D56
+#define GL_STENCIL_BITS 0x0D57
+#define GL_POLYGON_OFFSET_UNITS 0x2A00
+#define GL_POLYGON_OFFSET_FACTOR 0x8038
+#define GL_TEXTURE_BINDING_2D 0x8069
+#define GL_SAMPLE_BUFFERS 0x80A8
+#define GL_SAMPLES 0x80A9
+#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
+#define GL_DONT_CARE 0x1100
+#define GL_FASTEST 0x1101
+#define GL_NICEST 0x1102
+#define GL_GENERATE_MIPMAP_HINT 0x8192
+#define GL_BYTE 0x1400
+#define GL_UNSIGNED_BYTE 0x1401
+#define GL_SHORT 0x1402
+#define GL_UNSIGNED_SHORT 0x1403
+#define GL_INT 0x1404
+#define GL_UNSIGNED_INT 0x1405
+#define GL_FLOAT 0x1406
+#define GL_FIXED 0x140C
+#define GL_DEPTH_COMPONENT 0x1902
+#define GL_ALPHA 0x1906
+#define GL_RGB 0x1907
+#define GL_RGBA 0x1908
+#define GL_LUMINANCE 0x1909
+#define GL_LUMINANCE_ALPHA 0x190A
+#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
+#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
+#define GL_UNSIGNED_SHORT_5_6_5 0x8363
+#define GL_FRAGMENT_SHADER 0x8B30
+#define GL_VERTEX_SHADER 0x8B31
+#define GL_MAX_VERTEX_ATTRIBS 0x8869
+#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
+#define GL_MAX_VARYING_VECTORS 0x8DFC
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
+#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
+#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
+#define GL_SHADER_TYPE 0x8B4F
+#define GL_DELETE_STATUS 0x8B80
+#define GL_LINK_STATUS 0x8B82
+#define GL_VALIDATE_STATUS 0x8B83
+#define GL_ATTACHED_SHADERS 0x8B85
+#define GL_ACTIVE_UNIFORMS 0x8B86
+#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
+#define GL_ACTIVE_ATTRIBUTES 0x8B89
+#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
+#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
+#define GL_CURRENT_PROGRAM 0x8B8D
+#define GL_NEVER 0x0200
+#define GL_LESS 0x0201
+#define GL_EQUAL 0x0202
+#define GL_LEQUAL 0x0203
+#define GL_GREATER 0x0204
+#define GL_NOTEQUAL 0x0205
+#define GL_GEQUAL 0x0206
+#define GL_ALWAYS 0x0207
+#define GL_KEEP 0x1E00
+#define GL_REPLACE 0x1E01
+#define GL_INCR 0x1E02
+#define GL_DECR 0x1E03
+#define GL_INVERT 0x150A
+#define GL_INCR_WRAP 0x8507
+#define GL_DECR_WRAP 0x8508
+#define GL_VENDOR 0x1F00
+#define GL_RENDERER 0x1F01
+#define GL_VERSION 0x1F02
+#define GL_EXTENSIONS 0x1F03
+#define GL_NEAREST 0x2600
+#define GL_LINEAR 0x2601
+#define GL_NEAREST_MIPMAP_NEAREST 0x2700
+#define GL_LINEAR_MIPMAP_NEAREST 0x2701
+#define GL_NEAREST_MIPMAP_LINEAR 0x2702
+#define GL_LINEAR_MIPMAP_LINEAR 0x2703
+#define GL_TEXTURE_MAG_FILTER 0x2800
+#define GL_TEXTURE_MIN_FILTER 0x2801
+#define GL_TEXTURE_WRAP_S 0x2802
+#define GL_TEXTURE_WRAP_T 0x2803
+#define GL_TEXTURE 0x1702
+#define GL_TEXTURE_CUBE_MAP 0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
+#define GL_TEXTURE0 0x84C0
+#define GL_TEXTURE1 0x84C1
+#define GL_TEXTURE2 0x84C2
+#define GL_TEXTURE3 0x84C3
+#define GL_TEXTURE4 0x84C4
+#define GL_TEXTURE5 0x84C5
+#define GL_TEXTURE6 0x84C6
+#define GL_TEXTURE7 0x84C7
+#define GL_TEXTURE8 0x84C8
+#define GL_TEXTURE9 0x84C9
+#define GL_TEXTURE10 0x84CA
+#define GL_TEXTURE11 0x84CB
+#define GL_TEXTURE12 0x84CC
+#define GL_TEXTURE13 0x84CD
+#define GL_TEXTURE14 0x84CE
+#define GL_TEXTURE15 0x84CF
+#define GL_TEXTURE16 0x84D0
+#define GL_TEXTURE17 0x84D1
+#define GL_TEXTURE18 0x84D2
+#define GL_TEXTURE19 0x84D3
+#define GL_TEXTURE20 0x84D4
+#define GL_TEXTURE21 0x84D5
+#define GL_TEXTURE22 0x84D6
+#define GL_TEXTURE23 0x84D7
+#define GL_TEXTURE24 0x84D8
+#define GL_TEXTURE25 0x84D9
+#define GL_TEXTURE26 0x84DA
+#define GL_TEXTURE27 0x84DB
+#define GL_TEXTURE28 0x84DC
+#define GL_TEXTURE29 0x84DD
+#define GL_TEXTURE30 0x84DE
+#define GL_TEXTURE31 0x84DF
+#define GL_ACTIVE_TEXTURE 0x84E0
+#define GL_REPEAT 0x2901
+#define GL_CLAMP_TO_EDGE 0x812F
+#define GL_MIRRORED_REPEAT 0x8370
+#define GL_FLOAT_VEC2 0x8B50
+#define GL_FLOAT_VEC3 0x8B51
+#define GL_FLOAT_VEC4 0x8B52
+#define GL_INT_VEC2 0x8B53
+#define GL_INT_VEC3 0x8B54
+#define GL_INT_VEC4 0x8B55
+#define GL_BOOL 0x8B56
+#define GL_BOOL_VEC2 0x8B57
+#define GL_BOOL_VEC3 0x8B58
+#define GL_BOOL_VEC4 0x8B59
+#define GL_FLOAT_MAT2 0x8B5A
+#define GL_FLOAT_MAT3 0x8B5B
+#define GL_FLOAT_MAT4 0x8B5C
+#define GL_SAMPLER_2D 0x8B5E
+#define GL_SAMPLER_CUBE 0x8B60
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
+#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
+#define GL_COMPILE_STATUS 0x8B81
+#define GL_INFO_LOG_LENGTH 0x8B84
+#define GL_SHADER_SOURCE_LENGTH 0x8B88
+#define GL_SHADER_COMPILER 0x8DFA
+#define GL_SHADER_BINARY_FORMATS 0x8DF8
+#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
+#define GL_LOW_FLOAT 0x8DF0
+#define GL_MEDIUM_FLOAT 0x8DF1
+#define GL_HIGH_FLOAT 0x8DF2
+#define GL_LOW_INT 0x8DF3
+#define GL_MEDIUM_INT 0x8DF4
+#define GL_HIGH_INT 0x8DF5
+#define GL_FRAMEBUFFER 0x8D40
+#define GL_RENDERBUFFER 0x8D41
+#define GL_RGBA4 0x8056
+#define GL_RGB5_A1 0x8057
+#define GL_RGB565 0x8D62
+#define GL_DEPTH_COMPONENT16 0x81A5
+#define GL_STENCIL_INDEX8 0x8D48
+#define GL_RENDERBUFFER_WIDTH 0x8D42
+#define GL_RENDERBUFFER_HEIGHT 0x8D43
+#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
+#define GL_RENDERBUFFER_RED_SIZE 0x8D50
+#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
+#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
+#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
+#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
+#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
+#define GL_COLOR_ATTACHMENT0 0x8CE0
+#define GL_DEPTH_ATTACHMENT 0x8D00
+#define GL_STENCIL_ATTACHMENT 0x8D20
+#define GL_NONE 0
+#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
+#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9
+#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
+#define GL_FRAMEBUFFER_BINDING 0x8CA6
+#define GL_RENDERBUFFER_BINDING 0x8CA7
+#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
+#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
+GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture);
+GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader);
+GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name);
+GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer);
+GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer);
+GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer);
+GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture);
+GL_APICALL void GL_APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+GL_APICALL void GL_APIENTRY glBlendEquation (GLenum mode);
+GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha);
+GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);
+GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage);
+GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data);
+GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target);
+GL_APICALL void GL_APIENTRY glClear (GLbitfield mask);
+GL_APICALL void GL_APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+GL_APICALL void GL_APIENTRY glClearDepthf (GLfloat d);
+GL_APICALL void GL_APIENTRY glClearStencil (GLint s);
+GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader);
+GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data);
+GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data);
+GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GL_APICALL GLuint GL_APIENTRY glCreateProgram (void);
+GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type);
+GL_APICALL void GL_APIENTRY glCullFace (GLenum mode);
+GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers);
+GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers);
+GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program);
+GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers);
+GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader);
+GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures);
+GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func);
+GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag);
+GL_APICALL void GL_APIENTRY glDepthRangef (GLfloat n, GLfloat f);
+GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader);
+GL_APICALL void GL_APIENTRY glDisable (GLenum cap);
+GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index);
+GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count);
+GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices);
+GL_APICALL void GL_APIENTRY glEnable (GLenum cap);
+GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index);
+GL_APICALL void GL_APIENTRY glFinish (void);
+GL_APICALL void GL_APIENTRY glFlush (void);
+GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode);
+GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint *buffers);
+GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target);
+GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers);
+GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers);
+GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint *textures);
+GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders);
+GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar *name);
+GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *data);
+GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params);
+GL_APICALL GLenum GL_APIENTRY glGetError (void);
+GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat *data);
+GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint *data);
+GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision);
+GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
+GL_APICALL const GLubyte *GL_APIENTRY glGetString (GLenum name);
+GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params);
+GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params);
+GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params);
+GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar *name);
+GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params);
+GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer);
+GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode);
+GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer);
+GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap);
+GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer);
+GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program);
+GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer);
+GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader);
+GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture);
+GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width);
+GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program);
+GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param);
+GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units);
+GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels);
+GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void);
+GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glSampleCoverage (GLfloat value, GLboolean invert);
+GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length);
+GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length);
+GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);
+GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask);
+GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask);
+GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask);
+GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
+GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels);
+GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param);
+GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params);
+GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);
+GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params);
+GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);
+GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat v0);
+GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint v0);
+GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1);
+GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint v0, GLint v1);
+GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2);
+GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUseProgram (GLuint program);
+GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program);
+GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint index, GLfloat x);
+GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y);
+GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v);
+GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);
+GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
+#endif /* GL_ES_VERSION_2_0 */
+
+#ifndef GL_ES_VERSION_3_0
+#define GL_ES_VERSION_3_0 1
+typedef unsigned short GLhalf;
+#define GL_READ_BUFFER 0x0C02
+#define GL_UNPACK_ROW_LENGTH 0x0CF2
+#define GL_UNPACK_SKIP_ROWS 0x0CF3
+#define GL_UNPACK_SKIP_PIXELS 0x0CF4
+#define GL_PACK_ROW_LENGTH 0x0D02
+#define GL_PACK_SKIP_ROWS 0x0D03
+#define GL_PACK_SKIP_PIXELS 0x0D04
+#define GL_COLOR 0x1800
+#define GL_DEPTH 0x1801
+#define GL_STENCIL 0x1802
+#define GL_RED 0x1903
+#define GL_RGB8 0x8051
+#define GL_RGBA8 0x8058
+#define GL_RGB10_A2 0x8059
+#define GL_TEXTURE_BINDING_3D 0x806A
+#define GL_UNPACK_SKIP_IMAGES 0x806D
+#define GL_UNPACK_IMAGE_HEIGHT 0x806E
+#define GL_TEXTURE_3D 0x806F
+#define GL_TEXTURE_WRAP_R 0x8072
+#define GL_MAX_3D_TEXTURE_SIZE 0x8073
+#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
+#define GL_MAX_ELEMENTS_VERTICES 0x80E8
+#define GL_MAX_ELEMENTS_INDICES 0x80E9
+#define GL_TEXTURE_MIN_LOD 0x813A
+#define GL_TEXTURE_MAX_LOD 0x813B
+#define GL_TEXTURE_BASE_LEVEL 0x813C
+#define GL_TEXTURE_MAX_LEVEL 0x813D
+#define GL_MIN 0x8007
+#define GL_MAX 0x8008
+#define GL_DEPTH_COMPONENT24 0x81A6
+#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD
+#define GL_TEXTURE_COMPARE_MODE 0x884C
+#define GL_TEXTURE_COMPARE_FUNC 0x884D
+#define GL_CURRENT_QUERY 0x8865
+#define GL_QUERY_RESULT 0x8866
+#define GL_QUERY_RESULT_AVAILABLE 0x8867
+#define GL_BUFFER_MAPPED 0x88BC
+#define GL_BUFFER_MAP_POINTER 0x88BD
+#define GL_STREAM_READ 0x88E1
+#define GL_STREAM_COPY 0x88E2
+#define GL_STATIC_READ 0x88E5
+#define GL_STATIC_COPY 0x88E6
+#define GL_DYNAMIC_READ 0x88E9
+#define GL_DYNAMIC_COPY 0x88EA
+#define GL_MAX_DRAW_BUFFERS 0x8824
+#define GL_DRAW_BUFFER0 0x8825
+#define GL_DRAW_BUFFER1 0x8826
+#define GL_DRAW_BUFFER2 0x8827
+#define GL_DRAW_BUFFER3 0x8828
+#define GL_DRAW_BUFFER4 0x8829
+#define GL_DRAW_BUFFER5 0x882A
+#define GL_DRAW_BUFFER6 0x882B
+#define GL_DRAW_BUFFER7 0x882C
+#define GL_DRAW_BUFFER8 0x882D
+#define GL_DRAW_BUFFER9 0x882E
+#define GL_DRAW_BUFFER10 0x882F
+#define GL_DRAW_BUFFER11 0x8830
+#define GL_DRAW_BUFFER12 0x8831
+#define GL_DRAW_BUFFER13 0x8832
+#define GL_DRAW_BUFFER14 0x8833
+#define GL_DRAW_BUFFER15 0x8834
+#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
+#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
+#define GL_SAMPLER_3D 0x8B5F
+#define GL_SAMPLER_2D_SHADOW 0x8B62
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B
+#define GL_PIXEL_PACK_BUFFER 0x88EB
+#define GL_PIXEL_UNPACK_BUFFER 0x88EC
+#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED
+#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
+#define GL_FLOAT_MAT2x3 0x8B65
+#define GL_FLOAT_MAT2x4 0x8B66
+#define GL_FLOAT_MAT3x2 0x8B67
+#define GL_FLOAT_MAT3x4 0x8B68
+#define GL_FLOAT_MAT4x2 0x8B69
+#define GL_FLOAT_MAT4x3 0x8B6A
+#define GL_SRGB 0x8C40
+#define GL_SRGB8 0x8C41
+#define GL_SRGB8_ALPHA8 0x8C43
+#define GL_COMPARE_REF_TO_TEXTURE 0x884E
+#define GL_MAJOR_VERSION 0x821B
+#define GL_MINOR_VERSION 0x821C
+#define GL_NUM_EXTENSIONS 0x821D
+#define GL_RGBA32F 0x8814
+#define GL_RGB32F 0x8815
+#define GL_RGBA16F 0x881A
+#define GL_RGB16F 0x881B
+#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD
+#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF
+#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904
+#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905
+#define GL_MAX_VARYING_COMPONENTS 0x8B4B
+#define GL_TEXTURE_2D_ARRAY 0x8C1A
+#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D
+#define GL_R11F_G11F_B10F 0x8C3A
+#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B
+#define GL_RGB9_E5 0x8C3D
+#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E
+#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76
+#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80
+#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83
+#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84
+#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85
+#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88
+#define GL_RASTERIZER_DISCARD 0x8C89
#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A
-#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B
-#define GL_INTERLEAVED_ATTRIBS 0x8C8C
-#define GL_SEPARATE_ATTRIBS 0x8C8D
-#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E
-#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F
-#define GL_RGBA32UI 0x8D70
-#define GL_RGB32UI 0x8D71
-#define GL_RGBA16UI 0x8D76
-#define GL_RGB16UI 0x8D77
-#define GL_RGBA8UI 0x8D7C
-#define GL_RGB8UI 0x8D7D
-#define GL_RGBA32I 0x8D82
-#define GL_RGB32I 0x8D83
-#define GL_RGBA16I 0x8D88
-#define GL_RGB16I 0x8D89
-#define GL_RGBA8I 0x8D8E
-#define GL_RGB8I 0x8D8F
-#define GL_RED_INTEGER 0x8D94
-#define GL_RGB_INTEGER 0x8D98
-#define GL_RGBA_INTEGER 0x8D99
-#define GL_SAMPLER_2D_ARRAY 0x8DC1
-#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4
-#define GL_SAMPLER_CUBE_SHADOW 0x8DC5
-#define GL_UNSIGNED_INT_VEC2 0x8DC6
-#define GL_UNSIGNED_INT_VEC3 0x8DC7
-#define GL_UNSIGNED_INT_VEC4 0x8DC8
-#define GL_INT_SAMPLER_2D 0x8DCA
-#define GL_INT_SAMPLER_3D 0x8DCB
-#define GL_INT_SAMPLER_CUBE 0x8DCC
-#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF
-#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2
-#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3
-#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4
-#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7
-#define GL_BUFFER_ACCESS_FLAGS 0x911F
-#define GL_BUFFER_MAP_LENGTH 0x9120
-#define GL_BUFFER_MAP_OFFSET 0x9121
-#define GL_DEPTH_COMPONENT32F 0x8CAC
-#define GL_DEPTH32F_STENCIL8 0x8CAD
-#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD
-#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210
-#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211
-#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212
-#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213
-#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214
-#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215
-#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216
-#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217
-#define GL_FRAMEBUFFER_DEFAULT 0x8218
-#define GL_FRAMEBUFFER_UNDEFINED 0x8219
-#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
-#define GL_DEPTH_STENCIL 0x84F9
-#define GL_UNSIGNED_INT_24_8 0x84FA
-#define GL_DEPTH24_STENCIL8 0x88F0
-#define GL_UNSIGNED_NORMALIZED 0x8C17
-#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING
-#define GL_READ_FRAMEBUFFER 0x8CA8
-#define GL_DRAW_FRAMEBUFFER 0x8CA9
-#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA
-#define GL_RENDERBUFFER_SAMPLES 0x8CAB
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4
-#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF
-#define GL_COLOR_ATTACHMENT1 0x8CE1
-#define GL_COLOR_ATTACHMENT2 0x8CE2
-#define GL_COLOR_ATTACHMENT3 0x8CE3
-#define GL_COLOR_ATTACHMENT4 0x8CE4
-#define GL_COLOR_ATTACHMENT5 0x8CE5
-#define GL_COLOR_ATTACHMENT6 0x8CE6
-#define GL_COLOR_ATTACHMENT7 0x8CE7
-#define GL_COLOR_ATTACHMENT8 0x8CE8
-#define GL_COLOR_ATTACHMENT9 0x8CE9
-#define GL_COLOR_ATTACHMENT10 0x8CEA
-#define GL_COLOR_ATTACHMENT11 0x8CEB
-#define GL_COLOR_ATTACHMENT12 0x8CEC
-#define GL_COLOR_ATTACHMENT13 0x8CED
-#define GL_COLOR_ATTACHMENT14 0x8CEE
-#define GL_COLOR_ATTACHMENT15 0x8CEF
-#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
-#define GL_MAX_SAMPLES 0x8D57
-#define GL_HALF_FLOAT 0x140B
-#define GL_MAP_READ_BIT 0x0001
-#define GL_MAP_WRITE_BIT 0x0002
-#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004
-#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008
-#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010
-#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020
-#define GL_RG 0x8227
-#define GL_RG_INTEGER 0x8228
-#define GL_R8 0x8229
-#define GL_RG8 0x822B
-#define GL_R16F 0x822D
-#define GL_R32F 0x822E
-#define GL_RG16F 0x822F
-#define GL_RG32F 0x8230
-#define GL_R8I 0x8231
-#define GL_R8UI 0x8232
-#define GL_R16I 0x8233
-#define GL_R16UI 0x8234
-#define GL_R32I 0x8235
-#define GL_R32UI 0x8236
-#define GL_RG8I 0x8237
-#define GL_RG8UI 0x8238
-#define GL_RG16I 0x8239
-#define GL_RG16UI 0x823A
-#define GL_RG32I 0x823B
-#define GL_RG32UI 0x823C
-#define GL_VERTEX_ARRAY_BINDING 0x85B5
-#define GL_R8_SNORM 0x8F94
-#define GL_RG8_SNORM 0x8F95
-#define GL_RGB8_SNORM 0x8F96
-#define GL_RGBA8_SNORM 0x8F97
-#define GL_SIGNED_NORMALIZED 0x8F9C
-#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69
-#define GL_COPY_READ_BUFFER 0x8F36
-#define GL_COPY_WRITE_BUFFER 0x8F37
-#define GL_COPY_READ_BUFFER_BINDING GL_COPY_READ_BUFFER
-#define GL_COPY_WRITE_BUFFER_BINDING GL_COPY_WRITE_BUFFER
-#define GL_UNIFORM_BUFFER 0x8A11
-#define GL_UNIFORM_BUFFER_BINDING 0x8A28
-#define GL_UNIFORM_BUFFER_START 0x8A29
-#define GL_UNIFORM_BUFFER_SIZE 0x8A2A
-#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B
-#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D
-#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E
-#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F
-#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30
-#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31
-#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33
-#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34
-#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35
-#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36
-#define GL_UNIFORM_TYPE 0x8A37
-#define GL_UNIFORM_SIZE 0x8A38
-#define GL_UNIFORM_NAME_LENGTH 0x8A39
-#define GL_UNIFORM_BLOCK_INDEX 0x8A3A
-#define GL_UNIFORM_OFFSET 0x8A3B
-#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C
-#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D
-#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E
-#define GL_UNIFORM_BLOCK_BINDING 0x8A3F
-#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40
-#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41
-#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42
-#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43
-#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44
-#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46
-#define GL_INVALID_INDEX 0xFFFFFFFFu
-#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122
-#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125
-#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111
-#define GL_OBJECT_TYPE 0x9112
-#define GL_SYNC_CONDITION 0x9113
-#define GL_SYNC_STATUS 0x9114
-#define GL_SYNC_FLAGS 0x9115
-#define GL_SYNC_FENCE 0x9116
-#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
-#define GL_UNSIGNALED 0x9118
-#define GL_SIGNALED 0x9119
-#define GL_ALREADY_SIGNALED 0x911A
-#define GL_TIMEOUT_EXPIRED 0x911B
-#define GL_CONDITION_SATISFIED 0x911C
-#define GL_WAIT_FAILED 0x911D
-#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
-#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull
-#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE
-#define GL_ANY_SAMPLES_PASSED 0x8C2F
-#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A
-#define GL_SAMPLER_BINDING 0x8919
-#define GL_RGB10_A2UI 0x906F
-#define GL_TEXTURE_SWIZZLE_R 0x8E42
-#define GL_TEXTURE_SWIZZLE_G 0x8E43
-#define GL_TEXTURE_SWIZZLE_B 0x8E44
-#define GL_TEXTURE_SWIZZLE_A 0x8E45
-#define GL_GREEN 0x1904
-#define GL_BLUE 0x1905
-#define GL_INT_2_10_10_10_REV 0x8D9F
-#define GL_TRANSFORM_FEEDBACK 0x8E22
-#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23
-#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24
-#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25
-#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257
-#define GL_PROGRAM_BINARY_LENGTH 0x8741
-#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE
-#define GL_PROGRAM_BINARY_FORMATS 0x87FF
-#define GL_COMPRESSED_R11_EAC 0x9270
-#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271
-#define GL_COMPRESSED_RG11_EAC 0x9272
-#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273
-#define GL_COMPRESSED_RGB8_ETC2 0x9274
-#define GL_COMPRESSED_SRGB8_ETC2 0x9275
-#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276
-#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277
-#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278
-#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279
-#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F
-#define GL_MAX_ELEMENT_INDEX 0x8D6B
-#define GL_NUM_SAMPLE_COUNTS 0x9380
-#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF
-
-/*-------------------------------------------------------------------------
- * Entrypoint definitions
- *-----------------------------------------------------------------------*/
-
-/* OpenGL ES 2.0 */
-
-GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture);
-GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader);
-GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar* name);
-GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer);
-GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer);
-GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer);
-GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture);
-GL_APICALL void GL_APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
-GL_APICALL void GL_APIENTRY glBlendEquation (GLenum mode);
-GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha);
-GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor);
-GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
-GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage);
-GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data);
-GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target);
-GL_APICALL void GL_APIENTRY glClear (GLbitfield mask);
-GL_APICALL void GL_APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
-GL_APICALL void GL_APIENTRY glClearDepthf (GLfloat depth);
-GL_APICALL void GL_APIENTRY glClearStencil (GLint s);
-GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
-GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader);
-GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data);
-GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data);
-GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
-GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-GL_APICALL GLuint GL_APIENTRY glCreateProgram (void);
-GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type);
-GL_APICALL void GL_APIENTRY glCullFace (GLenum mode);
-GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers);
-GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers);
-GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program);
-GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers);
-GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader);
-GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures);
-GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func);
-GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag);
-GL_APICALL void GL_APIENTRY glDepthRangef (GLfloat n, GLfloat f);
-GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader);
-GL_APICALL void GL_APIENTRY glDisable (GLenum cap);
-GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index);
-GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count);
-GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices);
-GL_APICALL void GL_APIENTRY glEnable (GLenum cap);
-GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index);
-GL_APICALL void GL_APIENTRY glFinish (void);
-GL_APICALL void GL_APIENTRY glFlush (void);
-GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
-GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode);
-GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers);
-GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target);
-GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers);
-GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers);
-GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures);
-GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
-GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
-GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
-GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name);
-GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params);
-GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params);
-GL_APICALL GLenum GL_APIENTRY glGetError (void);
-GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params);
-GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params);
-GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint* params);
-GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint* params);
-GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog);
-GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params);
-GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint* params);
-GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog);
-GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
-GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);
-GL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenum name);
-GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params);
-GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params);
-GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params);
-GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params);
-GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name);
-GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params);
-GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params);
-GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer);
-GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode);
-GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer);
-GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap);
-GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer);
-GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program);
-GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer);
-GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader);
-GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture);
-GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width);
-GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program);
-GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param);
-GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units);
-GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);
-GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void);
-GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
-GL_APICALL void GL_APIENTRY glSampleCoverage (GLfloat value, GLboolean invert);
-GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height);
-GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length);
-GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length);
-GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask);
-GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask);
-GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask);
-GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask);
-GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass);
-GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
-GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
-GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param);
-GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params);
-GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param);
-GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint* params);
-GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels);
-GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat x);
-GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v);
-GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint x);
-GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* v);
-GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat x, GLfloat y);
-GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat* v);
-GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint x, GLint y);
-GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint* v);
-GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z);
-GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat* v);
-GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint x, GLint y, GLint z);
-GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint* v);
-GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* v);
-GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w);
-GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* v);
-GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GL_APICALL void GL_APIENTRY glUseProgram (GLuint program);
-GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program);
-GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x);
-GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values);
-GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y);
-GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint indx, const GLfloat* values);
-GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z);
-GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint indx, const GLfloat* values);
-GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint indx, const GLfloat* values);
-GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr);
-GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height);
-
-/* OpenGL ES 3.0 */
-
-GL_APICALL void GL_APIENTRY glReadBuffer (GLenum mode);
-GL_APICALL void GL_APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices);
-GL_APICALL void GL_APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
-GL_APICALL void GL_APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels);
-GL_APICALL void GL_APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-GL_APICALL void GL_APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data);
-GL_APICALL void GL_APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data);
-GL_APICALL void GL_APIENTRY glGenQueries (GLsizei n, GLuint* ids);
-GL_APICALL void GL_APIENTRY glDeleteQueries (GLsizei n, const GLuint* ids);
-GL_APICALL GLboolean GL_APIENTRY glIsQuery (GLuint id);
-GL_APICALL void GL_APIENTRY glBeginQuery (GLenum target, GLuint id);
-GL_APICALL void GL_APIENTRY glEndQuery (GLenum target);
-GL_APICALL void GL_APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint* params);
-GL_APICALL void GL_APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint* params);
-GL_APICALL GLboolean GL_APIENTRY glUnmapBuffer (GLenum target);
-GL_APICALL void GL_APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid** params);
-GL_APICALL void GL_APIENTRY glDrawBuffers (GLsizei n, const GLenum* bufs);
-GL_APICALL void GL_APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GL_APICALL void GL_APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GL_APICALL void GL_APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GL_APICALL void GL_APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GL_APICALL void GL_APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GL_APICALL void GL_APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
-GL_APICALL void GL_APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
-GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
-GL_APICALL void GL_APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
-GL_APICALL GLvoid* GL_APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
-GL_APICALL void GL_APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length);
-GL_APICALL void GL_APIENTRY glBindVertexArray (GLuint array);
-GL_APICALL void GL_APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint* arrays);
-GL_APICALL void GL_APIENTRY glGenVertexArrays (GLsizei n, GLuint* arrays);
-GL_APICALL GLboolean GL_APIENTRY glIsVertexArray (GLuint array);
-GL_APICALL void GL_APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint* data);
-GL_APICALL void GL_APIENTRY glBeginTransformFeedback (GLenum primitiveMode);
-GL_APICALL void GL_APIENTRY glEndTransformFeedback (void);
-GL_APICALL void GL_APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
-GL_APICALL void GL_APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer);
-GL_APICALL void GL_APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode);
-GL_APICALL void GL_APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name);
-GL_APICALL void GL_APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
-GL_APICALL void GL_APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint* params);
-GL_APICALL void GL_APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint* params);
-GL_APICALL void GL_APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w);
-GL_APICALL void GL_APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
-GL_APICALL void GL_APIENTRY glVertexAttribI4iv (GLuint index, const GLint* v);
-GL_APICALL void GL_APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint* v);
-GL_APICALL void GL_APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint* params);
-GL_APICALL GLint GL_APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name);
-GL_APICALL void GL_APIENTRY glUniform1ui (GLint location, GLuint v0);
-GL_APICALL void GL_APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1);
-GL_APICALL void GL_APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2);
-GL_APICALL void GL_APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
-GL_APICALL void GL_APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint* value);
-GL_APICALL void GL_APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint* value);
-GL_APICALL void GL_APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint* value);
-GL_APICALL void GL_APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint* value);
-GL_APICALL void GL_APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint* value);
-GL_APICALL void GL_APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint* value);
-GL_APICALL void GL_APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat* value);
-GL_APICALL void GL_APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
-GL_APICALL const GLubyte* GL_APIENTRY glGetStringi (GLenum name, GLuint index);
-GL_APICALL void GL_APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
-GL_APICALL void GL_APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices);
-GL_APICALL void GL_APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params);
-GL_APICALL GLuint GL_APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar* uniformBlockName);
-GL_APICALL void GL_APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params);
-GL_APICALL void GL_APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName);
-GL_APICALL void GL_APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
-GL_APICALL void GL_APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instanceCount);
-GL_APICALL void GL_APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount);
-GL_APICALL GLsync GL_APIENTRY glFenceSync (GLenum condition, GLbitfield flags);
-GL_APICALL GLboolean GL_APIENTRY glIsSync (GLsync sync);
-GL_APICALL void GL_APIENTRY glDeleteSync (GLsync sync);
-GL_APICALL GLenum GL_APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout);
-GL_APICALL void GL_APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout);
-GL_APICALL void GL_APIENTRY glGetInteger64v (GLenum pname, GLint64* params);
-GL_APICALL void GL_APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values);
-GL_APICALL void GL_APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64* data);
-GL_APICALL void GL_APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64* params);
-GL_APICALL void GL_APIENTRY glGenSamplers (GLsizei count, GLuint* samplers);
-GL_APICALL void GL_APIENTRY glDeleteSamplers (GLsizei count, const GLuint* samplers);
-GL_APICALL GLboolean GL_APIENTRY glIsSampler (GLuint sampler);
-GL_APICALL void GL_APIENTRY glBindSampler (GLuint unit, GLuint sampler);
-GL_APICALL void GL_APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param);
-GL_APICALL void GL_APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint* param);
-GL_APICALL void GL_APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param);
-GL_APICALL void GL_APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat* param);
-GL_APICALL void GL_APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint* params);
-GL_APICALL void GL_APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat* params);
-GL_APICALL void GL_APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor);
-GL_APICALL void GL_APIENTRY glBindTransformFeedback (GLenum target, GLuint id);
-GL_APICALL void GL_APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint* ids);
-GL_APICALL void GL_APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint* ids);
-GL_APICALL GLboolean GL_APIENTRY glIsTransformFeedback (GLuint id);
-GL_APICALL void GL_APIENTRY glPauseTransformFeedback (void);
-GL_APICALL void GL_APIENTRY glResumeTransformFeedback (void);
-GL_APICALL void GL_APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary);
-GL_APICALL void GL_APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length);
-GL_APICALL void GL_APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value);
-GL_APICALL void GL_APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum* attachments);
-GL_APICALL void GL_APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height);
-GL_APICALL void GL_APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
-GL_APICALL void GL_APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
-GL_APICALL void GL_APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params);
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B
+#define GL_INTERLEAVED_ATTRIBS 0x8C8C
+#define GL_SEPARATE_ATTRIBS 0x8C8D
+#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E
+#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F
+#define GL_RGBA32UI 0x8D70
+#define GL_RGB32UI 0x8D71
+#define GL_RGBA16UI 0x8D76
+#define GL_RGB16UI 0x8D77
+#define GL_RGBA8UI 0x8D7C
+#define GL_RGB8UI 0x8D7D
+#define GL_RGBA32I 0x8D82
+#define GL_RGB32I 0x8D83
+#define GL_RGBA16I 0x8D88
+#define GL_RGB16I 0x8D89
+#define GL_RGBA8I 0x8D8E
+#define GL_RGB8I 0x8D8F
+#define GL_RED_INTEGER 0x8D94
+#define GL_RGB_INTEGER 0x8D98
+#define GL_RGBA_INTEGER 0x8D99
+#define GL_SAMPLER_2D_ARRAY 0x8DC1
+#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4
+#define GL_SAMPLER_CUBE_SHADOW 0x8DC5
+#define GL_UNSIGNED_INT_VEC2 0x8DC6
+#define GL_UNSIGNED_INT_VEC3 0x8DC7
+#define GL_UNSIGNED_INT_VEC4 0x8DC8
+#define GL_INT_SAMPLER_2D 0x8DCA
+#define GL_INT_SAMPLER_3D 0x8DCB
+#define GL_INT_SAMPLER_CUBE 0x8DCC
+#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF
+#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2
+#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3
+#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4
+#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7
+#define GL_BUFFER_ACCESS_FLAGS 0x911F
+#define GL_BUFFER_MAP_LENGTH 0x9120
+#define GL_BUFFER_MAP_OFFSET 0x9121
+#define GL_DEPTH_COMPONENT32F 0x8CAC
+#define GL_DEPTH32F_STENCIL8 0x8CAD
+#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD
+#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210
+#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211
+#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212
+#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213
+#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214
+#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215
+#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216
+#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217
+#define GL_FRAMEBUFFER_DEFAULT 0x8218
+#define GL_FRAMEBUFFER_UNDEFINED 0x8219
+#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
+#define GL_DEPTH_STENCIL 0x84F9
+#define GL_UNSIGNED_INT_24_8 0x84FA
+#define GL_DEPTH24_STENCIL8 0x88F0
+#define GL_UNSIGNED_NORMALIZED 0x8C17
+#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6
+#define GL_READ_FRAMEBUFFER 0x8CA8
+#define GL_DRAW_FRAMEBUFFER 0x8CA9
+#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA
+#define GL_RENDERBUFFER_SAMPLES 0x8CAB
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4
+#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF
+#define GL_COLOR_ATTACHMENT1 0x8CE1
+#define GL_COLOR_ATTACHMENT2 0x8CE2
+#define GL_COLOR_ATTACHMENT3 0x8CE3
+#define GL_COLOR_ATTACHMENT4 0x8CE4
+#define GL_COLOR_ATTACHMENT5 0x8CE5
+#define GL_COLOR_ATTACHMENT6 0x8CE6
+#define GL_COLOR_ATTACHMENT7 0x8CE7
+#define GL_COLOR_ATTACHMENT8 0x8CE8
+#define GL_COLOR_ATTACHMENT9 0x8CE9
+#define GL_COLOR_ATTACHMENT10 0x8CEA
+#define GL_COLOR_ATTACHMENT11 0x8CEB
+#define GL_COLOR_ATTACHMENT12 0x8CEC
+#define GL_COLOR_ATTACHMENT13 0x8CED
+#define GL_COLOR_ATTACHMENT14 0x8CEE
+#define GL_COLOR_ATTACHMENT15 0x8CEF
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
+#define GL_MAX_SAMPLES 0x8D57
+#define GL_HALF_FLOAT 0x140B
+#define GL_MAP_READ_BIT 0x0001
+#define GL_MAP_WRITE_BIT 0x0002
+#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004
+#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008
+#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010
+#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020
+#define GL_RG 0x8227
+#define GL_RG_INTEGER 0x8228
+#define GL_R8 0x8229
+#define GL_RG8 0x822B
+#define GL_R16F 0x822D
+#define GL_R32F 0x822E
+#define GL_RG16F 0x822F
+#define GL_RG32F 0x8230
+#define GL_R8I 0x8231
+#define GL_R8UI 0x8232
+#define GL_R16I 0x8233
+#define GL_R16UI 0x8234
+#define GL_R32I 0x8235
+#define GL_R32UI 0x8236
+#define GL_RG8I 0x8237
+#define GL_RG8UI 0x8238
+#define GL_RG16I 0x8239
+#define GL_RG16UI 0x823A
+#define GL_RG32I 0x823B
+#define GL_RG32UI 0x823C
+#define GL_VERTEX_ARRAY_BINDING 0x85B5
+#define GL_R8_SNORM 0x8F94
+#define GL_RG8_SNORM 0x8F95
+#define GL_RGB8_SNORM 0x8F96
+#define GL_RGBA8_SNORM 0x8F97
+#define GL_SIGNED_NORMALIZED 0x8F9C
+#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69
+#define GL_COPY_READ_BUFFER 0x8F36
+#define GL_COPY_WRITE_BUFFER 0x8F37
+#define GL_COPY_READ_BUFFER_BINDING 0x8F36
+#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37
+#define GL_UNIFORM_BUFFER 0x8A11
+#define GL_UNIFORM_BUFFER_BINDING 0x8A28
+#define GL_UNIFORM_BUFFER_START 0x8A29
+#define GL_UNIFORM_BUFFER_SIZE 0x8A2A
+#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B
+#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D
+#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E
+#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F
+#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30
+#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31
+#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33
+#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34
+#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35
+#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36
+#define GL_UNIFORM_TYPE 0x8A37
+#define GL_UNIFORM_SIZE 0x8A38
+#define GL_UNIFORM_NAME_LENGTH 0x8A39
+#define GL_UNIFORM_BLOCK_INDEX 0x8A3A
+#define GL_UNIFORM_OFFSET 0x8A3B
+#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C
+#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D
+#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E
+#define GL_UNIFORM_BLOCK_BINDING 0x8A3F
+#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40
+#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41
+#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42
+#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46
+#define GL_INVALID_INDEX 0xFFFFFFFFu
+#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122
+#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125
+#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111
+#define GL_OBJECT_TYPE 0x9112
+#define GL_SYNC_CONDITION 0x9113
+#define GL_SYNC_STATUS 0x9114
+#define GL_SYNC_FLAGS 0x9115
+#define GL_SYNC_FENCE 0x9116
+#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
+#define GL_UNSIGNALED 0x9118
+#define GL_SIGNALED 0x9119
+#define GL_ALREADY_SIGNALED 0x911A
+#define GL_TIMEOUT_EXPIRED 0x911B
+#define GL_CONDITION_SATISFIED 0x911C
+#define GL_WAIT_FAILED 0x911D
+#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
+#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE
+#define GL_ANY_SAMPLES_PASSED 0x8C2F
+#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A
+#define GL_SAMPLER_BINDING 0x8919
+#define GL_RGB10_A2UI 0x906F
+#define GL_TEXTURE_SWIZZLE_R 0x8E42
+#define GL_TEXTURE_SWIZZLE_G 0x8E43
+#define GL_TEXTURE_SWIZZLE_B 0x8E44
+#define GL_TEXTURE_SWIZZLE_A 0x8E45
+#define GL_GREEN 0x1904
+#define GL_BLUE 0x1905
+#define GL_INT_2_10_10_10_REV 0x8D9F
+#define GL_TRANSFORM_FEEDBACK 0x8E22
+#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23
+#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24
+#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25
+#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257
+#define GL_PROGRAM_BINARY_LENGTH 0x8741
+#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE
+#define GL_PROGRAM_BINARY_FORMATS 0x87FF
+#define GL_COMPRESSED_R11_EAC 0x9270
+#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271
+#define GL_COMPRESSED_RG11_EAC 0x9272
+#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273
+#define GL_COMPRESSED_RGB8_ETC2 0x9274
+#define GL_COMPRESSED_SRGB8_ETC2 0x9275
+#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276
+#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277
+#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278
+#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279
+#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F
+#define GL_MAX_ELEMENT_INDEX 0x8D6B
+#define GL_NUM_SAMPLE_COUNTS 0x9380
+#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF
+GL_APICALL void GL_APIENTRY glReadBuffer (GLenum mode);
+GL_APICALL void GL_APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices);
+GL_APICALL void GL_APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);
+GL_APICALL void GL_APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);
+GL_APICALL void GL_APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data);
+GL_APICALL void GL_APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);
+GL_APICALL void GL_APIENTRY glGenQueries (GLsizei n, GLuint *ids);
+GL_APICALL void GL_APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids);
+GL_APICALL GLboolean GL_APIENTRY glIsQuery (GLuint id);
+GL_APICALL void GL_APIENTRY glBeginQuery (GLenum target, GLuint id);
+GL_APICALL void GL_APIENTRY glEndQuery (GLenum target);
+GL_APICALL void GL_APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params);
+GL_APICALL GLboolean GL_APIENTRY glUnmapBuffer (GLenum target);
+GL_APICALL void GL_APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, void **params);
+GL_APICALL void GL_APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs);
+GL_APICALL void GL_APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
+GL_APICALL void *GL_APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+GL_APICALL void GL_APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length);
+GL_APICALL void GL_APIENTRY glBindVertexArray (GLuint array);
+GL_APICALL void GL_APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays);
+GL_APICALL void GL_APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays);
+GL_APICALL GLboolean GL_APIENTRY glIsVertexArray (GLuint array);
+GL_APICALL void GL_APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data);
+GL_APICALL void GL_APIENTRY glBeginTransformFeedback (GLenum primitiveMode);
+GL_APICALL void GL_APIENTRY glEndTransformFeedback (void);
+GL_APICALL void GL_APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
+GL_APICALL void GL_APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer);
+GL_APICALL void GL_APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode);
+GL_APICALL void GL_APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
+GL_APICALL void GL_APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer);
+GL_APICALL void GL_APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params);
+GL_APICALL void GL_APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w);
+GL_APICALL void GL_APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+GL_APICALL void GL_APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v);
+GL_APICALL void GL_APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v);
+GL_APICALL void GL_APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params);
+GL_APICALL GLint GL_APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name);
+GL_APICALL void GL_APIENTRY glUniform1ui (GLint location, GLuint v0);
+GL_APICALL void GL_APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1);
+GL_APICALL void GL_APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2);
+GL_APICALL void GL_APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+GL_APICALL void GL_APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value);
+GL_APICALL void GL_APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value);
+GL_APICALL void GL_APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value);
+GL_APICALL void GL_APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value);
+GL_APICALL void GL_APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value);
+GL_APICALL void GL_APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value);
+GL_APICALL void GL_APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value);
+GL_APICALL void GL_APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
+GL_APICALL const GLubyte *GL_APIENTRY glGetStringi (GLenum name, GLuint index);
+GL_APICALL void GL_APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
+GL_APICALL void GL_APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices);
+GL_APICALL void GL_APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params);
+GL_APICALL GLuint GL_APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName);
+GL_APICALL void GL_APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName);
+GL_APICALL void GL_APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
+GL_APICALL void GL_APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount);
+GL_APICALL void GL_APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount);
+GL_APICALL GLsync GL_APIENTRY glFenceSync (GLenum condition, GLbitfield flags);
+GL_APICALL GLboolean GL_APIENTRY glIsSync (GLsync sync);
+GL_APICALL void GL_APIENTRY glDeleteSync (GLsync sync);
+GL_APICALL GLenum GL_APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout);
+GL_APICALL void GL_APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout);
+GL_APICALL void GL_APIENTRY glGetInteger64v (GLenum pname, GLint64 *data);
+GL_APICALL void GL_APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
+GL_APICALL void GL_APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data);
+GL_APICALL void GL_APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params);
+GL_APICALL void GL_APIENTRY glGenSamplers (GLsizei count, GLuint *samplers);
+GL_APICALL void GL_APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers);
+GL_APICALL GLboolean GL_APIENTRY glIsSampler (GLuint sampler);
+GL_APICALL void GL_APIENTRY glBindSampler (GLuint unit, GLuint sampler);
+GL_APICALL void GL_APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param);
+GL_APICALL void GL_APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param);
+GL_APICALL void GL_APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param);
+GL_APICALL void GL_APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param);
+GL_APICALL void GL_APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params);
+GL_APICALL void GL_APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params);
+GL_APICALL void GL_APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor);
+GL_APICALL void GL_APIENTRY glBindTransformFeedback (GLenum target, GLuint id);
+GL_APICALL void GL_APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids);
+GL_APICALL void GL_APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids);
+GL_APICALL GLboolean GL_APIENTRY glIsTransformFeedback (GLuint id);
+GL_APICALL void GL_APIENTRY glPauseTransformFeedback (void);
+GL_APICALL void GL_APIENTRY glResumeTransformFeedback (void);
+GL_APICALL void GL_APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary);
+GL_APICALL void GL_APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length);
+GL_APICALL void GL_APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value);
+GL_APICALL void GL_APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments);
+GL_APICALL void GL_APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+GL_APICALL void GL_APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+GL_APICALL void GL_APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params);
+#endif /* GL_ES_VERSION_3_0 */
#ifdef __cplusplus
}
diff --git a/mesalib/include/c11/threads.h b/mesalib/include/c11/threads.h
new file mode 100644
index 000000000..45823df35
--- /dev/null
+++ b/mesalib/include/c11/threads.h
@@ -0,0 +1,79 @@
+/*
+ * C11 <threads.h> emulation library
+ *
+ * (C) Copyright yohhoy 2012.
+ * Distributed under the Boost Software License, Version 1.0.
+ *
+ * Permission is hereby granted, free of charge, to any person or organization
+ * obtaining a copy of the software and accompanying documentation covered by
+ * this license (the "Software") to use, reproduce, display, distribute,
+ * execute, and transmit the Software, and to prepare [[derivative work]]s of the
+ * Software, and to permit third-parties to whom the Software is furnished to
+ * do so, all subject to the following:
+ *
+ * The copyright notices in the Software and this entire statement, including
+ * the above license grant, this restriction and the following disclaimer,
+ * must be included in all copies of the Software, in whole or in part, and
+ * all derivative works of the Software, unless such copies or derivative
+ * works are solely in the form of machine-executable object code generated by
+ * a source language processor.
+ *
+ * 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+ * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+ * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+#ifndef EMULATED_THREADS_H_INCLUDED_
+#define EMULATED_THREADS_H_INCLUDED_
+
+#include <time.h>
+
+#ifndef TIME_UTC
+#define TIME_UTC 1
+#endif
+
+#include "c99_compat.h" /* for `inline` */
+
+/*---------------------------- types ----------------------------*/
+typedef void (*tss_dtor_t)(void*);
+typedef int (*thrd_start_t)(void*);
+
+struct xtime {
+ time_t sec;
+ long nsec;
+};
+typedef struct xtime xtime;
+
+
+/*-------------------- enumeration constants --------------------*/
+enum {
+ mtx_plain = 0,
+ mtx_try = 1,
+ mtx_timed = 2,
+ mtx_recursive = 4
+};
+
+enum {
+ thrd_success = 0, // succeeded
+ thrd_timeout, // timeout
+ thrd_error, // failed
+ thrd_busy, // resource busy
+ thrd_nomem // out of memory
+};
+
+/*-------------------------- functions --------------------------*/
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#include "threads_win32.h"
+#elif defined(HAVE_PTHREAD)
+#include "threads_posix.h"
+#else
+#error Not supported on this platform.
+#endif
+
+
+
+#endif /* EMULATED_THREADS_H_INCLUDED_ */
diff --git a/mesalib/include/c11/threads_posix.h b/mesalib/include/c11/threads_posix.h
new file mode 100644
index 000000000..7e96715c2
--- /dev/null
+++ b/mesalib/include/c11/threads_posix.h
@@ -0,0 +1,373 @@
+/*
+ * C11 <threads.h> emulation library
+ *
+ * (C) Copyright yohhoy 2012.
+ * Distributed under the Boost Software License, Version 1.0.
+ *
+ * Permission is hereby granted, free of charge, to any person or organization
+ * obtaining a copy of the software and accompanying documentation covered by
+ * this license (the "Software") to use, reproduce, display, distribute,
+ * execute, and transmit the Software, and to prepare [[derivative work]]s of the
+ * Software, and to permit third-parties to whom the Software is furnished to
+ * do so, all subject to the following:
+ *
+ * The copyright notices in the Software and this entire statement, including
+ * the above license grant, this restriction and the following disclaimer,
+ * must be included in all copies of the Software, in whole or in part, and
+ * all derivative works of the Software, unless such copies or derivative
+ * works are solely in the form of machine-executable object code generated by
+ * a source language processor.
+ *
+ * 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+ * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+ * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+#include <stdlib.h>
+#include <assert.h>
+#include <limits.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sched.h>
+#include <stdint.h> /* for intptr_t */
+
+/*
+Configuration macro:
+
+ EMULATED_THREADS_USE_NATIVE_TIMEDLOCK
+ Use pthread_mutex_timedlock() for `mtx_timedlock()'
+ Otherwise use mtx_trylock() + *busy loop* emulation.
+*/
+#if !defined(__CYGWIN__) && !defined(__APPLE__) && !defined(__NetBSD__)
+#define EMULATED_THREADS_USE_NATIVE_TIMEDLOCK
+#endif
+
+
+#include <pthread.h>
+
+/*---------------------------- macros ----------------------------*/
+#define ONCE_FLAG_INIT PTHREAD_ONCE_INIT
+#ifdef INIT_ONCE_STATIC_INIT
+#define TSS_DTOR_ITERATIONS PTHREAD_DESTRUCTOR_ITERATIONS
+#else
+#define TSS_DTOR_ITERATIONS 1 // assume TSS dtor MAY be called at least once.
+#endif
+
+// FIXME: temporary non-standard hack to ease transition
+#define _MTX_INITIALIZER_NP PTHREAD_MUTEX_INITIALIZER
+
+/*---------------------------- types ----------------------------*/
+typedef pthread_cond_t cnd_t;
+typedef pthread_t thrd_t;
+typedef pthread_key_t tss_t;
+typedef pthread_mutex_t mtx_t;
+typedef pthread_once_t once_flag;
+
+
+/*
+Implementation limits:
+ - Conditionally emulation for "mutex with timeout"
+ (see EMULATED_THREADS_USE_NATIVE_TIMEDLOCK macro)
+*/
+struct impl_thrd_param {
+ thrd_start_t func;
+ void *arg;
+};
+
+static inline void *
+impl_thrd_routine(void *p)
+{
+ struct impl_thrd_param pack = *((struct impl_thrd_param *)p);
+ free(p);
+ return (void*)(intptr_t)pack.func(pack.arg);
+}
+
+
+/*--------------- 7.25.2 Initialization functions ---------------*/
+// 7.25.2.1
+static inline void
+call_once(once_flag *flag, void (*func)(void))
+{
+ pthread_once(flag, func);
+}
+
+
+/*------------- 7.25.3 Condition variable functions -------------*/
+// 7.25.3.1
+static inline int
+cnd_broadcast(cnd_t *cond)
+{
+ if (!cond) return thrd_error;
+ pthread_cond_broadcast(cond);
+ return thrd_success;
+}
+
+// 7.25.3.2
+static inline void
+cnd_destroy(cnd_t *cond)
+{
+ assert(cond);
+ pthread_cond_destroy(cond);
+}
+
+// 7.25.3.3
+static inline int
+cnd_init(cnd_t *cond)
+{
+ if (!cond) return thrd_error;
+ pthread_cond_init(cond, NULL);
+ return thrd_success;
+}
+
+// 7.25.3.4
+static inline int
+cnd_signal(cnd_t *cond)
+{
+ if (!cond) return thrd_error;
+ pthread_cond_signal(cond);
+ return thrd_success;
+}
+
+// 7.25.3.5
+static inline int
+cnd_timedwait(cnd_t *cond, mtx_t *mtx, const xtime *xt)
+{
+ struct timespec abs_time;
+ int rt;
+ if (!cond || !mtx || !xt) return thrd_error;
+ rt = pthread_cond_timedwait(cond, mtx, &abs_time);
+ if (rt == ETIMEDOUT)
+ return thrd_busy;
+ return (rt == 0) ? thrd_success : thrd_error;
+}
+
+// 7.25.3.6
+static inline int
+cnd_wait(cnd_t *cond, mtx_t *mtx)
+{
+ if (!cond || !mtx) return thrd_error;
+ pthread_cond_wait(cond, mtx);
+ return thrd_success;
+}
+
+
+/*-------------------- 7.25.4 Mutex functions --------------------*/
+// 7.25.4.1
+static inline void
+mtx_destroy(mtx_t *mtx)
+{
+ assert(mtx);
+ pthread_mutex_destroy(mtx);
+}
+
+// 7.25.4.2
+static inline int
+mtx_init(mtx_t *mtx, int type)
+{
+ pthread_mutexattr_t attr;
+ if (!mtx) return thrd_error;
+ if (type != mtx_plain && type != mtx_timed && type != mtx_try
+ && type != (mtx_plain|mtx_recursive)
+ && type != (mtx_timed|mtx_recursive)
+ && type != (mtx_try|mtx_recursive))
+ return thrd_error;
+ pthread_mutexattr_init(&attr);
+ if ((type & mtx_recursive) != 0) {
+#if defined(__linux__) || defined(__linux)
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
+#else
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+#endif
+ }
+ pthread_mutex_init(mtx, &attr);
+ pthread_mutexattr_destroy(&attr);
+ return thrd_success;
+}
+
+// 7.25.4.3
+static inline int
+mtx_lock(mtx_t *mtx)
+{
+ if (!mtx) return thrd_error;
+ pthread_mutex_lock(mtx);
+ return thrd_success;
+}
+
+static inline int
+mtx_trylock(mtx_t *mtx);
+
+static inline void
+thrd_yield(void);
+
+// 7.25.4.4
+static inline int
+mtx_timedlock(mtx_t *mtx, const xtime *xt)
+{
+ if (!mtx || !xt) return thrd_error;
+ {
+#ifdef EMULATED_THREADS_USE_NATIVE_TIMEDLOCK
+ struct timespec ts;
+ int rt;
+ ts.tv_sec = xt->sec;
+ ts.tv_nsec = xt->nsec;
+ rt = pthread_mutex_timedlock(mtx, &ts);
+ if (rt == 0)
+ return thrd_success;
+ return (rt == ETIMEDOUT) ? thrd_busy : thrd_error;
+#else
+ time_t expire = time(NULL);
+ expire += xt->sec;
+ while (mtx_trylock(mtx) != thrd_success) {
+ time_t now = time(NULL);
+ if (expire < now)
+ return thrd_busy;
+ // busy loop!
+ thrd_yield();
+ }
+ return thrd_success;
+#endif
+ }
+}
+
+// 7.25.4.5
+static inline int
+mtx_trylock(mtx_t *mtx)
+{
+ if (!mtx) return thrd_error;
+ return (pthread_mutex_trylock(mtx) == 0) ? thrd_success : thrd_busy;
+}
+
+// 7.25.4.6
+static inline int
+mtx_unlock(mtx_t *mtx)
+{
+ if (!mtx) return thrd_error;
+ pthread_mutex_unlock(mtx);
+ return thrd_success;
+}
+
+
+/*------------------- 7.25.5 Thread functions -------------------*/
+// 7.25.5.1
+static inline int
+thrd_create(thrd_t *thr, thrd_start_t func, void *arg)
+{
+ struct impl_thrd_param *pack;
+ if (!thr) return thrd_error;
+ pack = (struct impl_thrd_param *)malloc(sizeof(struct impl_thrd_param));
+ if (!pack) return thrd_nomem;
+ pack->func = func;
+ pack->arg = arg;
+ if (pthread_create(thr, NULL, impl_thrd_routine, pack) != 0) {
+ free(pack);
+ return thrd_error;
+ }
+ return thrd_success;
+}
+
+// 7.25.5.2
+static inline thrd_t
+thrd_current(void)
+{
+ return pthread_self();
+}
+
+// 7.25.5.3
+static inline int
+thrd_detach(thrd_t thr)
+{
+ return (pthread_detach(thr) == 0) ? thrd_success : thrd_error;
+}
+
+// 7.25.5.4
+static inline int
+thrd_equal(thrd_t thr0, thrd_t thr1)
+{
+ return pthread_equal(thr0, thr1);
+}
+
+// 7.25.5.5
+static inline void
+thrd_exit(int res)
+{
+ pthread_exit((void*)(intptr_t)res);
+}
+
+// 7.25.5.6
+static inline int
+thrd_join(thrd_t thr, int *res)
+{
+ void *code;
+ if (pthread_join(thr, &code) != 0)
+ return thrd_error;
+ if (res)
+ *res = (int)(intptr_t)code;
+ return thrd_success;
+}
+
+// 7.25.5.7
+static inline void
+thrd_sleep(const xtime *xt)
+{
+ struct timespec req;
+ assert(xt);
+ req.tv_sec = xt->sec;
+ req.tv_nsec = xt->nsec;
+ nanosleep(&req, NULL);
+}
+
+// 7.25.5.8
+static inline void
+thrd_yield(void)
+{
+ sched_yield();
+}
+
+
+/*----------- 7.25.6 Thread-specific storage functions -----------*/
+// 7.25.6.1
+static inline int
+tss_create(tss_t *key, tss_dtor_t dtor)
+{
+ if (!key) return thrd_error;
+ return (pthread_key_create(key, dtor) == 0) ? thrd_success : thrd_error;
+}
+
+// 7.25.6.2
+static inline void
+tss_delete(tss_t key)
+{
+ pthread_key_delete(key);
+}
+
+// 7.25.6.3
+static inline void *
+tss_get(tss_t key)
+{
+ return pthread_getspecific(key);
+}
+
+// 7.25.6.4
+static inline int
+tss_set(tss_t key, void *val)
+{
+ return (pthread_setspecific(key, val) == 0) ? thrd_success : thrd_error;
+}
+
+
+/*-------------------- 7.25.7 Time functions --------------------*/
+// 7.25.6.1
+static inline int
+xtime_get(xtime *xt, int base)
+{
+ if (!xt) return 0;
+ if (base == TIME_UTC) {
+ xt->sec = time(NULL);
+ xt->nsec = 0;
+ return base;
+ }
+ return 0;
+}
diff --git a/mesalib/include/c11/threads_win32.h b/mesalib/include/c11/threads_win32.h
new file mode 100644
index 000000000..ee2946025
--- /dev/null
+++ b/mesalib/include/c11/threads_win32.h
@@ -0,0 +1,609 @@
+/*
+ * C11 <threads.h> emulation library
+ *
+ * (C) Copyright yohhoy 2012.
+ * Distributed under the Boost Software License, Version 1.0.
+ *
+ * Permission is hereby granted, free of charge, to any person or organization
+ * obtaining a copy of the software and accompanying documentation covered by
+ * this license (the "Software") to use, reproduce, display, distribute,
+ * execute, and transmit the Software, and to prepare [[derivative work]]s of the
+ * Software, and to permit third-parties to whom the Software is furnished to
+ * do so, all subject to the following:
+ *
+ * The copyright notices in the Software and this entire statement, including
+ * the above license grant, this restriction and the following disclaimer,
+ * must be included in all copies of the Software, in whole or in part, and
+ * all derivative works of the Software, unless such copies or derivative
+ * works are solely in the form of machine-executable object code generated by
+ * a source language processor.
+ *
+ * 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+ * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+ * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+#include <assert.h>
+#include <limits.h>
+#include <errno.h>
+#include <process.h> // MSVCRT
+
+/*
+Configuration macro:
+
+ EMULATED_THREADS_USE_NATIVE_CALL_ONCE
+ Use native WindowsAPI one-time initialization function.
+ (requires WinVista or later)
+ Otherwise emulate by mtx_trylock() + *busy loop* for WinXP.
+
+ EMULATED_THREADS_USE_NATIVE_CV
+ Use native WindowsAPI condition variable object.
+ (requires WinVista or later)
+ Otherwise use emulated implementation for WinXP.
+
+ EMULATED_THREADS_TSS_DTOR_SLOTNUM
+ Max registerable TSS dtor number.
+*/
+
+// XXX: Retain XP compatability
+#if 0
+#if _WIN32_WINNT >= 0x0600
+// Prefer native WindowsAPI on newer environment.
+#if !defined(__MINGW32__)
+#define EMULATED_THREADS_USE_NATIVE_CALL_ONCE
+#endif
+#define EMULATED_THREADS_USE_NATIVE_CV
+#endif
+#endif
+#define EMULATED_THREADS_TSS_DTOR_SLOTNUM 64 // see TLS_MINIMUM_AVAILABLE
+
+
+#include <windows.h>
+
+// check configuration
+#if defined(EMULATED_THREADS_USE_NATIVE_CALL_ONCE) && (_WIN32_WINNT < 0x0600)
+#error EMULATED_THREADS_USE_NATIVE_CALL_ONCE requires _WIN32_WINNT>=0x0600
+#endif
+
+#if defined(EMULATED_THREADS_USE_NATIVE_CV) && (_WIN32_WINNT < 0x0600)
+#error EMULATED_THREADS_USE_NATIVE_CV requires _WIN32_WINNT>=0x0600
+#endif
+
+
+/*---------------------------- macros ----------------------------*/
+#ifdef EMULATED_THREADS_USE_NATIVE_CALL_ONCE
+#define ONCE_FLAG_INIT INIT_ONCE_STATIC_INIT
+#else
+#define ONCE_FLAG_INIT {0}
+#endif
+#define TSS_DTOR_ITERATIONS 1
+
+// FIXME: temporary non-standard hack to ease transition
+#define _MTX_INITIALIZER_NP {(PCRITICAL_SECTION_DEBUG)-1, -1, 0, 0, 0, 0}
+
+/*---------------------------- types ----------------------------*/
+typedef struct cnd_t {
+#ifdef EMULATED_THREADS_USE_NATIVE_CV
+ CONDITION_VARIABLE condvar;
+#else
+ int blocked;
+ int gone;
+ int to_unblock;
+ HANDLE sem_queue;
+ HANDLE sem_gate;
+ CRITICAL_SECTION monitor;
+#endif
+} cnd_t;
+
+typedef HANDLE thrd_t;
+
+typedef DWORD tss_t;
+
+typedef CRITICAL_SECTION mtx_t;
+
+#ifdef EMULATED_THREADS_USE_NATIVE_CALL_ONCE
+typedef INIT_ONCE once_flag;
+#else
+typedef struct once_flag_t {
+ volatile LONG status;
+} once_flag;
+#endif
+
+
+static inline void * tss_get(tss_t key);
+static inline void thrd_yield(void);
+static inline int mtx_trylock(mtx_t *mtx);
+static inline int mtx_lock(mtx_t *mtx);
+static inline int mtx_unlock(mtx_t *mtx);
+
+/*
+Implementation limits:
+ - Conditionally emulation for "Initialization functions"
+ (see EMULATED_THREADS_USE_NATIVE_CALL_ONCE macro)
+ - Emulated `mtx_timelock()' with mtx_trylock() + *busy loop*
+*/
+static void impl_tss_dtor_invoke(void); // forward decl.
+
+struct impl_thrd_param {
+ thrd_start_t func;
+ void *arg;
+};
+
+static unsigned __stdcall impl_thrd_routine(void *p)
+{
+ struct impl_thrd_param pack;
+ int code;
+ memcpy(&pack, p, sizeof(struct impl_thrd_param));
+ free(p);
+ code = pack.func(pack.arg);
+ impl_tss_dtor_invoke();
+ return (unsigned)code;
+}
+
+static DWORD impl_xtime2msec(const xtime *xt)
+{
+ return (DWORD)((xt->sec * 1000u) + (xt->nsec / 1000));
+}
+
+#ifdef EMULATED_THREADS_USE_NATIVE_CALL_ONCE
+struct impl_call_once_param { void (*func)(void); };
+static BOOL CALLBACK impl_call_once_callback(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *Context)
+{
+ struct impl_call_once_param *param = (struct impl_call_once_param*)Parameter;
+ (param->func)();
+ ((void)InitOnce); ((void)Context); // suppress warning
+ return TRUE;
+}
+#endif // ifdef EMULATED_THREADS_USE_NATIVE_CALL_ONCE
+
+#ifndef EMULATED_THREADS_USE_NATIVE_CV
+/*
+Note:
+ The implementation of condition variable is ported from Boost.Interprocess
+ See http://www.boost.org/boost/interprocess/sync/windows/condition.hpp
+*/
+static void impl_cond_do_signal(cnd_t *cond, int broadcast)
+{
+ int nsignal = 0;
+
+ EnterCriticalSection(&cond->monitor);
+ if (cond->to_unblock != 0) {
+ if (cond->blocked == 0) {
+ LeaveCriticalSection(&cond->monitor);
+ return;
+ }
+ if (broadcast) {
+ cond->to_unblock += nsignal = cond->blocked;
+ cond->blocked = 0;
+ } else {
+ nsignal = 1;
+ cond->to_unblock++;
+ cond->blocked--;
+ }
+ } else if (cond->blocked > cond->gone) {
+ WaitForSingleObject(cond->sem_gate, INFINITE);
+ if (cond->gone != 0) {
+ cond->blocked -= cond->gone;
+ cond->gone = 0;
+ }
+ if (broadcast) {
+ nsignal = cond->to_unblock = cond->blocked;
+ cond->blocked = 0;
+ } else {
+ nsignal = cond->to_unblock = 1;
+ cond->blocked--;
+ }
+ }
+ LeaveCriticalSection(&cond->monitor);
+
+ if (0 < nsignal)
+ ReleaseSemaphore(cond->sem_queue, nsignal, NULL);
+}
+
+static int impl_cond_do_wait(cnd_t *cond, mtx_t *mtx, const xtime *xt)
+{
+ int nleft = 0;
+ int ngone = 0;
+ int timeout = 0;
+ DWORD w;
+
+ WaitForSingleObject(cond->sem_gate, INFINITE);
+ cond->blocked++;
+ ReleaseSemaphore(cond->sem_gate, 1, NULL);
+
+ mtx_unlock(mtx);
+
+ w = WaitForSingleObject(cond->sem_queue, xt ? impl_xtime2msec(xt) : INFINITE);
+ timeout = (w == WAIT_TIMEOUT);
+
+ EnterCriticalSection(&cond->monitor);
+ if ((nleft = cond->to_unblock) != 0) {
+ if (timeout) {
+ if (cond->blocked != 0) {
+ cond->blocked--;
+ } else {
+ cond->gone++;
+ }
+ }
+ if (--cond->to_unblock == 0) {
+ if (cond->blocked != 0) {
+ ReleaseSemaphore(cond->sem_gate, 1, NULL);
+ nleft = 0;
+ }
+ else if ((ngone = cond->gone) != 0) {
+ cond->gone = 0;
+ }
+ }
+ } else if (++cond->gone == INT_MAX/2) {
+ WaitForSingleObject(cond->sem_gate, INFINITE);
+ cond->blocked -= cond->gone;
+ ReleaseSemaphore(cond->sem_gate, 1, NULL);
+ cond->gone = 0;
+ }
+ LeaveCriticalSection(&cond->monitor);
+
+ if (nleft == 1) {
+ while (ngone--)
+ WaitForSingleObject(cond->sem_queue, INFINITE);
+ ReleaseSemaphore(cond->sem_gate, 1, NULL);
+ }
+
+ mtx_lock(mtx);
+ return timeout ? thrd_busy : thrd_success;
+}
+#endif // ifndef EMULATED_THREADS_USE_NATIVE_CV
+
+static struct impl_tss_dtor_entry {
+ tss_t key;
+ tss_dtor_t dtor;
+} impl_tss_dtor_tbl[EMULATED_THREADS_TSS_DTOR_SLOTNUM];
+
+static int impl_tss_dtor_register(tss_t key, tss_dtor_t dtor)
+{
+ int i;
+ for (i = 0; i < EMULATED_THREADS_TSS_DTOR_SLOTNUM; i++) {
+ if (!impl_tss_dtor_tbl[i].dtor)
+ break;
+ }
+ if (i == EMULATED_THREADS_TSS_DTOR_SLOTNUM)
+ return 1;
+ impl_tss_dtor_tbl[i].key = key;
+ impl_tss_dtor_tbl[i].dtor = dtor;
+ return 0;
+}
+
+static void impl_tss_dtor_invoke()
+{
+ int i;
+ for (i = 0; i < EMULATED_THREADS_TSS_DTOR_SLOTNUM; i++) {
+ if (impl_tss_dtor_tbl[i].dtor) {
+ void* val = tss_get(impl_tss_dtor_tbl[i].key);
+ if (val)
+ (impl_tss_dtor_tbl[i].dtor)(val);
+ }
+ }
+}
+
+
+/*--------------- 7.25.2 Initialization functions ---------------*/
+// 7.25.2.1
+static inline void
+call_once(once_flag *flag, void (*func)(void))
+{
+ assert(!flag && !func);
+#ifdef EMULATED_THREADS_USE_NATIVE_CALL_ONCE
+ {
+ struct impl_call_once_param param;
+ param.func = func;
+ InitOnceExecuteOnce(flag, impl_call_once_callback, (PVOID)&param, NULL);
+ }
+#else
+ if (InterlockedCompareExchange(&flag->status, 1, 0) == 0) {
+ (func)();
+ InterlockedExchange(&flag->status, 2);
+ } else {
+ while (flag->status == 1) {
+ // busy loop!
+ thrd_yield();
+ }
+ }
+#endif
+}
+
+
+/*------------- 7.25.3 Condition variable functions -------------*/
+// 7.25.3.1
+static inline int
+cnd_broadcast(cnd_t *cond)
+{
+ if (!cond) return thrd_error;
+#ifdef EMULATED_THREADS_USE_NATIVE_CV
+ WakeAllConditionVariable(&cond->condvar);
+#else
+ impl_cond_do_signal(cond, 1);
+#endif
+ return thrd_success;
+}
+
+// 7.25.3.2
+static inline void
+cnd_destroy(cnd_t *cond)
+{
+ assert(cond);
+#ifdef EMULATED_THREADS_USE_NATIVE_CV
+ // do nothing
+#else
+ CloseHandle(cond->sem_queue);
+ CloseHandle(cond->sem_gate);
+ DeleteCriticalSection(&cond->monitor);
+#endif
+}
+
+// 7.25.3.3
+static inline int
+cnd_init(cnd_t *cond)
+{
+ if (!cond) return thrd_error;
+#ifdef EMULATED_THREADS_USE_NATIVE_CV
+ InitializeConditionVariable(&cond->condvar);
+#else
+ cond->blocked = 0;
+ cond->gone = 0;
+ cond->to_unblock = 0;
+ cond->sem_queue = CreateSemaphore(NULL, 0, LONG_MAX, NULL);
+ cond->sem_gate = CreateSemaphore(NULL, 1, 1, NULL);
+ InitializeCriticalSection(&cond->monitor);
+#endif
+ return thrd_success;
+}
+
+// 7.25.3.4
+static inline int
+cnd_signal(cnd_t *cond)
+{
+ if (!cond) return thrd_error;
+#ifdef EMULATED_THREADS_USE_NATIVE_CV
+ WakeConditionVariable(&cond->condvar);
+#else
+ impl_cond_do_signal(cond, 0);
+#endif
+ return thrd_success;
+}
+
+// 7.25.3.5
+static inline int
+cnd_timedwait(cnd_t *cond, mtx_t *mtx, const xtime *xt)
+{
+ if (!cond || !mtx || !xt) return thrd_error;
+#ifdef EMULATED_THREADS_USE_NATIVE_CV
+ if (SleepConditionVariableCS(&cond->condvar, mtx, impl_xtime2msec(xt)))
+ return thrd_success;
+ return (GetLastError() == ERROR_TIMEOUT) ? thrd_busy : thrd_error;
+#else
+ return impl_cond_do_wait(cond, mtx, xt);
+#endif
+}
+
+// 7.25.3.6
+static inline int
+cnd_wait(cnd_t *cond, mtx_t *mtx)
+{
+ if (!cond || !mtx) return thrd_error;
+#ifdef EMULATED_THREADS_USE_NATIVE_CV
+ SleepConditionVariableCS(&cond->condvar, mtx, INFINITE);
+#else
+ impl_cond_do_wait(cond, mtx, NULL);
+#endif
+ return thrd_success;
+}
+
+
+/*-------------------- 7.25.4 Mutex functions --------------------*/
+// 7.25.4.1
+static inline void
+mtx_destroy(mtx_t *mtx)
+{
+ assert(mtx);
+ DeleteCriticalSection(mtx);
+}
+
+// 7.25.4.2
+static inline int
+mtx_init(mtx_t *mtx, int type)
+{
+ if (!mtx) return thrd_error;
+ if (type != mtx_plain && type != mtx_timed && type != mtx_try
+ && type != (mtx_plain|mtx_recursive)
+ && type != (mtx_timed|mtx_recursive)
+ && type != (mtx_try|mtx_recursive))
+ return thrd_error;
+ InitializeCriticalSection(mtx);
+ return thrd_success;
+}
+
+// 7.25.4.3
+static inline int
+mtx_lock(mtx_t *mtx)
+{
+ if (!mtx) return thrd_error;
+ EnterCriticalSection(mtx);
+ return thrd_success;
+}
+
+// 7.25.4.4
+static inline int
+mtx_timedlock(mtx_t *mtx, const xtime *xt)
+{
+ time_t expire, now;
+ if (!mtx || !xt) return thrd_error;
+ expire = time(NULL);
+ expire += xt->sec;
+ while (mtx_trylock(mtx) != thrd_success) {
+ now = time(NULL);
+ if (expire < now)
+ return thrd_busy;
+ // busy loop!
+ thrd_yield();
+ }
+ return thrd_success;
+}
+
+// 7.25.4.5
+static inline int
+mtx_trylock(mtx_t *mtx)
+{
+ if (!mtx) return thrd_error;
+ return TryEnterCriticalSection(mtx) ? thrd_success : thrd_busy;
+}
+
+// 7.25.4.6
+static inline int
+mtx_unlock(mtx_t *mtx)
+{
+ if (!mtx) return thrd_error;
+ LeaveCriticalSection(mtx);
+ return thrd_success;
+}
+
+
+/*------------------- 7.25.5 Thread functions -------------------*/
+// 7.25.5.1
+static inline int
+thrd_create(thrd_t *thr, thrd_start_t func, void *arg)
+{
+ struct impl_thrd_param *pack;
+ uintptr_t handle;
+ if (!thr) return thrd_error;
+ pack = (struct impl_thrd_param *)malloc(sizeof(struct impl_thrd_param));
+ if (!pack) return thrd_nomem;
+ pack->func = func;
+ pack->arg = arg;
+ handle = _beginthreadex(NULL, 0, impl_thrd_routine, pack, 0, NULL);
+ if (handle == 0) {
+ if (errno == EAGAIN || errno == EACCES)
+ return thrd_nomem;
+ return thrd_error;
+ }
+ *thr = (thrd_t)handle;
+ return thrd_success;
+}
+
+// 7.25.5.2
+static inline thrd_t
+thrd_current(void)
+{
+ return GetCurrentThread();
+}
+
+// 7.25.5.3
+static inline int
+thrd_detach(thrd_t thr)
+{
+ CloseHandle(thr);
+ return thrd_success;
+}
+
+// 7.25.5.4
+static inline int
+thrd_equal(thrd_t thr0, thrd_t thr1)
+{
+ return (thr0 == thr1);
+}
+
+// 7.25.5.5
+static inline void
+thrd_exit(int res)
+{
+ impl_tss_dtor_invoke();
+ _endthreadex((unsigned)res);
+}
+
+// 7.25.5.6
+static inline int
+thrd_join(thrd_t thr, int *res)
+{
+ DWORD w, code;
+ w = WaitForSingleObject(thr, INFINITE);
+ if (w != WAIT_OBJECT_0)
+ return thrd_error;
+ if (res) {
+ if (!GetExitCodeThread(thr, &code)) {
+ CloseHandle(thr);
+ return thrd_error;
+ }
+ *res = (int)code;
+ }
+ CloseHandle(thr);
+ return thrd_success;
+}
+
+// 7.25.5.7
+static inline void
+thrd_sleep(const xtime *xt)
+{
+ assert(xt);
+ Sleep(impl_xtime2msec(xt));
+}
+
+// 7.25.5.8
+static inline void
+thrd_yield(void)
+{
+ SwitchToThread();
+}
+
+
+/*----------- 7.25.6 Thread-specific storage functions -----------*/
+// 7.25.6.1
+static inline int
+tss_create(tss_t *key, tss_dtor_t dtor)
+{
+ if (!key) return thrd_error;
+ *key = TlsAlloc();
+ if (dtor) {
+ if (impl_tss_dtor_register(*key, dtor)) {
+ TlsFree(*key);
+ return thrd_error;
+ }
+ }
+ return (*key != 0xFFFFFFFF) ? thrd_success : thrd_error;
+}
+
+// 7.25.6.2
+static inline void
+tss_delete(tss_t key)
+{
+ TlsFree(key);
+}
+
+// 7.25.6.3
+static inline void *
+tss_get(tss_t key)
+{
+ return TlsGetValue(key);
+}
+
+// 7.25.6.4
+static inline int
+tss_set(tss_t key, void *val)
+{
+ return TlsSetValue(key, val) ? thrd_success : thrd_error;
+}
+
+
+/*-------------------- 7.25.7 Time functions --------------------*/
+// 7.25.6.1
+static inline int
+xtime_get(xtime *xt, int base)
+{
+ if (!xt) return 0;
+ if (base == TIME_UTC) {
+ xt->sec = time(NULL);
+ xt->nsec = 0;
+ return base;
+ }
+ return 0;
+}
diff --git a/mesalib/src/gallium/auxiliary/hud/hud_context.c b/mesalib/src/gallium/auxiliary/hud/hud_context.c
index c4a4f1877..465013cb8 100644
--- a/mesalib/src/gallium/auxiliary/hud/hud_context.c
+++ b/mesalib/src/gallium/auxiliary/hud/hud_context.c
@@ -479,7 +479,7 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex)
}
/* unmap the uploader's vertex buffer before drawing */
- u_upload_flush(hud->uploader);
+ u_upload_unmap(hud->uploader);
/* draw accumulated vertices for background quads */
cso_set_fragment_shader_handle(hud->cso, hud->fs_color);
diff --git a/mesalib/src/gallium/auxiliary/util/u_format.h b/mesalib/src/gallium/auxiliary/util/u_format.h
index 0fbaf4cc1..5f86e2d2c 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format.h
+++ b/mesalib/src/gallium/auxiliary/util/u_format.h
@@ -872,6 +872,9 @@ util_format_get_component_bits(enum pipe_format format,
static INLINE enum pipe_format
util_format_srgb(enum pipe_format format)
{
+ if (util_format_is_srgb(format))
+ return format;
+
switch (format) {
case PIPE_FORMAT_L8_UNORM:
return PIPE_FORMAT_L8_SRGB;
diff --git a/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c b/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c
index 6859751c5..7349d0068 100644
--- a/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c
+++ b/mesalib/src/gallium/auxiliary/util/u_upload_mgr.c
@@ -87,16 +87,8 @@ void u_upload_unmap( struct u_upload_mgr *upload )
}
}
-/* Release old buffer.
- *
- * This must usually be called prior to firing the command stream
- * which references the upload buffer, as many memory managers will
- * cause subsequent maps of a fired buffer to wait.
- *
- * Can improve this with a change to pipe_buffer_write to use the
- * DONT_WAIT bit, but for now, it's easiest just to grab a new buffer.
- */
-void u_upload_flush( struct u_upload_mgr *upload )
+
+static void u_upload_release_buffer(struct u_upload_mgr *upload)
{
/* Unmap and unreference the upload buffer. */
u_upload_unmap(upload);
@@ -107,7 +99,7 @@ void u_upload_flush( struct u_upload_mgr *upload )
void u_upload_destroy( struct u_upload_mgr *upload )
{
- u_upload_flush( upload );
+ u_upload_release_buffer( upload );
FREE( upload );
}
@@ -120,7 +112,7 @@ u_upload_alloc_buffer( struct u_upload_mgr *upload,
/* Release the old buffer, if present:
*/
- u_upload_flush( upload );
+ u_upload_release_buffer( upload );
/* Allocate a new one:
*/
diff --git a/mesalib/src/gallium/auxiliary/util/u_upload_mgr.h b/mesalib/src/gallium/auxiliary/util/u_upload_mgr.h
index 82215a556..63bf30e38 100644
--- a/mesalib/src/gallium/auxiliary/util/u_upload_mgr.h
+++ b/mesalib/src/gallium/auxiliary/util/u_upload_mgr.h
@@ -57,16 +57,6 @@ struct u_upload_mgr *u_upload_create( struct pipe_context *pipe,
void u_upload_destroy( struct u_upload_mgr *upload );
/**
- * Unmap and release old upload buffer.
- *
- * This is like u_upload_unmap() except the upload buffer is released for
- * recycling. This should be called on real hardware flushes on systems
- * that don't support the PIPE_TRANSFER_UNSYNCHRONIZED flag, as otherwise
- * the next u_upload_buffer will cause a sync on the buffer.
- */
-void u_upload_flush( struct u_upload_mgr *upload );
-
-/**
* Unmap upload buffer
*
* \param upload Upload manager
diff --git a/mesalib/src/glsl/Makefile.sources b/mesalib/src/glsl/Makefile.sources
index 2e81dedda..e69c1ac61 100644
--- a/mesalib/src/glsl/Makefile.sources
+++ b/mesalib/src/glsl/Makefile.sources
@@ -99,6 +99,7 @@ LIBGLSL_FILES = \
$(GLSL_SRCDIR)/opt_structure_splitting.cpp \
$(GLSL_SRCDIR)/opt_swizzle_swizzle.cpp \
$(GLSL_SRCDIR)/opt_tree_grafting.cpp \
+ $(GLSL_SRCDIR)/opt_vectorize.cpp \
$(GLSL_SRCDIR)/s_expression.cpp \
$(GLSL_SRCDIR)/strtod.c
diff --git a/mesalib/src/glsl/ast.h b/mesalib/src/glsl/ast.h
index 76911f056..0bda28d20 100644
--- a/mesalib/src/glsl/ast.h
+++ b/mesalib/src/glsl/ast.h
@@ -276,6 +276,43 @@ private:
bool cons;
};
+class ast_array_specifier : public ast_node {
+public:
+ /** Unsized array specifier ([]) */
+ explicit ast_array_specifier(const struct YYLTYPE &locp)
+ : dimension_count(1), is_unsized_array(true)
+ {
+ set_location(locp);
+ }
+
+ /** Sized array specifier ([dim]) */
+ ast_array_specifier(const struct YYLTYPE &locp, ast_expression *dim)
+ : dimension_count(1), is_unsized_array(false)
+ {
+ set_location(locp);
+ array_dimensions.push_tail(&dim->link);
+ }
+
+ void add_dimension(ast_expression *dim)
+ {
+ array_dimensions.push_tail(&dim->link);
+ dimension_count++;
+ }
+
+ virtual void print(void) const;
+
+ /* Count including sized and unsized dimensions */
+ unsigned dimension_count;
+
+ /* If true, this means that the array has an unsized outermost dimension. */
+ bool is_unsized_array;
+
+ /* This list contains objects of type ast_node containing the
+ * sized dimensions only, in outermost-to-innermost order.
+ */
+ exec_list array_dimensions;
+};
+
/**
* C-style aggregate initialization class
*
@@ -296,7 +333,16 @@ public:
/* empty */
}
- ast_type_specifier *constructor_type;
+ /**
+ * glsl_type of the aggregate, which is inferred from the LHS of whatever
+ * the aggregate is being used to initialize. This can't be inferred at
+ * parse time (since the parser deals with ast_type_specifiers, not
+ * glsl_types), so the parser leaves it NULL. However, the ast-to-hir
+ * conversion code makes sure to fill it in with the appropriate type
+ * before hir() is called.
+ */
+ const glsl_type *constructor_type;
+
virtual ir_rvalue *hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state);
};
@@ -325,14 +371,14 @@ public:
class ast_declaration : public ast_node {
public:
- ast_declaration(const char *identifier, bool is_array, ast_expression *array_size,
- ast_expression *initializer);
+ ast_declaration(const char *identifier,
+ ast_array_specifier *array_specifier,
+ ast_expression *initializer);
virtual void print(void) const;
const char *identifier;
-
- bool is_array;
- ast_expression *array_size;
+
+ ast_array_specifier *array_specifier;
ast_expression *initializer;
};
@@ -541,10 +587,10 @@ public:
* Use only if the objects are allocated from the same context and will not
* be modified. Zeros the inherited ast_node's fields.
*/
- ast_type_specifier(const ast_type_specifier *that, bool is_array,
- ast_expression *array_size)
+ ast_type_specifier(const ast_type_specifier *that,
+ ast_array_specifier *array_specifier)
: ast_node(), type_name(that->type_name), structure(that->structure),
- is_array(is_array), array_size(array_size),
+ array_specifier(array_specifier),
default_precision(that->default_precision)
{
/* empty */
@@ -552,8 +598,7 @@ public:
/** Construct a type specifier from a type name */
ast_type_specifier(const char *name)
- : type_name(name), structure(NULL),
- is_array(false), array_size(NULL),
+ : type_name(name), structure(NULL), array_specifier(NULL),
default_precision(ast_precision_none)
{
/* empty */
@@ -561,8 +606,7 @@ public:
/** Construct a type specifier from a structure definition */
ast_type_specifier(ast_struct_specifier *s)
- : type_name(s->name), structure(s),
- is_array(false), array_size(NULL),
+ : type_name(s->name), structure(s), array_specifier(NULL),
default_precision(ast_precision_none)
{
/* empty */
@@ -579,8 +623,7 @@ public:
const char *type_name;
ast_struct_specifier *structure;
- bool is_array;
- ast_expression *array_size;
+ ast_array_specifier *array_specifier;
/** For precision statements, this is the given precision; otherwise none. */
unsigned default_precision:2;
@@ -633,8 +676,7 @@ public:
ast_parameter_declarator() :
type(NULL),
identifier(NULL),
- is_array(false),
- array_size(NULL),
+ array_specifier(NULL),
formal_parameter(false),
is_void(false)
{
@@ -648,8 +690,7 @@ public:
ast_fully_specified_type *type;
const char *identifier;
- bool is_array;
- ast_expression *array_size;
+ ast_array_specifier *array_specifier;
static void parameters_to_hir(exec_list *ast_parameters,
bool formal, exec_list *ir_parameters,
@@ -896,13 +937,10 @@ class ast_interface_block : public ast_node {
public:
ast_interface_block(ast_type_qualifier layout,
const char *instance_name,
- bool is_array,
- ast_expression *array_size)
+ ast_array_specifier *array_specifier)
: layout(layout), block_name(NULL), instance_name(instance_name),
- is_array(is_array), array_size(array_size)
+ array_specifier(array_specifier)
{
- if (!is_array)
- assert(array_size == NULL);
}
virtual ir_rvalue *hir(exec_list *instructions,
@@ -923,21 +961,12 @@ public:
exec_list declarations;
/**
- * True if the block is declared as an array
- *
- * \note
- * A block can only be an array if it also has an instance name. If this
- * field is true, ::instance_name must also not be \c NULL.
- */
- bool is_array;
-
- /**
* Declared array size of the block instance
*
* If the block is not declared as an array or if the block instance array
* is unsized, this field will be \c NULL.
*/
- ast_expression *array_size;
+ ast_array_specifier *array_specifier;
};
@@ -978,9 +1007,8 @@ _mesa_ast_array_index_to_hir(void *mem_ctx,
YYLTYPE &loc, YYLTYPE &idx_loc);
extern void
-_mesa_ast_set_aggregate_type(const ast_type_specifier *type,
- ast_expression *expr,
- _mesa_glsl_parse_state *state);
+_mesa_ast_set_aggregate_type(const glsl_type *type,
+ ast_expression *expr);
void
emit_function(_mesa_glsl_parse_state *state, ir_function *f);
diff --git a/mesalib/src/glsl/ast_array_index.cpp b/mesalib/src/glsl/ast_array_index.cpp
index a5f23206a..f3b060ea6 100644
--- a/mesalib/src/glsl/ast_array_index.cpp
+++ b/mesalib/src/glsl/ast_array_index.cpp
@@ -25,6 +25,19 @@
#include "glsl_types.h"
#include "ir.h"
+void
+ast_array_specifier::print(void) const
+{
+ if (this->is_unsized_array) {
+ printf("[ ] ");
+ }
+
+ foreach_list_typed (ast_node, array_dimension, link, &this->array_dimensions) {
+ printf("[ ");
+ array_dimension->print();
+ printf("] ");
+ }
+}
/**
* If \c ir is a reference to an array for which we are tracking the max array
diff --git a/mesalib/src/glsl/ast_function.cpp b/mesalib/src/glsl/ast_function.cpp
index 2d05d0723..4c5b0e4aa 100644
--- a/mesalib/src/glsl/ast_function.cpp
+++ b/mesalib/src/glsl/ast_function.cpp
@@ -1687,14 +1687,12 @@ ast_aggregate_initializer::hir(exec_list *instructions,
{
void *ctx = state;
YYLTYPE loc = this->get_location();
- const char *name;
if (!this->constructor_type) {
_mesa_glsl_error(&loc, state, "type of C-style initializer unknown");
return ir_rvalue::error_value(ctx);
}
- const glsl_type *const constructor_type =
- this->constructor_type->glsl_type(&name, state);
+ const glsl_type *const constructor_type = this->constructor_type;
if (!state->ARB_shading_language_420pack_enable) {
_mesa_glsl_error(&loc, state, "C-style initialization requires the "
@@ -1702,12 +1700,12 @@ ast_aggregate_initializer::hir(exec_list *instructions,
return ir_rvalue::error_value(ctx);
}
- if (this->constructor_type->is_array) {
+ if (constructor_type->is_array()) {
return process_array_constructor(instructions, constructor_type, &loc,
&this->expressions, state);
}
- if (this->constructor_type->structure) {
+ if (constructor_type->is_record()) {
return process_record_constructor(instructions, constructor_type, &loc,
&this->expressions, state);
}
diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp
index 4cc8eb18d..1bfb4e531 100644
--- a/mesalib/src/glsl/ast_to_hir.cpp
+++ b/mesalib/src/glsl/ast_to_hir.cpp
@@ -740,14 +740,15 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state,
{
void *ctx = state;
bool error_emitted = (lhs->type->is_error() || rhs->type->is_error());
+ ir_rvalue *extract_channel = NULL;
/* If the assignment LHS comes back as an ir_binop_vector_extract
* expression, move it to the RHS as an ir_triop_vector_insert.
*/
if (lhs->ir_type == ir_type_expression) {
- ir_expression *const expr = lhs->as_expression();
+ ir_expression *const lhs_expr = lhs->as_expression();
- if (unlikely(expr->operation == ir_binop_vector_extract)) {
+ if (unlikely(lhs_expr->operation == ir_binop_vector_extract)) {
ir_rvalue *new_rhs =
validate_assignment(state, lhs_loc, lhs->type,
rhs, is_initializer);
@@ -755,12 +756,24 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state,
if (new_rhs == NULL) {
return lhs;
} else {
+ /* This converts:
+ * - LHS: (expression float vector_extract <vec> <channel>)
+ * - RHS: <scalar>
+ * into:
+ * - LHS: <vec>
+ * - RHS: (expression vec2 vector_insert <vec> <channel> <scalar>)
+ *
+ * The LHS type is now a vector instead of a scalar. Since GLSL
+ * allows assignments to be used as rvalues, we need to re-extract
+ * the channel from assignment_temp when returning the rvalue.
+ */
+ extract_channel = lhs_expr->operands[1];
rhs = new(ctx) ir_expression(ir_triop_vector_insert,
- expr->operands[0]->type,
- expr->operands[0],
+ lhs_expr->operands[0]->type,
+ lhs_expr->operands[0],
new_rhs,
- expr->operands[1]);
- lhs = expr->operands[0]->clone(ctx, NULL);
+ extract_channel);
+ lhs = lhs_expr->operands[0]->clone(ctx, NULL);
}
}
}
@@ -830,8 +843,10 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state,
rhs->type->array_size());
d->type = var->type;
}
- mark_whole_array_access(rhs);
- mark_whole_array_access(lhs);
+ if (lhs->type->is_array()) {
+ mark_whole_array_access(rhs);
+ mark_whole_array_access(lhs);
+ }
}
/* Most callers of do_assignment (assign, add_assign, pre_inc/dec,
@@ -854,6 +869,11 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state,
if (!error_emitted)
instructions->push_tail(new(ctx) ir_assignment(lhs, deref_var));
+ if (extract_channel) {
+ return new(ctx) ir_expression(ir_binop_vector_extract,
+ new(ctx) ir_dereference_variable(var),
+ extract_channel->clone(ctx, NULL));
+ }
return new(ctx) ir_dereference_variable(var);
}
@@ -1771,64 +1791,108 @@ ast_compound_statement::hir(exec_list *instructions,
return NULL;
}
+/**
+ * Evaluate the given exec_node (which should be an ast_node representing
+ * a single array dimension) and return its integer value.
+ */
+static const unsigned
+process_array_size(exec_node *node,
+ struct _mesa_glsl_parse_state *state)
+{
+ exec_list dummy_instructions;
+
+ ast_node *array_size = exec_node_data(ast_node, node, link);
+ ir_rvalue *const ir = array_size->hir(& dummy_instructions,
+ state);
+ YYLTYPE loc = array_size->get_location();
+
+ if (ir == NULL) {
+ _mesa_glsl_error(& loc, state,
+ "array size could not be resolved");
+ return 0;
+ }
+
+ if (!ir->type->is_integer()) {
+ _mesa_glsl_error(& loc, state,
+ "array size must be integer type");
+ return 0;
+ }
+
+ if (!ir->type->is_scalar()) {
+ _mesa_glsl_error(& loc, state,
+ "array size must be scalar type");
+ return 0;
+ }
+
+ ir_constant *const size = ir->constant_expression_value();
+ if (size == NULL) {
+ _mesa_glsl_error(& loc, state, "array size must be a "
+ "constant valued expression");
+ return 0;
+ }
+
+ if (size->value.i[0] <= 0) {
+ _mesa_glsl_error(& loc, state, "array size must be > 0");
+ return 0;
+ }
+
+ assert(size->type == ir->type);
+
+ /* If the array size is const (and we've verified that
+ * it is) then no instructions should have been emitted
+ * when we converted it to HIR. If they were emitted,
+ * then either the array size isn't const after all, or
+ * we are emitting unnecessary instructions.
+ */
+ assert(dummy_instructions.is_empty());
+
+ return size->value.u[0];
+}
static const glsl_type *
-process_array_type(YYLTYPE *loc, const glsl_type *base, ast_node *array_size,
- struct _mesa_glsl_parse_state *state)
+process_array_type(YYLTYPE *loc, const glsl_type *base,
+ ast_array_specifier *array_specifier,
+ struct _mesa_glsl_parse_state *state)
{
- unsigned length = 0;
+ const glsl_type *array_type = base;
- if (base == NULL)
- return glsl_type::error_type;
+ if (array_specifier != NULL) {
+ if (base->is_array()) {
- /* From page 19 (page 25) of the GLSL 1.20 spec:
- *
- * "Only one-dimensional arrays may be declared."
- */
- if (base->is_array()) {
- _mesa_glsl_error(loc, state,
- "invalid array of `%s' (only one-dimensional arrays "
- "may be declared)",
- base->name);
- return glsl_type::error_type;
- }
+ /* From page 19 (page 25) of the GLSL 1.20 spec:
+ *
+ * "Only one-dimensional arrays may be declared."
+ */
+ if (!state->ARB_arrays_of_arrays_enable) {
+ _mesa_glsl_error(loc, state,
+ "invalid array of `%s'"
+ "GL_ARB_arrays_of_arrays "
+ "required for defining arrays of arrays",
+ base->name);
+ return glsl_type::error_type;
+ }
- if (array_size != NULL) {
- exec_list dummy_instructions;
- ir_rvalue *const ir = array_size->hir(& dummy_instructions, state);
- YYLTYPE loc = array_size->get_location();
+ if (base->length == 0) {
+ _mesa_glsl_error(loc, state,
+ "only the outermost array dimension can "
+ "be unsized",
+ base->name);
+ return glsl_type::error_type;
+ }
+ }
- if (ir != NULL) {
- if (!ir->type->is_integer()) {
- _mesa_glsl_error(& loc, state, "array size must be integer type");
- } else if (!ir->type->is_scalar()) {
- _mesa_glsl_error(& loc, state, "array size must be scalar type");
- } else {
- ir_constant *const size = ir->constant_expression_value();
-
- if (size == NULL) {
- _mesa_glsl_error(& loc, state, "array size must be a "
- "constant valued expression");
- } else if (size->value.i[0] <= 0) {
- _mesa_glsl_error(& loc, state, "array size must be > 0");
- } else {
- assert(size->type == ir->type);
- length = size->value.u[0];
-
- /* If the array size is const (and we've verified that
- * it is) then no instructions should have been emitted
- * when we converted it to HIR. If they were emitted,
- * then either the array size isn't const after all, or
- * we are emitting unnecessary instructions.
- */
- assert(dummy_instructions.is_empty());
- }
- }
+ for (exec_node *node = array_specifier->array_dimensions.tail_pred;
+ !node->is_head_sentinel(); node = node->prev) {
+ unsigned array_size = process_array_size(node, state);
+ array_type = glsl_type::get_array_instance(array_type,
+ array_size);
}
+
+ if (array_specifier->is_unsized_array)
+ array_type = glsl_type::get_array_instance(array_type, 0);
}
- const glsl_type *array_type = glsl_type::get_array_instance(base, length);
- return array_type != NULL ? array_type : glsl_type::error_type;
+ return array_type;
}
@@ -1841,10 +1905,8 @@ ast_type_specifier::glsl_type(const char **name,
type = state->symbols->get_type(this->type_name);
*name = this->type_name;
- if (this->is_array) {
- YYLTYPE loc = this->get_location();
- type = process_array_type(&loc, type, this->array_size, state);
- }
+ YYLTYPE loc = this->get_location();
+ type = process_array_type(&loc, type, this->array_specifier, state);
return type;
}
@@ -2593,6 +2655,13 @@ process_initializer(ir_variable *var, ast_declaration *decl,
? "attribute" : "varying");
}
+ /* If the initializer is an ast_aggregate_initializer, recursively store
+ * type information from the LHS into it, so that its hir() function can do
+ * type checking.
+ */
+ if (decl->initializer->oper == ast_aggregate)
+ _mesa_ast_set_aggregate_type(var->type, decl->initializer);
+
ir_dereference *const lhs = new(state) ir_dereference_variable(var);
ir_rvalue *rhs = decl->initializer->hir(initializer_instructions,
state);
@@ -2823,8 +2892,7 @@ ast_declarator_list::hir(exec_list *instructions,
}
foreach_list_typed (ast_declaration, decl, link, &this->declarations) {
- assert(!decl->is_array);
- assert(decl->array_size == NULL);
+ assert(decl->array_specifier == NULL);
assert(decl->initializer == NULL);
ir_variable *const earlier =
@@ -2959,14 +3027,8 @@ ast_declarator_list::hir(exec_list *instructions,
continue;
}
- if (decl->is_array) {
- var_type = process_array_type(&loc, decl_type, decl->array_size,
- state);
- if (var_type->is_error())
- continue;
- } else {
- var_type = decl_type;
- }
+ var_type = process_array_type(&loc, decl_type, decl->array_specifier,
+ state);
var = new(ctx) ir_variable(var_type, decl->identifier, ir_var_auto);
@@ -3098,8 +3160,9 @@ ast_declarator_list::hir(exec_list *instructions,
* vectors. Vertex shader inputs cannot be arrays or
* structures."
*/
- const glsl_type *check_type = var->type->is_array()
- ? var->type->fields.array : var->type;
+ const glsl_type *check_type = var->type;
+ while (check_type->is_array())
+ check_type = check_type->element_type();
switch (check_type->base_type) {
case GLSL_TYPE_FLOAT:
@@ -3523,9 +3586,7 @@ ast_parameter_declarator::hir(exec_list *instructions,
/* This only handles "vec4 foo[..]". The earlier specifier->glsl_type(...)
* call already handled the "vec4[..] foo" case.
*/
- if (this->is_array) {
- type = process_array_type(&loc, type, this->array_size, state);
- }
+ type = process_array_type(&loc, type, this->array_specifier, state);
if (!type->is_error() && type->is_unsized_array()) {
_mesa_glsl_error(&loc, state, "arrays passed as parameters must have "
@@ -4463,7 +4524,7 @@ ast_type_specifier::hir(exec_list *instructions,
return NULL;
}
- if (this->is_array) {
+ if (this->array_specifier != NULL) {
_mesa_glsl_error(&loc, state,
"default precision statements do not apply to "
"arrays");
@@ -4653,10 +4714,8 @@ ast_process_structure_or_interface_block(exec_list *instructions,
"members");
}
- if (decl->is_array) {
- field_type = process_array_type(&loc, decl_type, decl->array_size,
- state);
- }
+ field_type = process_array_type(&loc, decl_type,
+ decl->array_specifier, state);
fields[i].type = field_type;
fields[i].name = decl->identifier;
fields[i].location = -1;
@@ -4882,7 +4941,7 @@ ast_interface_block::hir(exec_list *instructions,
_mesa_shader_stage_to_string(state->stage));
}
if (this->instance_name == NULL ||
- strcmp(this->instance_name, "gl_in") != 0 || !this->is_array) {
+ strcmp(this->instance_name, "gl_in") != 0 || this->array_specifier == NULL) {
_mesa_glsl_error(&loc, state,
"gl_PerVertex input must be redeclared as "
"gl_in[]");
@@ -4984,7 +5043,7 @@ ast_interface_block::hir(exec_list *instructions,
* variable (or input block, see interface blocks below) needs to be
* declared as an array.
*/
- if (state->stage == MESA_SHADER_GEOMETRY && !this->is_array &&
+ if (state->stage == MESA_SHADER_GEOMETRY && this->array_specifier == NULL &&
var_mode == ir_var_shader_in) {
_mesa_glsl_error(&loc, state, "geometry shader inputs must be arrays");
}
@@ -5018,7 +5077,7 @@ ast_interface_block::hir(exec_list *instructions,
ir_variable *var;
- if (this->is_array) {
+ if (this->array_specifier != NULL) {
/* Section 4.3.7 (Interface Blocks) of the GLSL 1.50 spec says:
*
* For uniform blocks declared an array, each individual array
@@ -5038,7 +5097,7 @@ ast_interface_block::hir(exec_list *instructions,
* interface array size *doesn't* need to be specified is on a
* geometry shader input.
*/
- if (this->array_size == NULL &&
+ if (this->array_specifier->is_unsized_array &&
(state->stage != MESA_SHADER_GEOMETRY || !this->layout.flags.q.in)) {
_mesa_glsl_error(&loc, state,
"only geometry shader inputs may be unsized "
@@ -5047,7 +5106,7 @@ ast_interface_block::hir(exec_list *instructions,
}
const glsl_type *block_array_type =
- process_array_type(&loc, block_type, this->array_size, state);
+ process_array_type(&loc, block_type, this->array_specifier, state);
var = new(state) ir_variable(block_array_type,
this->instance_name,
@@ -5079,7 +5138,7 @@ ast_interface_block::hir(exec_list *instructions,
/* In order to have an array size, the block must also be declared with
* an instane name.
*/
- assert(!this->is_array);
+ assert(this->array_specifier == NULL);
for (unsigned i = 0; i < num_variables; i++) {
ir_variable *var =
diff --git a/mesalib/src/glsl/ast_type.cpp b/mesalib/src/glsl/ast_type.cpp
index d758bfa1f..637da0dfb 100644
--- a/mesalib/src/glsl/ast_type.cpp
+++ b/mesalib/src/glsl/ast_type.cpp
@@ -32,14 +32,8 @@ ast_type_specifier::print(void) const
printf("%s ", type_name);
}
- if (is_array) {
- printf("[ ");
-
- if (array_size) {
- array_size->print();
- }
-
- printf("] ");
+ if (array_specifier) {
+ array_specifier->print();
}
}
diff --git a/mesalib/src/glsl/builtin_functions.cpp b/mesalib/src/glsl/builtin_functions.cpp
index 662ff4cea..aeb8e5d94 100644
--- a/mesalib/src/glsl/builtin_functions.cpp
+++ b/mesalib/src/glsl/builtin_functions.cpp
@@ -576,20 +576,9 @@ private:
ir_function_signature *_atomic_op(const char *intrinsic,
builtin_available_predicate avail);
- ir_function_signature *_min3(builtin_available_predicate avail,
- const glsl_type *x_type,
- const glsl_type *y_type,
- const glsl_type *z_type);
-
- ir_function_signature *_max3(builtin_available_predicate avail,
- const glsl_type *x_type,
- const glsl_type *y_type,
- const glsl_type *z_type);
-
- ir_function_signature *_mid3(builtin_available_predicate avail,
- const glsl_type *x_type,
- const glsl_type *y_type,
- const glsl_type *z_type);
+ B1(min3)
+ B1(max3)
+ B1(mid3)
#undef B0
#undef B1
@@ -2128,54 +2117,54 @@ builtin_builder::create_builtins()
NULL);
add_function("min3",
- _min3(shader_trinary_minmax, glsl_type::float_type, glsl_type::float_type, glsl_type::float_type),
- _min3(shader_trinary_minmax, glsl_type::vec2_type, glsl_type::vec2_type, glsl_type::vec2_type),
- _min3(shader_trinary_minmax, glsl_type::vec3_type, glsl_type::vec3_type, glsl_type::vec3_type),
- _min3(shader_trinary_minmax, glsl_type::vec4_type, glsl_type::vec4_type, glsl_type::vec4_type),
-
- _min3(shader_trinary_minmax, glsl_type::int_type, glsl_type::int_type, glsl_type::int_type),
- _min3(shader_trinary_minmax, glsl_type::ivec2_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
- _min3(shader_trinary_minmax, glsl_type::ivec3_type, glsl_type::ivec3_type, glsl_type::ivec3_type),
- _min3(shader_trinary_minmax, glsl_type::ivec4_type, glsl_type::ivec4_type, glsl_type::ivec4_type),
-
- _min3(shader_trinary_minmax, glsl_type::uint_type, glsl_type::uint_type, glsl_type::uint_type),
- _min3(shader_trinary_minmax, glsl_type::uvec2_type, glsl_type::uvec2_type, glsl_type::uvec2_type),
- _min3(shader_trinary_minmax, glsl_type::uvec3_type, glsl_type::uvec3_type, glsl_type::uvec3_type),
- _min3(shader_trinary_minmax, glsl_type::uvec4_type, glsl_type::uvec4_type, glsl_type::uvec4_type),
+ _min3(glsl_type::float_type),
+ _min3(glsl_type::vec2_type),
+ _min3(glsl_type::vec3_type),
+ _min3(glsl_type::vec4_type),
+
+ _min3(glsl_type::int_type),
+ _min3(glsl_type::ivec2_type),
+ _min3(glsl_type::ivec3_type),
+ _min3(glsl_type::ivec4_type),
+
+ _min3(glsl_type::uint_type),
+ _min3(glsl_type::uvec2_type),
+ _min3(glsl_type::uvec3_type),
+ _min3(glsl_type::uvec4_type),
NULL);
add_function("max3",
- _max3(shader_trinary_minmax, glsl_type::float_type, glsl_type::float_type, glsl_type::float_type),
- _max3(shader_trinary_minmax, glsl_type::vec2_type, glsl_type::vec2_type, glsl_type::vec2_type),
- _max3(shader_trinary_minmax, glsl_type::vec3_type, glsl_type::vec3_type, glsl_type::vec3_type),
- _max3(shader_trinary_minmax, glsl_type::vec4_type, glsl_type::vec4_type, glsl_type::vec4_type),
-
- _max3(shader_trinary_minmax, glsl_type::int_type, glsl_type::int_type, glsl_type::int_type),
- _max3(shader_trinary_minmax, glsl_type::ivec2_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
- _max3(shader_trinary_minmax, glsl_type::ivec3_type, glsl_type::ivec3_type, glsl_type::ivec3_type),
- _max3(shader_trinary_minmax, glsl_type::ivec4_type, glsl_type::ivec4_type, glsl_type::ivec4_type),
-
- _max3(shader_trinary_minmax, glsl_type::uint_type, glsl_type::uint_type, glsl_type::uint_type),
- _max3(shader_trinary_minmax, glsl_type::uvec2_type, glsl_type::uvec2_type, glsl_type::uvec2_type),
- _max3(shader_trinary_minmax, glsl_type::uvec3_type, glsl_type::uvec3_type, glsl_type::uvec3_type),
- _max3(shader_trinary_minmax, glsl_type::uvec4_type, glsl_type::uvec4_type, glsl_type::uvec4_type),
+ _max3(glsl_type::float_type),
+ _max3(glsl_type::vec2_type),
+ _max3(glsl_type::vec3_type),
+ _max3(glsl_type::vec4_type),
+
+ _max3(glsl_type::int_type),
+ _max3(glsl_type::ivec2_type),
+ _max3(glsl_type::ivec3_type),
+ _max3(glsl_type::ivec4_type),
+
+ _max3(glsl_type::uint_type),
+ _max3(glsl_type::uvec2_type),
+ _max3(glsl_type::uvec3_type),
+ _max3(glsl_type::uvec4_type),
NULL);
add_function("mid3",
- _mid3(shader_trinary_minmax, glsl_type::float_type, glsl_type::float_type, glsl_type::float_type),
- _mid3(shader_trinary_minmax, glsl_type::vec2_type, glsl_type::vec2_type, glsl_type::vec2_type),
- _mid3(shader_trinary_minmax, glsl_type::vec3_type, glsl_type::vec3_type, glsl_type::vec3_type),
- _mid3(shader_trinary_minmax, glsl_type::vec4_type, glsl_type::vec4_type, glsl_type::vec4_type),
-
- _mid3(shader_trinary_minmax, glsl_type::int_type, glsl_type::int_type, glsl_type::int_type),
- _mid3(shader_trinary_minmax, glsl_type::ivec2_type, glsl_type::ivec2_type, glsl_type::ivec2_type),
- _mid3(shader_trinary_minmax, glsl_type::ivec3_type, glsl_type::ivec3_type, glsl_type::ivec3_type),
- _mid3(shader_trinary_minmax, glsl_type::ivec4_type, glsl_type::ivec4_type, glsl_type::ivec4_type),
-
- _mid3(shader_trinary_minmax, glsl_type::uint_type, glsl_type::uint_type, glsl_type::uint_type),
- _mid3(shader_trinary_minmax, glsl_type::uvec2_type, glsl_type::uvec2_type, glsl_type::uvec2_type),
- _mid3(shader_trinary_minmax, glsl_type::uvec3_type, glsl_type::uvec3_type, glsl_type::uvec3_type),
- _mid3(shader_trinary_minmax, glsl_type::uvec4_type, glsl_type::uvec4_type, glsl_type::uvec4_type),
+ _mid3(glsl_type::float_type),
+ _mid3(glsl_type::vec2_type),
+ _mid3(glsl_type::vec3_type),
+ _mid3(glsl_type::vec4_type),
+
+ _mid3(glsl_type::int_type),
+ _mid3(glsl_type::ivec2_type),
+ _mid3(glsl_type::ivec3_type),
+ _mid3(glsl_type::ivec4_type),
+
+ _mid3(glsl_type::uint_type),
+ _mid3(glsl_type::uvec2_type),
+ _mid3(glsl_type::uvec3_type),
+ _mid3(glsl_type::uvec4_type),
NULL);
#undef F
@@ -4064,14 +4053,12 @@ builtin_builder::_atomic_op(const char *intrinsic,
}
ir_function_signature *
-builtin_builder::_min3(builtin_available_predicate avail,
- const glsl_type *x_type, const glsl_type *y_type,
- const glsl_type *z_type)
+builtin_builder::_min3(const glsl_type *type)
{
- ir_variable *x = in_var(x_type, "x");
- ir_variable *y = in_var(y_type, "y");
- ir_variable *z = in_var(z_type, "z");
- MAKE_SIG(x_type, avail, 3, x, y, z);
+ ir_variable *x = in_var(type, "x");
+ ir_variable *y = in_var(type, "y");
+ ir_variable *z = in_var(type, "z");
+ MAKE_SIG(type, shader_trinary_minmax, 3, x, y, z);
ir_expression *min3 = min2(x, min2(y,z));
body.emit(ret(min3));
@@ -4080,14 +4067,12 @@ builtin_builder::_min3(builtin_available_predicate avail,
}
ir_function_signature *
-builtin_builder::_max3(builtin_available_predicate avail,
- const glsl_type *x_type, const glsl_type *y_type,
- const glsl_type *z_type)
+builtin_builder::_max3(const glsl_type *type)
{
- ir_variable *x = in_var(x_type, "x");
- ir_variable *y = in_var(y_type, "y");
- ir_variable *z = in_var(z_type, "z");
- MAKE_SIG(x_type, avail, 3, x, y, z);
+ ir_variable *x = in_var(type, "x");
+ ir_variable *y = in_var(type, "y");
+ ir_variable *z = in_var(type, "z");
+ MAKE_SIG(type, shader_trinary_minmax, 3, x, y, z);
ir_expression *max3 = max2(x, max2(y,z));
body.emit(ret(max3));
@@ -4096,14 +4081,12 @@ builtin_builder::_max3(builtin_available_predicate avail,
}
ir_function_signature *
-builtin_builder::_mid3(builtin_available_predicate avail,
- const glsl_type *x_type, const glsl_type *y_type,
- const glsl_type *z_type)
+builtin_builder::_mid3(const glsl_type *type)
{
- ir_variable *x = in_var(x_type, "x");
- ir_variable *y = in_var(y_type, "y");
- ir_variable *z = in_var(z_type, "z");
- MAKE_SIG(x_type, avail, 3, x, y, z);
+ ir_variable *x = in_var(type, "x");
+ ir_variable *y = in_var(type, "y");
+ ir_variable *z = in_var(type, "z");
+ MAKE_SIG(type, shader_trinary_minmax, 3, x, y, z);
ir_expression *mid3 = max2(min2(x, y), max2(min2(x, z), min2(y, z)));
body.emit(ret(mid3));
diff --git a/mesalib/src/glsl/builtin_variables.cpp b/mesalib/src/glsl/builtin_variables.cpp
index f630923ed..d6bc3c073 100644
--- a/mesalib/src/glsl/builtin_variables.cpp
+++ b/mesalib/src/glsl/builtin_variables.cpp
@@ -780,6 +780,8 @@ void
builtin_variable_generator::generate_gs_special_vars()
{
add_output(VARYING_SLOT_LAYER, int_t, "gl_Layer");
+ if (state->ARB_viewport_array_enable)
+ add_output(VARYING_SLOT_VIEWPORT, int_t, "gl_ViewportIndex");
/* Although gl_PrimitiveID appears in tessellation control and tessellation
* evaluation shaders, it has a different function there than it has in
diff --git a/mesalib/src/glsl/glcpp/glcpp-parse.y b/mesalib/src/glsl/glcpp/glcpp-parse.y
index 55c498195..184e5c237 100644
--- a/mesalib/src/glsl/glcpp/glcpp-parse.y
+++ b/mesalib/src/glsl/glcpp/glcpp-parse.y
@@ -30,7 +30,6 @@
#include "glcpp.h"
#include "main/core.h" /* for struct gl_extensions */
-#include "main/mtypes.h" /* for gl_api enum */
static void
yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error);
@@ -135,7 +134,7 @@ _glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc);
static void
_glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t version,
- const char *ident);
+ const char *ident, bool explicitly_set);
static int
glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser);
@@ -194,12 +193,15 @@ line:
control_line {
ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "\n");
}
-| HASH_LINE pp_tokens NEWLINE {
+| HASH_LINE {
+ glcpp_parser_resolve_version(parser);
+ } pp_tokens NEWLINE {
+
if (parser->skip_stack == NULL ||
parser->skip_stack->type == SKIP_NO_SKIP)
{
_glcpp_parser_expand_and_lex_from (parser,
- LINE_EXPANDED, $2);
+ LINE_EXPANDED, $3);
}
}
| text_line {
@@ -238,25 +240,35 @@ expanded_line:
}
;
-control_line:
- HASH_DEFINE OBJ_IDENTIFIER replacement_list NEWLINE {
- _define_object_macro (parser, & @2, $2, $3);
+define:
+ OBJ_IDENTIFIER replacement_list NEWLINE {
+ _define_object_macro (parser, & @1, $1, $2);
}
-| HASH_DEFINE FUNC_IDENTIFIER '(' ')' replacement_list NEWLINE {
- _define_function_macro (parser, & @2, $2, NULL, $5);
+| FUNC_IDENTIFIER '(' ')' replacement_list NEWLINE {
+ _define_function_macro (parser, & @1, $1, NULL, $4);
}
-| HASH_DEFINE FUNC_IDENTIFIER '(' identifier_list ')' replacement_list NEWLINE {
- _define_function_macro (parser, & @2, $2, $4, $6);
+| FUNC_IDENTIFIER '(' identifier_list ')' replacement_list NEWLINE {
+ _define_function_macro (parser, & @1, $1, $3, $5);
}
-| HASH_UNDEF IDENTIFIER NEWLINE {
- macro_t *macro = hash_table_find (parser->defines, $2);
+;
+
+control_line:
+ HASH_DEFINE {
+ glcpp_parser_resolve_version(parser);
+ } define
+| HASH_UNDEF {
+ glcpp_parser_resolve_version(parser);
+ } IDENTIFIER NEWLINE {
+ macro_t *macro = hash_table_find (parser->defines, $3);
if (macro) {
- hash_table_remove (parser->defines, $2);
+ hash_table_remove (parser->defines, $3);
ralloc_free (macro);
}
- ralloc_free ($2);
+ ralloc_free ($3);
}
-| HASH_IF conditional_tokens NEWLINE {
+| HASH_IF {
+ glcpp_parser_resolve_version(parser);
+ } conditional_tokens NEWLINE {
/* Be careful to only evaluate the 'if' expression if
* we are not skipping. When we are skipping, we
* simply push a new 0-valued 'if' onto the skip
@@ -268,7 +280,7 @@ control_line:
parser->skip_stack->type == SKIP_NO_SKIP)
{
_glcpp_parser_expand_and_lex_from (parser,
- IF_EXPANDED, $2);
+ IF_EXPANDED, $3);
}
else
{
@@ -286,15 +298,19 @@ control_line:
}
_glcpp_parser_skip_stack_push_if (parser, & @1, 0);
}
-| HASH_IFDEF IDENTIFIER junk NEWLINE {
- macro_t *macro = hash_table_find (parser->defines, $2);
- ralloc_free ($2);
+| HASH_IFDEF {
+ glcpp_parser_resolve_version(parser);
+ } IDENTIFIER junk NEWLINE {
+ macro_t *macro = hash_table_find (parser->defines, $3);
+ ralloc_free ($3);
_glcpp_parser_skip_stack_push_if (parser, & @1, macro != NULL);
}
-| HASH_IFNDEF IDENTIFIER junk NEWLINE {
- macro_t *macro = hash_table_find (parser->defines, $2);
- ralloc_free ($2);
- _glcpp_parser_skip_stack_push_if (parser, & @1, macro == NULL);
+| HASH_IFNDEF {
+ glcpp_parser_resolve_version(parser);
+ } IDENTIFIER junk NEWLINE {
+ macro_t *macro = hash_table_find (parser->defines, $3);
+ ralloc_free ($3);
+ _glcpp_parser_skip_stack_push_if (parser, & @2, macro == NULL);
}
| HASH_ELIF conditional_tokens NEWLINE {
/* Be careful to only evaluate the 'elif' expression
@@ -358,12 +374,14 @@ control_line:
_glcpp_parser_skip_stack_pop (parser, & @1);
} NEWLINE
| HASH_VERSION integer_constant NEWLINE {
- _glcpp_parser_handle_version_declaration(parser, $2, NULL);
+ _glcpp_parser_handle_version_declaration(parser, $2, NULL, true);
}
| HASH_VERSION integer_constant IDENTIFIER NEWLINE {
- _glcpp_parser_handle_version_declaration(parser, $2, $3);
+ _glcpp_parser_handle_version_declaration(parser, $2, $3, true);
+ }
+| HASH NEWLINE {
+ glcpp_parser_resolve_version(parser);
}
-| HASH NEWLINE
;
integer_constant:
@@ -1168,10 +1186,9 @@ static void add_builtin_define(glcpp_parser_t *parser,
}
glcpp_parser_t *
-glcpp_parser_create (const struct gl_extensions *extensions, int api)
+glcpp_parser_create (const struct gl_extensions *extensions)
{
glcpp_parser_t *parser;
- int language_version;
parser = ralloc (NULL, glcpp_parser_t);
@@ -1197,99 +1214,14 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api)
parser->info_log_length = 0;
parser->error = 0;
+ parser->extensions = extensions;
+ parser->version_resolved = false;
+
parser->has_new_line_number = 0;
parser->new_line_number = 1;
parser->has_new_source_number = 0;
parser->new_source_number = 0;
- parser->is_gles = false;
-
- /* Add pre-defined macros. */
- if (api == API_OPENGLES2) {
- parser->is_gles = true;
- add_builtin_define(parser, "GL_ES", 1);
-
- if (extensions != NULL) {
- if (extensions->OES_EGL_image_external)
- add_builtin_define(parser, "GL_OES_EGL_image_external", 1);
- }
- } else {
- add_builtin_define(parser, "GL_ARB_draw_buffers", 1);
- add_builtin_define(parser, "GL_ARB_texture_rectangle", 1);
-
- if (extensions != NULL) {
- if (extensions->EXT_texture_array) {
- add_builtin_define(parser, "GL_EXT_texture_array", 1);
- }
-
- if (extensions->ARB_fragment_coord_conventions)
- add_builtin_define(parser, "GL_ARB_fragment_coord_conventions",
- 1);
-
- if (extensions->ARB_explicit_attrib_location)
- add_builtin_define(parser, "GL_ARB_explicit_attrib_location", 1);
-
- if (extensions->ARB_shader_texture_lod)
- add_builtin_define(parser, "GL_ARB_shader_texture_lod", 1);
-
- if (extensions->ARB_draw_instanced)
- add_builtin_define(parser, "GL_ARB_draw_instanced", 1);
-
- if (extensions->ARB_conservative_depth) {
- add_builtin_define(parser, "GL_AMD_conservative_depth", 1);
- add_builtin_define(parser, "GL_ARB_conservative_depth", 1);
- }
-
- if (extensions->ARB_shader_bit_encoding)
- add_builtin_define(parser, "GL_ARB_shader_bit_encoding", 1);
-
- if (extensions->ARB_uniform_buffer_object)
- add_builtin_define(parser, "GL_ARB_uniform_buffer_object", 1);
-
- if (extensions->ARB_texture_cube_map_array)
- add_builtin_define(parser, "GL_ARB_texture_cube_map_array", 1);
-
- if (extensions->ARB_shading_language_packing)
- add_builtin_define(parser, "GL_ARB_shading_language_packing", 1);
-
- if (extensions->ARB_texture_multisample)
- add_builtin_define(parser, "GL_ARB_texture_multisample", 1);
-
- if (extensions->ARB_texture_query_levels)
- add_builtin_define(parser, "GL_ARB_texture_query_levels", 1);
-
- if (extensions->ARB_texture_query_lod)
- add_builtin_define(parser, "GL_ARB_texture_query_lod", 1);
-
- if (extensions->ARB_gpu_shader5)
- add_builtin_define(parser, "GL_ARB_gpu_shader5", 1);
-
- if (extensions->AMD_vertex_shader_layer)
- add_builtin_define(parser, "GL_AMD_vertex_shader_layer", 1);
-
- if (extensions->ARB_shading_language_420pack)
- add_builtin_define(parser, "GL_ARB_shading_language_420pack", 1);
-
- if (extensions->ARB_sample_shading)
- add_builtin_define(parser, "GL_ARB_sample_shading", 1);
-
- if (extensions->EXT_shader_integer_mix)
- add_builtin_define(parser, "GL_EXT_shader_integer_mix", 1);
-
- if (extensions->ARB_texture_gather)
- add_builtin_define(parser, "GL_ARB_texture_gather", 1);
-
- if (extensions->ARB_shader_atomic_counters)
- add_builtin_define(parser, "GL_ARB_shader_atomic_counters", 1);
-
- if (extensions->AMD_shader_trinary_minmax)
- add_builtin_define(parser, "GL_AMD_shader_trinary_minmax", 1);
- }
- }
-
- language_version = 110;
- add_builtin_define(parser, "__VERSION__", language_version);
-
return parser;
}
@@ -2087,24 +2019,106 @@ _glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc)
static void
_glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t version,
- const char *es_identifier)
+ const char *es_identifier,
+ bool explicitly_set)
{
- macro_t *macro = hash_table_find (parser->defines, "__VERSION__");
- if (macro) {
- hash_table_remove (parser->defines, "__VERSION__");
- ralloc_free (macro);
- }
+ const struct gl_extensions *extensions = parser->extensions;
+
+ parser->version_resolved = true;
+
add_builtin_define (parser, "__VERSION__", version);
- /* If we didn't have a GLES context to begin with, (indicated
- * by parser->api), then the version declaration here might
- * indicate GLES. */
- if (! parser->is_gles &&
- (version == 100 ||
- (es_identifier && (strcmp(es_identifier, "es") == 0))))
- {
- parser->is_gles = true;
- add_builtin_define (parser, "GL_ES", 1);
+ parser->is_gles = (version == 100) ||
+ (es_identifier &&
+ (strcmp(es_identifier, "es") == 0));
+
+ /* Add pre-defined macros. */
+ if (parser->is_gles) {
+ add_builtin_define(parser, "GL_ES", 1);
+
+ if (extensions != NULL) {
+ if (extensions->OES_EGL_image_external)
+ add_builtin_define(parser, "GL_OES_EGL_image_external", 1);
+ }
+ } else {
+ add_builtin_define(parser, "GL_ARB_draw_buffers", 1);
+ add_builtin_define(parser, "GL_ARB_texture_rectangle", 1);
+
+ if (extensions != NULL) {
+ if (extensions->EXT_texture_array)
+ add_builtin_define(parser, "GL_EXT_texture_array", 1);
+
+ if (extensions->ARB_arrays_of_arrays)
+ add_builtin_define(parser, "GL_ARB_arrays_of_arrays", 1);
+
+ if (extensions->ARB_fragment_coord_conventions)
+ add_builtin_define(parser, "GL_ARB_fragment_coord_conventions",
+ 1);
+
+ if (extensions->ARB_explicit_attrib_location)
+ add_builtin_define(parser, "GL_ARB_explicit_attrib_location", 1);
+
+ if (extensions->ARB_shader_texture_lod)
+ add_builtin_define(parser, "GL_ARB_shader_texture_lod", 1);
+
+ if (extensions->ARB_draw_instanced)
+ add_builtin_define(parser, "GL_ARB_draw_instanced", 1);
+
+ if (extensions->ARB_conservative_depth) {
+ add_builtin_define(parser, "GL_AMD_conservative_depth", 1);
+ add_builtin_define(parser, "GL_ARB_conservative_depth", 1);
+ }
+
+ if (extensions->ARB_shader_bit_encoding)
+ add_builtin_define(parser, "GL_ARB_shader_bit_encoding", 1);
+
+ if (extensions->ARB_uniform_buffer_object)
+ add_builtin_define(parser, "GL_ARB_uniform_buffer_object", 1);
+
+ if (extensions->ARB_texture_cube_map_array)
+ add_builtin_define(parser, "GL_ARB_texture_cube_map_array", 1);
+
+ if (extensions->ARB_shading_language_packing)
+ add_builtin_define(parser, "GL_ARB_shading_language_packing", 1);
+
+ if (extensions->ARB_texture_multisample)
+ add_builtin_define(parser, "GL_ARB_texture_multisample", 1);
+
+ if (extensions->ARB_texture_query_levels)
+ add_builtin_define(parser, "GL_ARB_texture_query_levels", 1);
+
+ if (extensions->ARB_texture_query_lod)
+ add_builtin_define(parser, "GL_ARB_texture_query_lod", 1);
+
+ if (extensions->ARB_gpu_shader5)
+ add_builtin_define(parser, "GL_ARB_gpu_shader5", 1);
+
+ if (extensions->AMD_vertex_shader_layer)
+ add_builtin_define(parser, "GL_AMD_vertex_shader_layer", 1);
+
+ if (extensions->ARB_shading_language_420pack)
+ add_builtin_define(parser, "GL_ARB_shading_language_420pack", 1);
+
+ if (extensions->ARB_sample_shading)
+ add_builtin_define(parser, "GL_ARB_sample_shading", 1);
+
+ if (extensions->ARB_texture_gather)
+ add_builtin_define(parser, "GL_ARB_texture_gather", 1);
+
+ if (extensions->ARB_shader_atomic_counters)
+ add_builtin_define(parser, "GL_ARB_shader_atomic_counters", 1);
+
+ if (extensions->AMD_shader_trinary_minmax)
+ add_builtin_define(parser, "GL_AMD_shader_trinary_minmax", 1);
+
+ if (extensions->ARB_viewport_array)
+ add_builtin_define(parser, "GL_ARB_viewport_array", 1);
+ }
+ }
+
+ if (extensions != NULL) {
+ if (extensions->EXT_shader_integer_mix)
+ add_builtin_define(parser, "GL_EXT_shader_integer_mix", 1);
}
if (version >= 150)
@@ -2118,8 +2132,23 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t versio
if (version >= 130 || parser->is_gles)
add_builtin_define (parser, "GL_FRAGMENT_PRECISION_HIGH", 1);
- ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length,
- "#version %" PRIiMAX "%s%s", version,
- es_identifier ? " " : "",
- es_identifier ? es_identifier : "");
+ if (explicitly_set) {
+ ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length,
+ "#version %" PRIiMAX "%s%s", version,
+ es_identifier ? " " : "",
+ es_identifier ? es_identifier : "");
+ }
+}
+
+/* GLSL version is no version is explicitly specified. */
+#define IMPLICIT_GLSL_VERSION 110
+
+void
+glcpp_parser_resolve_version(glcpp_parser_t *parser)
+{
+ if (parser->version_resolved)
+ return;
+
+ _glcpp_parser_handle_version_declaration(parser, IMPLICIT_GLSL_VERSION,
+ NULL, false);
}
diff --git a/mesalib/src/glsl/glcpp/glcpp.c b/mesalib/src/glsl/glcpp/glcpp.c
index 6994d7bb9..c9c2ff29e 100644
--- a/mesalib/src/glsl/glcpp/glcpp.c
+++ b/mesalib/src/glsl/glcpp/glcpp.c
@@ -101,7 +101,6 @@ load_text_file(void *ctx, const char *filename)
static void
init_fake_gl_context (struct gl_context *gl_ctx)
{
- gl_ctx->API = API_OPENGL_COMPAT;
gl_ctx->Const.DisableGLSLLineContinuations = false;
}
diff --git a/mesalib/src/glsl/glcpp/glcpp.h b/mesalib/src/glsl/glcpp/glcpp.h
index 85f3fdcd2..4aa200a63 100644
--- a/mesalib/src/glsl/glcpp/glcpp.h
+++ b/mesalib/src/glsl/glcpp/glcpp.h
@@ -182,6 +182,8 @@ struct glcpp_parser {
size_t output_length;
size_t info_log_length;
int error;
+ const struct gl_extensions *extensions;
+ bool version_resolved;
bool has_new_line_number;
int new_line_number;
bool has_new_source_number;
@@ -192,7 +194,7 @@ struct glcpp_parser {
struct gl_extensions;
glcpp_parser_t *
-glcpp_parser_create (const struct gl_extensions *extensions, int api);
+glcpp_parser_create (const struct gl_extensions *extensions);
int
glcpp_parser_parse (glcpp_parser_t *parser);
@@ -200,6 +202,9 @@ glcpp_parser_parse (glcpp_parser_t *parser);
void
glcpp_parser_destroy (glcpp_parser_t *parser);
+void
+glcpp_parser_resolve_version(glcpp_parser_t *parser);
+
int
glcpp_preprocess(void *ralloc_ctx, const char **shader, char **info_log,
const struct gl_extensions *extensions, struct gl_context *g_ctx);
diff --git a/mesalib/src/glsl/glcpp/pp.c b/mesalib/src/glsl/glcpp/pp.c
index 7e1b6c689..637a58f9c 100644
--- a/mesalib/src/glsl/glcpp/pp.c
+++ b/mesalib/src/glsl/glcpp/pp.c
@@ -139,7 +139,7 @@ glcpp_preprocess(void *ralloc_ctx, const char **shader, char **info_log,
const struct gl_extensions *extensions, struct gl_context *gl_ctx)
{
int errors;
- glcpp_parser_t *parser = glcpp_parser_create (extensions, gl_ctx->API);
+ glcpp_parser_t *parser = glcpp_parser_create (extensions);
if (! gl_ctx->Const.DisableGLSLLineContinuations)
*shader = remove_line_continuations(parser, *shader);
@@ -151,6 +151,8 @@ glcpp_preprocess(void *ralloc_ctx, const char **shader, char **info_log,
if (parser->skip_stack)
glcpp_error (&parser->skip_stack->loc, parser, "Unterminated #if\n");
+ glcpp_parser_resolve_version(parser);
+
ralloc_strcat(info_log, parser->info_log);
ralloc_steal(ralloc_ctx, parser->output);
diff --git a/mesalib/src/glsl/glsl_parser.yy b/mesalib/src/glsl/glsl_parser.yy
index 1c56d6f14..928c57e20 100644
--- a/mesalib/src/glsl/glsl_parser.yy
+++ b/mesalib/src/glsl/glsl_parser.yy
@@ -97,6 +97,7 @@ static bool match_layout_qualifier(const char *s1, const char *s2,
ast_node *node;
ast_type_specifier *type_specifier;
+ ast_array_specifier *array_specifier;
ast_fully_specified_type *fully_specified_type;
ast_function *function;
ast_parameter_declarator *parameter_declarator;
@@ -202,6 +203,7 @@ static bool match_layout_qualifier(const char *s1, const char *s2,
%type <type_qualifier> interface_qualifier
%type <type_specifier> type_specifier
%type <type_specifier> type_specifier_nonarray
+%type <array_specifier> array_specifier
%type <identifier> basic_type_specifier_nonarray
%type <fully_specified_type> fully_specified_type
%type <function> function_prototype
@@ -880,7 +882,7 @@ parameter_declarator:
$$->type->specifier = $1;
$$->identifier = $2;
}
- | type_specifier any_identifier '[' constant_expression ']'
+ | type_specifier any_identifier array_specifier
{
void *ctx = state;
$$ = new(ctx) ast_parameter_declarator();
@@ -889,8 +891,7 @@ parameter_declarator:
$$->type->set_location(yylloc);
$$->type->specifier = $1;
$$->identifier = $2;
- $$->is_array = true;
- $$->array_size = $4;
+ $$->array_specifier = $3;
}
;
@@ -976,76 +977,42 @@ init_declarator_list:
| init_declarator_list ',' any_identifier
{
void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, NULL);
+ ast_declaration *decl = new(ctx) ast_declaration($3, NULL, NULL);
decl->set_location(yylloc);
$$ = $1;
$$->declarations.push_tail(&decl->link);
state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
}
- | init_declarator_list ',' any_identifier '[' ']'
+ | init_declarator_list ',' any_identifier array_specifier
{
void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, NULL);
+ ast_declaration *decl = new(ctx) ast_declaration($3, $4, NULL);
decl->set_location(yylloc);
$$ = $1;
$$->declarations.push_tail(&decl->link);
state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
}
- | init_declarator_list ',' any_identifier '[' constant_expression ']'
+ | init_declarator_list ',' any_identifier array_specifier '=' initializer
{
void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, NULL);
+ ast_declaration *decl = new(ctx) ast_declaration($3, $4, $6);
decl->set_location(yylloc);
$$ = $1;
$$->declarations.push_tail(&decl->link);
state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
}
- | init_declarator_list ',' any_identifier '[' ']' '=' initializer
- {
- void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($3, true, NULL, $7);
- decl->set_location(yylloc);
-
- $$ = $1;
- $$->declarations.push_tail(&decl->link);
- state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
- if ($7->oper == ast_aggregate) {
- ast_aggregate_initializer *ai = (ast_aggregate_initializer *)$7;
- ast_type_specifier *type = new(ctx) ast_type_specifier($1->type->specifier, true, NULL);
- _mesa_ast_set_aggregate_type(type, ai, state);
- }
- }
- | init_declarator_list ',' any_identifier '[' constant_expression ']' '=' initializer
- {
- void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($3, true, $5, $8);
- decl->set_location(yylloc);
-
- $$ = $1;
- $$->declarations.push_tail(&decl->link);
- state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
- if ($8->oper == ast_aggregate) {
- ast_aggregate_initializer *ai = (ast_aggregate_initializer *)$8;
- ast_type_specifier *type = new(ctx) ast_type_specifier($1->type->specifier, true, $5);
- _mesa_ast_set_aggregate_type(type, ai, state);
- }
- }
| init_declarator_list ',' any_identifier '=' initializer
{
void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($3, false, NULL, $5);
+ ast_declaration *decl = new(ctx) ast_declaration($3, NULL, $5);
decl->set_location(yylloc);
$$ = $1;
$$->declarations.push_tail(&decl->link);
state->symbols->add_variable(new(state) ir_variable(NULL, $3, ir_var_auto));
- if ($5->oper == ast_aggregate) {
- ast_aggregate_initializer *ai = (ast_aggregate_initializer *)$5;
- _mesa_ast_set_aggregate_type($1->type->specifier, ai, state);
- }
}
;
@@ -1061,74 +1028,43 @@ single_declaration:
| fully_specified_type any_identifier
{
void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL);
+ ast_declaration *decl = new(ctx) ast_declaration($2, NULL, NULL);
$$ = new(ctx) ast_declarator_list($1);
$$->set_location(yylloc);
$$->declarations.push_tail(&decl->link);
}
- | fully_specified_type any_identifier '[' ']'
+ | fully_specified_type any_identifier array_specifier
{
void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, NULL);
+ ast_declaration *decl = new(ctx) ast_declaration($2, $3, NULL);
$$ = new(ctx) ast_declarator_list($1);
$$->set_location(yylloc);
$$->declarations.push_tail(&decl->link);
}
- | fully_specified_type any_identifier '[' constant_expression ']'
+ | fully_specified_type any_identifier array_specifier '=' initializer
{
void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, NULL);
+ ast_declaration *decl = new(ctx) ast_declaration($2, $3, $5);
$$ = new(ctx) ast_declarator_list($1);
$$->set_location(yylloc);
$$->declarations.push_tail(&decl->link);
}
- | fully_specified_type any_identifier '[' ']' '=' initializer
- {
- void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($2, true, NULL, $6);
-
- $$ = new(ctx) ast_declarator_list($1);
- $$->set_location(yylloc);
- $$->declarations.push_tail(&decl->link);
- if ($6->oper == ast_aggregate) {
- ast_aggregate_initializer *ai = (ast_aggregate_initializer *)$6;
- ast_type_specifier *type = new(ctx) ast_type_specifier($1->specifier, true, NULL);
- _mesa_ast_set_aggregate_type(type, ai, state);
- }
- }
- | fully_specified_type any_identifier '[' constant_expression ']' '=' initializer
- {
- void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($2, true, $4, $7);
-
- $$ = new(ctx) ast_declarator_list($1);
- $$->set_location(yylloc);
- $$->declarations.push_tail(&decl->link);
- if ($7->oper == ast_aggregate) {
- ast_aggregate_initializer *ai = (ast_aggregate_initializer *)$7;
- ast_type_specifier *type = new(ctx) ast_type_specifier($1->specifier, true, $4);
- _mesa_ast_set_aggregate_type(type, ai, state);
- }
- }
| fully_specified_type any_identifier '=' initializer
{
void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4);
+ ast_declaration *decl = new(ctx) ast_declaration($2, NULL, $4);
$$ = new(ctx) ast_declarator_list($1);
$$->set_location(yylloc);
$$->declarations.push_tail(&decl->link);
- if ($4->oper == ast_aggregate) {
- _mesa_ast_set_aggregate_type($1->specifier, $4, state);
- }
}
| INVARIANT variable_identifier // Vertex only.
{
void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, NULL);
+ ast_declaration *decl = new(ctx) ast_declaration($2, NULL, NULL);
$$ = new(ctx) ast_declarator_list(NULL);
$$->set_location(yylloc);
@@ -1611,19 +1547,51 @@ storage_qualifier:
}
;
-type_specifier:
- type_specifier_nonarray
- | type_specifier_nonarray '[' ']'
+array_specifier:
+ '[' ']'
+ {
+ void *ctx = state;
+ $$ = new(ctx) ast_array_specifier(yylloc);
+ }
+ | '[' constant_expression ']'
+ {
+ void *ctx = state;
+ $$ = new(ctx) ast_array_specifier(yylloc, $2);
+ }
+ | array_specifier '[' ']'
{
$$ = $1;
- $$->is_array = true;
- $$->array_size = NULL;
+
+ if (!state->ARB_arrays_of_arrays_enable) {
+ _mesa_glsl_error(& @1, state,
+ "GL_ARB_arrays_of_arrays "
+ "required for defining arrays of arrays");
+ } else {
+ _mesa_glsl_error(& @1, state,
+ "only the outermost array dimension can "
+ "be unsized");
+ }
}
- | type_specifier_nonarray '[' constant_expression ']'
+ | array_specifier '[' constant_expression ']'
{
$$ = $1;
- $$->is_array = true;
- $$->array_size = $3;
+
+ if (!state->ARB_arrays_of_arrays_enable) {
+ _mesa_glsl_error(& @1, state,
+ "GL_ARB_arrays_of_arrays "
+ "required for defining arrays of arrays");
+ }
+
+ $$->add_dimension($3);
+ }
+ ;
+
+type_specifier:
+ type_specifier_nonarray
+ | type_specifier_nonarray array_specifier
+ {
+ $$ = $1;
+ $$->array_specifier = $2;
}
;
@@ -1803,19 +1771,13 @@ struct_declarator:
any_identifier
{
void *ctx = state;
- $$ = new(ctx) ast_declaration($1, false, NULL, NULL);
- $$->set_location(yylloc);
- }
- | any_identifier '[' ']'
- {
- void *ctx = state;
- $$ = new(ctx) ast_declaration($1, true, NULL, NULL);
+ $$ = new(ctx) ast_declaration($1, NULL, NULL);
$$->set_location(yylloc);
}
- | any_identifier '[' constant_expression ']'
+ | any_identifier array_specifier
{
void *ctx = state;
- $$ = new(ctx) ast_declaration($1, true, $3, NULL);
+ $$ = new(ctx) ast_declaration($1, $2, NULL);
$$->set_location(yylloc);
}
;
@@ -1973,7 +1935,7 @@ condition:
| fully_specified_type any_identifier '=' initializer
{
void *ctx = state;
- ast_declaration *decl = new(ctx) ast_declaration($2, false, NULL, $4);
+ ast_declaration *decl = new(ctx) ast_declaration($2, NULL, $4);
ast_declarator_list *declarator = new(ctx) ast_declarator_list($1);
decl->set_location(yylloc);
declarator->set_location(yylloc);
@@ -2308,22 +2270,17 @@ instance_name_opt:
/* empty */
{
$$ = new(state) ast_interface_block(*state->default_uniform_qualifier,
- NULL, false, NULL);
+ NULL, NULL);
}
| NEW_IDENTIFIER
{
$$ = new(state) ast_interface_block(*state->default_uniform_qualifier,
- $1, false, NULL);
- }
- | NEW_IDENTIFIER '[' constant_expression ']'
- {
- $$ = new(state) ast_interface_block(*state->default_uniform_qualifier,
- $1, true, $3);
+ $1, NULL);
}
- | NEW_IDENTIFIER '[' ']'
+ | NEW_IDENTIFIER array_specifier
{
$$ = new(state) ast_interface_block(*state->default_uniform_qualifier,
- $1, true, NULL);
+ $1, $2);
}
;
diff --git a/mesalib/src/glsl/glsl_parser_extras.cpp b/mesalib/src/glsl/glsl_parser_extras.cpp
index 21dc3abd7..87784ed69 100644
--- a/mesalib/src/glsl/glsl_parser_extras.cpp
+++ b/mesalib/src/glsl/glsl_parser_extras.cpp
@@ -50,7 +50,7 @@ glsl_compute_version_string(void *mem_ctx, bool is_es, unsigned version)
static unsigned known_desktop_glsl_versions[] =
- { 110, 120, 130, 140, 150, 330, 400, 410, 420, 430 };
+ { 110, 120, 130, 140, 150, 330, 400, 410, 420, 430, 440 };
_mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
@@ -291,6 +291,10 @@ _mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version,
}
}
+ if (this->es_shader) {
+ this->ARB_texture_rectangle_enable = false;
+ }
+
this->language_version = version;
bool supported = false;
@@ -484,6 +488,7 @@ struct _mesa_glsl_extension {
static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = {
/* API availability */
/* name GL ES supported flag */
+ EXT(ARB_arrays_of_arrays, true, false, ARB_arrays_of_arrays),
EXT(ARB_conservative_depth, true, false, ARB_conservative_depth),
EXT(ARB_draw_buffers, true, false, dummy_true),
EXT(ARB_draw_instanced, true, false, ARB_draw_instanced),
@@ -513,6 +518,7 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = {
EXT(ARB_shader_atomic_counters, true, false, ARB_shader_atomic_counters),
EXT(ARB_sample_shading, true, false, ARB_sample_shading),
EXT(AMD_shader_trinary_minmax, true, false, dummy_true),
+ EXT(ARB_viewport_array, true, false, ARB_viewport_array),
};
#undef EXT
@@ -634,25 +640,6 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
/**
- * Returns the name of the type of a column of a matrix. E.g.,
- *
- * "mat3" -> "vec3"
- * "mat4x2" -> "vec2"
- */
-static const char *
-_mesa_ast_get_matrix_column_type_name(const char *matrix_type_name)
-{
- static const char *vec_name[] = { "vec2", "vec3", "vec4" };
-
- /* The number of elements in a row of a matrix is specified by the last
- * character of the matrix type name.
- */
- long rows = strtol(matrix_type_name + strlen(matrix_type_name) - 1,
- NULL, 10);
- return vec_name[rows - 2];
-}
-
-/**
* Recurses through <type> and <expr> if <expr> is an aggregate initializer
* and sets <expr>'s <constructor_type> field to <type>. Gives later functions
* (process_array_constructor, et al) sufficient information to do type
@@ -699,37 +686,19 @@ _mesa_ast_get_matrix_column_type_name(const char *matrix_type_name)
* doesn't contain sufficient information to determine if the types match.
*/
void
-_mesa_ast_set_aggregate_type(const ast_type_specifier *type,
- ast_expression *expr,
- _mesa_glsl_parse_state *state)
+_mesa_ast_set_aggregate_type(const glsl_type *type,
+ ast_expression *expr)
{
- void *ctx = state;
ast_aggregate_initializer *ai = (ast_aggregate_initializer *)expr;
- ai->constructor_type = (ast_type_specifier *)type;
-
- bool is_declaration = ai->constructor_type->structure != NULL;
- if (!is_declaration) {
- /* Look up <type> name in the symbol table to see if it's a struct. */
- const ast_type_specifier *struct_type =
- state->symbols->get_type_ast(type->type_name);
- ai->constructor_type->structure =
- struct_type ? new(ctx) ast_struct_specifier(*struct_type->structure)
- : NULL;
- }
+ ai->constructor_type = type;
/* If the aggregate is an array, recursively set its elements' types. */
- if (type->is_array) {
- /* We want to set the element type which is not an array itself, so make
- * a copy of the array type and set its is_array field to false.
+ if (type->is_array()) {
+ /* Each array element has the type type->element_type().
*
* E.g., if <type> if struct S[2] we want to set each element's type to
* struct S.
- *
- * FINISHME: Update when ARB_array_of_arrays is supported.
*/
- const ast_type_specifier *non_array_type =
- new(ctx) ast_type_specifier(type, false, NULL);
-
for (exec_node *expr_node = ai->expressions.head;
!expr_node->is_tail_sentinel();
expr_node = expr_node->next) {
@@ -737,84 +706,33 @@ _mesa_ast_set_aggregate_type(const ast_type_specifier *type,
link);
if (expr->oper == ast_aggregate)
- _mesa_ast_set_aggregate_type(non_array_type, expr, state);
+ _mesa_ast_set_aggregate_type(type->element_type(), expr);
}
/* If the aggregate is a struct, recursively set its fields' types. */
- } else if (ai->constructor_type->structure) {
- ai->constructor_type->structure->is_declaration = is_declaration;
+ } else if (type->is_record()) {
exec_node *expr_node = ai->expressions.head;
- /* Iterate through the struct's fields' declarations. E.g., iterate from
- * "float a, b" to "int c" in the struct below.
- *
- * struct {
- * float a, b;
- * int c;
- * } s;
- */
- for (exec_node *decl_list_node =
- ai->constructor_type->structure->declarations.head;
- !decl_list_node->is_tail_sentinel();
- decl_list_node = decl_list_node->next) {
- ast_declarator_list *decl_list = exec_node_data(ast_declarator_list,
- decl_list_node, link);
-
- for (exec_node *decl_node = decl_list->declarations.head;
- !decl_node->is_tail_sentinel() && !expr_node->is_tail_sentinel();
- decl_node = decl_node->next, expr_node = expr_node->next) {
- ast_declaration *decl = exec_node_data(ast_declaration, decl_node,
- link);
- ast_expression *expr = exec_node_data(ast_expression, expr_node,
- link);
-
- bool is_array = decl_list->type->specifier->is_array;
- ast_expression *array_size = decl_list->type->specifier->array_size;
-
- /* Recognize variable declarations with the bracketed size attached
- * to the type rather than the variable name as arrays. E.g.,
- *
- * float a[2];
- * float[2] b;
- *
- * are both arrays, but <a>'s array_size is decl->array_size, while
- * <b>'s array_size is decl_list->type->specifier->array_size.
- */
- if (!is_array) {
- /* FINISHME: Update when ARB_array_of_arrays is supported. */
- is_array = decl->is_array;
- array_size = decl->array_size;
- }
-
- /* Declaration shadows the <type> parameter. */
- ast_type_specifier *type =
- new(ctx) ast_type_specifier(decl_list->type->specifier,
- is_array, array_size);
+ /* Iterate through the struct's fields. */
+ for (unsigned i = 0; !expr_node->is_tail_sentinel() && i < type->length;
+ i++, expr_node = expr_node->next) {
+ ast_expression *expr = exec_node_data(ast_expression, expr_node,
+ link);
- if (expr->oper == ast_aggregate)
- _mesa_ast_set_aggregate_type(type, expr, state);
+ if (expr->oper == ast_aggregate) {
+ _mesa_ast_set_aggregate_type(type->fields.structure[i].type, expr);
}
}
- } else {
- /* If the aggregate is a matrix, set its columns' types. */
- const char *name;
- const glsl_type *const constructor_type =
- ai->constructor_type->glsl_type(&name, state);
-
- if (constructor_type->is_matrix()) {
- for (exec_node *expr_node = ai->expressions.head;
- !expr_node->is_tail_sentinel();
- expr_node = expr_node->next) {
- ast_expression *expr = exec_node_data(ast_expression, expr_node,
- link);
-
- /* Declaration shadows the <type> parameter. */
- ast_type_specifier *type = new(ctx)
- ast_type_specifier(_mesa_ast_get_matrix_column_type_name(name));
-
- if (expr->oper == ast_aggregate)
- _mesa_ast_set_aggregate_type(type, expr, state);
- }
+ /* If the aggregate is a matrix, set its columns' types. */
+ } else if (type->is_matrix()) {
+ for (exec_node *expr_node = ai->expressions.head;
+ !expr_node->is_tail_sentinel();
+ expr_node = expr_node->next) {
+ ast_expression *expr = exec_node_data(ast_expression, expr_node,
+ link);
+
+ if (expr->oper == ast_aggregate)
+ _mesa_ast_set_aggregate_type(type->column_type(), expr);
}
}
}
@@ -876,16 +794,10 @@ ast_node::ast_node(void)
static void
-ast_opt_array_size_print(bool is_array, const ast_expression *array_size)
+ast_opt_array_dimensions_print(const ast_array_specifier *array_specifier)
{
- if (is_array) {
- printf("[ ");
-
- if (array_size)
- array_size->print();
-
- printf("] ");
- }
+ if (array_specifier)
+ array_specifier->print();
}
@@ -1108,7 +1020,7 @@ ast_parameter_declarator::print(void) const
type->print();
if (identifier)
printf("%s ", identifier);
- ast_opt_array_size_print(is_array, array_size);
+ ast_opt_array_dimensions_print(array_specifier);
}
@@ -1124,7 +1036,7 @@ void
ast_declaration::print(void) const
{
printf("%s ", identifier);
- ast_opt_array_size_print(is_array, array_size);
+ ast_opt_array_dimensions_print(array_specifier);
if (initializer) {
printf("= ");
@@ -1133,13 +1045,12 @@ ast_declaration::print(void) const
}
-ast_declaration::ast_declaration(const char *identifier, bool is_array,
- ast_expression *array_size,
+ast_declaration::ast_declaration(const char *identifier,
+ ast_array_specifier *array_specifier,
ast_expression *initializer)
{
this->identifier = identifier;
- this->is_array = is_array;
- this->array_size = array_size;
+ this->array_specifier = array_specifier;
this->initializer = initializer;
}
@@ -1560,9 +1471,13 @@ do_common_optimization(exec_list *ir, bool linked,
progress = do_copy_propagation(ir) || progress;
progress = do_copy_propagation_elements(ir) || progress;
- if (options->PreferDP4 && !linked)
+ if (options->OptimizeForAOS && !linked)
progress = opt_flip_matrices(ir) || progress;
+ if (linked && options->OptimizeForAOS) {
+ progress = do_vectorize(ir) || progress;
+ }
+
if (linked)
progress = do_dead_code(ir, uniform_locations_assigned) || progress;
else
diff --git a/mesalib/src/glsl/glsl_parser_extras.h b/mesalib/src/glsl/glsl_parser_extras.h
index 2444a96ce..8a4cbf14c 100644
--- a/mesalib/src/glsl/glsl_parser_extras.h
+++ b/mesalib/src/glsl/glsl_parser_extras.h
@@ -294,6 +294,8 @@ struct _mesa_glsl_parse_state {
* \name Enable bits for GLSL extensions
*/
/*@{*/
+ bool ARB_arrays_of_arrays_enable;
+ bool ARB_arrays_of_arrays_warn;
bool ARB_draw_buffers_enable;
bool ARB_draw_buffers_warn;
bool ARB_draw_instanced_enable;
@@ -352,6 +354,8 @@ struct _mesa_glsl_parse_state {
bool ARB_shader_atomic_counters_warn;
bool AMD_shader_trinary_minmax_enable;
bool AMD_shader_trinary_minmax_warn;
+ bool ARB_viewport_array_enable;
+ bool ARB_viewport_array_warn;
/*@}*/
/** Extensions supported by the OpenGL implementation. */
diff --git a/mesalib/src/glsl/glsl_types.cpp b/mesalib/src/glsl/glsl_types.cpp
index 12d4ac0ee..1b0b3ef88 100644
--- a/mesalib/src/glsl/glsl_types.cpp
+++ b/mesalib/src/glsl/glsl_types.cpp
@@ -300,8 +300,20 @@ glsl_type::glsl_type(const glsl_type *array, unsigned length) :
if (length == 0)
snprintf(n, name_length, "%s[]", array->name);
- else
- snprintf(n, name_length, "%s[%u]", array->name, length);
+ else {
+ /* insert outermost dimensions in the correct spot
+ * otherwise the dimension order will be backwards
+ */
+ const char *pos = strchr(array->name, '[');
+ if (pos) {
+ int idx = pos - array->name;
+ snprintf(n, idx+1, "%s", array->name);
+ snprintf(n + idx, name_length - idx, "[%u]%s",
+ length, array->name + idx);
+ } else {
+ snprintf(n, name_length, "%s[%u]", array->name, length);
+ }
+ }
this->name = n;
}
@@ -449,6 +461,42 @@ glsl_type::get_array_instance(const glsl_type *base, unsigned array_size)
}
+bool
+glsl_type::record_compare(const glsl_type *b) const
+{
+ if (this->length != b->length)
+ return false;
+
+ if (this->interface_packing != b->interface_packing)
+ return false;
+
+ for (unsigned i = 0; i < this->length; i++) {
+ if (this->fields.structure[i].type != b->fields.structure[i].type)
+ return false;
+ if (strcmp(this->fields.structure[i].name,
+ b->fields.structure[i].name) != 0)
+ return false;
+ if (this->fields.structure[i].row_major
+ != b->fields.structure[i].row_major)
+ return false;
+ if (this->fields.structure[i].location
+ != b->fields.structure[i].location)
+ return false;
+ if (this->fields.structure[i].interpolation
+ != b->fields.structure[i].interpolation)
+ return false;
+ if (this->fields.structure[i].centroid
+ != b->fields.structure[i].centroid)
+ return false;
+ if (this->fields.structure[i].sample
+ != b->fields.structure[i].sample)
+ return false;
+ }
+
+ return true;
+}
+
+
int
glsl_type::record_key_compare(const void *a, const void *b)
{
@@ -461,36 +509,7 @@ glsl_type::record_key_compare(const void *a, const void *b)
if (strcmp(key1->name, key2->name) != 0)
return 1;
- if (key1->length != key2->length)
- return 1;
-
- if (key1->interface_packing != key2->interface_packing)
- return 1;
-
- for (unsigned i = 0; i < key1->length; i++) {
- if (key1->fields.structure[i].type != key2->fields.structure[i].type)
- return 1;
- if (strcmp(key1->fields.structure[i].name,
- key2->fields.structure[i].name) != 0)
- return 1;
- if (key1->fields.structure[i].row_major
- != key2->fields.structure[i].row_major)
- return 1;
- if (key1->fields.structure[i].location
- != key2->fields.structure[i].location)
- return 1;
- if (key1->fields.structure[i].interpolation
- != key2->fields.structure[i].interpolation)
- return 1;
- if (key1->fields.structure[i].centroid
- != key2->fields.structure[i].centroid)
- return 1;
- if (key1->fields.structure[i].sample
- != key2->fields.structure[i].sample)
- return 1;
- }
-
- return 0;
+ return !key1->record_compare(key2);
}
diff --git a/mesalib/src/glsl/glsl_types.h b/mesalib/src/glsl/glsl_types.h
index fb7c9288d..f88758a9a 100644
--- a/mesalib/src/glsl/glsl_types.h
+++ b/mesalib/src/glsl/glsl_types.h
@@ -542,6 +542,13 @@ struct glsl_type {
*/
int sampler_coordinate_components() const;
+ /**
+ * Compare a record type against another record type.
+ *
+ * This is useful for matching record types declared across shader stages.
+ */
+ bool record_compare(const glsl_type *b) const;
+
private:
/**
* ralloc context for all glsl_type allocations
diff --git a/mesalib/src/glsl/ir.h b/mesalib/src/glsl/ir.h
index 2ae8513a6..19e8383b2 100644
--- a/mesalib/src/glsl/ir.h
+++ b/mesalib/src/glsl/ir.h
@@ -148,7 +148,7 @@ public:
* in particular. No support for other instruction types (assignments,
* jumps, calls, etc.) is planned.
*/
- virtual bool equals(ir_instruction *ir);
+ virtual bool equals(ir_instruction *ir, enum ir_node_type ignore = ir_type_unset);
protected:
ir_instruction()
@@ -1413,7 +1413,7 @@ public:
return this;
}
- virtual bool equals(ir_instruction *ir);
+ virtual bool equals(ir_instruction *ir, enum ir_node_type ignore = ir_type_unset);
virtual ir_expression *clone(void *mem_ctx, struct hash_table *ht) const;
@@ -1741,7 +1741,7 @@ public:
virtual ir_visitor_status accept(ir_hierarchical_visitor *);
- virtual bool equals(ir_instruction *ir);
+ virtual bool equals(ir_instruction *ir, enum ir_node_type ignore = ir_type_unset);
/**
* Return a string representing the ir_texture_opcode.
@@ -1847,7 +1847,7 @@ public:
virtual ir_visitor_status accept(ir_hierarchical_visitor *);
- virtual bool equals(ir_instruction *ir);
+ virtual bool equals(ir_instruction *ir, enum ir_node_type ignore = ir_type_unset);
bool is_lvalue() const
{
@@ -1913,7 +1913,7 @@ public:
return this;
}
- virtual bool equals(ir_instruction *ir);
+ virtual bool equals(ir_instruction *ir, enum ir_node_type ignore = ir_type_unset);
/**
* Get the variable that is ultimately referenced by an r-value
@@ -1973,7 +1973,7 @@ public:
return this;
}
- virtual bool equals(ir_instruction *ir);
+ virtual bool equals(ir_instruction *ir, enum ir_node_type ignore = ir_type_unset);
/**
* Get the variable that is ultimately referenced by an r-value
@@ -2109,7 +2109,7 @@ public:
virtual ir_visitor_status accept(ir_hierarchical_visitor *);
- virtual bool equals(ir_instruction *ir);
+ virtual bool equals(ir_instruction *ir, enum ir_node_type ignore = ir_type_unset);
/**
* Get a particular component of a constant as a specific type
diff --git a/mesalib/src/glsl/ir_equals.cpp b/mesalib/src/glsl/ir_equals.cpp
index 7cfe1e66b..484530019 100644
--- a/mesalib/src/glsl/ir_equals.cpp
+++ b/mesalib/src/glsl/ir_equals.cpp
@@ -28,12 +28,12 @@
* can't access a's vtable in that case.
*/
static bool
-possibly_null_equals(ir_instruction *a, ir_instruction *b)
+possibly_null_equals(ir_instruction *a, ir_instruction *b, enum ir_node_type ignore)
{
if (!a || !b)
return !a && !b;
- return a->equals(b);
+ return a->equals(b, ignore);
}
/**
@@ -41,13 +41,13 @@ possibly_null_equals(ir_instruction *a, ir_instruction *b)
* about.
*/
bool
-ir_instruction::equals(ir_instruction *ir)
+ir_instruction::equals(ir_instruction *ir, enum ir_node_type)
{
return false;
}
bool
-ir_constant::equals(ir_instruction *ir)
+ir_constant::equals(ir_instruction *ir, enum ir_node_type ignore)
{
const ir_constant *other = ir->as_constant();
if (!other)
@@ -65,7 +65,7 @@ ir_constant::equals(ir_instruction *ir)
}
bool
-ir_dereference_variable::equals(ir_instruction *ir)
+ir_dereference_variable::equals(ir_instruction *ir, enum ir_node_type ignore)
{
const ir_dereference_variable *other = ir->as_dereference_variable();
if (!other)
@@ -75,7 +75,7 @@ ir_dereference_variable::equals(ir_instruction *ir)
}
bool
-ir_dereference_array::equals(ir_instruction *ir)
+ir_dereference_array::equals(ir_instruction *ir, enum ir_node_type ignore)
{
const ir_dereference_array *other = ir->as_dereference_array();
if (!other)
@@ -84,17 +84,17 @@ ir_dereference_array::equals(ir_instruction *ir)
if (type != other->type)
return false;
- if (!array->equals(other->array))
+ if (!array->equals(other->array, ignore))
return false;
- if (!array_index->equals(other->array_index))
+ if (!array_index->equals(other->array_index, ignore))
return false;
return true;
}
bool
-ir_swizzle::equals(ir_instruction *ir)
+ir_swizzle::equals(ir_instruction *ir, enum ir_node_type ignore)
{
const ir_swizzle *other = ir->as_swizzle();
if (!other)
@@ -103,18 +103,20 @@ ir_swizzle::equals(ir_instruction *ir)
if (type != other->type)
return false;
- if (mask.x != other->mask.x ||
- mask.y != other->mask.y ||
- mask.z != other->mask.z ||
- mask.w != other->mask.w) {
- return false;
+ if (ignore != ir_type_swizzle) {
+ if (mask.x != other->mask.x ||
+ mask.y != other->mask.y ||
+ mask.z != other->mask.z ||
+ mask.w != other->mask.w) {
+ return false;
+ }
}
- return val->equals(other->val);
+ return val->equals(other->val, ignore);
}
bool
-ir_texture::equals(ir_instruction *ir)
+ir_texture::equals(ir_instruction *ir, enum ir_node_type ignore)
{
const ir_texture *other = ir->as_texture();
if (!other)
@@ -126,19 +128,19 @@ ir_texture::equals(ir_instruction *ir)
if (op != other->op)
return false;
- if (!possibly_null_equals(coordinate, other->coordinate))
+ if (!possibly_null_equals(coordinate, other->coordinate, ignore))
return false;
- if (!possibly_null_equals(projector, other->projector))
+ if (!possibly_null_equals(projector, other->projector, ignore))
return false;
- if (!possibly_null_equals(shadow_comparitor, other->shadow_comparitor))
+ if (!possibly_null_equals(shadow_comparitor, other->shadow_comparitor, ignore))
return false;
- if (!possibly_null_equals(offset, other->offset))
+ if (!possibly_null_equals(offset, other->offset, ignore))
return false;
- if (!sampler->equals(other->sampler))
+ if (!sampler->equals(other->sampler, ignore))
return false;
switch (op) {
@@ -147,26 +149,26 @@ ir_texture::equals(ir_instruction *ir)
case ir_query_levels:
break;
case ir_txb:
- if (!lod_info.bias->equals(other->lod_info.bias))
+ if (!lod_info.bias->equals(other->lod_info.bias, ignore))
return false;
break;
case ir_txl:
case ir_txf:
case ir_txs:
- if (!lod_info.lod->equals(other->lod_info.lod))
+ if (!lod_info.lod->equals(other->lod_info.lod, ignore))
return false;
break;
case ir_txd:
- if (!lod_info.grad.dPdx->equals(other->lod_info.grad.dPdx) ||
- !lod_info.grad.dPdy->equals(other->lod_info.grad.dPdy))
+ if (!lod_info.grad.dPdx->equals(other->lod_info.grad.dPdx, ignore) ||
+ !lod_info.grad.dPdy->equals(other->lod_info.grad.dPdy, ignore))
return false;
break;
case ir_txf_ms:
- if (!lod_info.sample_index->equals(other->lod_info.sample_index))
+ if (!lod_info.sample_index->equals(other->lod_info.sample_index, ignore))
return false;
break;
case ir_tg4:
- if (!lod_info.component->equals(other->lod_info.component))
+ if (!lod_info.component->equals(other->lod_info.component, ignore))
return false;
break;
default:
@@ -177,7 +179,7 @@ ir_texture::equals(ir_instruction *ir)
}
bool
-ir_expression::equals(ir_instruction *ir)
+ir_expression::equals(ir_instruction *ir, enum ir_node_type ignore)
{
const ir_expression *other = ir->as_expression();
if (!other)
@@ -190,7 +192,7 @@ ir_expression::equals(ir_instruction *ir)
return false;
for (unsigned i = 0; i < get_num_operands(); i++) {
- if (!operands[i]->equals(other->operands[i]))
+ if (!operands[i]->equals(other->operands[i], ignore))
return false;
}
diff --git a/mesalib/src/glsl/ir_optimization.h b/mesalib/src/glsl/ir_optimization.h
index 3ca9f5744..055d65547 100644
--- a/mesalib/src/glsl/ir_optimization.h
+++ b/mesalib/src/glsl/ir_optimization.h
@@ -98,6 +98,7 @@ bool do_mat_op_to_vec(exec_list *instructions);
bool do_noop_swizzle(exec_list *instructions);
bool do_structure_splitting(exec_list *instructions);
bool do_swizzle_swizzle(exec_list *instructions);
+bool do_vectorize(exec_list *instructions);
bool do_tree_grafting(exec_list *instructions);
bool do_vec_index_to_cond_assign(exec_list *instructions);
bool do_vec_index_to_swizzle(exec_list *instructions);
diff --git a/mesalib/src/glsl/link_atomics.cpp b/mesalib/src/glsl/link_atomics.cpp
index db9c53965..d92cdb117 100644
--- a/mesalib/src/glsl/link_atomics.cpp
+++ b/mesalib/src/glsl/link_atomics.cpp
@@ -105,9 +105,10 @@ namespace {
ir_variable *var = ((ir_instruction *)node)->as_variable();
if (var && var->type->contains_atomic()) {
- unsigned id;
+ unsigned id = 0;
bool found = prog->UniformHash->get(id, var->name);
assert(found);
+ (void) found;
active_atomic_buffer *buf = &buffers[var->data.binding];
/* If this is the first time the buffer is used, increment
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index 85a4d3883..93b475497 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -609,6 +609,10 @@ cross_validate_globals(struct gl_shader_program *prog,
if (var->type->length != 0) {
existing->type = var->type;
}
+ } else if (var->type->is_record()
+ && existing->type->is_record()
+ && existing->type->record_compare(var->type)) {
+ existing->type = var->type;
} else {
linker_error(prog, "%s `%s' declared as type "
"`%s' and type `%s'\n",
@@ -1992,19 +1996,14 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
/* Separate the shaders into groups based on their type.
*/
- struct gl_shader **vert_shader_list;
- unsigned num_vert_shaders = 0;
- struct gl_shader **frag_shader_list;
- unsigned num_frag_shaders = 0;
- struct gl_shader **geom_shader_list;
- unsigned num_geom_shaders = 0;
-
- vert_shader_list = (struct gl_shader **)
- calloc(prog->NumShaders, sizeof(struct gl_shader *));
- frag_shader_list = (struct gl_shader **)
- calloc(prog->NumShaders, sizeof(struct gl_shader *));
- geom_shader_list = (struct gl_shader **)
- calloc(prog->NumShaders, sizeof(struct gl_shader *));
+ struct gl_shader **shader_list[MESA_SHADER_STAGES];
+ unsigned num_shaders[MESA_SHADER_STAGES];
+
+ for (int i = 0; i < MESA_SHADER_STAGES; i++) {
+ shader_list[i] = (struct gl_shader **)
+ calloc(prog->NumShaders, sizeof(struct gl_shader *));
+ num_shaders[i] = 0;
+ }
unsigned min_version = UINT_MAX;
unsigned max_version = 0;
@@ -2020,20 +2019,9 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
goto done;
}
- switch (prog->Shaders[i]->Stage) {
- case MESA_SHADER_VERTEX:
- vert_shader_list[num_vert_shaders] = prog->Shaders[i];
- num_vert_shaders++;
- break;
- case MESA_SHADER_FRAGMENT:
- frag_shader_list[num_frag_shaders] = prog->Shaders[i];
- num_frag_shaders++;
- break;
- case MESA_SHADER_GEOMETRY:
- geom_shader_list[num_geom_shaders] = prog->Shaders[i];
- num_geom_shaders++;
- break;
- }
+ gl_shader_stage shader_type = prog->Shaders[i]->Stage;
+ shader_list[shader_type][num_shaders[shader_type]] = prog->Shaders[i];
+ num_shaders[shader_type]++;
}
/* In desktop GLSL, different shader versions may be linked together. In
@@ -2050,7 +2038,8 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
/* Geometry shaders have to be linked with vertex shaders.
*/
- if (num_geom_shaders > 0 && num_vert_shaders == 0) {
+ if (num_shaders[MESA_SHADER_GEOMETRY] > 0 &&
+ num_shaders[MESA_SHADER_VERTEX] == 0) {
linker_error(prog, "Geometry shader must be linked with "
"vertex shader\n");
goto done;
@@ -2065,55 +2054,39 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
/* Link all shaders for a particular stage and validate the result.
*/
- if (num_vert_shaders > 0) {
- gl_shader *const sh =
- link_intrastage_shaders(mem_ctx, ctx, prog, vert_shader_list,
- num_vert_shaders);
-
- if (!prog->LinkStatus)
- goto done;
-
- validate_vertex_shader_executable(prog, sh);
- if (!prog->LinkStatus)
- goto done;
- prog->LastClipDistanceArraySize = prog->Vert.ClipDistanceArraySize;
+ for (int stage = 0; stage < MESA_SHADER_STAGES; stage++) {
+ if (num_shaders[stage] > 0) {
+ gl_shader *const sh =
+ link_intrastage_shaders(mem_ctx, ctx, prog, shader_list[stage],
+ num_shaders[stage]);
- _mesa_reference_shader(ctx, &prog->_LinkedShaders[MESA_SHADER_VERTEX],
- sh);
- }
-
- if (num_frag_shaders > 0) {
- gl_shader *const sh =
- link_intrastage_shaders(mem_ctx, ctx, prog, frag_shader_list,
- num_frag_shaders);
-
- if (!prog->LinkStatus)
- goto done;
+ if (!prog->LinkStatus)
+ goto done;
- validate_fragment_shader_executable(prog, sh);
- if (!prog->LinkStatus)
- goto done;
+ switch (stage) {
+ case MESA_SHADER_VERTEX:
+ validate_vertex_shader_executable(prog, sh);
+ break;
+ case MESA_SHADER_GEOMETRY:
+ validate_geometry_shader_executable(prog, sh);
+ break;
+ case MESA_SHADER_FRAGMENT:
+ validate_fragment_shader_executable(prog, sh);
+ break;
+ }
+ if (!prog->LinkStatus)
+ goto done;
- _mesa_reference_shader(ctx, &prog->_LinkedShaders[MESA_SHADER_FRAGMENT],
- sh);
+ _mesa_reference_shader(ctx, &prog->_LinkedShaders[stage], sh);
+ }
}
- if (num_geom_shaders > 0) {
- gl_shader *const sh =
- link_intrastage_shaders(mem_ctx, ctx, prog, geom_shader_list,
- num_geom_shaders);
-
- if (!prog->LinkStatus)
- goto done;
-
- validate_geometry_shader_executable(prog, sh);
- if (!prog->LinkStatus)
- goto done;
+ if (num_shaders[MESA_SHADER_GEOMETRY] > 0)
prog->LastClipDistanceArraySize = prog->Geom.ClipDistanceArraySize;
-
- _mesa_reference_shader(ctx, &prog->_LinkedShaders[MESA_SHADER_GEOMETRY],
- sh);
- }
+ else if (num_shaders[MESA_SHADER_VERTEX] > 0)
+ prog->LastClipDistanceArraySize = prog->Vert.ClipDistanceArraySize;
+ else
+ prog->LastClipDistanceArraySize = 0; /* Not used */
/* Here begins the inter-stage linking phase. Some initial validation is
* performed, then locations are assigned for uniforms, attributes, and
@@ -2371,11 +2344,8 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
/* FINISHME: Assign fragment shader output locations. */
done:
- free(vert_shader_list);
- free(frag_shader_list);
- free(geom_shader_list);
-
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+ free(shader_list[i]);
if (prog->_LinkedShaders[i] == NULL)
continue;
diff --git a/mesalib/src/glsl/opt_algebraic.cpp b/mesalib/src/glsl/opt_algebraic.cpp
index 332f0b77b..d1f6435f4 100644
--- a/mesalib/src/glsl/opt_algebraic.cpp
+++ b/mesalib/src/glsl/opt_algebraic.cpp
@@ -285,6 +285,58 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
reassociate_constant(ir, 0, op_const[0], op_expr[1]);
if (op_const[1] && !op_const[0])
reassociate_constant(ir, 1, op_const[1], op_expr[0]);
+
+ /* Replace (-x + y) * a + x and commutative variations with lrp(x, y, a).
+ *
+ * (-x + y) * a + x
+ * (x * -a) + (y * a) + x
+ * x + (x * -a) + (y * a)
+ * x * (1 - a) + y * a
+ * lrp(x, y, a)
+ */
+ for (int mul_pos = 0; mul_pos < 2; mul_pos++) {
+ ir_expression *mul = op_expr[mul_pos];
+
+ if (!mul || mul->operation != ir_binop_mul)
+ continue;
+
+ /* Multiply found on one of the operands. Now check for an
+ * inner addition operation.
+ */
+ for (int inner_add_pos = 0; inner_add_pos < 2; inner_add_pos++) {
+ ir_expression *inner_add =
+ mul->operands[inner_add_pos]->as_expression();
+
+ if (!inner_add || inner_add->operation != ir_binop_add)
+ continue;
+
+ /* Inner addition found on one of the operands. Now check for
+ * one of the operands of the inner addition to be the negative
+ * of x_operand.
+ */
+ for (int neg_pos = 0; neg_pos < 2; neg_pos++) {
+ ir_expression *neg =
+ inner_add->operands[neg_pos]->as_expression();
+
+ if (!neg || neg->operation != ir_unop_neg)
+ continue;
+
+ ir_rvalue *x_operand = ir->operands[1 - mul_pos];
+
+ if (!neg->operands[0]->equals(x_operand))
+ continue;
+
+ ir_rvalue *y_operand = inner_add->operands[1 - neg_pos];
+ ir_rvalue *a_operand = mul->operands[1 - inner_add_pos];
+
+ if (x_operand->type != y_operand->type ||
+ x_operand->type != a_operand->type)
+ continue;
+
+ return lrp(x_operand, y_operand, a_operand);
+ }
+ }
+ }
break;
case ir_binop_sub:
diff --git a/mesalib/src/glsl/opt_vectorize.cpp b/mesalib/src/glsl/opt_vectorize.cpp
new file mode 100644
index 000000000..9ca811a86
--- /dev/null
+++ b/mesalib/src/glsl/opt_vectorize.cpp
@@ -0,0 +1,319 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ *
+ * 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.
+ */
+
+/**
+ * \file opt_vectorize.cpp
+ *
+ * Combines scalar assignments of the same expression (modulo swizzle) to
+ * multiple channels of the same variable into a single vectorized expression
+ * and assignment.
+ *
+ * Many generated shaders contain scalarized code. That is, they contain
+ *
+ * r1.x = log2(v0.x);
+ * r1.y = log2(v0.y);
+ * r1.z = log2(v0.z);
+ *
+ * rather than
+ *
+ * r1.xyz = log2(v0.xyz);
+ *
+ * We look for consecutive assignments of the same expression (modulo swizzle)
+ * to each channel of the same variable.
+ *
+ * For instance, we want to convert these three scalar operations
+ *
+ * (assign (x) (var_ref r1) (expression float log2 (swiz x (var_ref v0))))
+ * (assign (y) (var_ref r1) (expression float log2 (swiz y (var_ref v0))))
+ * (assign (z) (var_ref r1) (expression float log2 (swiz z (var_ref v0))))
+ *
+ * into a single vector operation
+ *
+ * (assign (xyz) (var_ref r1) (expression vec3 log2 (swiz xyz (var_ref v0))))
+ */
+
+#include "ir.h"
+#include "ir_visitor.h"
+#include "ir_optimization.h"
+#include "glsl_types.h"
+#include "program/prog_instruction.h"
+
+namespace {
+
+class ir_vectorize_visitor : public ir_hierarchical_visitor {
+public:
+ void clear()
+ {
+ assignment[0] = NULL;
+ assignment[1] = NULL;
+ assignment[2] = NULL;
+ assignment[3] = NULL;
+ current_assignment = NULL;
+ last_assignment = NULL;
+ channels = 0;
+ has_swizzle = false;
+ }
+
+ ir_vectorize_visitor()
+ {
+ clear();
+ progress = false;
+ }
+
+ virtual ir_visitor_status visit_enter(ir_assignment *);
+ virtual ir_visitor_status visit_enter(ir_swizzle *);
+
+ virtual ir_visitor_status visit_leave(ir_assignment *);
+
+ void try_vectorize();
+
+ ir_assignment *assignment[4];
+ ir_assignment *current_assignment, *last_assignment;
+ unsigned channels;
+ bool has_swizzle;
+
+ bool progress;
+};
+
+} /* unnamed namespace */
+
+/**
+ * Rewrites the swizzles and types of a right-hand side of an assignment.
+ *
+ * From the example above, this function would be called (by visit_tree()) on
+ * the nodes of the tree (expression float log2 (swiz z (var_ref v0))),
+ * rewriting it into (expression vec3 log2 (swiz xyz (var_ref v0))).
+ *
+ * The function modifies only ir_expressions and ir_swizzles. For expressions
+ * it sets a new type and swizzles any scalar dereferences into appropriately
+ * sized vector arguments. For example, if combining
+ *
+ * (assign (x) (var_ref r1) (expression float + (swiz x (var_ref v0) (var_ref v1))))
+ * (assign (y) (var_ref r1) (expression float + (swiz y (var_ref v0) (var_ref v1))))
+ *
+ * where v1 is a scalar, rewrite_swizzle() would insert a swizzle on
+ * (var_ref v1) such that the final result was
+ *
+ * (assign (xy) (var_ref r1) (expression vec2 + (swiz xy (var_ref v0))
+ * (swiz xx (var_ref v1))))
+ *
+ * For swizzles, it sets a new type, and if the variable being swizzled is a
+ * vector it overwrites the swizzle mask with the ir_swizzle_mask passed as the
+ * data parameter. If the swizzled variable is scalar, then the swizzle was
+ * added by an earlier call to rewrite_swizzle() on an expression, so the
+ * mask should not be modified.
+ */
+static void
+rewrite_swizzle(ir_instruction *ir, void *data)
+{
+ ir_swizzle_mask *mask = (ir_swizzle_mask *)data;
+
+ switch (ir->ir_type) {
+ case ir_type_swizzle: {
+ ir_swizzle *swz = (ir_swizzle *)ir;
+ if (swz->val->type->is_vector()) {
+ swz->mask = *mask;
+ }
+ swz->type = glsl_type::get_instance(swz->type->base_type,
+ mask->num_components, 1);
+ break;
+ }
+ case ir_type_expression: {
+ ir_expression *expr = (ir_expression *)ir;
+ expr->type = glsl_type::get_instance(expr->type->base_type,
+ mask->num_components, 1);
+ for (unsigned i = 0; i < 4; i++) {
+ if (expr->operands[i]) {
+ ir_dereference *deref = expr->operands[i]->as_dereference();
+ if (deref && deref->type->is_scalar()) {
+ expr->operands[i] = new(ir) ir_swizzle(deref, 0, 0, 0, 0,
+ mask->num_components);
+ }
+ }
+ }
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+/**
+ * Attempt to vectorize the previously saved assignments, and clear them from
+ * consideration.
+ *
+ * If the assignments are able to be combined, it modifies in-place the last
+ * assignment seen to be an equivalent vector form of the scalar assignments.
+ * It then removes the other now obsolete scalar assignments.
+ */
+void
+ir_vectorize_visitor::try_vectorize()
+{
+ if (this->last_assignment && this->channels > 1) {
+ ir_swizzle_mask mask = {0, 1, 2, 3, channels, 0};
+
+ visit_tree(this->last_assignment->rhs, rewrite_swizzle, &mask);
+
+ this->last_assignment->write_mask = 0;
+
+ for (unsigned i = 0; i < 4; i++) {
+ if (this->assignment[i]) {
+ this->last_assignment->write_mask |= 1 << i;
+
+ if (this->assignment[i] != this->last_assignment) {
+ this->assignment[i]->remove();
+ }
+ }
+ }
+
+ this->progress = true;
+ }
+ clear();
+}
+
+/**
+ * Returns whether the write mask is a single channel.
+ */
+static bool
+single_channel_write_mask(unsigned write_mask)
+{
+ return write_mask != 0 && (write_mask & (write_mask - 1)) == 0;
+}
+
+/**
+ * Translates single-channeled write mask to single-channeled swizzle.
+ */
+static unsigned
+write_mask_to_swizzle(unsigned write_mask)
+{
+ switch (write_mask) {
+ case WRITEMASK_X: return SWIZZLE_X;
+ case WRITEMASK_Y: return SWIZZLE_Y;
+ case WRITEMASK_Z: return SWIZZLE_Z;
+ case WRITEMASK_W: return SWIZZLE_W;
+ }
+ assert(!"not reached");
+ unreachable();
+}
+
+/**
+ * Returns whether a single-channeled write mask matches a swizzle.
+ */
+static bool
+write_mask_matches_swizzle(unsigned write_mask,
+ const ir_swizzle *swz)
+{
+ return ((write_mask == WRITEMASK_X && swz->mask.x == SWIZZLE_X) ||
+ (write_mask == WRITEMASK_Y && swz->mask.x == SWIZZLE_Y) ||
+ (write_mask == WRITEMASK_Z && swz->mask.x == SWIZZLE_Z) ||
+ (write_mask == WRITEMASK_W && swz->mask.x == SWIZZLE_W));
+}
+
+/**
+ * Upon entering an ir_assignment, attempt to vectorize the currently tracked
+ * assignments if the current assignment is not suitable. Keep a pointer to
+ * the current assignment.
+ */
+ir_visitor_status
+ir_vectorize_visitor::visit_enter(ir_assignment *ir)
+{
+ ir_dereference *lhs = this->last_assignment != NULL ?
+ this->last_assignment->lhs : NULL;
+ ir_rvalue *rhs = this->last_assignment != NULL ?
+ this->last_assignment->rhs : NULL;
+
+ if (ir->condition ||
+ this->channels >= 4 ||
+ !single_channel_write_mask(ir->write_mask) ||
+ (lhs && !ir->lhs->equals(lhs)) ||
+ (rhs && !ir->rhs->equals(rhs, ir_type_swizzle))) {
+ try_vectorize();
+ }
+
+ this->current_assignment = ir;
+
+ return visit_continue;
+}
+
+/**
+ * Upon entering an ir_swizzle, set ::has_swizzle if we're visiting from an
+ * ir_assignment (i.e., that ::current_assignment is set) and the swizzle mask
+ * matches the current assignment's write mask.
+ *
+ * If the write mask doesn't match the swizzle mask, remove the current
+ * assignment from further consideration.
+ */
+ir_visitor_status
+ir_vectorize_visitor::visit_enter(ir_swizzle *ir)
+{
+ if (this->current_assignment) {
+ if (write_mask_matches_swizzle(this->current_assignment->write_mask, ir)) {
+ this->has_swizzle = true;
+ } else {
+ this->current_assignment = NULL;
+ }
+ }
+ return visit_continue;
+}
+
+/**
+ * Upon leaving an ir_assignment, save a pointer to it in ::assignment[] if
+ * the swizzle mask(s) found were appropriate. Also save a pointer in
+ * ::last_assignment so that we can compare future assignments with it.
+ *
+ * Finally, clear ::current_assignment and ::has_swizzle.
+ */
+ir_visitor_status
+ir_vectorize_visitor::visit_leave(ir_assignment *ir)
+{
+ if (this->has_swizzle && this->current_assignment) {
+ assert(this->current_assignment == ir);
+
+ unsigned channel = write_mask_to_swizzle(this->current_assignment->write_mask);
+ this->assignment[channel] = ir;
+ this->channels++;
+
+ this->last_assignment = this->current_assignment;
+ }
+ this->current_assignment = NULL;
+ this->has_swizzle = false;
+ return visit_continue;
+}
+
+/**
+ * Combines scalar assignments of the same expression (modulo swizzle) to
+ * multiple channels of the same variable into a single vectorized expression
+ * and assignment.
+ */
+bool
+do_vectorize(exec_list *instructions)
+{
+ ir_vectorize_visitor v;
+
+ v.run(instructions);
+
+ /* Try to vectorize the last assignments seen. */
+ v.try_vectorize();
+
+ return v.progress;
+}
diff --git a/mesalib/src/glsl/standalone_scaffolding.cpp b/mesalib/src/glsl/standalone_scaffolding.cpp
index 257d2e7a9..91794719b 100644
--- a/mesalib/src/glsl/standalone_scaffolding.cpp
+++ b/mesalib/src/glsl/standalone_scaffolding.cpp
@@ -110,6 +110,7 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api)
ctx->Extensions.ARB_texture_query_levels = true;
ctx->Extensions.ARB_texture_query_lod = true;
ctx->Extensions.ARB_uniform_buffer_object = true;
+ ctx->Extensions.ARB_viewport_array = true;
ctx->Extensions.OES_EGL_image_external = true;
ctx->Extensions.OES_standard_derivatives = true;
diff --git a/mesalib/src/mapi/glapi/gen/ARB_viewport_array.xml b/mesalib/src/mapi/glapi/gen/ARB_viewport_array.xml
new file mode 100644
index 000000000..e1c6c2d81
--- /dev/null
+++ b/mesalib/src/mapi/glapi/gen/ARB_viewport_array.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0"?>
+<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
+
+<!-- Note: no GLX protocol info yet. -->
+
+<OpenGLAPI>
+
+<category name="GL_ARB_viewport_array" number="100">
+
+ <enum name="MAX_VIEWPORTS" value="0x825B"/>
+ <enum name="VIEWPORT_SUBPIXEL_BITS" value="0x825C"/>
+ <enum name="VIEWPORT_BOUNDS_RANGE" value="0x825D"/>
+ <enum name="LAYER_PROVOKING_VERTEX" value="0x825E"/>
+ <enum name="VIEWPORT_INDEX_PROVOKING_VERTEX" value="0x825F"/>
+ <enum name="SCISSOR_BOX" value="0x0C10"/>
+ <enum name="VIEWPORT" value="0x0BA2"/>
+ <enum name="DEPTH_RANGE" value="0x0B70"/>
+ <enum name="SCISSOR_TEST" value="0x0C11"/>
+ <enum name="FIRST_VERTEX_CONVENTION" value="0x8E4D"/>
+ <enum name="LAST_VERTEX_CONVENTION" value="0x8E4E"/>
+ <enum name="PROVOKING_VERTEX" value="0x8E4F"/>
+ <enum name="UNDEFINED_VERTEX" value="0x8260"/>
+
+ <function name="ViewportArrayv" offset="assign">
+ <param name="first" type="GLuint"/>
+ <param name="count" type="GLsizei"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+ <function name="ViewportIndexedf" offset="assign">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="w" type="GLfloat"/>
+ <param name="h" type="GLfloat"/>
+ </function>
+ <function name="ViewportIndexedfv" offset="assign">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+ <function name="ScissorArrayv" offset="assign">
+ <param name="first" type="GLuint"/>
+ <param name="count" type="GLsizei"/>
+ <param name="v" type="const int *"/>
+ </function>
+ <function name="ScissorIndexed" offset="assign">
+ <param name="index" type="GLuint"/>
+ <param name="left" type="GLint"/>
+ <param name="bottom" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ </function>
+ <function name="ScissorIndexedv" offset="assign">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLint *"/>
+ </function>
+ <function name="DepthRangeArrayv" offset="assign">
+ <param name="first" type="GLuint"/>
+ <param name="count" type="GLsizei"/>
+ <param name="v" type="const GLclampd *"/>
+ </function>
+ <function name="DepthRangeIndexed" offset="assign">
+ <param name="index" type="GLuint"/>
+ <param name="n" type="GLclampd"/>
+ <param name="f" type="GLclampd"/>
+ </function>
+ <function name="GetFloati_v" offset="assign">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="data" type="GLfloat *"/>
+ </function>
+ <function name="GetDoublei_v" offset="assign">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="data" type="GLdouble *"/>
+ </function>
+
+</category>
+
+</OpenGLAPI>
diff --git a/mesalib/src/mapi/glapi/gen/Makefile.am b/mesalib/src/mapi/glapi/gen/Makefile.am
index d5c20b71e..7354725df 100644
--- a/mesalib/src/mapi/glapi/gen/Makefile.am
+++ b/mesalib/src/mapi/glapi/gen/Makefile.am
@@ -129,6 +129,7 @@ API_XML = \
ARB_texture_view.xml \
ARB_vertex_array_object.xml \
ARB_vertex_attrib_binding.xml \
+ ARB_viewport_array.xml \
AMD_draw_buffers_blend.xml \
AMD_performance_monitor.xml \
ARB_vertex_type_2_10_10_10_rev.xml \
diff --git a/mesalib/src/mapi/glapi/gen/gl_API.xml b/mesalib/src/mapi/glapi/gen/gl_API.xml
index ff65b489a..193ee370c 100644
--- a/mesalib/src/mapi/glapi/gen/gl_API.xml
+++ b/mesalib/src/mapi/glapi/gen/gl_API.xml
@@ -9926,7 +9926,7 @@
</category>
<!-- Extension number 99 is not listed in the extension registry. -->
-<!-- Extension number 100 is a GLU extension. -->
+<xi:include href="ARB_viewport_array.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<!-- Shouldn't this be EXT_fragment_lighting? -->
<category name="GL_SGIX_fragment_lighting" number="102">
diff --git a/mesalib/src/mapi/u_thread.h b/mesalib/src/mapi/u_thread.h
index 31999c4df..ba5d98ea9 100644
--- a/mesalib/src/mapi/u_thread.h
+++ b/mesalib/src/mapi/u_thread.h
@@ -46,12 +46,7 @@
#include <stdlib.h>
#include "u_compiler.h"
-#if defined(HAVE_PTHREAD)
-#include <pthread.h> /* POSIX threads headers */
-#endif
-#ifdef _WIN32
-#include <windows.h>
-#endif
+#include "c11/threads.h"
#if defined(HAVE_PTHREAD) || defined(_WIN32)
#ifndef THREADS
@@ -79,43 +74,32 @@ extern "C" {
#endif
-/*
- * POSIX threads. This should be your choice in the Unix world
- * whenever possible. When building with POSIX threads, be sure
- * to enable any compiler flags which will cause the MT-safe
- * libc (if one exists) to be used when linking, as well as any
- * header macros for MT-safe errno, etc. For Solaris, this is the -mt
- * compiler flag. On Solaris with gcc, use -D_REENTRANT to enable
- * proper compiling for MT-safe libc etc.
- */
-#if defined(HAVE_PTHREAD)
-
struct u_tsd {
- pthread_key_t key;
+ tss_t key;
unsigned initMagic;
};
-typedef pthread_mutex_t u_mutex;
+typedef mtx_t u_mutex;
#define u_mutex_declare_static(name) \
- static u_mutex name = PTHREAD_MUTEX_INITIALIZER
+ static u_mutex name = _MTX_INITIALIZER_NP
-#define u_mutex_init(name) pthread_mutex_init(&(name), NULL)
-#define u_mutex_destroy(name) pthread_mutex_destroy(&(name))
-#define u_mutex_lock(name) (void) pthread_mutex_lock(&(name))
-#define u_mutex_unlock(name) (void) pthread_mutex_unlock(&(name))
+#define u_mutex_init(name) mtx_init(&(name), mtx_plain)
+#define u_mutex_destroy(name) mtx_destroy(&(name))
+#define u_mutex_lock(name) (void) mtx_lock(&(name))
+#define u_mutex_unlock(name) (void) mtx_unlock(&(name))
static INLINE unsigned long
u_thread_self(void)
{
- return (unsigned long) pthread_self();
+ return (unsigned long) (uintptr_t) thrd_current();
}
static INLINE void
u_tsd_init(struct u_tsd *tsd)
{
- if (pthread_key_create(&tsd->key, NULL/*free*/) != 0) {
+ if (tss_create(&tsd->key, NULL/*free*/) != 0) {
perror(INIT_TSD_ERROR);
exit(-1);
}
@@ -129,7 +113,7 @@ u_tsd_get(struct u_tsd *tsd)
if (tsd->initMagic != INIT_MAGIC) {
u_tsd_init(tsd);
}
- return pthread_getspecific(tsd->key);
+ return tss_get(tsd->key);
}
@@ -139,56 +123,12 @@ u_tsd_set(struct u_tsd *tsd, void *ptr)
if (tsd->initMagic != INIT_MAGIC) {
u_tsd_init(tsd);
}
- if (pthread_setspecific(tsd->key, ptr) != 0) {
+ if (tss_set(tsd->key, ptr) != 0) {
perror(SET_TSD_ERROR);
exit(-1);
}
}
-#endif /* HAVE_PTHREAD */
-
-
-/*
- * Windows threads. Should work with Windows NT and 95.
- * IMPORTANT: Link with multithreaded runtime library when THREADS are
- * used!
- */
-#ifdef _WIN32
-
-struct u_tsd {
- DWORD key;
- unsigned initMagic;
-};
-
-typedef CRITICAL_SECTION u_mutex;
-
-/* http://locklessinc.com/articles/pthreads_on_windows/ */
-#define u_mutex_declare_static(name) \
- static u_mutex name = {(PCRITICAL_SECTION_DEBUG)-1, -1, 0, 0, 0, 0}
-
-#define u_mutex_init(name) InitializeCriticalSection(&name)
-#define u_mutex_destroy(name) DeleteCriticalSection(&name)
-#define u_mutex_lock(name) EnterCriticalSection(&name)
-#define u_mutex_unlock(name) LeaveCriticalSection(&name)
-
-static INLINE unsigned long
-u_thread_self(void)
-{
- return GetCurrentThreadId();
-}
-
-
-static INLINE void
-u_tsd_init(struct u_tsd *tsd)
-{
- tsd->key = TlsAlloc();
- if (tsd->key == TLS_OUT_OF_INDEXES) {
- perror(INIT_TSD_ERROR);
- exit(-1);
- }
- tsd->initMagic = INIT_MAGIC;
-}
-
static INLINE void
u_tsd_destroy(struct u_tsd *tsd)
@@ -196,90 +136,11 @@ u_tsd_destroy(struct u_tsd *tsd)
if (tsd->initMagic != INIT_MAGIC) {
return;
}
- TlsFree(tsd->key);
+ tss_delete(tsd->key);
tsd->initMagic = 0x0;
}
-static INLINE void *
-u_tsd_get(struct u_tsd *tsd)
-{
- if (tsd->initMagic != INIT_MAGIC) {
- u_tsd_init(tsd);
- }
- return TlsGetValue(tsd->key);
-}
-
-
-static INLINE void
-u_tsd_set(struct u_tsd *tsd, void *ptr)
-{
- /* the following code assumes that the struct u_tsd has been initialized
- to zero at creation */
- if (tsd->initMagic != INIT_MAGIC) {
- u_tsd_init(tsd);
- }
- if (TlsSetValue(tsd->key, ptr) == 0) {
- perror(SET_TSD_ERROR);
- exit(-1);
- }
-}
-
-#endif /* _WIN32 */
-
-
-/*
- * THREADS not defined
- */
-#ifndef THREADS
-
-struct u_tsd {
- unsigned initMagic;
-};
-
-typedef unsigned u_mutex;
-
-#define u_mutex_declare_static(name) static u_mutex name = 0
-#define u_mutex_init(name) (void) name
-#define u_mutex_destroy(name) (void) name
-#define u_mutex_lock(name) (void) name
-#define u_mutex_unlock(name) (void) name
-
-/*
- * no-op functions
- */
-
-static INLINE unsigned long
-u_thread_self(void)
-{
- return 0;
-}
-
-
-static INLINE void
-u_tsd_init(struct u_tsd *tsd)
-{
- (void) tsd;
-}
-
-
-static INLINE void *
-u_tsd_get(struct u_tsd *tsd)
-{
- (void) tsd;
- return NULL;
-}
-
-
-static INLINE void
-u_tsd_set(struct u_tsd *tsd, void *ptr)
-{
- (void) tsd;
- (void) ptr;
-}
-#endif /* THREADS */
-
-
#ifdef __cplusplus
}
#endif
diff --git a/mesalib/src/mesa/drivers/common/driverfuncs.c b/mesalib/src/mesa/drivers/common/driverfuncs.c
index e8dcb2476..6d56838cd 100644
--- a/mesalib/src/mesa/drivers/common/driverfuncs.c
+++ b/mesalib/src/mesa/drivers/common/driverfuncs.c
@@ -274,7 +274,7 @@ _mesa_init_driver_state(struct gl_context *ctx)
ctx->Driver.Enable(ctx, GL_LIGHTING, ctx->Light.Enabled);
ctx->Driver.Enable(ctx, GL_LINE_SMOOTH, ctx->Line.SmoothFlag);
ctx->Driver.Enable(ctx, GL_POLYGON_STIPPLE, ctx->Polygon.StippleFlag);
- ctx->Driver.Enable(ctx, GL_SCISSOR_TEST, ctx->Scissor.Enabled);
+ ctx->Driver.Enable(ctx, GL_SCISSOR_TEST, ctx->Scissor.EnableFlags);
ctx->Driver.Enable(ctx, GL_STENCIL_TEST, ctx->Stencil._Enabled);
ctx->Driver.Enable(ctx, GL_TEXTURE_1D, GL_FALSE);
ctx->Driver.Enable(ctx, GL_TEXTURE_2D, GL_FALSE);
diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c
index 129451471..2443a7723 100644
--- a/mesalib/src/mesa/drivers/common/meta.c
+++ b/mesalib/src/mesa/drivers/common/meta.c
@@ -138,9 +138,7 @@ struct save_state
GLboolean FragmentProgramEnabled;
struct gl_fragment_program *FragmentProgram;
GLboolean ATIFragmentShaderEnabled;
- struct gl_shader_program *VertexShader;
- struct gl_shader_program *GeometryShader;
- struct gl_shader_program *FragmentShader;
+ struct gl_shader_program *Shader[MESA_SHADER_STAGES];
struct gl_shader_program *ActiveShader;
/** MESA_META_STENCIL_TEST */
@@ -170,7 +168,7 @@ struct save_state
struct gl_buffer_object *ArrayBufferObj;
/** MESA_META_VIEWPORT */
- GLint ViewportX, ViewportY, ViewportW, ViewportH;
+ GLfloat ViewportX, ViewportY, ViewportW, ViewportH;
GLclampd DepthNear, DepthFar;
/** MESA_META_CLAMP_FRAGMENT_COLOR */
@@ -598,6 +596,8 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
}
if (state & MESA_META_SHADER) {
+ int i;
+
if (ctx->API == API_OPENGL_COMPAT && ctx->Extensions.ARB_vertex_program) {
save->VertexProgramEnabled = ctx->VertexProgram.Enabled;
_mesa_reference_vertprog(ctx, &save->VertexProgram,
@@ -617,12 +617,10 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
_mesa_set_enable(ctx, GL_FRAGMENT_SHADER_ATI, GL_FALSE);
}
- _mesa_reference_shader_program(ctx, &save->VertexShader,
- ctx->Shader.CurrentVertexProgram);
- _mesa_reference_shader_program(ctx, &save->GeometryShader,
- ctx->Shader.CurrentGeometryProgram);
- _mesa_reference_shader_program(ctx, &save->FragmentShader,
- ctx->Shader.CurrentFragmentProgram);
+ for (i = 0; i < MESA_SHADER_STAGES; i++) {
+ _mesa_reference_shader_program(ctx, &save->Shader[i],
+ ctx->Shader.CurrentProgram[i]);
+ }
_mesa_reference_shader_program(ctx, &save->ActiveShader,
ctx->Shader.ActiveProgram);
@@ -737,21 +735,21 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
if (state & MESA_META_VIEWPORT) {
/* save viewport state */
- save->ViewportX = ctx->Viewport.X;
- save->ViewportY = ctx->Viewport.Y;
- save->ViewportW = ctx->Viewport.Width;
- save->ViewportH = ctx->Viewport.Height;
+ save->ViewportX = ctx->ViewportArray[0].X;
+ save->ViewportY = ctx->ViewportArray[0].Y;
+ save->ViewportW = ctx->ViewportArray[0].Width;
+ save->ViewportH = ctx->ViewportArray[0].Height;
/* set viewport to match window size */
- if (ctx->Viewport.X != 0 ||
- ctx->Viewport.Y != 0 ||
- ctx->Viewport.Width != ctx->DrawBuffer->Width ||
- ctx->Viewport.Height != ctx->DrawBuffer->Height) {
- _mesa_set_viewport(ctx, 0, 0,
+ if (ctx->ViewportArray[0].X != 0 ||
+ ctx->ViewportArray[0].Y != 0 ||
+ ctx->ViewportArray[0].Width != (float) ctx->DrawBuffer->Width ||
+ ctx->ViewportArray[0].Height != (float) ctx->DrawBuffer->Height) {
+ _mesa_set_viewport(ctx, 0, 0, 0,
ctx->DrawBuffer->Width, ctx->DrawBuffer->Height);
}
/* save depth range state */
- save->DepthNear = ctx->Viewport.Near;
- save->DepthFar = ctx->Viewport.Far;
+ save->DepthNear = ctx->ViewportArray[0].Near;
+ save->DepthFar = ctx->ViewportArray[0].Far;
/* set depth range to default */
_mesa_DepthRange(0.0, 1.0);
}
@@ -829,6 +827,7 @@ _mesa_meta_end(struct gl_context *ctx)
{
struct save_state *save = &ctx->Meta->Save[ctx->Meta->SaveStackDepth - 1];
const GLbitfield state = save->SavedState;
+ int i;
/* After starting a new occlusion query, initialize the results to the
* values saved previously. The driver will then continue to increment
@@ -933,9 +932,17 @@ _mesa_meta_end(struct gl_context *ctx)
}
if (state & MESA_META_SCISSOR) {
- _mesa_set_enable(ctx, GL_SCISSOR_TEST, save->Scissor.Enabled);
- _mesa_Scissor(save->Scissor.X, save->Scissor.Y,
- save->Scissor.Width, save->Scissor.Height);
+ unsigned i;
+
+ for (i = 0; i < ctx->Const.MaxViewports; i++) {
+ _mesa_set_scissor(ctx, i,
+ save->Scissor.ScissorArray[i].X,
+ save->Scissor.ScissorArray[i].Y,
+ save->Scissor.ScissorArray[i].Width,
+ save->Scissor.ScissorArray[i].Height);
+ _mesa_set_enablei(ctx, GL_SCISSOR_TEST, i,
+ (save->Scissor.EnableFlags >> i) & 1);
+ }
}
if (state & MESA_META_SHADER) {
@@ -960,23 +967,24 @@ _mesa_meta_end(struct gl_context *ctx)
save->ATIFragmentShaderEnabled);
}
- if (ctx->Extensions.ARB_vertex_shader)
- _mesa_use_shader_program(ctx, GL_VERTEX_SHADER, save->VertexShader);
+ if (ctx->Extensions.ARB_vertex_shader) {
+ _mesa_use_shader_program(ctx, GL_VERTEX_SHADER,
+ save->Shader[MESA_SHADER_VERTEX]);
+ }
if (_mesa_has_geometry_shaders(ctx))
_mesa_use_shader_program(ctx, GL_GEOMETRY_SHADER_ARB,
- save->GeometryShader);
+ save->Shader[MESA_SHADER_GEOMETRY]);
if (ctx->Extensions.ARB_fragment_shader)
_mesa_use_shader_program(ctx, GL_FRAGMENT_SHADER,
- save->FragmentShader);
+ save->Shader[MESA_SHADER_FRAGMENT]);
_mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram,
save->ActiveShader);
- _mesa_reference_shader_program(ctx, &save->VertexShader, NULL);
- _mesa_reference_shader_program(ctx, &save->GeometryShader, NULL);
- _mesa_reference_shader_program(ctx, &save->FragmentShader, NULL);
+ for (i = 0; i < MESA_SHADER_STAGES; i++)
+ _mesa_reference_shader_program(ctx, &save->Shader[i], NULL);
_mesa_reference_shader_program(ctx, &save->ActiveShader, NULL);
}
@@ -1089,11 +1097,11 @@ _mesa_meta_end(struct gl_context *ctx)
}
if (state & MESA_META_VIEWPORT) {
- if (save->ViewportX != ctx->Viewport.X ||
- save->ViewportY != ctx->Viewport.Y ||
- save->ViewportW != ctx->Viewport.Width ||
- save->ViewportH != ctx->Viewport.Height) {
- _mesa_set_viewport(ctx, save->ViewportX, save->ViewportY,
+ if (save->ViewportX != ctx->ViewportArray[0].X ||
+ save->ViewportY != ctx->ViewportArray[0].Y ||
+ save->ViewportW != ctx->ViewportArray[0].Width ||
+ save->ViewportH != ctx->ViewportArray[0].Height) {
+ _mesa_set_viewport(ctx, 0, save->ViewportX, save->ViewportY,
save->ViewportW, save->ViewportH);
}
_mesa_DepthRange(save->DepthNear, save->DepthFar);
@@ -1761,7 +1769,7 @@ blitframebuffer_texture(struct gl_context *ctx,
}
/* setup viewport */
- _mesa_set_viewport(ctx, dstX, dstY, dstW, dstH);
+ _mesa_set_viewport(ctx, 0, dstX, dstY, dstW, dstH);
_mesa_ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
_mesa_DepthMask(GL_FALSE);
_mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
@@ -1916,7 +1924,7 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx,
_mesa_BufferSubData(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts);
}
- _mesa_set_viewport(ctx, dstX, dstY, dstW, dstH);
+ _mesa_set_viewport(ctx, 0, dstX, dstY, dstW, dstH);
_mesa_ColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
_mesa_set_enable(ctx, GL_DEPTH_TEST, GL_FALSE);
_mesa_DepthMask(GL_FALSE);
@@ -1965,7 +1973,7 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx,
_mesa_DepthFunc(GL_ALWAYS);
_mesa_DepthMask(GL_TRUE);
- _mesa_set_viewport(ctx, dstX, dstY, dstW, dstH);
+ _mesa_set_viewport(ctx, 0, dstX, dstY, dstW, dstH);
_mesa_BufferSubData(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts);
_mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
mask &= ~GL_DEPTH_BUFFER_BIT;
@@ -3782,7 +3790,7 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target,
assert(dstHeight == ctx->DrawBuffer->Height);
/* setup viewport */
- _mesa_set_viewport(ctx, 0, 0, dstWidth, dstHeight);
+ _mesa_set_viewport(ctx, 0, 0, 0, dstWidth, dstHeight);
_mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
@@ -4072,7 +4080,7 @@ decompress_texture_image(struct gl_context *ctx,
_mesa_MatrixMode(GL_PROJECTION);
_mesa_LoadIdentity();
_mesa_Ortho(0.0, width, 0.0, height, -1.0, 1.0);
- _mesa_set_viewport(ctx, 0, 0, width, height);
+ _mesa_set_viewport(ctx, 0, 0, 0, width, height);
/* upload new vertex data */
_mesa_BufferSubData(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts);
diff --git a/mesalib/src/mesa/drivers/dri/common/xmlpool/.gitignore b/mesalib/src/mesa/drivers/dri/common/xmlpool/.gitignore
index 0e0bf178e..383df727a 100644
--- a/mesalib/src/mesa/drivers/dri/common/xmlpool/.gitignore
+++ b/mesalib/src/mesa/drivers/dri/common/xmlpool/.gitignore
@@ -1,3 +1,4 @@
+ca
de
es
fr
diff --git a/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am b/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am
index ad7887d06..0908c8264 100644
--- a/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am
+++ b/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am
@@ -41,7 +41,7 @@
# - info gettext
# The set of supported languages. Add languages as needed.
-POS=de.po es.po nl.po fr.po sv.po
+POS=ca.po de.po es.po nl.po fr.po sv.po
#
# Don't change anything below, unless you know what you're doing.
diff --git a/mesalib/src/mesa/drivers/dri/common/xmlpool/ca.po b/mesalib/src/mesa/drivers/dri/common/xmlpool/ca.po
new file mode 100644
index 000000000..c0cf7f62c
--- /dev/null
+++ b/mesalib/src/mesa/drivers/dri/common/xmlpool/ca.po
@@ -0,0 +1,321 @@
+# Language translations for Mesa package
+# Traduccions al català del paquet «Mesa».
+#
+# Copyright © 2014 Alex Henrie <alexhenrie24@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.
+
+msgid ""
+msgstr ""
+"Project-Id-Version: Mesa 10.1.0-devel\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-01-13 22:30-0700\n"
+"PO-Revision-Date: 2014-01-15 10:37-0700\n"
+"Last-Translator: Alex Henrie <alexhenrie24@gmail.com>\n"
+"Language-Team: Catalan <ca@li.org>\n"
+"Language: ca\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: Poedit 1.5.4\n"
+
+#: t_options.h:56
+msgid "Debugging"
+msgstr "Depuració"
+
+#: t_options.h:60
+msgid "Disable 3D acceleration"
+msgstr "Deshabilita l'acceleració 3D"
+
+#: t_options.h:65
+msgid "Show performance boxes"
+msgstr "Mostra les caixes de rendiment"
+
+#: t_options.h:70
+msgid "Enable flushing batchbuffer after each draw call"
+msgstr "Habilita el buidatge del batchbuffer després de cada trucada de dibuix"
+
+#: t_options.h:75
+msgid "Enable flushing GPU caches with each draw call"
+msgstr ""
+"Habilita el buidatge de les memòries cau de GPU amb cada trucada de dibuix"
+
+#: t_options.h:80
+msgid "Disable throttling on first batch after flush"
+msgstr "Deshabilita la regulació en el primer lot després de buidar"
+
+#: t_options.h:85
+msgid "Force GLSL extension default behavior to 'warn'"
+msgstr ""
+"Força que el comportament per defecte de les extensions GLSL sigui 'warn'"
+
+#: t_options.h:90
+msgid "Disable dual source blending"
+msgstr "Deshabilita la barreja de font dual"
+
+#: t_options.h:95
+msgid "Disable backslash-based line continuations in GLSL source"
+msgstr ""
+"Deshabilitar les continuacions de línia basades en barra invertida en la "
+"font GLSL"
+
+#: t_options.h:100
+msgid "Disable GL_ARB_shader_bit_encoding"
+msgstr "Deshabilita el GL_ARB_shader_bit_encoding"
+
+#: t_options.h:105
+msgid ""
+"Force a default GLSL version for shaders that lack an explicit #version line"
+msgstr ""
+"Força una versió GLSL per defecte en els shaders als quals falta una línia "
+"#version explícita"
+
+#: t_options.h:115
+msgid "Image Quality"
+msgstr "Qualitat d'Imatge"
+
+#: t_options.h:128
+msgid "Texture color depth"
+msgstr "Profunditat de color de textura"
+
+#: t_options.h:129
+msgid "Prefer frame buffer color depth"
+msgstr "Prefereix profunditat de color del framebuffer"
+
+#: t_options.h:130
+msgid "Prefer 32 bits per texel"
+msgstr "Prefereix 32 bits per texel"
+
+#: t_options.h:131
+msgid "Prefer 16 bits per texel"
+msgstr "Prefereix 16 bits per texel"
+
+#: t_options.h:132
+msgid "Force 16 bits per texel"
+msgstr "Força 16 bits per texel"
+
+#: t_options.h:138
+msgid "Initial maximum value for anisotropic texture filtering"
+msgstr "Valor màxim inicial per a la filtració de textura anisòtropa"
+
+#: t_options.h:143
+msgid "Forbid negative texture LOD bias"
+msgstr ""
+"Prohibeix una parcialitat negativa del Nivell de Detalle (LOD) de les "
+"textures"
+
+#: t_options.h:148
+msgid ""
+"Enable S3TC texture compression even if software support is not available"
+msgstr ""
+"Habilitar la compressió de textures S3TC encara que el suport de programari "
+"no estigui disponible"
+
+#: t_options.h:155
+msgid "Initial color reduction method"
+msgstr "Mètode inicial de reducció de color"
+
+#: t_options.h:156
+msgid "Round colors"
+msgstr "Colors arrodonits"
+
+#: t_options.h:157
+msgid "Dither colors"
+msgstr "Colors tramats"
+
+#: t_options.h:165
+msgid "Color rounding method"
+msgstr "Mètode d'arrodoniment de color"
+
+#: t_options.h:166
+msgid "Round color components downward"
+msgstr "Arrondeix els components de color a baix"
+
+#: t_options.h:167
+msgid "Round to nearest color"
+msgstr "Arrondeix al color més proper"
+
+#: t_options.h:176
+msgid "Color dithering method"
+msgstr "Mètode de tramat de color"
+
+#: t_options.h:177
+msgid "Horizontal error diffusion"
+msgstr "Difusió d'error horitzontal"
+
+#: t_options.h:178
+msgid "Horizontal error diffusion, reset error at line start"
+msgstr "Difusió d'error horitzontal, reinicia l'error a l'inici de la línia"
+
+#: t_options.h:179
+msgid "Ordered 2D color dithering"
+msgstr "Tramat de color 2D ordenat"
+
+#: t_options.h:185
+msgid "Floating point depth buffer"
+msgstr "Buffer de profunditat de punt flotant"
+
+#: t_options.h:190
+msgid "A post-processing filter to cel-shade the output"
+msgstr "Un filtre de postprocessament per a aplicar cel shading a la sortida"
+
+#: t_options.h:195
+msgid "A post-processing filter to remove the red channel"
+msgstr "Un filtre de postprocessament per a treure el canal vermell"
+
+#: t_options.h:200
+msgid "A post-processing filter to remove the green channel"
+msgstr "Un filtre de postprocessament per a treure el canal verd"
+
+#: t_options.h:205
+msgid "A post-processing filter to remove the blue channel"
+msgstr "Un filtre de postprocessament per a treure el canal blau"
+
+#: t_options.h:210
+msgid ""
+"Morphological anti-aliasing based on Jimenez\\' MLAA. 0 to disable, 8 for "
+"default quality"
+msgstr ""
+"Antialiàsing morfològic basat en el MLAA de Jimenez. 0 per deshabilitar, 8 "
+"per qualitat per defecte"
+
+#: t_options.h:215
+msgid ""
+"Morphological anti-aliasing based on Jimenez\\' MLAA. 0 to disable, 8 for "
+"default quality. Color version, usable with 2d GL apps"
+msgstr ""
+"Antialiàsing morfològic basat en el MLAA de Jimenez. 0 per deshabilitar, 8 "
+"per qualitat per defecte. Versió en color, utilitzable amb les aplicacions "
+"GL 2D"
+
+#: t_options.h:225
+msgid "Performance"
+msgstr "Rendiment"
+
+#: t_options.h:233
+msgid "TCL mode (Transformation, Clipping, Lighting)"
+msgstr "Mode TCL (Transformació, Retall, Il·luminació)"
+
+#: t_options.h:234
+msgid "Use software TCL pipeline"
+msgstr "Utilitza la canonada TCL de programari"
+
+#: t_options.h:235
+msgid "Use hardware TCL as first TCL pipeline stage"
+msgstr "Utilitza el TCL maquinàri com la primera fase de la canonada TCL"
+
+#: t_options.h:236
+msgid "Bypass the TCL pipeline"
+msgstr "Passar per alt la canonada TCL"
+
+#: t_options.h:237
+msgid ""
+"Bypass the TCL pipeline with state-based machine code generated on-the-fly"
+msgstr ""
+"Passar per alt la canonada TCL amb codi màquina basat en estats, generat "
+"sobre la marxa"
+
+#: t_options.h:246
+msgid "Method to limit rendering latency"
+msgstr "Mètode per a limitar la latència de renderització"
+
+#: t_options.h:247
+msgid "Busy waiting for the graphics hardware"
+msgstr "Espera activa pel maquinari de gràfics"
+
+#: t_options.h:248
+msgid "Sleep for brief intervals while waiting for the graphics hardware"
+msgstr "Dormi per intervals breus mentre s'espera al maquinari de gràfics"
+
+#: t_options.h:249
+msgid "Let the graphics hardware emit a software interrupt and sleep"
+msgstr ""
+"Deixa que el maquinari de gràfics emeti una interrupció de programari i dormi"
+
+#: t_options.h:259
+msgid "Synchronization with vertical refresh (swap intervals)"
+msgstr "Sincronització amb refresc vertical (intervals d'intercanvi)"
+
+#: t_options.h:260
+msgid "Never synchronize with vertical refresh, ignore application's choice"
+msgstr ""
+"Mai sincronitzis amb el refresc vertial, ignora l'elecció de l'aplicació"
+
+#: t_options.h:261
+msgid "Initial swap interval 0, obey application's choice"
+msgstr "Interval d'intercanvi inicial 0, obeeix l'elecció de l'aplicació"
+
+#: t_options.h:262
+msgid "Initial swap interval 1, obey application's choice"
+msgstr "Interval d'intercanvi inicial 1, obeeix l'elecció de l'aplicació"
+
+#: t_options.h:263
+msgid ""
+"Always synchronize with vertical refresh, application chooses the minimum "
+"swap interval"
+msgstr ""
+"Sempre sincronitza amb el refresc vertical, l'aplicació tria l'interval "
+"mínim d'intercanvi"
+
+#: t_options.h:271
+msgid "Use HyperZ to boost performance"
+msgstr "Utilitza el HyperZ per a augmentar el rendiment"
+
+#: t_options.h:276
+msgid "Number of texture units used"
+msgstr "Nombre d'unitats de textura utilitzades"
+
+#: t_options.h:281
+msgid "Texture filtering quality vs. speed, AKA “brilinear” texture filtering"
+msgstr ""
+"Qualitat vs. velocitat de filtració de textura, àlies filtració \"brilinear"
+"\" de textura"
+
+#: t_options.h:289
+msgid "Used types of texture memory"
+msgstr "Tipus utilitzats de memòria de textura"
+
+#: t_options.h:290
+msgid "All available memory"
+msgstr "Tota la memòria disponible"
+
+#: t_options.h:291
+msgid "Only card memory (if available)"
+msgstr "Només memòria de tarjeta (si està disponible)"
+
+#: t_options.h:292
+msgid "Only GART (AGP/PCIE) memory (if available)"
+msgstr "Només memòria GART (AGP/PCIE) (si està disponible)"
+
+#: t_options.h:304
+msgid "Features that are not hardware-accelerated"
+msgstr "Característiques no accelerades per maquinari"
+
+#: t_options.h:308
+msgid "Enable extension GL_ARB_vertex_program"
+msgstr "Habilita l'extensió GL_ARB_vertex_program"
+
+#: t_options.h:318
+msgid "Miscellaneous"
+msgstr "Miscel·lània"
+
+#: t_options.h:322
+msgid "Create all visuals with a depth buffer"
+msgstr "Crea tots els visuals amb buffer de profunditat"
diff --git a/mesalib/src/mesa/drivers/dri/common/xmlpool/de.po b/mesalib/src/mesa/drivers/dri/common/xmlpool/de.po
index a87c8d513..fff7e8bef 100644
--- a/mesalib/src/mesa/drivers/dri/common/xmlpool/de.po
+++ b/mesalib/src/mesa/drivers/dri/common/xmlpool/de.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Mesa 6.3\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-08-30 11:40+0200\n"
+"POT-Creation-Date: 2014-01-13 22:30-0700\n"
"PO-Revision-Date: 2005-04-11 01:34+0200\n"
"Last-Translator: Felix Kuehling <fxkuehl@gmx.de>\n"
"Language-Team: German <de@li.org>\n"
@@ -17,164 +17,230 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-#: t_options.h:53
+#: t_options.h:56
msgid "Debugging"
msgstr "Fehlersuche"
-#: t_options.h:57
+#: t_options.h:60
msgid "Disable 3D acceleration"
msgstr "3D-Beschleunigung abschalten"
-#: t_options.h:62
+#: t_options.h:65
msgid "Show performance boxes"
msgstr "Zeige Performanceboxen"
-#: t_options.h:69
+#: t_options.h:70
+msgid "Enable flushing batchbuffer after each draw call"
+msgstr "Aktiviere sofortige Leerung des Stapelpuffers nach jedem Zeichenaufruf"
+
+#: t_options.h:75
+msgid "Enable flushing GPU caches with each draw call"
+msgstr ""
+"Aktiviere sofortige Leerung der GPU-Zwischenspeicher mit jedem Zeichenaufruf"
+
+#: t_options.h:80
+msgid "Disable throttling on first batch after flush"
+msgstr ""
+
+#: t_options.h:85
+msgid "Force GLSL extension default behavior to 'warn'"
+msgstr ""
+
+#: t_options.h:90
+msgid "Disable dual source blending"
+msgstr ""
+
+#: t_options.h:95
+msgid "Disable backslash-based line continuations in GLSL source"
+msgstr ""
+
+#: t_options.h:100
+msgid "Disable GL_ARB_shader_bit_encoding"
+msgstr ""
+
+#: t_options.h:105
+msgid ""
+"Force a default GLSL version for shaders that lack an explicit #version line"
+msgstr ""
+
+#: t_options.h:115
msgid "Image Quality"
msgstr "Bildqualität"
-#: t_options.h:82
+#: t_options.h:128
msgid "Texture color depth"
msgstr "Texturfarbtiefe"
-#: t_options.h:83
+#: t_options.h:129
msgid "Prefer frame buffer color depth"
msgstr "Bevorzuge Farbtiefe des Framebuffers"
-#: t_options.h:84
+#: t_options.h:130
msgid "Prefer 32 bits per texel"
msgstr "Bevorzuge 32 bits pro Texel"
-#: t_options.h:85
+#: t_options.h:131
msgid "Prefer 16 bits per texel"
msgstr "Bevorzuge 16 bits pro Texel"
-#: t_options.h:86
+#: t_options.h:132
msgid "Force 16 bits per texel"
msgstr "Erzwinge 16 bits pro Texel"
-#: t_options.h:92
+#: t_options.h:138
msgid "Initial maximum value for anisotropic texture filtering"
msgstr "Initialer Maximalwert für anisotropische Texturfilterung"
-#: t_options.h:97
+#: t_options.h:143
msgid "Forbid negative texture LOD bias"
msgstr "Verbiete negative Textur-Detailgradverschiebung"
-#: t_options.h:102
+#: t_options.h:148
msgid ""
"Enable S3TC texture compression even if software support is not available"
msgstr ""
"Aktiviere S3TC Texturkomprimierung auch wenn die nötige "
"Softwareunterstützung fehlt"
-#: t_options.h:109
+#: t_options.h:155
msgid "Initial color reduction method"
msgstr "Initiale Farbreduktionsmethode"
-#: t_options.h:110
+#: t_options.h:156
msgid "Round colors"
msgstr "Farben runden"
-#: t_options.h:111
+#: t_options.h:157
msgid "Dither colors"
msgstr "Farben rastern"
-#: t_options.h:119
+#: t_options.h:165
msgid "Color rounding method"
msgstr "Farbrundungsmethode"
-#: t_options.h:120
+#: t_options.h:166
msgid "Round color components downward"
msgstr "Farbkomponenten abrunden"
-#: t_options.h:121
+#: t_options.h:167
msgid "Round to nearest color"
msgstr "Zur ähnlichsten Farbe runden"
-#: t_options.h:130
+#: t_options.h:176
msgid "Color dithering method"
msgstr "Farbrasterungsmethode"
-#: t_options.h:131
+#: t_options.h:177
msgid "Horizontal error diffusion"
msgstr "Horizontale Fehlerstreuung"
-#: t_options.h:132
+#: t_options.h:178
msgid "Horizontal error diffusion, reset error at line start"
msgstr "Horizontale Fehlerstreuung, Fehler am Zeilenanfang zurücksetzen"
-#: t_options.h:133
+#: t_options.h:179
msgid "Ordered 2D color dithering"
msgstr "Geordnete 2D Farbrasterung"
-#: t_options.h:139
+#: t_options.h:185
msgid "Floating point depth buffer"
msgstr "Fließkomma z-Puffer"
-#: t_options.h:145
+#: t_options.h:190
+msgid "A post-processing filter to cel-shade the output"
+msgstr "Nachbearbeitungsfilter für Cell Shading"
+
+#: t_options.h:195
+msgid "A post-processing filter to remove the red channel"
+msgstr "Nachbearbeitungsfilter zum Entfernen des Rotkanals"
+
+#: t_options.h:200
+msgid "A post-processing filter to remove the green channel"
+msgstr "Nachbearbeitungsfilter zum Entfernen des Grünkanals"
+
+#: t_options.h:205
+msgid "A post-processing filter to remove the blue channel"
+msgstr "Nachbearbeitungsfilter zum Entfernen des Blaukanals"
+
+#: t_options.h:210
+msgid ""
+"Morphological anti-aliasing based on Jimenez\\' MLAA. 0 to disable, 8 for "
+"default quality"
+msgstr ""
+"Morphologische Kantenglättung (Anti-Aliasing) basierend auf Jimenez' MLAA. 0 "
+"für deaktiviert, 8 für Standardqualität"
+
+#: t_options.h:215
+msgid ""
+"Morphological anti-aliasing based on Jimenez\\' MLAA. 0 to disable, 8 for "
+"default quality. Color version, usable with 2d GL apps"
+msgstr ""
+"Morphologische Kantenglättung (Anti-Aliasing) basierend auf Jimenez' MLAA. 0 "
+"für deaktiviert, 8 für Standardqualität. Farbversion, für 2D-Anwendungen"
+
+#: t_options.h:225
msgid "Performance"
msgstr "Leistung"
-#: t_options.h:153
+#: t_options.h:233
msgid "TCL mode (Transformation, Clipping, Lighting)"
msgstr "TCL-Modus (Transformation, Clipping, Licht)"
-#: t_options.h:154
+#: t_options.h:234
msgid "Use software TCL pipeline"
msgstr "Benutze die Software-TCL-Pipeline"
-#: t_options.h:155
+#: t_options.h:235
msgid "Use hardware TCL as first TCL pipeline stage"
msgstr "Benutze Hardware TCL als erste Stufe der TCL-Pipeline"
-#: t_options.h:156
+#: t_options.h:236
msgid "Bypass the TCL pipeline"
msgstr "Umgehe die TCL-Pipeline"
-#: t_options.h:157
+#: t_options.h:237
msgid ""
"Bypass the TCL pipeline with state-based machine code generated on-the-fly"
msgstr ""
"Umgehe die TCL-Pipeline mit zur Laufzeit erzeugtem, zustandsbasiertem "
"Maschinencode"
-#: t_options.h:166
+#: t_options.h:246
msgid "Method to limit rendering latency"
msgstr "Methode zur Begrenzung der Bildverzögerung"
-#: t_options.h:167
+#: t_options.h:247
msgid "Busy waiting for the graphics hardware"
msgstr "Aktives Warten auf die Grafikhardware"
-#: t_options.h:168
+#: t_options.h:248
msgid "Sleep for brief intervals while waiting for the graphics hardware"
msgstr "Kurze Schlafintervalle beim Warten auf die Grafikhardware"
-#: t_options.h:169
+#: t_options.h:249
msgid "Let the graphics hardware emit a software interrupt and sleep"
msgstr ""
"Die Grafikhardware eine Softwareunterbrechnung erzeugen lassen und schlafen"
-#: t_options.h:179
+#: t_options.h:259
msgid "Synchronization with vertical refresh (swap intervals)"
msgstr "Synchronisation mit der vertikalen Bildwiederholung"
-#: t_options.h:180
+#: t_options.h:260
msgid "Never synchronize with vertical refresh, ignore application's choice"
msgstr ""
"Niemals mit der Bildwiederholung synchronisieren, Anweisungen der Anwendung "
"ignorieren"
-#: t_options.h:181
+#: t_options.h:261
msgid "Initial swap interval 0, obey application's choice"
msgstr "Initiales Bildinterval 0, Anweisungen der Anwendung gehorchen"
-#: t_options.h:182
+#: t_options.h:262
msgid "Initial swap interval 1, obey application's choice"
msgstr "Initiales Bildinterval 1, Anweisungen der Anwendung gehorchen"
-#: t_options.h:183
+#: t_options.h:263
msgid ""
"Always synchronize with vertical refresh, application chooses the minimum "
"swap interval"
@@ -182,96 +248,61 @@ msgstr ""
"Immer mit der Bildwiederholung synchronisieren, Anwendung wählt das minimale "
"Bildintervall"
-#: t_options.h:191
+#: t_options.h:271
msgid "Use HyperZ to boost performance"
msgstr "HyperZ zur Leistungssteigerung verwenden"
-#: t_options.h:196
-msgid "A post-processing filter to cel-shade the output"
-msgstr "Nachbearbeitungsfilter für Cell Shading"
-
-#: t_options.h:201
-msgid "A post-processing filter to remove the red channel"
-msgstr "Nachbearbeitungsfilter zum Entfernen des Rotkanals"
-
-#: t_options.h:206
-msgid "A post-processing filter to remove the green channel"
-msgstr "Nachbearbeitungsfilter zum Entfernen des Grünkanals"
-
-#: t_options.h:211
-msgid "A post-processing filter to remove the blue channel"
-msgstr "Nachbearbeitungsfilter zum Entfernen des Blaukanals"
-
-#: t_options.h:216
-msgid ""
-"Morphological anti-aliasing based on Jimenez\\' MLAA. 0 to disable, 8 for "
-"default quality"
-msgstr "Morphologische Kantenglättung (Anti-Aliasing) basierend auf "
-"Jimenez' MLAA. 0 für deaktiviert, 8 für Standardqualität"
-
-#: t_options.h:221
-msgid ""
-"Morphological anti-aliasing based on Jimenez\\' MLAA. 0 to disable, 8 for "
-"default quality. Color version, usable with 2d GL apps"
-msgstr "Morphologische Kantenglättung (Anti-Aliasing) basierend auf "
-"Jimenez' MLAA. 0 für deaktiviert, 8 für Standardqualität. "
-"Farbversion, für 2D-Anwendungen"
-
-#: t_options.h:226
+#: t_options.h:276
msgid "Number of texture units used"
msgstr "Anzahl der benutzten Textureinheiten"
-#: t_options.h:231
-msgid "Support larger textures not guaranteed to fit into graphics memory"
-msgstr ""
-"Unterstütze grosse Texturen die evtl. nicht in den Grafikspeicher passen"
-
-#: t_options.h:232
-msgid "No"
-msgstr "Nein"
-
-#: t_options.h:233
-msgid "At least 1 texture must fit under worst-case assumptions"
-msgstr "Mindestens 1 Textur muss auch im schlechtesten Fall Platz haben"
-
-#: t_options.h:234
-msgid "Announce hardware limits"
-msgstr "Benutze Hardware-Limits"
-
-#: t_options.h:240
+#: t_options.h:281
msgid "Texture filtering quality vs. speed, AKA “brilinear” texture filtering"
msgstr ""
"Texturfilterqualität versus -geschwindigkeit, auch bekannt als „brilineare“ "
"Texturfilterung"
-#: t_options.h:248
+#: t_options.h:289
msgid "Used types of texture memory"
msgstr "Benutzte Arten von Texturspeicher"
-#: t_options.h:249
+#: t_options.h:290
msgid "All available memory"
msgstr "Aller verfügbarer Speicher"
-#: t_options.h:250
+#: t_options.h:291
msgid "Only card memory (if available)"
msgstr "Nur Grafikspeicher (falls verfügbar)"
-#: t_options.h:251
+#: t_options.h:292
msgid "Only GART (AGP/PCIE) memory (if available)"
msgstr "Nur GART-Speicher (AGP/PCIE) (falls verfügbar)"
-#: t_options.h:259
+#: t_options.h:304
msgid "Features that are not hardware-accelerated"
msgstr "Funktionalität, die nicht hardwarebeschleunigt ist"
-#: t_options.h:263
+#: t_options.h:308
msgid "Enable extension GL_ARB_vertex_program"
msgstr "Erweiterung GL_ARB_vertex_program aktivieren"
-#: t_options.h:273
-msgid "Enable flushing batchbuffer after each draw call"
-msgstr "Aktiviere sofortige Leerung des Stapelpuffers nach jedem Zeichenaufruf"
+#: t_options.h:318
+msgid "Miscellaneous"
+msgstr ""
-#: t_options.h:278
-msgid "Enable flushing GPU caches with each draw call"
-msgstr "Aktiviere sofortige Leerung der GPU-Zwischenspeicher mit jedem Zeichenaufruf"
+#: t_options.h:322
+msgid "Create all visuals with a depth buffer"
+msgstr ""
+
+#~ msgid "Support larger textures not guaranteed to fit into graphics memory"
+#~ msgstr ""
+#~ "Unterstütze grosse Texturen die evtl. nicht in den Grafikspeicher passen"
+
+#~ msgid "No"
+#~ msgstr "Nein"
+
+#~ msgid "At least 1 texture must fit under worst-case assumptions"
+#~ msgstr "Mindestens 1 Textur muss auch im schlechtesten Fall Platz haben"
+
+#~ msgid "Announce hardware limits"
+#~ msgstr "Benutze Hardware-Limits"
diff --git a/mesalib/src/mesa/drivers/dri/common/xmlpool/es.po b/mesalib/src/mesa/drivers/dri/common/xmlpool/es.po
index 8bccd8631..4a6ab91a5 100644
--- a/mesalib/src/mesa/drivers/dri/common/xmlpool/es.po
+++ b/mesalib/src/mesa/drivers/dri/common/xmlpool/es.po
@@ -9,206 +9,296 @@ msgid ""
msgstr ""
"Project-Id-Version: es\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2005-04-12 12:18+0200\n"
-"PO-Revision-Date: 2005-04-12 20:26+0200\n"
-"Last-Translator: David Rubio Miguélez <deifo@ono.com>\n"
+"POT-Creation-Date: 2014-01-13 22:30-0700\n"
+"PO-Revision-Date: 2014-01-15 10:34-0700\n"
+"Last-Translator: Alex Henrie <alexhenrie24@gmail.com>\n"
"Language-Team: Spanish <es@li.org>\n"
+"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-"X-Generator: KBabel 1.10\n"
+"X-Generator: Poedit 1.5.4\n"
-#: t_options.h:53
+#: t_options.h:56
msgid "Debugging"
-msgstr "Depurando"
+msgstr "Depuración"
-#: t_options.h:57
+#: t_options.h:60
msgid "Disable 3D acceleration"
-msgstr "Desactivar aceleración 3D"
+msgstr "Deshabilitar aceleración 3D"
-#: t_options.h:62
+#: t_options.h:65
msgid "Show performance boxes"
msgstr "Mostrar cajas de rendimiento"
-#: t_options.h:69
+#: t_options.h:70
+msgid "Enable flushing batchbuffer after each draw call"
+msgstr "Habilitar vaciado del batchbuffer después de cada llamada de dibujo"
+
+#: t_options.h:75
+msgid "Enable flushing GPU caches with each draw call"
+msgstr "Habilitar vaciado de los cachés GPU con cada llamada de dibujo"
+
+#: t_options.h:80
+msgid "Disable throttling on first batch after flush"
+msgstr "Deshabilitar regulación del primer lote después de vaciar"
+
+#: t_options.h:85
+msgid "Force GLSL extension default behavior to 'warn'"
+msgstr ""
+"Forzar que el comportamiento por defecto de las extensiones GLSL sea 'warn'"
+
+#: t_options.h:90
+msgid "Disable dual source blending"
+msgstr "Deshabilitar mezcla de fuente dual"
+
+#: t_options.h:95
+msgid "Disable backslash-based line continuations in GLSL source"
+msgstr ""
+"Deshabilitar continuaciones de línea basadas en barra inversa en el código "
+"GLSL"
+
+#: t_options.h:100
+msgid "Disable GL_ARB_shader_bit_encoding"
+msgstr "Deshabilitar GL_ARB_shader_bit_encoding"
+
+#: t_options.h:105
+msgid ""
+"Force a default GLSL version for shaders that lack an explicit #version line"
+msgstr ""
+"Forzar una versión de GLSL por defecto en los shaders a los cuales les falta "
+"una línea #version explícita"
+
+#: t_options.h:115
msgid "Image Quality"
msgstr "Calidad de imagen"
-#: t_options.h:77
+#: t_options.h:128
msgid "Texture color depth"
msgstr "Profundidad de color de textura"
-#: t_options.h:78
+#: t_options.h:129
msgid "Prefer frame buffer color depth"
-msgstr "Preferir profundidad de color del \"framebuffer\""
+msgstr "Preferir profundidad de color del framebuffer"
-#: t_options.h:79
+#: t_options.h:130
msgid "Prefer 32 bits per texel"
msgstr "Preferir 32 bits por texel"
-#: t_options.h:80
+#: t_options.h:131
msgid "Prefer 16 bits per texel"
msgstr "Preferir 16 bits por texel"
-#: t_options.h:81
+#: t_options.h:132
msgid "Force 16 bits per texel"
msgstr "Forzar a 16 bits por texel"
-#: t_options.h:87
+#: t_options.h:138
msgid "Initial maximum value for anisotropic texture filtering"
msgstr "Valor máximo inicial para filtrado anisotrópico de textura"
-#: t_options.h:92
+#: t_options.h:143
msgid "Forbid negative texture LOD bias"
msgstr "Prohibir valores negativos de Nivel De Detalle (LOD) de texturas"
-#: t_options.h:97
-msgid "Enable S3TC texture compression even if software support is not available"
-msgstr "Activar la compresión de texturas S3TC incluso si el soporte por software no está disponible"
+#: t_options.h:148
+msgid ""
+"Enable S3TC texture compression even if software support is not available"
+msgstr ""
+"Habilitar la compresión de texturas S3TC incluso si el soporte por software "
+"no está disponible"
-#: t_options.h:104
+#: t_options.h:155
msgid "Initial color reduction method"
msgstr "Método inicial de reducción de color"
-#: t_options.h:105
+#: t_options.h:156
msgid "Round colors"
msgstr "Colores redondeados"
-#: t_options.h:106
+#: t_options.h:157
msgid "Dither colors"
msgstr "Colores suavizados"
-#: t_options.h:114
+#: t_options.h:165
msgid "Color rounding method"
msgstr "Método de redondeo de colores"
-#: t_options.h:115
+#: t_options.h:166
msgid "Round color components downward"
msgstr "Redondear hacia abajo los componentes de color"
-#: t_options.h:116
+#: t_options.h:167
msgid "Round to nearest color"
msgstr "Redondear al color más cercano"
-#: t_options.h:125
+#: t_options.h:176
msgid "Color dithering method"
msgstr "Método de suavizado de color"
-#: t_options.h:126
+#: t_options.h:177
msgid "Horizontal error diffusion"
msgstr "Difusión de error horizontal"
-#: t_options.h:127
+#: t_options.h:178
msgid "Horizontal error diffusion, reset error at line start"
msgstr "Difusión de error horizontal, reiniciar error al comienzo de línea"
-#: t_options.h:128
+#: t_options.h:179
msgid "Ordered 2D color dithering"
msgstr "Suavizado de color 2D ordenado"
-#: t_options.h:134
+#: t_options.h:185
msgid "Floating point depth buffer"
msgstr "Búfer de profundidad en coma flotante"
-#: t_options.h:140
+#: t_options.h:190
+msgid "A post-processing filter to cel-shade the output"
+msgstr "Un filtro de postprocesamiento para aplicar cel shading a la salida"
+
+#: t_options.h:195
+msgid "A post-processing filter to remove the red channel"
+msgstr "Un filtro de postprocesamiento para eliminar el canal rojo"
+
+#: t_options.h:200
+msgid "A post-processing filter to remove the green channel"
+msgstr "Un filtro de postprocesamiento para eliminar el canal verde"
+
+#: t_options.h:205
+msgid "A post-processing filter to remove the blue channel"
+msgstr "Un filtro de postprocesamiento para eliminar el canal azul"
+
+#: t_options.h:210
+msgid ""
+"Morphological anti-aliasing based on Jimenez\\' MLAA. 0 to disable, 8 for "
+"default quality"
+msgstr ""
+"Antialiasing morfológico basado en el MLAA de Jimenez. 0 para deshabilitar, "
+"8 para calidad por defecto"
+
+#: t_options.h:215
+msgid ""
+"Morphological anti-aliasing based on Jimenez\\' MLAA. 0 to disable, 8 for "
+"default quality. Color version, usable with 2d GL apps"
+msgstr ""
+"Antialiasing morfológico basado en el MLAA de Jimenez. 0 para deshabilitar, "
+"8 para calidad por defecto. Versión en color, usable con aplicaciones GL 2D"
+
+#: t_options.h:225
msgid "Performance"
msgstr "Rendimiento"
-#: t_options.h:148
+#: t_options.h:233
msgid "TCL mode (Transformation, Clipping, Lighting)"
msgstr "Modo TCL (Transformación, Recorte, Iluminación)"
-#: t_options.h:149
+#: t_options.h:234
msgid "Use software TCL pipeline"
msgstr "Usar tubería TCL por software"
-#: t_options.h:150
+#: t_options.h:235
msgid "Use hardware TCL as first TCL pipeline stage"
msgstr "Usar TCL por hardware en la primera fase de la tubería TCL"
-#: t_options.h:151
+#: t_options.h:236
msgid "Bypass the TCL pipeline"
msgstr "Pasar por alto la tubería TCL"
-#: t_options.h:152
-msgid "Bypass the TCL pipeline with state-based machine code generated on-the-fly"
-msgstr "Pasar por alto la tubería TCL con código máquina basado en estados generado al vuelo"
+#: t_options.h:237
+msgid ""
+"Bypass the TCL pipeline with state-based machine code generated on-the-fly"
+msgstr ""
+"Pasar por alto la tubería TCL con código máquina basado en estados, generado "
+"al vuelo"
-#: t_options.h:161
+#: t_options.h:246
msgid "Method to limit rendering latency"
-msgstr "Método para limitar la latencia de rénder"
+msgstr "Método para limitar la latencia de renderización"
-#: t_options.h:162
+#: t_options.h:247
msgid "Busy waiting for the graphics hardware"
msgstr "Esperar activamente al hardware gráfico"
-#: t_options.h:163
+#: t_options.h:248
msgid "Sleep for brief intervals while waiting for the graphics hardware"
msgstr "Dormir en intervalos cortos mientras se espera al hardware gráfico"
-#: t_options.h:164
+#: t_options.h:249
msgid "Let the graphics hardware emit a software interrupt and sleep"
-msgstr "Permitir que el hardware gráfico emita una interrupción de software y duerma"
+msgstr ""
+"Permitir que el hardware gráfico emita una interrupción de software y duerma"
-#: t_options.h:174
+#: t_options.h:259
msgid "Synchronization with vertical refresh (swap intervals)"
msgstr "Sincronización con el refresco vertical (intervalos de intercambio)"
-#: t_options.h:175
+#: t_options.h:260
msgid "Never synchronize with vertical refresh, ignore application's choice"
-msgstr "No sincronizar nunca con el refresco vertical, ignorar la elección de la aplicación"
+msgstr ""
+"No sincronizar nunca con el refresco vertical, ignorar la elección de la "
+"aplicación"
-#: t_options.h:176
+#: t_options.h:261
msgid "Initial swap interval 0, obey application's choice"
-msgstr "Intervalo de intercambio inicial 0, obedecer la elección de la aplicación"
+msgstr ""
+"Intervalo de intercambio inicial 0, obedecer la elección de la aplicación"
-#: t_options.h:177
+#: t_options.h:262
msgid "Initial swap interval 1, obey application's choice"
-msgstr "Intervalo de intercambio inicial 1, obedecer la elección de la aplicación"
+msgstr ""
+"Intervalo de intercambio inicial 1, obedecer la elección de la aplicación"
-#: t_options.h:178
+#: t_options.h:263
msgid ""
"Always synchronize with vertical refresh, application chooses the minimum "
"swap interval"
-msgstr "Sincronizar siempre con el refresco vertical, la aplicación elige el intervalo de intercambio mínimo"
+msgstr ""
+"Sincronizar siempre con el refresco vertical, la aplicación elige el "
+"intervalo de intercambio mínimo"
-#: t_options.h:186
+#: t_options.h:271
msgid "Use HyperZ to boost performance"
msgstr "Usar HyperZ para potenciar rendimiento"
-#: t_options.h:191
+#: t_options.h:276
msgid "Number of texture units used"
msgstr "Número de unidades de textura usadas"
-#: t_options.h:196
-msgid "Enable hack to allow larger textures with texture compression on radeon/r200"
-msgstr "Activar \"hack\" para permitir texturas más grandes con compresión de textura activada en la Radeon/r200"
-
-#: t_options.h:201
+#: t_options.h:281
msgid "Texture filtering quality vs. speed, AKA “brilinear” texture filtering"
-msgstr "Calidad de filtrado de textura vs. velocidad, alias filtrado \"brilinear\" de textura"
+msgstr ""
+"Calidad de filtrado de textura vs. velocidad, alias filtrado \"brilinear\" "
+"de textura"
-#: t_options.h:209
+#: t_options.h:289
msgid "Used types of texture memory"
msgstr "Tipos de memoria de textura usados"
-#: t_options.h:210
+#: t_options.h:290
msgid "All available memory"
msgstr "Toda la memoria disponible"
-#: t_options.h:211
+#: t_options.h:291
msgid "Only card memory (if available)"
-msgstr "Sólo la memoria de la tarjeta (si disponible)"
+msgstr "Solo memoria de tarjeta (si está disponible)"
-#: t_options.h:212
+#: t_options.h:292
msgid "Only GART (AGP/PCIE) memory (if available)"
-msgstr "Sólo memoria GART (AGP/PCIE) (si disponible)"
+msgstr "Solo memoria GART (AGP/PCIE) (si está disponible)"
-#: t_options.h:220
+#: t_options.h:304
msgid "Features that are not hardware-accelerated"
msgstr "Características no aceleradas por hardware"
-#: t_options.h:224
+#: t_options.h:308
msgid "Enable extension GL_ARB_vertex_program"
-msgstr "Activar la extensión GL_ARB_vertex_program"
+msgstr "Habilitar la extensión GL_ARB_vertex_program"
+
+#: t_options.h:318
+msgid "Miscellaneous"
+msgstr "Misceláneo"
+
+#: t_options.h:322
+msgid "Create all visuals with a depth buffer"
+msgstr "Crear todos los visuales con buffer de profundidad"
diff --git a/mesalib/src/mesa/drivers/dri/common/xmlpool/fr.po b/mesalib/src/mesa/drivers/dri/common/xmlpool/fr.po
index 7a10969b8..4a747b355 100644
--- a/mesalib/src/mesa/drivers/dri/common/xmlpool/fr.po
+++ b/mesalib/src/mesa/drivers/dri/common/xmlpool/fr.po
@@ -7,215 +7,292 @@ msgid ""
msgstr ""
"Project-Id-Version: Mesa 6.3\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2005-04-11 23:19+0200\n"
+"POT-Creation-Date: 2014-01-13 22:30-0700\n"
"PO-Revision-Date: 2005-04-11 01:34+0200\n"
"Last-Translator: Stephane Marchesin <marchesin@icps.u-strasbg.fr>\n"
"Language-Team: French <fr@li.org>\n"
+"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-#: t_options.h:53
+#: t_options.h:56
msgid "Debugging"
msgstr "Debogage"
-#: t_options.h:57
+#: t_options.h:60
msgid "Disable 3D acceleration"
msgstr "Désactiver l'accélération 3D"
-#: t_options.h:62
+#: t_options.h:65
msgid "Show performance boxes"
msgstr "Afficher les boîtes de performance"
-#: t_options.h:69
+#: t_options.h:70
+msgid "Enable flushing batchbuffer after each draw call"
+msgstr ""
+
+#: t_options.h:75
+msgid "Enable flushing GPU caches with each draw call"
+msgstr ""
+
+#: t_options.h:80
+msgid "Disable throttling on first batch after flush"
+msgstr ""
+
+#: t_options.h:85
+msgid "Force GLSL extension default behavior to 'warn'"
+msgstr ""
+
+#: t_options.h:90
+msgid "Disable dual source blending"
+msgstr ""
+
+#: t_options.h:95
+msgid "Disable backslash-based line continuations in GLSL source"
+msgstr ""
+
+#: t_options.h:100
+msgid "Disable GL_ARB_shader_bit_encoding"
+msgstr ""
+
+#: t_options.h:105
+msgid ""
+"Force a default GLSL version for shaders that lack an explicit #version line"
+msgstr ""
+
+#: t_options.h:115
msgid "Image Quality"
msgstr "Qualité d'image"
-#: t_options.h:77
+#: t_options.h:128
msgid "Texture color depth"
msgstr "Profondeur de texture"
-#: t_options.h:78
+#: t_options.h:129
msgid "Prefer frame buffer color depth"
msgstr "Profondeur de couleur"
-#: t_options.h:79
+#: t_options.h:130
msgid "Prefer 32 bits per texel"
msgstr "Préférer 32 bits par texel"
-#: t_options.h:80
+#: t_options.h:131
msgid "Prefer 16 bits per texel"
msgstr "Prérérer 16 bits par texel"
-#: t_options.h:81
+#: t_options.h:132
msgid "Force 16 bits per texel"
msgstr "Forcer 16 bits par texel"
-#: t_options.h:87
+#: t_options.h:138
msgid "Initial maximum value for anisotropic texture filtering"
msgstr "Valeur maximale initiale pour le filtrage anisotropique de texture"
-#: t_options.h:92
+#: t_options.h:143
msgid "Forbid negative texture LOD bias"
msgstr "Interdire le LOD bias negatif"
-#: t_options.h:97
+#: t_options.h:148
msgid ""
"Enable S3TC texture compression even if software support is not available"
msgstr ""
"Activer la compression de texture S3TC même si le support logiciel est absent"
-#: t_options.h:104
+#: t_options.h:155
msgid "Initial color reduction method"
msgstr "Technique de réduction de couleurs"
-#: t_options.h:105
+#: t_options.h:156
msgid "Round colors"
msgstr "Arrondir les valeurs de couleur"
-#: t_options.h:106
+#: t_options.h:157
msgid "Dither colors"
msgstr "Tramer les couleurs"
-#: t_options.h:114
+#: t_options.h:165
msgid "Color rounding method"
msgstr "Méthode d'arrondi des couleurs"
-#: t_options.h:115
+#: t_options.h:166
msgid "Round color components downward"
msgstr "Arrondi à l'inférieur"
-#: t_options.h:116
+#: t_options.h:167
msgid "Round to nearest color"
msgstr "Arrondi au plus proche"
-#: t_options.h:125
+#: t_options.h:176
msgid "Color dithering method"
msgstr "Méthode de tramage"
-#: t_options.h:126
+#: t_options.h:177
msgid "Horizontal error diffusion"
msgstr "Diffusion d'erreur horizontale"
-#: t_options.h:127
+#: t_options.h:178
msgid "Horizontal error diffusion, reset error at line start"
msgstr "Diffusion d'erreur horizontale, réinitialisé pour chaque ligne"
-#: t_options.h:128
+#: t_options.h:179
msgid "Ordered 2D color dithering"
msgstr "Tramage ordonné des couleurs"
-#: t_options.h:134
+#: t_options.h:185
msgid "Floating point depth buffer"
msgstr "Z-buffer en virgule flottante"
-#: t_options.h:140
+#: t_options.h:190
+msgid "A post-processing filter to cel-shade the output"
+msgstr ""
+
+#: t_options.h:195
+msgid "A post-processing filter to remove the red channel"
+msgstr ""
+
+#: t_options.h:200
+msgid "A post-processing filter to remove the green channel"
+msgstr ""
+
+#: t_options.h:205
+msgid "A post-processing filter to remove the blue channel"
+msgstr ""
+
+#: t_options.h:210
+msgid ""
+"Morphological anti-aliasing based on Jimenez\\' MLAA. 0 to disable, 8 for "
+"default quality"
+msgstr ""
+
+#: t_options.h:215
+msgid ""
+"Morphological anti-aliasing based on Jimenez\\' MLAA. 0 to disable, 8 for "
+"default quality. Color version, usable with 2d GL apps"
+msgstr ""
+
+#: t_options.h:225
msgid "Performance"
msgstr "Performance"
-#: t_options.h:148
+#: t_options.h:233
msgid "TCL mode (Transformation, Clipping, Lighting)"
msgstr "Mode de TCL (Transformation, Clipping, Eclairage)"
-#: t_options.h:149
+#: t_options.h:234
msgid "Use software TCL pipeline"
msgstr "Utiliser un pipeline TCL logiciel"
-#: t_options.h:150
+#: t_options.h:235
msgid "Use hardware TCL as first TCL pipeline stage"
msgstr "Utiliser le TCL matériel pour le premier niveau de pipeline"
-#: t_options.h:151
+#: t_options.h:236
msgid "Bypass the TCL pipeline"
msgstr "Court-circuiter le pipeline TCL"
-#: t_options.h:152
+#: t_options.h:237
msgid ""
"Bypass the TCL pipeline with state-based machine code generated on-the-fly"
msgstr ""
-"Court-circuiter le pipeline TCL par une machine à états qui génère le code"
-"de TCL à la volée"
+"Court-circuiter le pipeline TCL par une machine à états qui génère le codede "
+"TCL à la volée"
-#: t_options.h:161
+#: t_options.h:246
msgid "Method to limit rendering latency"
msgstr "Méthode d'attente de la carte graphique"
-#: t_options.h:162
+#: t_options.h:247
msgid "Busy waiting for the graphics hardware"
msgstr "Attente active de la carte graphique"
-#: t_options.h:163
+#: t_options.h:248
msgid "Sleep for brief intervals while waiting for the graphics hardware"
msgstr "Attente utilisant usleep()"
-#: t_options.h:164
+#: t_options.h:249
msgid "Let the graphics hardware emit a software interrupt and sleep"
msgstr "Utiliser les interruptions"
-#: t_options.h:174
+#: t_options.h:259
msgid "Synchronization with vertical refresh (swap intervals)"
msgstr "Synchronisation de l'affichage avec le balayage vertical"
-#: t_options.h:175
+#: t_options.h:260
msgid "Never synchronize with vertical refresh, ignore application's choice"
-msgstr "Ne jamais synchroniser avec le balayage vertical, ignorer le choix de l'application"
+msgstr ""
+"Ne jamais synchroniser avec le balayage vertical, ignorer le choix de "
+"l'application"
-#: t_options.h:176
+#: t_options.h:261
msgid "Initial swap interval 0, obey application's choice"
-msgstr "Ne pas synchroniser avec le balayage vertical par défaut, mais obéir au choix de l'application"
+msgstr ""
+"Ne pas synchroniser avec le balayage vertical par défaut, mais obéir au "
+"choix de l'application"
-#: t_options.h:177
+#: t_options.h:262
msgid "Initial swap interval 1, obey application's choice"
-msgstr "Synchroniser avec le balayage vertical par défaut, mais obéir au choix de l'application"
+msgstr ""
+"Synchroniser avec le balayage vertical par défaut, mais obéir au choix de "
+"l'application"
-#: t_options.h:178
+#: t_options.h:263
msgid ""
"Always synchronize with vertical refresh, application chooses the minimum "
"swap interval"
msgstr ""
-"Toujours synchroniser avec le balayage vertical, l'application choisit l'intervalle minimal"
+"Toujours synchroniser avec le balayage vertical, l'application choisit "
+"l'intervalle minimal"
-#: t_options.h:186
+#: t_options.h:271
msgid "Use HyperZ to boost performance"
msgstr "Utiliser le HyperZ pour améliorer les performances"
-#: t_options.h:191
+#: t_options.h:276
msgid "Number of texture units used"
msgstr "Nombre d'unités de texture"
-#: t_options.h:196
-msgid ""
-"Enable hack to allow larger textures with texture compression on radeon/r200"
-msgstr ""
-"Activer le hack permettant l'utilisation de textures de grande taille avec la "
-"compression de textures sur radeon/r200"
-
-#: t_options.h:201
+#: t_options.h:281
msgid "Texture filtering quality vs. speed, AKA “brilinear” texture filtering"
msgstr ""
"Qualité/performance du filtrage trilinéaire de texture (filtrage brilinéaire)"
-#: t_options.h:209
+#: t_options.h:289
msgid "Used types of texture memory"
msgstr "Types de mémoire de texture"
-#: t_options.h:210
+#: t_options.h:290
msgid "All available memory"
msgstr "Utiliser toute la mémoire disponible"
-#: t_options.h:211
+#: t_options.h:291
msgid "Only card memory (if available)"
msgstr "Utiliser uniquement la mémoire graphique (si disponible)"
-#: t_options.h:212
+#: t_options.h:292
msgid "Only GART (AGP/PCIE) memory (if available)"
msgstr "Utiliser uniquement la mémoire GART (AGP/PCIE) (si disponible)"
-#: t_options.h:220
+#: t_options.h:304
msgid "Features that are not hardware-accelerated"
msgstr "Fonctionnalités ne bénéficiant pas d'une accélération matérielle"
-#: t_options.h:224
+#: t_options.h:308
msgid "Enable extension GL_ARB_vertex_program"
msgstr "Activer l'extension GL_ARB_vertex_program"
+
+#: t_options.h:318
+msgid "Miscellaneous"
+msgstr ""
+
+#: t_options.h:322
+msgid "Create all visuals with a depth buffer"
+msgstr ""
+
+#~ msgid ""
+#~ "Enable hack to allow larger textures with texture compression on radeon/"
+#~ "r200"
+#~ msgstr ""
+#~ "Activer le hack permettant l'utilisation de textures de grande taille "
+#~ "avec la compression de textures sur radeon/r200"
diff --git a/mesalib/src/mesa/drivers/dri/common/xmlpool/nl.po b/mesalib/src/mesa/drivers/dri/common/xmlpool/nl.po
index 64516f606..8dc1f5566 100644
--- a/mesalib/src/mesa/drivers/dri/common/xmlpool/nl.po
+++ b/mesalib/src/mesa/drivers/dri/common/xmlpool/nl.po
@@ -7,173 +7,237 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2005-04-12 20:09+0200\n"
+"POT-Creation-Date: 2014-01-13 22:30-0700\n"
"PO-Revision-Date: 2005-04-12 20:09+0200\n"
"Last-Translator: Manfred Stienstra <manfred.stienstra@dwerg.net>\n"
"Language-Team: Dutch <vertaling@nl.linux.org>\n"
+"Language: nl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-#: t_options.h:53
+#: t_options.h:56
msgid "Debugging"
msgstr "Debuggen"
-#: t_options.h:57
+#: t_options.h:60
msgid "Disable 3D acceleration"
msgstr "3D versnelling uitschakelen"
-#: t_options.h:62
+#: t_options.h:65
msgid "Show performance boxes"
msgstr "Laat prestatie boxjes zien"
-#: t_options.h:69
+#: t_options.h:70
+msgid "Enable flushing batchbuffer after each draw call"
+msgstr ""
+
+#: t_options.h:75
+msgid "Enable flushing GPU caches with each draw call"
+msgstr ""
+
+#: t_options.h:80
+msgid "Disable throttling on first batch after flush"
+msgstr ""
+
+#: t_options.h:85
+msgid "Force GLSL extension default behavior to 'warn'"
+msgstr ""
+
+#: t_options.h:90
+msgid "Disable dual source blending"
+msgstr ""
+
+#: t_options.h:95
+msgid "Disable backslash-based line continuations in GLSL source"
+msgstr ""
+
+#: t_options.h:100
+msgid "Disable GL_ARB_shader_bit_encoding"
+msgstr ""
+
+#: t_options.h:105
+msgid ""
+"Force a default GLSL version for shaders that lack an explicit #version line"
+msgstr ""
+
+#: t_options.h:115
msgid "Image Quality"
msgstr "Beeldkwaliteit"
-#: t_options.h:77
+#: t_options.h:128
msgid "Texture color depth"
msgstr "Textuurkleurendiepte"
-#: t_options.h:78
+#: t_options.h:129
msgid "Prefer frame buffer color depth"
msgstr "Prefereer kaderbufferkleurdiepte"
-#: t_options.h:79
+#: t_options.h:130
msgid "Prefer 32 bits per texel"
msgstr "Prefereer 32 bits per texel"
-#: t_options.h:80
+#: t_options.h:131
msgid "Prefer 16 bits per texel"
msgstr "Prefereer 16 bits per texel"
-#: t_options.h:81
+#: t_options.h:132
msgid "Force 16 bits per texel"
msgstr "Dwing 16 bits per texel af"
-#: t_options.h:87
+#: t_options.h:138
msgid "Initial maximum value for anisotropic texture filtering"
msgstr "Initïele maximum waarde voor anisotrophische textuur filtering"
-#: t_options.h:92
+#: t_options.h:143
msgid "Forbid negative texture LOD bias"
msgstr "Verbied negatief niveau detailonderscheid (LOD) van texturen"
-#: t_options.h:97
+#: t_options.h:148
msgid ""
"Enable S3TC texture compression even if software support is not available"
msgstr ""
"Schakel S3TC textuurcompressie in, zelfs als softwareondersteuning niet "
"aanwezig is"
-#: t_options.h:104
+#: t_options.h:155
msgid "Initial color reduction method"
msgstr "Initïele kleurreductie methode"
-#: t_options.h:105
+#: t_options.h:156
msgid "Round colors"
msgstr "Rond kleuren af"
-#: t_options.h:106
+#: t_options.h:157
msgid "Dither colors"
msgstr "Rasteriseer kleuren"
-#: t_options.h:114
+#: t_options.h:165
msgid "Color rounding method"
msgstr "Kleurafrondingmethode"
-#: t_options.h:115
+#: t_options.h:166
msgid "Round color components downward"
msgstr "Rond kleurencomponenten af naar beneden"
-#: t_options.h:116
+#: t_options.h:167
msgid "Round to nearest color"
msgstr "Rond af naar dichtsbijzijnde kleur"
-#: t_options.h:125
+#: t_options.h:176
msgid "Color dithering method"
msgstr "Kleurrasteriseringsmethode"
-#: t_options.h:126
+#: t_options.h:177
msgid "Horizontal error diffusion"
msgstr "Horizontale foutdiffusie"
-#: t_options.h:127
+#: t_options.h:178
msgid "Horizontal error diffusion, reset error at line start"
msgstr "Horizontale foutdiffusie, zet fout bij lijnbegin terug"
-#: t_options.h:128
+#: t_options.h:179
msgid "Ordered 2D color dithering"
msgstr "Geordende 2D kleurrasterisering"
-#: t_options.h:134
+#: t_options.h:185
msgid "Floating point depth buffer"
msgstr "Dieptebuffer als commagetal"
-#: t_options.h:140
+#: t_options.h:190
+msgid "A post-processing filter to cel-shade the output"
+msgstr ""
+
+#: t_options.h:195
+msgid "A post-processing filter to remove the red channel"
+msgstr ""
+
+#: t_options.h:200
+msgid "A post-processing filter to remove the green channel"
+msgstr ""
+
+#: t_options.h:205
+msgid "A post-processing filter to remove the blue channel"
+msgstr ""
+
+#: t_options.h:210
+msgid ""
+"Morphological anti-aliasing based on Jimenez\\' MLAA. 0 to disable, 8 for "
+"default quality"
+msgstr ""
+
+#: t_options.h:215
+msgid ""
+"Morphological anti-aliasing based on Jimenez\\' MLAA. 0 to disable, 8 for "
+"default quality. Color version, usable with 2d GL apps"
+msgstr ""
+
+#: t_options.h:225
msgid "Performance"
msgstr "Prestatie"
-#: t_options.h:148
+#: t_options.h:233
msgid "TCL mode (Transformation, Clipping, Lighting)"
msgstr "TCL-modus (Transformatie, Clipping, Licht)"
-#: t_options.h:149
+#: t_options.h:234
msgid "Use software TCL pipeline"
msgstr "Gebruik software TCL pijpleiding"
-#: t_options.h:150
+#: t_options.h:235
msgid "Use hardware TCL as first TCL pipeline stage"
msgstr "Gebruik hardware TCL as eerste TCL pijpleiding trap"
-#: t_options.h:151
+#: t_options.h:236
msgid "Bypass the TCL pipeline"
msgstr "Omzeil de TCL pijpleiding"
-#: t_options.h:152
+#: t_options.h:237
msgid ""
"Bypass the TCL pipeline with state-based machine code generated on-the-fly"
msgstr ""
"Omzeil de TCL pijpleiding met staatgebaseerde machinecode die tijdens "
"executie gegenereerd wordt"
-#: t_options.h:161
+#: t_options.h:246
msgid "Method to limit rendering latency"
msgstr "Methode om beeldopbouwvertraging te onderdrukken"
-#: t_options.h:162
+#: t_options.h:247
msgid "Busy waiting for the graphics hardware"
msgstr "Actief wachten voor de grafische hardware"
-#: t_options.h:163
+#: t_options.h:248
msgid "Sleep for brief intervals while waiting for the graphics hardware"
-msgstr "Slaap voor korte intervallen tijdens het wachten op de grafische "
-"hardware"
+msgstr ""
+"Slaap voor korte intervallen tijdens het wachten op de grafische hardware"
-#: t_options.h:164
+#: t_options.h:249
msgid "Let the graphics hardware emit a software interrupt and sleep"
-msgstr "Laat de grafische hardware een software onderbreking uitzenden en in "
-"slaap vallen"
+msgstr ""
+"Laat de grafische hardware een software onderbreking uitzenden en in slaap "
+"vallen"
-#: t_options.h:174
+#: t_options.h:259
msgid "Synchronization with vertical refresh (swap intervals)"
msgstr "Synchronisatie met verticale verversing (interval omwisselen)"
-#: t_options.h:175
+#: t_options.h:260
msgid "Never synchronize with vertical refresh, ignore application's choice"
-msgstr "Nooit synchroniseren met verticale verversing, negeer de keuze van de "
+msgstr ""
+"Nooit synchroniseren met verticale verversing, negeer de keuze van de "
"applicatie"
-#: t_options.h:176
+#: t_options.h:261
msgid "Initial swap interval 0, obey application's choice"
msgstr "Initïeel omwisselingsinterval 0, honoreer de keuze van de applicatie"
-#: t_options.h:177
+#: t_options.h:262
msgid "Initial swap interval 1, obey application's choice"
msgstr "Initïeel omwisselingsinterval 1, honoreer de keuze van de applicatie"
-#: t_options.h:178
+#: t_options.h:263
msgid ""
"Always synchronize with vertical refresh, application chooses the minimum "
"swap interval"
@@ -181,46 +245,55 @@ msgstr ""
"Synchroniseer altijd met verticale verversing, de applicatie kiest het "
"minimum omwisselingsinterval"
-#: t_options.h:186
+#: t_options.h:271
msgid "Use HyperZ to boost performance"
msgstr "Gebruik HyperZ om de prestaties te verbeteren"
-#: t_options.h:191
+#: t_options.h:276
msgid "Number of texture units used"
msgstr "Aantal textuureenheden in gebruik"
-#: t_options.h:196
-msgid ""
-"Enable hack to allow larger textures with texture compression on radeon/r200"
-msgstr ""
-"Schakel hack in om met textuurcompressie grotere texturen toe te staan op "
-"een radeon/r200"
-
-#: t_options.h:201
+#: t_options.h:281
msgid "Texture filtering quality vs. speed, AKA “brilinear” texture filtering"
-msgstr "Textuurfilterkwaliteit versus -snelheid, ookwel bekend als "
-"“brilineaire” textuurfiltering"
+msgstr ""
+"Textuurfilterkwaliteit versus -snelheid, ookwel bekend als “brilineaire” "
+"textuurfiltering"
-#: t_options.h:209
+#: t_options.h:289
msgid "Used types of texture memory"
msgstr "Gebruikte soorten textuurgeheugen"
-#: t_options.h:210
+#: t_options.h:290
msgid "All available memory"
msgstr "Al het beschikbaar geheugen"
-#: t_options.h:211
+#: t_options.h:291
msgid "Only card memory (if available)"
msgstr "Alleen geheugen op de kaart (als het aanwezig is)"
-#: t_options.h:212
+#: t_options.h:292
msgid "Only GART (AGP/PCIE) memory (if available)"
msgstr "Alleen GART (AGP/PCIE) geheugen (als het aanwezig is)"
-#: t_options.h:220
+#: t_options.h:304
msgid "Features that are not hardware-accelerated"
msgstr "Eigenschappen die niet hardwareversneld zijn"
-#: t_options.h:224
+#: t_options.h:308
msgid "Enable extension GL_ARB_vertex_program"
msgstr "Zet uitbreiding GL_ARB_vertex_program aan"
+
+#: t_options.h:318
+msgid "Miscellaneous"
+msgstr ""
+
+#: t_options.h:322
+msgid "Create all visuals with a depth buffer"
+msgstr ""
+
+#~ msgid ""
+#~ "Enable hack to allow larger textures with texture compression on radeon/"
+#~ "r200"
+#~ msgstr ""
+#~ "Schakel hack in om met textuurcompressie grotere texturen toe te staan op "
+#~ "een radeon/r200"
diff --git a/mesalib/src/mesa/drivers/dri/common/xmlpool/sv.po b/mesalib/src/mesa/drivers/dri/common/xmlpool/sv.po
index d1cb56bba..082a22a94 100644
--- a/mesalib/src/mesa/drivers/dri/common/xmlpool/sv.po
+++ b/mesalib/src/mesa/drivers/dri/common/xmlpool/sv.po
@@ -7,215 +7,291 @@ msgid ""
msgstr ""
"Project-Id-Version: Mesa DRI\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2005-04-11 23:19+0200\n"
+"POT-Creation-Date: 2014-01-13 22:30-0700\n"
"PO-Revision-Date: 2006-09-18 10:56+0100\n"
"Last-Translator: Daniel Nylander <po@danielnylander.se>\n"
"Language-Team: Swedish <tp-sv@listor.tp-sv.se>\n"
+"Language: sv\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-#: t_options.h:53
+#: t_options.h:56
msgid "Debugging"
msgstr "Felsökning"
-#: t_options.h:57
+#: t_options.h:60
msgid "Disable 3D acceleration"
msgstr "Inaktivera 3D-accelerering"
-#: t_options.h:62
+#: t_options.h:65
msgid "Show performance boxes"
msgstr "Visa prestandarutor"
-#: t_options.h:69
+#: t_options.h:70
+msgid "Enable flushing batchbuffer after each draw call"
+msgstr ""
+
+#: t_options.h:75
+msgid "Enable flushing GPU caches with each draw call"
+msgstr ""
+
+#: t_options.h:80
+msgid "Disable throttling on first batch after flush"
+msgstr ""
+
+#: t_options.h:85
+msgid "Force GLSL extension default behavior to 'warn'"
+msgstr ""
+
+#: t_options.h:90
+msgid "Disable dual source blending"
+msgstr ""
+
+#: t_options.h:95
+msgid "Disable backslash-based line continuations in GLSL source"
+msgstr ""
+
+#: t_options.h:100
+msgid "Disable GL_ARB_shader_bit_encoding"
+msgstr ""
+
+#: t_options.h:105
+msgid ""
+"Force a default GLSL version for shaders that lack an explicit #version line"
+msgstr ""
+
+#: t_options.h:115
msgid "Image Quality"
msgstr "Bildkvalitet"
-#: t_options.h:77
+#: t_options.h:128
msgid "Texture color depth"
msgstr "Färgdjup för texturer"
-#: t_options.h:78
+#: t_options.h:129
msgid "Prefer frame buffer color depth"
msgstr "Föredra färgdjupet för framebuffer"
-#: t_options.h:79
+#: t_options.h:130
msgid "Prefer 32 bits per texel"
msgstr "Föredra 32 bitar per texel"
-#: t_options.h:80
+#: t_options.h:131
msgid "Prefer 16 bits per texel"
msgstr "Föredra 16 bitar per texel"
-#: t_options.h:81
+#: t_options.h:132
msgid "Force 16 bits per texel"
msgstr "Tvinga 16 bitar per texel"
-#: t_options.h:87
+#: t_options.h:138
msgid "Initial maximum value for anisotropic texture filtering"
msgstr "Initialt maximalt värde för anisotropisk texturfiltrering"
-#: t_options.h:92
+#: t_options.h:143
msgid "Forbid negative texture LOD bias"
msgstr "Förbjud negativ LOD-kompensation för texturer"
-#: t_options.h:97
-msgid "Enable S3TC texture compression even if software support is not available"
+#: t_options.h:148
+msgid ""
+"Enable S3TC texture compression even if software support is not available"
msgstr "Aktivera S3TC-texturkomprimering även om programvarustöd saknas"
-#: t_options.h:104
+#: t_options.h:155
msgid "Initial color reduction method"
msgstr "Initial färgminskningsmetod"
-#: t_options.h:105
+#: t_options.h:156
msgid "Round colors"
msgstr "Avrunda färger"
-#: t_options.h:106
+#: t_options.h:157
msgid "Dither colors"
msgstr "Utjämna färger"
-#: t_options.h:114
+#: t_options.h:165
msgid "Color rounding method"
msgstr "Färgavrundningsmetod"
-#: t_options.h:115
+#: t_options.h:166
msgid "Round color components downward"
msgstr "Avrunda färdkomponenter nedåt"
-#: t_options.h:116
+#: t_options.h:167
msgid "Round to nearest color"
msgstr "Avrunda till närmsta färg"
-#: t_options.h:125
+#: t_options.h:176
msgid "Color dithering method"
msgstr "Färgutjämningsmetod"
-#: t_options.h:126
+#: t_options.h:177
msgid "Horizontal error diffusion"
msgstr "Horisontell felspridning"
-#: t_options.h:127
+#: t_options.h:178
msgid "Horizontal error diffusion, reset error at line start"
msgstr "Horisontell felspridning, återställ fel vid radbörjan"
-#: t_options.h:128
+#: t_options.h:179
msgid "Ordered 2D color dithering"
msgstr "Ordnad 2D-färgutjämning"
-#: t_options.h:134
+#: t_options.h:185
msgid "Floating point depth buffer"
msgstr "Buffert för flytande punktdjup"
-#: t_options.h:140
+#: t_options.h:190
+msgid "A post-processing filter to cel-shade the output"
+msgstr ""
+
+#: t_options.h:195
+msgid "A post-processing filter to remove the red channel"
+msgstr ""
+
+#: t_options.h:200
+msgid "A post-processing filter to remove the green channel"
+msgstr ""
+
+#: t_options.h:205
+msgid "A post-processing filter to remove the blue channel"
+msgstr ""
+
+#: t_options.h:210
+msgid ""
+"Morphological anti-aliasing based on Jimenez\\' MLAA. 0 to disable, 8 for "
+"default quality"
+msgstr ""
+
+#: t_options.h:215
+msgid ""
+"Morphological anti-aliasing based on Jimenez\\' MLAA. 0 to disable, 8 for "
+"default quality. Color version, usable with 2d GL apps"
+msgstr ""
+
+#: t_options.h:225
msgid "Performance"
msgstr "Prestanda"
-#: t_options.h:148
+#: t_options.h:233
msgid "TCL mode (Transformation, Clipping, Lighting)"
msgstr "TCL-läge (Transformation, Clipping, Lighting)"
-#: t_options.h:149
+#: t_options.h:234
msgid "Use software TCL pipeline"
msgstr "Använd programvaru-TCL-rörledning"
-#: t_options.h:150
+#: t_options.h:235
msgid "Use hardware TCL as first TCL pipeline stage"
msgstr "Använd maskinvaru-TCL som första TCL-rörledningssteg"
-#: t_options.h:151
+#: t_options.h:236
msgid "Bypass the TCL pipeline"
msgstr "Kringgå TCL-rörledningen"
-#: t_options.h:152
-msgid "Bypass the TCL pipeline with state-based machine code generated on-the-fly"
-msgstr "Kringgå TCL-rörledningen med tillståndsbaserad maskinkod som direktgenereras"
+#: t_options.h:237
+msgid ""
+"Bypass the TCL pipeline with state-based machine code generated on-the-fly"
+msgstr ""
+"Kringgå TCL-rörledningen med tillståndsbaserad maskinkod som direktgenereras"
-#: t_options.h:161
+#: t_options.h:246
msgid "Method to limit rendering latency"
msgstr "Metod för att begränsa renderingslatens"
-#: t_options.h:162
+#: t_options.h:247
msgid "Busy waiting for the graphics hardware"
msgstr "Upptagen med att vänta på grafikhårdvaran"
-#: t_options.h:163
+#: t_options.h:248
msgid "Sleep for brief intervals while waiting for the graphics hardware"
msgstr "Sov i korta intervall under väntan på grafikhårdvaran"
-#: t_options.h:164
+#: t_options.h:249
msgid "Let the graphics hardware emit a software interrupt and sleep"
msgstr "Låt grafikhårdvaran sända ut ett programvaruavbrott och sov"
-#: t_options.h:174
+#: t_options.h:259
msgid "Synchronization with vertical refresh (swap intervals)"
msgstr "Synkronisering med vertikal uppdatering (växlingsintervall)"
-#: t_options.h:175
+#: t_options.h:260
msgid "Never synchronize with vertical refresh, ignore application's choice"
msgstr "Synkronisera aldrig med vertikal uppdatering, ignorera programmets val"
-#: t_options.h:176
+#: t_options.h:261
msgid "Initial swap interval 0, obey application's choice"
msgstr "Initialt växlingsintervall 0, följ programmets val"
-#: t_options.h:177
+#: t_options.h:262
msgid "Initial swap interval 1, obey application's choice"
msgstr "Initialt växlingsintervall 1, följ programmets val"
-#: t_options.h:178
-msgid "Always synchronize with vertical refresh, application chooses the minimum swap interval"
-msgstr "Synkronisera alltid med vertikal uppdatering, programmet väljer den minsta växlingsintervallen"
+#: t_options.h:263
+msgid ""
+"Always synchronize with vertical refresh, application chooses the minimum "
+"swap interval"
+msgstr ""
+"Synkronisera alltid med vertikal uppdatering, programmet väljer den minsta "
+"växlingsintervallen"
-#: t_options.h:186
+#: t_options.h:271
msgid "Use HyperZ to boost performance"
msgstr "Använd HyperZ för att maximera prestandan"
-#: t_options.h:191
+#: t_options.h:276
msgid "Number of texture units used"
msgstr "Antal använda texturenheter"
-#: t_options.h:196
-msgid "Support larger textures not guaranteed to fit into graphics memory"
-msgstr "Stöd för större texturer är inte garanterat att passa i grafikminnet"
-
-#: t_options.h:197
-msgid "No"
-msgstr "Nej"
-
-#: t_options.h:198
-msgid "At least 1 texture must fit under worst-case assumptions"
-msgstr "Åtminstone en textur måste passa för antaget sämsta förhållande"
-
-#: t_options.h:199
-msgid "Announce hardware limits"
-msgstr "Annonsera hårdvarubegränsningar"
-
-#: t_options.h:205
+#: t_options.h:281
msgid "Texture filtering quality vs. speed, AKA “brilinear” texture filtering"
-msgstr "Texturfiltreringskvalitet mot hastighet, även kallad \"brilinear\"-texturfiltrering"
+msgstr ""
+"Texturfiltreringskvalitet mot hastighet, även kallad \"brilinear\"-"
+"texturfiltrering"
-#: t_options.h:213
+#: t_options.h:289
msgid "Used types of texture memory"
msgstr "Använda typer av texturminne"
-#: t_options.h:214
+#: t_options.h:290
msgid "All available memory"
msgstr "Allt tillgängligt minne"
-#: t_options.h:215
+#: t_options.h:291
msgid "Only card memory (if available)"
msgstr "Endast kortminne (om tillgängligt)"
-#: t_options.h:216
+#: t_options.h:292
msgid "Only GART (AGP/PCIE) memory (if available)"
msgstr "Endast GART-minne (AGP/PCIE) (om tillgängligt)"
-#: t_options.h:224
+#: t_options.h:304
msgid "Features that are not hardware-accelerated"
msgstr "Funktioner som inte är hårdvaruaccelererade"
-#: t_options.h:228
+#: t_options.h:308
msgid "Enable extension GL_ARB_vertex_program"
msgstr "Aktivera tillägget GL_ARB_vertex_program"
+
+#: t_options.h:318
+msgid "Miscellaneous"
+msgstr ""
+
+#: t_options.h:322
+msgid "Create all visuals with a depth buffer"
+msgstr ""
+
+#~ msgid "Support larger textures not guaranteed to fit into graphics memory"
+#~ msgstr ""
+#~ "Stöd för större texturer är inte garanterat att passa i grafikminnet"
+
+#~ msgid "No"
+#~ msgstr "Nej"
+
+#~ msgid "At least 1 texture must fit under worst-case assumptions"
+#~ msgstr "Åtminstone en textur måste passa för antaget sämsta förhållande"
+
+#~ msgid "Announce hardware limits"
+#~ msgstr "Annonsera hårdvarubegränsningar"
diff --git a/mesalib/src/mesa/main/api_validate.c b/mesalib/src/mesa/main/api_validate.c
index 96b178905..694558443 100644
--- a/mesalib/src/mesa/main/api_validate.c
+++ b/mesalib/src/mesa/main/api_validate.c
@@ -128,7 +128,7 @@ check_valid_to_render(struct gl_context *ctx, const char *function)
case API_OPENGL_CORE:
{
const struct gl_shader_program *vsProg =
- ctx->Shader.CurrentVertexProgram;
+ ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX];
GLboolean haveVertexShader = (vsProg && vsProg->LinkStatus);
GLboolean haveVertexProgram = ctx->VertexProgram._Enabled;
if (haveVertexShader || haveVertexProgram) {
@@ -269,9 +269,9 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
* TRIANGLES_ADJACENCY_ARB or TRIANGLE_STRIP_ADJACENCY_ARB.
*
*/
- if (ctx->Shader.CurrentGeometryProgram) {
+ if (ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]) {
const GLenum geom_mode =
- ctx->Shader.CurrentGeometryProgram->Geom.InputType;
+ ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]->Geom.InputType;
switch (mode) {
case GL_POINTS:
valid_enum = (geom_mode == GL_POINTS);
@@ -330,8 +330,8 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
if (_mesa_is_xfb_active_and_unpaused(ctx)) {
GLboolean pass = GL_TRUE;
- if(ctx->Shader.CurrentGeometryProgram) {
- switch (ctx->Shader.CurrentGeometryProgram->Geom.OutputType) {
+ if(ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]) {
+ switch (ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]->Geom.OutputType) {
case GL_POINTS:
pass = ctx->TransformFeedback.Mode == GL_POINTS;
break;
diff --git a/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c
index 30c815d67..7b7cf0ef3 100644
--- a/mesalib/src/mesa/main/attrib.c
+++ b/mesalib/src/mesa/main/attrib.c
@@ -112,7 +112,7 @@ struct gl_enable_attrib
GLboolean PolygonSmooth;
GLboolean PolygonStipple;
GLboolean RescaleNormals;
- GLboolean Scissor;
+ GLbitfield Scissor;
GLboolean Stencil;
GLboolean StencilTwoSide; /* GL_EXT_stencil_two_side */
GLboolean MultisampleEnabled; /* GL_ARB_multisample */
@@ -354,7 +354,7 @@ _mesa_PushAttrib(GLbitfield mask)
attr->PolygonSmooth = ctx->Polygon.SmoothFlag;
attr->PolygonStipple = ctx->Polygon.StippleFlag;
attr->RescaleNormals = ctx->Transform.RescaleNormals;
- attr->Scissor = ctx->Scissor.Enabled;
+ attr->Scissor = ctx->Scissor.EnableFlags;
attr->Stencil = ctx->Stencil.Enabled;
attr->StencilTwoSide = ctx->Stencil.TestTwoSide;
attr->MultisampleEnabled = ctx->Multisample.Enabled;
@@ -533,8 +533,9 @@ _mesa_PushAttrib(GLbitfield mask)
if (mask & GL_VIEWPORT_BIT) {
if (!push_attrib(ctx, &head, GL_VIEWPORT_BIT,
- sizeof(struct gl_viewport_attrib),
- (void*)&ctx->Viewport))
+ sizeof(struct gl_viewport_attrib)
+ * ctx->Const.MaxViewports,
+ (void*)&ctx->ViewportArray))
goto end;
}
@@ -658,7 +659,13 @@ pop_enable_group(struct gl_context *ctx, const struct gl_enable_attrib *enable)
GL_POLYGON_SMOOTH);
TEST_AND_UPDATE(ctx->Polygon.StippleFlag, enable->PolygonStipple,
GL_POLYGON_STIPPLE);
- TEST_AND_UPDATE(ctx->Scissor.Enabled, enable->Scissor, GL_SCISSOR_TEST);
+ if (ctx->Scissor.EnableFlags != enable->Scissor) {
+ unsigned i;
+
+ for (i = 0; i < ctx->Const.MaxViewports; i++) {
+ _mesa_set_enablei(ctx, GL_SCISSOR_TEST, i, (enable->Scissor >> i) & 1);
+ }
+ }
TEST_AND_UPDATE(ctx->Stencil.Enabled, enable->Stencil, GL_STENCIL_TEST);
if (ctx->Extensions.EXT_stencil_two_side) {
TEST_AND_UPDATE(ctx->Stencil.TestTwoSide, enable->StencilTwoSide, GL_STENCIL_TEST_TWO_SIDE_EXT);
@@ -1262,11 +1269,19 @@ _mesa_PopAttrib(void)
break;
case GL_SCISSOR_BIT:
{
+ unsigned i;
const struct gl_scissor_attrib *scissor;
scissor = (const struct gl_scissor_attrib *) attr->data;
- _mesa_Scissor(scissor->X, scissor->Y,
- scissor->Width, scissor->Height);
- _mesa_set_enable(ctx, GL_SCISSOR_TEST, scissor->Enabled);
+
+ for (i = 0; i < ctx->Const.MaxViewports; i++) {
+ _mesa_set_scissor(ctx, i,
+ scissor->ScissorArray[i].X,
+ scissor->ScissorArray[i].Y,
+ scissor->ScissorArray[i].Width,
+ scissor->ScissorArray[i].Height);
+ _mesa_set_enablei(ctx, GL_SCISSOR_TEST, i,
+ (scissor->EnableFlags >> i) & 1);
+ }
}
break;
case GL_STENCIL_BUFFER_BIT:
@@ -1342,10 +1357,15 @@ _mesa_PopAttrib(void)
break;
case GL_VIEWPORT_BIT:
{
+ unsigned i;
const struct gl_viewport_attrib *vp;
vp = (const struct gl_viewport_attrib *) attr->data;
- _mesa_Viewport(vp->X, vp->Y, vp->Width, vp->Height);
- _mesa_DepthRange(vp->Near, vp->Far);
+
+ for (i = 0; i < ctx->Const.MaxViewports; i++) {
+ _mesa_set_viewport(ctx, i, vp[i].X, vp[i].Y, vp[i].Width,
+ vp[i].Height);
+ _mesa_set_depth_range(ctx, i, vp[i].Near, vp[i].Far);
+ }
}
break;
case GL_MULTISAMPLE_BIT_ARB:
diff --git a/mesalib/src/mesa/main/config.h b/mesalib/src/mesa/main/config.h
index ff9da779b..0c1782ad7 100644
--- a/mesalib/src/mesa/main/config.h
+++ b/mesalib/src/mesa/main/config.h
@@ -121,7 +121,7 @@
* Max number of texture image units. Also determines number of texture
* samplers in shaders.
*/
-#define MAX_TEXTURE_IMAGE_UNITS 16
+#define MAX_TEXTURE_IMAGE_UNITS 32
/**
* Larger of MAX_TEXTURE_COORD_UNITS and MAX_TEXTURE_IMAGE_UNITS.
@@ -137,6 +137,9 @@
#define MAX_VIEWPORT_WIDTH 16384
#define MAX_VIEWPORT_HEIGHT 16384
+/** Maximun number of viewports supported with ARB_viewport_array */
+#define MAX_VIEWPORTS 16
+
/** Maxmimum size for CVA. May be overridden by the drivers. */
#define MAX_ARRAY_LOCK_SIZE 3000
diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c
index 0b8fb94e8..b7cd56866 100644
--- a/mesalib/src/mesa/main/context.c
+++ b/mesalib/src/mesa/main/context.c
@@ -587,6 +587,16 @@ _mesa_init_constants(struct gl_context *ctx)
ctx->Const.MaxSpotExponent = 128.0;
ctx->Const.MaxViewportWidth = MAX_VIEWPORT_WIDTH;
ctx->Const.MaxViewportHeight = MAX_VIEWPORT_HEIGHT;
+ ctx->Const.MinMapBufferAlignment = 1;
+
+ /* Driver must override these values if ARB_viewport_array is supported. */
+ ctx->Const.MaxViewports = 1;
+ ctx->Const.ViewportSubpixelBits = 0;
+ ctx->Const.ViewportBounds.Min = 0;
+ ctx->Const.ViewportBounds.Max = 0;
+
+ /* Driver must override if it supports ARB_viewport_array */
+ ctx->Const.MaxViewports = 1;
/** GL_ARB_uniform_buffer_object */
ctx->Const.MaxCombinedUniformBlocks = 36;
@@ -1348,13 +1358,17 @@ _mesa_copy_context( const struct gl_context *src, struct gl_context *dst,
}
if (mask & GL_VIEWPORT_BIT) {
/* Cannot use memcpy, because of pointers in GLmatrix _WindowMap */
- dst->Viewport.X = src->Viewport.X;
- dst->Viewport.Y = src->Viewport.Y;
- dst->Viewport.Width = src->Viewport.Width;
- dst->Viewport.Height = src->Viewport.Height;
- dst->Viewport.Near = src->Viewport.Near;
- dst->Viewport.Far = src->Viewport.Far;
- _math_matrix_copy(&dst->Viewport._WindowMap, &src->Viewport._WindowMap);
+ unsigned i;
+ for (i = 0; i < src->Const.MaxViewports; i++) {
+ dst->ViewportArray[i].X = src->ViewportArray[i].X;
+ dst->ViewportArray[i].Y = src->ViewportArray[i].Y;
+ dst->ViewportArray[i].Width = src->ViewportArray[i].Width;
+ dst->ViewportArray[i].Height = src->ViewportArray[i].Height;
+ dst->ViewportArray[i].Near = src->ViewportArray[i].Near;
+ dst->ViewportArray[i].Far = src->ViewportArray[i].Far;
+ _math_matrix_copy(&dst->ViewportArray[i]._WindowMap,
+ &src->ViewportArray[i]._WindowMap);
+ }
}
/* XXX FIXME: Call callbacks?
@@ -1423,12 +1437,20 @@ void
_mesa_check_init_viewport(struct gl_context *ctx, GLuint width, GLuint height)
{
if (!ctx->ViewportInitialized && width > 0 && height > 0) {
+ unsigned i;
+
/* Note: set flag here, before calling _mesa_set_viewport(), to prevent
* potential infinite recursion.
*/
ctx->ViewportInitialized = GL_TRUE;
- _mesa_set_viewport(ctx, 0, 0, width, height);
- _mesa_set_scissor(ctx, 0, 0, width, height);
+
+ /* Note: ctx->Const.MaxViewports may not have been set by the driver
+ * yet, so just initialize all of them.
+ */
+ for (i = 0; i < MAX_VIEWPORTS; i++) {
+ _mesa_set_viewport(ctx, i, 0, 0, width, height);
+ _mesa_set_scissor(ctx, i, 0, 0, width, height);
+ }
}
}
@@ -1744,10 +1766,10 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
if (ctx->NewState)
_mesa_update_state(ctx);
- if (ctx->Shader.CurrentVertexProgram) {
+ if (ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]) {
vert_from_glsl_shader = true;
- if (!ctx->Shader.CurrentVertexProgram->LinkStatus) {
+ if (!ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]->LinkStatus) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(shader not linked)", where);
return GL_FALSE;
@@ -1756,19 +1778,19 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
{
char errMsg[100];
if (!_mesa_validate_shader_program(ctx,
- ctx->Shader.CurrentVertexProgram,
+ ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX],
errMsg)) {
_mesa_warning(ctx, "Shader program %u is invalid: %s",
- ctx->Shader.CurrentVertexProgram->Name, errMsg);
+ ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]->Name, errMsg);
}
}
#endif
}
- if (ctx->Shader.CurrentGeometryProgram) {
+ if (ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]) {
geom_from_glsl_shader = true;
- if (!ctx->Shader.CurrentGeometryProgram->LinkStatus) {
+ if (!ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]->LinkStatus) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(shader not linked)", where);
return GL_FALSE;
@@ -1777,19 +1799,20 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
{
char errMsg[100];
if (!_mesa_validate_shader_program(ctx,
- ctx->Shader.CurrentGeometryProgram,
+ ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY],
errMsg)) {
_mesa_warning(ctx, "Shader program %u is invalid: %s",
- ctx->Shader.CurrentGeometryProgram->Name, errMsg);
+ ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY]->Name,
+ errMsg);
}
}
#endif
}
- if (ctx->Shader.CurrentFragmentProgram) {
+ if (ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT]) {
frag_from_glsl_shader = true;
- if (!ctx->Shader.CurrentFragmentProgram->LinkStatus) {
+ if (!ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT]->LinkStatus) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(shader not linked)", where);
return GL_FALSE;
@@ -1798,10 +1821,11 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
{
char errMsg[100];
if (!_mesa_validate_shader_program(ctx,
- ctx->Shader.CurrentFragmentProgram,
+ ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT],
errMsg)) {
_mesa_warning(ctx, "Shader program %u is invalid: %s",
- ctx->Shader.CurrentFragmentProgram->Name, errMsg);
+ ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT]->Name,
+ errMsg);
}
}
#endif
@@ -1851,13 +1875,9 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
#ifdef DEBUG
if (ctx->Shader.Flags & GLSL_LOG) {
- struct gl_shader_program *shProg[MESA_SHADER_STAGES];
+ struct gl_shader_program **shProg = ctx->Shader.CurrentProgram;
gl_shader_stage i;
- shProg[MESA_SHADER_VERTEX] = ctx->Shader.CurrentVertexProgram;
- shProg[MESA_SHADER_GEOMETRY] = ctx->Shader.CurrentGeometryProgram;
- shProg[MESA_SHADER_FRAGMENT] = ctx->Shader.CurrentFragmentProgram;
-
for (i = 0; i < MESA_SHADER_STAGES; i++) {
if (shProg[i] == NULL || shProg[i]->_Used
|| shProg[i]->_LinkedShaders[i] == NULL)
diff --git a/mesalib/src/mesa/main/dlist.c b/mesalib/src/mesa/main/dlist.c
index cb40ff4db..08943c9f9 100644
--- a/mesalib/src/mesa/main/dlist.c
+++ b/mesalib/src/mesa/main/dlist.c
@@ -767,6 +767,7 @@ _mesa_delete_list(struct gl_context *ctx, struct gl_display_list *dlist)
break;
case OPCODE_PIXEL_MAP:
free(get_pointer(&n[3]));
+ n += InstSize[n[0].opcode];
break;
case OPCODE_CONTINUE:
diff --git a/mesalib/src/mesa/main/enable.c b/mesalib/src/mesa/main/enable.c
index fca306890..640db8490 100644
--- a/mesalib/src/mesa/main/enable.c
+++ b/mesalib/src/mesa/main/enable.c
@@ -659,10 +659,15 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
ctx->Transform.RescaleNormals = state;
break;
case GL_SCISSOR_TEST:
- if (ctx->Scissor.Enabled == state)
- return;
- FLUSH_VERTICES(ctx, _NEW_SCISSOR);
- ctx->Scissor.Enabled = state;
+ {
+ /* Must expand glEnable to all scissors */
+ GLbitfield newEnabled =
+ state * ((1 << ctx->Const.MaxViewports) - 1);
+ if (newEnabled != ctx->Scissor.EnableFlags) {
+ FLUSH_VERTICES(ctx, _NEW_SCISSOR);
+ ctx->Scissor.EnableFlags = newEnabled;
+ }
+ }
break;
case GL_STENCIL_TEST:
if (ctx->Stencil.Enabled == state)
@@ -1076,6 +1081,20 @@ _mesa_set_enablei(struct gl_context *ctx, GLenum cap,
ctx->Color.BlendEnabled &= ~(1 << index);
}
break;
+ case GL_SCISSOR_TEST:
+ if (index >= ctx->Const.MaxViewports) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)",
+ state ? "glEnablei" : "glDisablei", index);
+ return;
+ }
+ if (((ctx->Scissor.EnableFlags >> index) & 1) != state) {
+ FLUSH_VERTICES(ctx, _NEW_SCISSOR);
+ if (state)
+ ctx->Scissor.EnableFlags |= (1 << index);
+ else
+ ctx->Scissor.EnableFlags &= ~(1 << index);
+ }
+ break;
default:
goto invalid_enum_error;
}
@@ -1117,6 +1136,13 @@ _mesa_IsEnabledi( GLenum cap, GLuint index )
return GL_FALSE;
}
return (ctx->Color.BlendEnabled >> index) & 1;
+ case GL_SCISSOR_TEST:
+ if (index >= ctx->Const.MaxViewports) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glIsEnabledIndexed(index=%u)",
+ index);
+ return GL_FALSE;
+ }
+ return (ctx->Scissor.EnableFlags >> index) & 1;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabledIndexed(cap=%s)",
_mesa_lookup_enum_by_nr(cap));
@@ -1349,7 +1375,7 @@ _mesa_IsEnabled( GLenum cap )
goto invalid_enum_error;
return ctx->Transform.RescaleNormals;
case GL_SCISSOR_TEST:
- return ctx->Scissor.Enabled;
+ return ctx->Scissor.EnableFlags & 1; /* return state for index 0 */
case GL_STENCIL_TEST:
return ctx->Stencil.Enabled;
case GL_TEXTURE_1D:
diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c
index 2e0ccc3b6..0676f1e3d 100644
--- a/mesalib/src/mesa/main/extensions.c
+++ b/mesalib/src/mesa/main/extensions.c
@@ -80,6 +80,7 @@ static const struct extension extension_table[] = {
/* ARB Extensions */
{ "GL_ARB_ES2_compatibility", o(ARB_ES2_compatibility), GL, 2009 },
{ "GL_ARB_ES3_compatibility", o(ARB_ES3_compatibility), GL, 2012 },
+ { "GL_ARB_arrays_of_arrays", o(ARB_arrays_of_arrays), GL, 2012 },
{ "GL_ARB_base_instance", o(ARB_base_instance), GL, 2011 },
{ "GL_ARB_blend_func_extended", o(ARB_blend_func_extended), GL, 2009 },
{ "GL_ARB_clear_buffer_object", o(dummy_true), GL, 2012 },
@@ -176,6 +177,7 @@ static const struct extension extension_table[] = {
{ "GL_ARB_vertex_shader", o(ARB_vertex_shader), GL, 2002 },
{ "GL_ARB_vertex_type_10f_11f_11f_rev", o(ARB_vertex_type_10f_11f_11f_rev), GL, 2013 },
{ "GL_ARB_vertex_type_2_10_10_10_rev", o(ARB_vertex_type_2_10_10_10_rev), GL, 2009 },
+ { "GL_ARB_viewport_array", o(ARB_viewport_array), GLC, 2010 },
{ "GL_ARB_window_pos", o(dummy_true), GLL, 2001 },
/* EXT extensions */
{ "GL_EXT_abgr", o(dummy_true), GL, 1995 },
diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c
index dc7184ad4..943f40bd9 100644
--- a/mesalib/src/mesa/main/fbobject.c
+++ b/mesalib/src/mesa/main/fbobject.c
@@ -880,7 +880,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
/* Covers max_layer_count, is_layered, and layer_tex_target */
bool layer_info_valid = false;
GLuint max_layer_count = 0, att_layer_count;
- bool is_layered;
+ bool is_layered = false;
GLenum layer_tex_target = 0;
assert(_mesa_is_user_fbo(fb));
diff --git a/mesalib/src/mesa/main/ff_fragment_shader.cpp b/mesalib/src/mesa/main/ff_fragment_shader.cpp
index 8523edf41..cad67aa85 100644
--- a/mesalib/src/mesa/main/ff_fragment_shader.cpp
+++ b/mesalib/src/mesa/main/ff_fragment_shader.cpp
@@ -317,9 +317,9 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx )
{
/* _NEW_PROGRAM */
const GLboolean vertexShader =
- (ctx->Shader.CurrentVertexProgram &&
- ctx->Shader.CurrentVertexProgram->LinkStatus &&
- ctx->Shader.CurrentVertexProgram->_LinkedShaders[MESA_SHADER_VERTEX]);
+ (ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX] &&
+ ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]->LinkStatus &&
+ ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]->_LinkedShaders[MESA_SHADER_VERTEX]);
const GLboolean vertexProgram = ctx->VertexProgram._Enabled;
GLbitfield fp_inputs = 0x0;
@@ -383,7 +383,7 @@ static GLbitfield get_fp_input_mask( struct gl_context *ctx )
* validation (see additional comments in state.c).
*/
if (vertexShader)
- vprog = ctx->Shader.CurrentVertexProgram->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
+ vprog = ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX]->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
else
vprog = &ctx->VertexProgram.Current->Base;
diff --git a/mesalib/src/mesa/main/ffvertex_prog.c b/mesalib/src/mesa/main/ffvertex_prog.c
index aec2b2dbc..4d71c55ee 100644
--- a/mesalib/src/mesa/main/ffvertex_prog.c
+++ b/mesalib/src/mesa/main/ffvertex_prog.c
@@ -1676,7 +1676,7 @@ _mesa_get_fixed_func_vertex_program(struct gl_context *ctx)
return NULL;
create_new_program( &key, prog,
- ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].PreferDP4,
+ ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS,
ctx->Const.Program[MESA_SHADER_VERTEX].MaxTemps );
#if 0
diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c
index 1246c4d92..7bde1f1a8 100644
--- a/mesalib/src/mesa/main/formats.c
+++ b/mesalib/src/mesa/main/formats.c
@@ -2032,6 +2032,9 @@ _mesa_get_format_color_encoding(gl_format format)
case MESA_FORMAT_SRGBA_DXT3:
case MESA_FORMAT_SRGBA_DXT5:
case MESA_FORMAT_XBGR8888_SRGB:
+ case MESA_FORMAT_ETC2_SRGB8:
+ case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC:
+ case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:
return GL_SRGB;
default:
return GL_LINEAR;
@@ -2077,6 +2080,15 @@ _mesa_get_srgb_format_linear(gl_format format)
case MESA_FORMAT_XBGR8888_SRGB:
format = MESA_FORMAT_RGBX8888_REV;
break;
+ case MESA_FORMAT_ETC2_SRGB8:
+ format = MESA_FORMAT_ETC2_RGB8;
+ break;
+ case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC:
+ format = MESA_FORMAT_ETC2_RGBA8_EAC;
+ break;
+ case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:
+ format = MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1;
+ break;
default:
break;
}
diff --git a/mesalib/src/mesa/main/framebuffer.c b/mesalib/src/mesa/main/framebuffer.c
index 2fad45880..bd8f4933f 100644
--- a/mesalib/src/mesa/main/framebuffer.c
+++ b/mesalib/src/mesa/main/framebuffer.c
@@ -357,6 +357,56 @@ update_framebuffer_size(struct gl_context *ctx, struct gl_framebuffer *fb)
/**
+ * Calculate the inclusive bounding box for the scissor of a specific viewport
+ *
+ * \param ctx GL context.
+ * \param buffer Framebuffer to be checked against
+ * \param idx Index of the desired viewport
+ * \param bbox Bounding box for the scissored viewport. Stored as xmin,
+ * xmax, ymin, ymax.
+ *
+ * \warning This function assumes that the framebuffer dimensions are up to
+ * date (e.g., update_framebuffer_size has been recently called on \c buffer).
+ *
+ * \sa _mesa_clip_to_region
+ */
+void
+_mesa_scissor_bounding_box(const struct gl_context *ctx,
+ const struct gl_framebuffer *buffer,
+ unsigned idx, int *bbox)
+{
+ bbox[0] = 0;
+ bbox[2] = 0;
+ bbox[1] = buffer->Width;
+ bbox[3] = buffer->Height;
+
+ if (ctx->Scissor.EnableFlags & (1u << idx)) {
+ if (ctx->Scissor.ScissorArray[idx].X > bbox[0]) {
+ bbox[0] = ctx->Scissor.ScissorArray[idx].X;
+ }
+ if (ctx->Scissor.ScissorArray[idx].Y > bbox[2]) {
+ bbox[2] = ctx->Scissor.ScissorArray[idx].Y;
+ }
+ if (ctx->Scissor.ScissorArray[idx].X + ctx->Scissor.ScissorArray[idx].Width < bbox[1]) {
+ bbox[1] = ctx->Scissor.ScissorArray[idx].X + ctx->Scissor.ScissorArray[idx].Width;
+ }
+ if (ctx->Scissor.ScissorArray[idx].Y + ctx->Scissor.ScissorArray[idx].Height < bbox[3]) {
+ bbox[3] = ctx->Scissor.ScissorArray[idx].Y + ctx->Scissor.ScissorArray[idx].Height;
+ }
+ /* finally, check for empty region */
+ if (bbox[0] > bbox[1]) {
+ bbox[0] = bbox[1];
+ }
+ if (bbox[2] > bbox[3]) {
+ bbox[2] = bbox[3];
+ }
+ }
+
+ ASSERT(bbox[0] <= bbox[1]);
+ ASSERT(bbox[2] <= bbox[3]);
+}
+
+/**
* Update the context's current drawing buffer's Xmin, Xmax, Ymin, Ymax fields.
* These values are computed from the buffer's width and height and
* the scissor box, if it's enabled.
@@ -366,6 +416,7 @@ void
_mesa_update_draw_buffer_bounds(struct gl_context *ctx)
{
struct gl_framebuffer *buffer = ctx->DrawBuffer;
+ int bbox[4];
if (!buffer)
return;
@@ -375,35 +426,12 @@ _mesa_update_draw_buffer_bounds(struct gl_context *ctx)
update_framebuffer_size(ctx, buffer);
}
- buffer->_Xmin = 0;
- buffer->_Ymin = 0;
- buffer->_Xmax = buffer->Width;
- buffer->_Ymax = buffer->Height;
-
- if (ctx->Scissor.Enabled) {
- if (ctx->Scissor.X > buffer->_Xmin) {
- buffer->_Xmin = ctx->Scissor.X;
- }
- if (ctx->Scissor.Y > buffer->_Ymin) {
- buffer->_Ymin = ctx->Scissor.Y;
- }
- if (ctx->Scissor.X + ctx->Scissor.Width < buffer->_Xmax) {
- buffer->_Xmax = ctx->Scissor.X + ctx->Scissor.Width;
- }
- if (ctx->Scissor.Y + ctx->Scissor.Height < buffer->_Ymax) {
- buffer->_Ymax = ctx->Scissor.Y + ctx->Scissor.Height;
- }
- /* finally, check for empty region */
- if (buffer->_Xmin > buffer->_Xmax) {
- buffer->_Xmin = buffer->_Xmax;
- }
- if (buffer->_Ymin > buffer->_Ymax) {
- buffer->_Ymin = buffer->_Ymax;
- }
- }
-
- ASSERT(buffer->_Xmin <= buffer->_Xmax);
- ASSERT(buffer->_Ymin <= buffer->_Ymax);
+ /* Default to the first scissor as that's always valid */
+ _mesa_scissor_bounding_box(ctx, buffer, 0, bbox);
+ buffer->_Xmin = bbox[0];
+ buffer->_Ymin = bbox[2];
+ buffer->_Xmax = bbox[1];
+ buffer->_Ymax = bbox[3];
}
diff --git a/mesalib/src/mesa/main/framebuffer.h b/mesalib/src/mesa/main/framebuffer.h
index 264566477..a4274216e 100644
--- a/mesalib/src/mesa/main/framebuffer.h
+++ b/mesalib/src/mesa/main/framebuffer.h
@@ -71,6 +71,11 @@ _mesa_resize_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
extern void
_mesa_resizebuffers( struct gl_context *ctx );
+extern void
+_mesa_scissor_bounding_box(const struct gl_context *ctx,
+ const struct gl_framebuffer *buffer,
+ unsigned idx, int *bbox);
+
extern void
_mesa_update_draw_buffer_bounds(struct gl_context *ctx);
diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c
index b13f9a3db..16dce5b65 100644
--- a/mesalib/src/mesa/main/get.c
+++ b/mesalib/src/mesa/main/get.c
@@ -113,6 +113,7 @@ enum value_type {
TYPE_FLOATN_3,
TYPE_FLOATN_4,
TYPE_DOUBLEN,
+ TYPE_DOUBLEN_2,
TYPE_MATRIX,
TYPE_MATRIX_T,
TYPE_CONST
@@ -162,6 +163,7 @@ struct value_desc {
union value {
GLfloat value_float;
GLfloat value_float_4[4];
+ GLdouble value_double_2[2];
GLmatrix *value_matrix;
GLint value_int;
GLint value_int_4[4];
@@ -389,6 +391,7 @@ EXTRA_EXT(ARB_texture_gather);
EXTRA_EXT(ARB_shader_atomic_counters);
EXTRA_EXT(ARB_draw_indirect);
EXTRA_EXT(ARB_shader_image_load_store);
+EXTRA_EXT(ARB_viewport_array);
static const int
extra_ARB_color_buffer_float_or_glcore[] = {
@@ -665,10 +668,14 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
break;
case GL_SCISSOR_BOX:
- v->value_int_4[0] = ctx->Scissor.X;
- v->value_int_4[1] = ctx->Scissor.Y;
- v->value_int_4[2] = ctx->Scissor.Width;
- v->value_int_4[3] = ctx->Scissor.Height;
+ v->value_int_4[0] = ctx->Scissor.ScissorArray[0].X;
+ v->value_int_4[1] = ctx->Scissor.ScissorArray[0].Y;
+ v->value_int_4[2] = ctx->Scissor.ScissorArray[0].Width;
+ v->value_int_4[3] = ctx->Scissor.ScissorArray[0].Height;
+ break;
+
+ case GL_SCISSOR_TEST:
+ v->value_bool = ctx->Scissor.EnableFlags & 1;
break;
case GL_LIST_INDEX:
@@ -685,10 +692,15 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
break;
case GL_VIEWPORT:
- v->value_int_4[0] = ctx->Viewport.X;
- v->value_int_4[1] = ctx->Viewport.Y;
- v->value_int_4[2] = ctx->Viewport.Width;
- v->value_int_4[3] = ctx->Viewport.Height;
+ v->value_float_4[0] = ctx->ViewportArray[0].X;
+ v->value_float_4[1] = ctx->ViewportArray[0].Y;
+ v->value_float_4[2] = ctx->ViewportArray[0].Width;
+ v->value_float_4[3] = ctx->ViewportArray[0].Height;
+ break;
+
+ case GL_DEPTH_RANGE:
+ v->value_double_2[0] = ctx->ViewportArray[0].Near;
+ v->value_double_2[1] = ctx->ViewportArray[0].Far;
break;
case GL_ACTIVE_STENCIL_FACE_EXT:
@@ -1235,6 +1247,8 @@ _mesa_GetBooleanv(GLenum pname, GLboolean *params)
params[0] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[0]);
break;
+ case TYPE_DOUBLEN_2:
+ params[1] = FLOAT_TO_BOOLEAN(((GLdouble *) p)[1]);
case TYPE_DOUBLEN:
params[0] = FLOAT_TO_BOOLEAN(((GLdouble *) p)[0]);
break;
@@ -1321,6 +1335,8 @@ _mesa_GetFloatv(GLenum pname, GLfloat *params)
params[0] = ((GLfloat *) p)[0];
break;
+ case TYPE_DOUBLEN_2:
+ params[1] = (GLfloat) (((GLdouble *) p)[1]);
case TYPE_DOUBLEN:
params[0] = (GLfloat) (((GLdouble *) p)[0]);
break;
@@ -1413,6 +1429,8 @@ _mesa_GetIntegerv(GLenum pname, GLint *params)
params[0] = FLOAT_TO_INT(((GLfloat *) p)[0]);
break;
+ case TYPE_DOUBLEN_2:
+ params[1] = FLOAT_TO_INT(((GLdouble *) p)[1]);
case TYPE_DOUBLEN:
params[0] = FLOAT_TO_INT(((GLdouble *) p)[0]);
break;
@@ -1505,6 +1523,8 @@ _mesa_GetInteger64v(GLenum pname, GLint64 *params)
params[0] = FLOAT_TO_INT64(((GLfloat *) p)[0]);
break;
+ case TYPE_DOUBLEN_2:
+ params[1] = FLOAT_TO_INT64(((GLdouble *) p)[1]);
case TYPE_DOUBLEN:
params[0] = FLOAT_TO_INT64(((GLdouble *) p)[0]);
break;
@@ -1591,6 +1611,8 @@ _mesa_GetDoublev(GLenum pname, GLdouble *params)
params[0] = ((GLfloat *) p)[0];
break;
+ case TYPE_DOUBLEN_2:
+ params[1] = ((GLdouble *) p)[1];
case TYPE_DOUBLEN:
params[0] = ((GLdouble *) p)[0];
break;
@@ -1719,6 +1741,31 @@ find_value_indexed(const char *func, GLenum pname, GLuint index, union value *v)
v->value_int_4[3] = ctx->Color.ColorMask[index][ACOMP] ? 1 : 0;
return TYPE_INT_4;
+ case GL_SCISSOR_BOX:
+ if (index >= ctx->Const.MaxViewports)
+ goto invalid_value;
+ v->value_int_4[0] = ctx->Scissor.ScissorArray[index].X;
+ v->value_int_4[1] = ctx->Scissor.ScissorArray[index].Y;
+ v->value_int_4[2] = ctx->Scissor.ScissorArray[index].Width;
+ v->value_int_4[3] = ctx->Scissor.ScissorArray[index].Height;
+ return TYPE_INT_4;
+
+ case GL_VIEWPORT:
+ if (index >= ctx->Const.MaxViewports)
+ goto invalid_value;
+ v->value_float_4[0] = ctx->ViewportArray[index].X;
+ v->value_float_4[1] = ctx->ViewportArray[index].Y;
+ v->value_float_4[2] = ctx->ViewportArray[index].Width;
+ v->value_float_4[3] = ctx->ViewportArray[index].Height;
+ return TYPE_FLOAT_4;
+
+ case GL_DEPTH_RANGE:
+ if (index >= ctx->Const.MaxViewports)
+ goto invalid_value;
+ v->value_double_2[0] = ctx->ViewportArray[index].Near;
+ v->value_double_2[1] = ctx->ViewportArray[index].Far;
+ return TYPE_DOUBLEN_2;
+
case GL_TRANSFORM_FEEDBACK_BUFFER_START:
if (index >= ctx->Const.MaxTransformFeedbackBuffers)
goto invalid_value;
@@ -1927,6 +1974,26 @@ _mesa_GetIntegeri_v( GLenum pname, GLuint index, GLint *params )
find_value_indexed("glGetIntegeri_v", pname, index, &v);
switch (type) {
+ case TYPE_FLOAT_4:
+ case TYPE_FLOATN_4:
+ params[3] = IROUND(v.value_float_4[3]);
+ case TYPE_FLOAT_3:
+ case TYPE_FLOATN_3:
+ params[2] = IROUND(v.value_float_4[2]);
+ case TYPE_FLOAT_2:
+ case TYPE_FLOATN_2:
+ params[1] = IROUND(v.value_float_4[1]);
+ case TYPE_FLOAT:
+ case TYPE_FLOATN:
+ params[0] = IROUND(v.value_float_4[0]);
+ break;
+
+ case TYPE_DOUBLEN_2:
+ params[1] = IROUND(v.value_double_2[1]);
+ case TYPE_DOUBLEN:
+ params[0] = IROUND(v.value_double_2[0]);
+ break;
+
case TYPE_INT:
params[0] = v.value_int;
break;
@@ -1970,6 +2037,150 @@ _mesa_GetInteger64i_v( GLenum pname, GLuint index, GLint64 *params )
}
void GLAPIENTRY
+_mesa_GetFloati_v(GLenum pname, GLuint index, GLfloat *params)
+{
+ int i;
+ GLmatrix *m;
+ union value v;
+ enum value_type type =
+ find_value_indexed("glGetFloati_v", pname, index, &v);
+
+ switch (type) {
+ case TYPE_FLOAT_4:
+ case TYPE_FLOATN_4:
+ params[3] = v.value_float_4[3];
+ case TYPE_FLOAT_3:
+ case TYPE_FLOATN_3:
+ params[2] = v.value_float_4[2];
+ case TYPE_FLOAT_2:
+ case TYPE_FLOATN_2:
+ params[1] = v.value_float_4[1];
+ case TYPE_FLOAT:
+ case TYPE_FLOATN:
+ params[0] = v.value_float_4[0];
+ break;
+
+ case TYPE_DOUBLEN_2:
+ params[1] = (GLfloat) v.value_double_2[1];
+ case TYPE_DOUBLEN:
+ params[0] = (GLfloat) v.value_double_2[0];
+ break;
+
+ case TYPE_INT_4:
+ params[3] = (GLfloat) v.value_int_4[3];
+ case TYPE_INT_3:
+ params[2] = (GLfloat) v.value_int_4[2];
+ case TYPE_INT_2:
+ case TYPE_ENUM_2:
+ params[1] = (GLfloat) v.value_int_4[1];
+ case TYPE_INT:
+ case TYPE_ENUM:
+ params[0] = (GLfloat) v.value_int_4[0];
+ break;
+
+ case TYPE_INT_N:
+ for (i = 0; i < v.value_int_n.n; i++)
+ params[i] = INT_TO_FLOAT(v.value_int_n.ints[i]);
+ break;
+
+ case TYPE_INT64:
+ params[0] = (GLfloat) v.value_int64;
+ break;
+
+ case TYPE_BOOLEAN:
+ params[0] = BOOLEAN_TO_FLOAT(v.value_bool);
+ break;
+
+ case TYPE_MATRIX:
+ m = *(GLmatrix **) &v;
+ for (i = 0; i < 16; i++)
+ params[i] = m->m[i];
+ break;
+
+ case TYPE_MATRIX_T:
+ m = *(GLmatrix **) &v;
+ for (i = 0; i < 16; i++)
+ params[i] = m->m[transpose[i]];
+ break;
+
+ default:
+ ;
+ }
+}
+
+void GLAPIENTRY
+_mesa_GetDoublei_v(GLenum pname, GLuint index, GLdouble *params)
+{
+ int i;
+ GLmatrix *m;
+ union value v;
+ enum value_type type =
+ find_value_indexed("glGetDoublei_v", pname, index, &v);
+
+ switch (type) {
+ case TYPE_FLOAT_4:
+ case TYPE_FLOATN_4:
+ params[3] = (GLdouble) v.value_float_4[3];
+ case TYPE_FLOAT_3:
+ case TYPE_FLOATN_3:
+ params[2] = (GLdouble) v.value_float_4[2];
+ case TYPE_FLOAT_2:
+ case TYPE_FLOATN_2:
+ params[1] = (GLdouble) v.value_float_4[1];
+ case TYPE_FLOAT:
+ case TYPE_FLOATN:
+ params[0] = (GLdouble) v.value_float_4[0];
+ break;
+
+ case TYPE_DOUBLEN_2:
+ params[1] = v.value_double_2[1];
+ case TYPE_DOUBLEN:
+ params[0] = v.value_double_2[0];
+ break;
+
+ case TYPE_INT_4:
+ params[3] = (GLdouble) v.value_int_4[3];
+ case TYPE_INT_3:
+ params[2] = (GLdouble) v.value_int_4[2];
+ case TYPE_INT_2:
+ case TYPE_ENUM_2:
+ params[1] = (GLdouble) v.value_int_4[1];
+ case TYPE_INT:
+ case TYPE_ENUM:
+ params[0] = (GLdouble) v.value_int_4[0];
+ break;
+
+ case TYPE_INT_N:
+ for (i = 0; i < v.value_int_n.n; i++)
+ params[i] = (GLdouble) INT_TO_FLOAT(v.value_int_n.ints[i]);
+ break;
+
+ case TYPE_INT64:
+ params[0] = (GLdouble) v.value_int64;
+ break;
+
+ case TYPE_BOOLEAN:
+ params[0] = (GLdouble) BOOLEAN_TO_FLOAT(v.value_bool);
+ break;
+
+ case TYPE_MATRIX:
+ m = *(GLmatrix **) &v;
+ for (i = 0; i < 16; i++)
+ params[i] = (GLdouble) m->m[i];
+ break;
+
+ case TYPE_MATRIX_T:
+ m = *(GLmatrix **) &v;
+ for (i = 0; i < 16; i++)
+ params[i] = (GLdouble) m->m[transpose[i]];
+ break;
+
+ default:
+ ;
+ }
+}
+
+void GLAPIENTRY
_mesa_GetFixedv(GLenum pname, GLfixed *params)
{
const struct value_desc *d;
@@ -2000,6 +2211,8 @@ _mesa_GetFixedv(GLenum pname, GLfixed *params)
params[0] = FLOAT_TO_FIXED(((GLfloat *) p)[0]);
break;
+ case TYPE_DOUBLEN_2:
+ params[1] = FLOAT_TO_FIXED(((GLdouble *) p)[1]);
case TYPE_DOUBLEN:
params[0] = FLOAT_TO_FIXED(((GLdouble *) p)[0]);
break;
diff --git a/mesalib/src/mesa/main/get.h b/mesalib/src/mesa/main/get.h
index 0f72508a7..ce97cc586 100644
--- a/mesalib/src/mesa/main/get.h
+++ b/mesalib/src/mesa/main/get.h
@@ -65,6 +65,12 @@ _mesa_GetInteger64i_v( GLenum pname, GLuint index, GLint64 *params );
extern void GLAPIENTRY
_mesa_GetPointerv( GLenum pname, GLvoid **params );
+extern void GLAPIENTRY
+_mesa_GetFloati_v(GLenum target, GLuint index, GLfloat *data);
+
+extern void GLAPIENTRY
+_mesa_GetDoublei_v(GLenum target, GLuint index, GLdouble *data);
+
extern const GLubyte * GLAPIENTRY
_mesa_GetString( GLenum name );
diff --git a/mesalib/src/mesa/main/get_hash_params.py b/mesalib/src/mesa/main/get_hash_params.py
index bc2bbafa8..b45e1430b 100644
--- a/mesalib/src/mesa/main/get_hash_params.py
+++ b/mesalib/src/mesa/main/get_hash_params.py
@@ -11,7 +11,7 @@ descriptor=[
[ "DEPTH_BITS", "BUFFER_INT(Visual.depthBits), extra_new_buffers" ],
[ "DEPTH_CLEAR_VALUE", "CONTEXT_FIELD(Depth.Clear, TYPE_DOUBLEN), NO_EXTRA" ],
[ "DEPTH_FUNC", "CONTEXT_ENUM(Depth.Func), NO_EXTRA" ],
- [ "DEPTH_RANGE", "CONTEXT_FIELD(Viewport.Near, TYPE_FLOATN_2), NO_EXTRA" ],
+ [ "DEPTH_RANGE", "LOC_CUSTOM, TYPE_DOUBLEN_2, 0, NO_EXTRA" ],
[ "DEPTH_TEST", "CONTEXT_BOOL(Depth.Test), NO_EXTRA" ],
[ "DEPTH_WRITEMASK", "CONTEXT_BOOL(Depth.Mask), NO_EXTRA" ],
[ "DITHER", "CONTEXT_BOOL(Color.DitherFlag), NO_EXTRA" ],
@@ -30,7 +30,7 @@ descriptor=[
[ "POLYGON_OFFSET_FILL", "CONTEXT_BOOL(Polygon.OffsetFill), NO_EXTRA" ],
[ "RED_BITS", "BUFFER_INT(Visual.redBits), extra_new_buffers" ],
[ "SCISSOR_BOX", "LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA" ],
- [ "SCISSOR_TEST", "CONTEXT_BOOL(Scissor.Enabled), NO_EXTRA" ],
+ [ "SCISSOR_TEST", "LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA" ],
[ "STENCIL_BITS", "BUFFER_INT(Visual.stencilBits), extra_new_buffers" ],
[ "STENCIL_CLEAR_VALUE", "CONTEXT_INT(Stencil.Clear), NO_EXTRA" ],
[ "STENCIL_FAIL", "LOC_CUSTOM, TYPE_ENUM, NO_OFFSET, NO_EXTRA" ],
@@ -44,7 +44,7 @@ descriptor=[
[ "SUBPIXEL_BITS", "CONTEXT_INT(Const.SubPixelBits), NO_EXTRA" ],
[ "TEXTURE_BINDING_2D", "LOC_CUSTOM, TYPE_INT, TEXTURE_2D_INDEX, NO_EXTRA" ],
[ "UNPACK_ALIGNMENT", "CONTEXT_INT(Unpack.Alignment), NO_EXTRA" ],
- [ "VIEWPORT", "LOC_CUSTOM, TYPE_INT_4, 0, NO_EXTRA" ],
+ [ "VIEWPORT", "LOC_CUSTOM, TYPE_FLOAT_4, 0, NO_EXTRA" ],
# GL_ARB_multitexture
[ "ACTIVE_TEXTURE", "LOC_CUSTOM, TYPE_INT, 0, NO_EXTRA" ],
@@ -759,6 +759,13 @@ descriptor=[
[ "TEXTURE_BUFFER_OFFSET_ALIGNMENT", "CONTEXT_INT(Const.TextureBufferOffsetAlignment), extra_ARB_texture_buffer_range" ],
# GL_ARB_draw_indirect
[ "DRAW_INDIRECT_BUFFER_BINDING", "LOC_CUSTOM, TYPE_INT, 0, extra_ARB_draw_indirect" ],
+
+# GL_ARB_viewport_array
+ [ "MAX_VIEWPORTS", "CONTEXT_INT(Const.MaxViewports), extra_ARB_viewport_array" ],
+ [ "VIEWPORT_SUBPIXEL_BITS", "CONTEXT_INT(Const.ViewportSubpixelBits), extra_ARB_viewport_array" ],
+ [ "VIEWPORT_BOUNDS_RANGE", "CONTEXT_FLOAT2(Const.ViewportBounds), extra_ARB_viewport_array" ],
+ [ "LAYER_PROVOKING_VERTEX", "CONTEXT_ENUM(Light.ProvokingVertex), extra_ARB_viewport_array" ],
+ [ "VIEWPORT_INDEX_PROVOKING_VERTEX", "CONTEXT_ENUM(Light.ProvokingVertex), extra_ARB_viewport_array" ],
]}
]
diff --git a/mesalib/src/mesa/main/glformats.c b/mesalib/src/mesa/main/glformats.c
index bec7a9bbb..7d4a31057 100644
--- a/mesalib/src/mesa/main/glformats.c
+++ b/mesalib/src/mesa/main/glformats.c
@@ -1136,76 +1136,60 @@ GLenum
_mesa_get_nongeneric_internalformat(GLenum format)
{
switch (format) {
- /* GL 1.1 formats. */
- case 4:
- case GL_RGBA:
- return GL_RGBA8;
-
- case 3:
- case GL_RGB:
- return GL_RGB8;
-
- case 2:
- case GL_LUMINANCE_ALPHA:
- return GL_LUMINANCE8_ALPHA8;
-
- case 1:
- case GL_LUMINANCE:
- return GL_LUMINANCE8;
-
- case GL_ALPHA:
- return GL_ALPHA8;
-
- case GL_INTENSITY:
- return GL_INTENSITY8;
-
- /* GL_ARB_texture_rg */
- case GL_RED:
- return GL_R8;
-
- case GL_RG:
- return GL_RG8;
-
- /* GL_EXT_texture_sRGB */
- case GL_SRGB:
- return GL_SRGB8;
-
- case GL_SRGB_ALPHA:
- return GL_SRGB8_ALPHA8;
-
- case GL_SLUMINANCE:
- return GL_SLUMINANCE8;
-
- case GL_SLUMINANCE_ALPHA:
- return GL_SLUMINANCE8_ALPHA8;
-
- /* GL_EXT_texture_snorm */
- case GL_RGBA_SNORM:
- return GL_RGBA8_SNORM;
-
- case GL_RGB_SNORM:
- return GL_RGB8_SNORM;
-
- case GL_RG_SNORM:
- return GL_RG8_SNORM;
-
- case GL_RED_SNORM:
- return GL_R8_SNORM;
-
- case GL_LUMINANCE_ALPHA_SNORM:
- return GL_LUMINANCE8_ALPHA8_SNORM;
-
- case GL_LUMINANCE_SNORM:
- return GL_LUMINANCE8_SNORM;
+ /* GL 1.1 formats. */
+ case 4:
+ case GL_RGBA:
+ return GL_RGBA8;
+ case 3:
+ case GL_RGB:
+ return GL_RGB8;
+ case 2:
+ case GL_LUMINANCE_ALPHA:
+ return GL_LUMINANCE8_ALPHA8;
+ case 1:
+ case GL_LUMINANCE:
+ return GL_LUMINANCE8;
+ case GL_ALPHA:
+ return GL_ALPHA8;
+ case GL_INTENSITY:
+ return GL_INTENSITY8;
- case GL_ALPHA_SNORM:
- return GL_ALPHA8_SNORM;
+ /* GL_ARB_texture_rg */
+ case GL_RED:
+ return GL_R8;
+ case GL_RG:
+ return GL_RG8;
- case GL_INTENSITY_SNORM:
- return GL_INTENSITY8_SNORM;
+ /* GL_EXT_texture_sRGB */
+ case GL_SRGB:
+ return GL_SRGB8;
+ case GL_SRGB_ALPHA:
+ return GL_SRGB8_ALPHA8;
+ case GL_SLUMINANCE:
+ return GL_SLUMINANCE8;
+ case GL_SLUMINANCE_ALPHA:
+ return GL_SLUMINANCE8_ALPHA8;
+
+ /* GL_EXT_texture_snorm */
+ case GL_RGBA_SNORM:
+ return GL_RGBA8_SNORM;
+ case GL_RGB_SNORM:
+ return GL_RGB8_SNORM;
+ case GL_RG_SNORM:
+ return GL_RG8_SNORM;
+ case GL_RED_SNORM:
+ return GL_R8_SNORM;
+ case GL_LUMINANCE_ALPHA_SNORM:
+ return GL_LUMINANCE8_ALPHA8_SNORM;
+ case GL_LUMINANCE_SNORM:
+ return GL_LUMINANCE8_SNORM;
+ case GL_ALPHA_SNORM:
+ return GL_ALPHA8_SNORM;
+ case GL_INTENSITY_SNORM:
+ return GL_INTENSITY8_SNORM;
- default:
- return format;
+ default:
+ return format;
}
}
@@ -1219,22 +1203,20 @@ _mesa_get_linear_internalformat(GLenum format)
switch (format) {
case GL_SRGB:
return GL_RGB;
-
case GL_SRGB_ALPHA:
return GL_RGBA;
-
case GL_SRGB8:
return GL_RGB8;
-
case GL_SRGB8_ALPHA8:
return GL_RGBA8;
-
- case GL_SLUMINANCE:
+ case GL_SLUMINANCE8:
return GL_LUMINANCE8;
-
+ case GL_SLUMINANCE:
+ return GL_LUMINANCE;
case GL_SLUMINANCE_ALPHA:
+ return GL_LUMINANCE_ALPHA;
+ case GL_SLUMINANCE8_ALPHA8:
return GL_LUMINANCE8_ALPHA8;
-
default:
return format;
}
diff --git a/mesalib/src/mesa/main/macros.h b/mesalib/src/mesa/main/macros.h
index 379f75663..dafeaa372 100644
--- a/mesalib/src/mesa/main/macros.h
+++ b/mesalib/src/mesa/main/macros.h
@@ -809,5 +809,7 @@ DIFFERENT_SIGNS(GLfloat x, GLfloat y)
/* Compute the size of an array */
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+/* Stringify */
+#define STRINGIFY(x) #x
#endif
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index 33df682cf..9ab2de026 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -235,6 +235,7 @@ typedef enum
VARYING_SLOT_CLIP_DIST1,
VARYING_SLOT_PRIMITIVE_ID, /* Does not appear in VS */
VARYING_SLOT_LAYER, /* Appears as VS or GS output */
+ VARYING_SLOT_VIEWPORT, /* Appears as VS or GS output */
VARYING_SLOT_FACE, /* FS only */
VARYING_SLOT_PNTC, /* FS only */
VARYING_SLOT_VAR0, /* First generic varying slot */
@@ -270,6 +271,7 @@ typedef enum
#define VARYING_BIT_CLIP_DIST1 BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST1)
#define VARYING_BIT_PRIMITIVE_ID BITFIELD64_BIT(VARYING_SLOT_PRIMITIVE_ID)
#define VARYING_BIT_LAYER BITFIELD64_BIT(VARYING_SLOT_LAYER)
+#define VARYING_BIT_VIEWPORT BITFIELD64_BIT(VARYING_SLOT_VIEWPORT)
#define VARYING_BIT_FACE BITFIELD64_BIT(VARYING_SLOT_FACE)
#define VARYING_BIT_PNTC BITFIELD64_BIT(VARYING_SLOT_PNTC)
#define VARYING_BIT_VAR(V) BITFIELD64_BIT(VARYING_SLOT_VAR0 + (V))
@@ -1009,12 +1011,16 @@ struct gl_polygon_attrib
/**
* Scissor attributes (GL_SCISSOR_BIT).
*/
-struct gl_scissor_attrib
+struct gl_scissor_rect
{
- GLboolean Enabled; /**< Scissor test enabled? */
GLint X, Y; /**< Lower left corner of box */
GLsizei Width, Height; /**< Size of box */
};
+struct gl_scissor_attrib
+{
+ GLbitfield EnableFlags; /**< Scissor test enabled? */
+ struct gl_scissor_rect ScissorArray[MAX_VIEWPORTS];
+};
/**
@@ -1428,9 +1434,9 @@ struct gl_transform_attrib
*/
struct gl_viewport_attrib
{
- GLint X, Y; /**< position */
- GLsizei Width, Height; /**< size */
- GLfloat Near, Far; /**< Depth buffer range */
+ GLfloat X, Y; /**< position */
+ GLfloat Width, Height; /**< size */
+ GLdouble Near, Far; /**< Depth buffer range */
GLmatrix _WindowMap; /**< Mapping transformation as a matrix. */
};
@@ -1809,7 +1815,9 @@ struct gl_transform_feedback_object
/**
* The shader program active when BeginTransformFeedback() was called.
- * When active and unpaused, this equals ctx->Shader.CurrentVertexProgram.
+ * When active and unpaused, this equals ctx->Shader.CurrentProgram[stage],
+ * where stage is the pipeline stage that is the source of data for
+ * transform feedback.
*/
struct gl_shader_program *shader_program;
@@ -2708,9 +2716,7 @@ struct gl_shader_state
* GL_EXT_separate_shader_objects is not supported, each of these must point
* to \c NULL or to the same program.
*/
- struct gl_shader_program *CurrentVertexProgram;
- struct gl_shader_program *CurrentGeometryProgram;
- struct gl_shader_program *CurrentFragmentProgram;
+ struct gl_shader_program *CurrentProgram[MESA_SHADER_STAGES];
struct gl_shader_program *_CurrentFragmentProgram;
@@ -2754,10 +2760,13 @@ struct gl_shader_compiler_options
GLuint MaxUnrollIterations;
/**
- * Prefer DP4 instructions (rather than MUL/MAD) for matrix * vector
- * operations, such as position transformation.
+ * Optimize code for array of structures backends.
+ *
+ * This is a proxy for:
+ * - preferring DP4 instructions (rather than MUL/MAD) for
+ * matrix * vector operations, such as position transformation.
*/
- GLboolean PreferDP4;
+ GLboolean OptimizeForAOS;
struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */
};
@@ -3166,6 +3175,12 @@ struct gl_constants
GLfloat MaxSpotExponent; /**< GL_NV_light_max_exponent */
GLuint MaxViewportWidth, MaxViewportHeight;
+ GLuint MaxViewports; /**< GL_ARB_viewport_array */
+ GLuint ViewportSubpixelBits; /**< GL_ARB_viewport_array */
+ struct {
+ GLfloat Min;
+ GLfloat Max;
+ } ViewportBounds; /**< GL_ARB_viewport_array */
struct gl_program_constants Program[MESA_SHADER_STAGES];
GLuint MaxProgramMatrices;
@@ -3366,6 +3381,7 @@ struct gl_extensions
GLboolean ANGLE_texture_compression_dxt;
GLboolean ARB_ES2_compatibility;
GLboolean ARB_ES3_compatibility;
+ GLboolean ARB_arrays_of_arrays;
GLboolean ARB_base_instance;
GLboolean ARB_blend_func_extended;
GLboolean ARB_color_buffer_float;
@@ -3434,6 +3450,7 @@ struct gl_extensions
GLboolean ARB_vertex_shader;
GLboolean ARB_vertex_type_10f_11f_11f_rev;
GLboolean ARB_vertex_type_2_10_10_10_rev;
+ GLboolean ARB_viewport_array;
GLboolean EXT_blend_color;
GLboolean EXT_blend_equation_separate;
GLboolean EXT_blend_func_separate;
@@ -3764,6 +3781,9 @@ struct gl_driver_flags
/** gl_context::TransformFeedback::CurrentObject */
GLbitfield NewTransformFeedback;
+ /** gl_context::TransformFeedback::CurrentObject::shader_program */
+ GLbitfield NewTransformFeedbackProg;
+
/** gl_context::RasterDiscard */
GLbitfield NewRasterizerDiscard;
@@ -3972,7 +3992,7 @@ struct gl_context
struct gl_stencil_attrib Stencil; /**< Stencil buffer attributes */
struct gl_texture_attrib Texture; /**< Texture attributes */
struct gl_transform_attrib Transform; /**< Transformation attributes */
- struct gl_viewport_attrib Viewport; /**< Viewport attributes */
+ struct gl_viewport_attrib ViewportArray[MAX_VIEWPORTS]; /**< Viewport attributes */
/*@}*/
/** \name Client attribute stack */
diff --git a/mesalib/src/mesa/main/rastpos.c b/mesalib/src/mesa/main/rastpos.c
index 1acdb8b53..a9a6ceec0 100644
--- a/mesalib/src/mesa/main/rastpos.c
+++ b/mesalib/src/mesa/main/rastpos.c
@@ -227,8 +227,9 @@ window_pos3f(GLfloat x, GLfloat y, GLfloat z)
FLUSH_VERTICES(ctx, 0);
FLUSH_CURRENT(ctx, 0);
- z2 = CLAMP(z, 0.0F, 1.0F) * (ctx->Viewport.Far - ctx->Viewport.Near)
- + ctx->Viewport.Near;
+ z2 = CLAMP(z, 0.0F, 1.0F)
+ * (ctx->ViewportArray[0].Far - ctx->ViewportArray[0].Near)
+ + ctx->ViewportArray[0].Near;
/* set raster position */
ctx->Current.RasterPos[0] = x;
diff --git a/mesalib/src/mesa/main/scissor.c b/mesalib/src/mesa/main/scissor.c
index ac86bd591..14c8e8a6c 100644
--- a/mesalib/src/mesa/main/scissor.c
+++ b/mesalib/src/mesa/main/scissor.c
@@ -30,11 +30,37 @@
/**
+ * Set scissor rectangle data directly in ScissorArray
+ *
+ * This is an internal function that performs no error checking on the
+ * supplied data. It also does \b not call \c dd_function_table::Scissor.
+ *
+ * \sa _mesa_set_scissor
+ */
+static void
+set_scissor_no_notify(struct gl_context *ctx, unsigned idx,
+ GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ if (x == ctx->Scissor.ScissorArray[idx].X &&
+ y == ctx->Scissor.ScissorArray[idx].Y &&
+ width == ctx->Scissor.ScissorArray[idx].Width &&
+ height == ctx->Scissor.ScissorArray[idx].Height)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_SCISSOR);
+ ctx->Scissor.ScissorArray[idx].X = x;
+ ctx->Scissor.ScissorArray[idx].Y = y;
+ ctx->Scissor.ScissorArray[idx].Width = width;
+ ctx->Scissor.ScissorArray[idx].Height = height;
+}
+
+/**
* Called via glScissor
*/
void GLAPIENTRY
_mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
{
+ unsigned i;
GET_CURRENT_CONTEXT(ctx);
if (MESA_VERBOSE & VERBOSE_API)
@@ -45,7 +71,23 @@ _mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
return;
}
- _mesa_set_scissor(ctx, x, y, width, height);
+ /* The GL_ARB_viewport_array spec says:
+ *
+ * "Scissor sets the scissor rectangle for all viewports to the same
+ * values and is equivalent (assuming no errors are generated) to:
+ *
+ * for (uint i = 0; i < MAX_VIEWPORTS; i++) {
+ * ScissorIndexed(i, left, bottom, width, height);
+ * }"
+ *
+ * Set the scissor rectangle for all of the viewports supported by the
+ * implementation, but only signal the driver once at the end.
+ */
+ for (i = 0; i < ctx->Const.MaxViewports; i++)
+ set_scissor_no_notify(ctx, i, x, y, width, height);
+
+ if (ctx->Driver.Scissor)
+ ctx->Driver.Scissor(ctx);
}
@@ -63,25 +105,108 @@ _mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
* the dd_function_table::Scissor callback.
*/
void
-_mesa_set_scissor(struct gl_context *ctx,
+_mesa_set_scissor(struct gl_context *ctx, unsigned idx,
GLint x, GLint y, GLsizei width, GLsizei height)
{
- if (x == ctx->Scissor.X &&
- y == ctx->Scissor.Y &&
- width == ctx->Scissor.Width &&
- height == ctx->Scissor.Height)
+ set_scissor_no_notify(ctx, idx, x, y, width, height);
+
+ if (ctx->Driver.Scissor)
+ ctx->Driver.Scissor(ctx);
+}
+
+/**
+ * Define count scissor boxes starting at index.
+ *
+ * \param index index of first scissor records to set
+ * \param count number of scissor records to set
+ * \param x, y pointer to array of struct gl_scissor_rects
+ *
+ * \sa glScissorArrayv().
+ *
+ * Verifies the parameters and call set_scissor_no_notify to do the work.
+ */
+void GLAPIENTRY
+_mesa_ScissorArrayv(GLuint first, GLsizei count, const GLint *v)
+{
+ int i;
+ struct gl_scissor_rect *p = (struct gl_scissor_rect *) v;
+ GET_CURRENT_CONTEXT(ctx);
+
+ if ((first + count) > ctx->Const.MaxViewports) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glScissorArrayv: first (%d) + count (%d) >= MaxViewports (%d)",
+ first, count, ctx->Const.MaxViewports);
return;
+ }
- FLUSH_VERTICES(ctx, _NEW_SCISSOR);
- ctx->Scissor.X = x;
- ctx->Scissor.Y = y;
- ctx->Scissor.Width = width;
- ctx->Scissor.Height = height;
+ /* Verify width & height */
+ for (i = 0; i < count; i++) {
+ if (p[i].Width < 0 || p[i].Height < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glScissorArrayv: index (%d) width or height < 0 (%d, %d)",
+ i, p[i].Width, p[i].Height);
+ }
+ }
+
+ for (i = 0; i < count; i++)
+ set_scissor_no_notify(ctx, i + first,
+ p[i].X, p[i].Y, p[i].Width, p[i].Height);
if (ctx->Driver.Scissor)
ctx->Driver.Scissor(ctx);
}
+/**
+ * Define the scissor box.
+ *
+ * \param index index of scissor records to set
+ * \param x, y coordinates of the scissor box lower-left corner.
+ * \param width width of the scissor box.
+ * \param height height of the scissor box.
+ *
+ * Verifies the parameters call set_scissor_no_notify to do the work.
+ */
+static void
+ScissorIndexed(GLuint index, GLint left, GLint bottom,
+ GLsizei width, GLsizei height, const char *function)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "%s(%d, %d, %d, %d, %d)\n",
+ function, index, left, bottom, width, height);
+
+ if (index >= ctx->Const.MaxViewports) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s: index (%d) >= MaxViewports (%d)",
+ function, index, ctx->Const.MaxViewports);
+ return;
+ }
+
+ if (width < 0 || height < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s: index (%d) width or height < 0 (%d, %d)",
+ function, index, width, height);
+ }
+
+ set_scissor_no_notify(ctx, index, left, bottom, width, height);
+
+ if (ctx->Driver.Scissor)
+ ctx->Driver.Scissor(ctx);
+}
+
+void GLAPIENTRY
+_mesa_ScissorIndexed(GLuint index, GLint left, GLint bottom,
+ GLsizei width, GLsizei height)
+{
+ ScissorIndexed(index, left, bottom, width, height, "glScissorIndexd");
+}
+
+void GLAPIENTRY
+_mesa_ScissorIndexedv(GLuint index, const GLint *v)
+{
+ ScissorIndexed(index, v[0], v[1], v[2], v[3], "glScissorIndexdv");
+}
/**
* Initialize the context's scissor state.
@@ -90,10 +215,14 @@ _mesa_set_scissor(struct gl_context *ctx,
void
_mesa_init_scissor(struct gl_context *ctx)
{
+ unsigned i;
+
/* Scissor group */
- ctx->Scissor.Enabled = GL_FALSE;
- ctx->Scissor.X = 0;
- ctx->Scissor.Y = 0;
- ctx->Scissor.Width = 0;
- ctx->Scissor.Height = 0;
+ ctx->Scissor.EnableFlags = 0;
+
+ /* Note: ctx->Const.MaxViewports may not have been set by the driver yet,
+ * so just initialize all of them.
+ */
+ for (i = 0; i < MAX_VIEWPORTS; i++)
+ set_scissor_no_notify(ctx, i, 0, 0, 0, 0);
}
diff --git a/mesalib/src/mesa/main/scissor.h b/mesalib/src/mesa/main/scissor.h
index 0d7e2010a..5f9a9945a 100644
--- a/mesalib/src/mesa/main/scissor.h
+++ b/mesalib/src/mesa/main/scissor.h
@@ -34,9 +34,17 @@ struct gl_context;
extern void GLAPIENTRY
_mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height );
+extern void GLAPIENTRY
+_mesa_ScissorArrayv(GLuint first, GLsizei count, const GLint * v);
+
+extern void GLAPIENTRY
+_mesa_ScissorIndexed(GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height);
+
+extern void GLAPIENTRY
+_mesa_ScissorIndexedv(GLuint index, const GLint * v);
extern void
-_mesa_set_scissor(struct gl_context *ctx,
+_mesa_set_scissor(struct gl_context *ctx, unsigned idx,
GLint x, GLint y, GLsizei width, GLsizei height);
diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c
index 6042fa896..61ac0e35a 100644
--- a/mesalib/src/mesa/main/shaderapi.c
+++ b/mesalib/src/mesa/main/shaderapi.c
@@ -130,11 +130,11 @@ _mesa_init_shader_state(struct gl_context *ctx)
void
_mesa_free_shader_state(struct gl_context *ctx)
{
- _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentVertexProgram, NULL);
- _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentGeometryProgram,
- NULL);
- _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentFragmentProgram,
- NULL);
+ int i;
+ for (i = 0; i < MESA_SHADER_STAGES; i++) {
+ _mesa_reference_shader_program(ctx, &ctx->Shader.CurrentProgram[i],
+ NULL);
+ }
_mesa_reference_shader_program(ctx, &ctx->Shader._CurrentFragmentProgram,
NULL);
_mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, NULL);
@@ -171,16 +171,23 @@ _mesa_copy_string(GLchar *dst, GLsizei maxLength,
* \param type Shader target
*
*/
-static bool
-validate_shader_target(const struct gl_context *ctx, GLenum type)
-{
+bool
+_mesa_validate_shader_target(const struct gl_context *ctx, GLenum type)
+{
+ /* Note: when building built-in GLSL functions, this function may be
+ * invoked with ctx == NULL. In that case, we can only validate that it's
+ * a shader target we recognize, not that it's supported in the current
+ * context. But that's fine--we don't need any further validation than
+ * that when building built-in GLSL functions.
+ */
+
switch (type) {
case GL_FRAGMENT_SHADER:
- return ctx->Extensions.ARB_fragment_shader;
+ return ctx == NULL || ctx->Extensions.ARB_fragment_shader;
case GL_VERTEX_SHADER:
- return ctx->Extensions.ARB_vertex_shader;
+ return ctx == NULL || ctx->Extensions.ARB_vertex_shader;
case GL_GEOMETRY_SHADER_ARB:
- return _mesa_has_geometry_shaders(ctx);
+ return ctx == NULL || _mesa_has_geometry_shaders(ctx);
default:
return false;
}
@@ -273,7 +280,7 @@ create_shader(struct gl_context *ctx, GLenum type)
struct gl_shader *sh;
GLuint name;
- if (!validate_shader_target(ctx, type)) {
+ if (!_mesa_validate_shader_target(ctx, type)) {
_mesa_error(ctx, GL_INVALID_ENUM, "CreateShader(type)");
return 0;
}
@@ -939,32 +946,11 @@ use_shader_program(struct gl_context *ctx, GLenum type,
struct gl_shader_program *shProg)
{
struct gl_shader_program **target;
+ gl_shader_stage stage = _mesa_shader_enum_to_shader_stage(type);
- switch (type) {
- case GL_VERTEX_SHADER:
- target = &ctx->Shader.CurrentVertexProgram;
- if ((shProg == NULL)
- || (shProg->_LinkedShaders[MESA_SHADER_VERTEX] == NULL)) {
- shProg = NULL;
- }
- break;
- case GL_GEOMETRY_SHADER_ARB:
- target = &ctx->Shader.CurrentGeometryProgram;
- if ((shProg == NULL)
- || (shProg->_LinkedShaders[MESA_SHADER_GEOMETRY] == NULL)) {
- shProg = NULL;
- }
- break;
- case GL_FRAGMENT_SHADER:
- target = &ctx->Shader.CurrentFragmentProgram;
- if ((shProg == NULL)
- || (shProg->_LinkedShaders[MESA_SHADER_FRAGMENT] == NULL)) {
- shProg = NULL;
- }
- break;
- default:
- return;
- }
+ target = &ctx->Shader.CurrentProgram[stage];
+ if ((shProg == NULL) || (shProg->_LinkedShaders[stage] == NULL))
+ shProg = NULL;
if (*target != shProg) {
FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
@@ -1739,7 +1725,7 @@ _mesa_UseShaderProgramEXT(GLenum type, GLuint program)
GET_CURRENT_CONTEXT(ctx);
struct gl_shader_program *shProg = NULL;
- if (!validate_shader_target(ctx, type)) {
+ if (!_mesa_validate_shader_target(ctx, type)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glUseShaderProgramEXT(type)");
return;
}
diff --git a/mesalib/src/mesa/main/shaderapi.h b/mesalib/src/mesa/main/shaderapi.h
index 4822e32c2..10f810caf 100644
--- a/mesalib/src/mesa/main/shaderapi.h
+++ b/mesalib/src/mesa/main/shaderapi.h
@@ -215,6 +215,9 @@ _mesa_copy_linked_program_data(gl_shader_stage type,
const struct gl_shader_program *src,
struct gl_program *dst);
+extern bool
+_mesa_validate_shader_target(const struct gl_context *ctx, GLenum type);
+
#ifdef __cplusplus
}
diff --git a/mesalib/src/mesa/main/shaderobj.c b/mesalib/src/mesa/main/shaderobj.c
index dc81bbc77..4f4bb69a8 100644
--- a/mesalib/src/mesa/main/shaderobj.c
+++ b/mesalib/src/mesa/main/shaderobj.c
@@ -34,6 +34,7 @@
#include "main/context.h"
#include "main/hash.h"
#include "main/mtypes.h"
+#include "main/shaderapi.h"
#include "main/shaderobj.h"
#include "main/uniforms.h"
#include "program/program.h"
@@ -105,8 +106,7 @@ struct gl_shader *
_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type)
{
struct gl_shader *shader;
- assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER ||
- type == GL_GEOMETRY_SHADER_ARB);
+ assert(_mesa_validate_shader_target(ctx, type));
shader = rzalloc(NULL, struct gl_shader);
if (shader) {
shader->Type = type;
diff --git a/mesalib/src/mesa/main/shared.c b/mesalib/src/mesa/main/shared.c
index 2f73cf3ca..c11c7f9e9 100644
--- a/mesalib/src/mesa/main/shared.c
+++ b/mesalib/src/mesa/main/shared.c
@@ -38,6 +38,7 @@
#include "dlist.h"
#include "samplerobj.h"
#include "set.h"
+#include "shaderapi.h"
#include "shaderobj.h"
#include "syncobj.h"
@@ -218,8 +219,7 @@ delete_shader_cb(GLuint id, void *data, void *userData)
{
struct gl_context *ctx = (struct gl_context *) userData;
struct gl_shader *sh = (struct gl_shader *) data;
- if (sh->Type == GL_FRAGMENT_SHADER || sh->Type == GL_VERTEX_SHADER ||
- sh->Type == GL_GEOMETRY_SHADER) {
+ if (_mesa_validate_shader_target(ctx, sh->Type)) {
ctx->Driver.DeleteShader(ctx, sh);
}
else {
diff --git a/mesalib/src/mesa/main/state.c b/mesalib/src/mesa/main/state.c
index 33070b7e0..bdebbc141 100644
--- a/mesalib/src/mesa/main/state.c
+++ b/mesalib/src/mesa/main/state.c
@@ -94,9 +94,12 @@ update_program_enables(struct gl_context *ctx)
static GLbitfield
update_program(struct gl_context *ctx)
{
- const struct gl_shader_program *vsProg = ctx->Shader.CurrentVertexProgram;
- const struct gl_shader_program *gsProg = ctx->Shader.CurrentGeometryProgram;
- struct gl_shader_program *fsProg = ctx->Shader.CurrentFragmentProgram;
+ const struct gl_shader_program *vsProg =
+ ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX];
+ const struct gl_shader_program *gsProg =
+ ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY];
+ struct gl_shader_program *fsProg =
+ ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT];
const struct gl_vertex_program *prevVP = ctx->VertexProgram._Current;
const struct gl_fragment_program *prevFP = ctx->FragmentProgram._Current;
const struct gl_geometry_program *prevGP = ctx->GeometryProgram._Current;
@@ -269,6 +272,7 @@ static void
update_viewport_matrix(struct gl_context *ctx)
{
const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF;
+ unsigned i;
ASSERT(depthMax > 0);
@@ -276,11 +280,13 @@ update_viewport_matrix(struct gl_context *ctx)
* and should be maintained elsewhere if at all.
* NOTE: RasterPos uses this.
*/
- _math_matrix_viewport(&ctx->Viewport._WindowMap,
- ctx->Viewport.X, ctx->Viewport.Y,
- ctx->Viewport.Width, ctx->Viewport.Height,
- ctx->Viewport.Near, ctx->Viewport.Far,
- depthMax);
+ for (i = 0; i < ctx->Const.MaxViewports; i++) {
+ _math_matrix_viewport(&ctx->ViewportArray[i]._WindowMap,
+ ctx->ViewportArray[i].X, ctx->ViewportArray[i].Y,
+ ctx->ViewportArray[i].Width, ctx->ViewportArray[i].Height,
+ ctx->ViewportArray[i].Near, ctx->ViewportArray[i].Far,
+ depthMax);
+ }
}
@@ -304,7 +310,7 @@ update_multisample(struct gl_context *ctx)
static void
update_twoside(struct gl_context *ctx)
{
- if (ctx->Shader.CurrentVertexProgram ||
+ if (ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX] ||
ctx->VertexProgram._Enabled) {
ctx->VertexProgram._TwoSideEnabled = ctx->VertexProgram.TwoSideEnabled;
} else {
diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c
index 3c64c4376..5d516c55f 100644
--- a/mesalib/src/mesa/main/texobj.c
+++ b/mesalib/src/mesa/main/texobj.c
@@ -1104,10 +1104,10 @@ unbind_texobj_from_texunits(struct gl_context *ctx,
* and unbind it if that's the case.
*/
static void
-unbind_texobj_from_imgunits(struct gl_context *ctx,
- struct gl_texture_object *texObj)
+unbind_texobj_from_image_units(struct gl_context *ctx,
+ struct gl_texture_object *texObj)
{
- int i;
+ GLuint i;
for (i = 0; i < ctx->Const.MaxImageUnits; i++) {
struct gl_image_unit *unit = &ctx->ImageUnits[i];
@@ -1169,7 +1169,7 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures)
* image unit. If so, unbind it.
* See section 3.9.X of GL_ARB_shader_image_load_store.
*/
- unbind_texobj_from_imgunits(ctx, delObj);
+ unbind_texobj_from_image_units(ctx, delObj);
_mesa_unlock_texture(ctx, delObj);
diff --git a/mesalib/src/mesa/main/texstate.c b/mesalib/src/mesa/main/texstate.c
index 7720965a8..08725f601 100644
--- a/mesalib/src/mesa/main/texstate.c
+++ b/mesalib/src/mesa/main/texstate.c
@@ -527,27 +527,20 @@ static void
update_texture_state( struct gl_context *ctx )
{
GLuint unit;
- struct gl_program *fprog = NULL;
- struct gl_program *vprog = NULL;
- struct gl_program *gprog = NULL;
+ struct gl_program *prog[MESA_SHADER_STAGES];
GLbitfield enabledFragUnits = 0x0;
-
- if (ctx->Shader.CurrentVertexProgram &&
- ctx->Shader.CurrentVertexProgram->LinkStatus) {
- vprog = ctx->Shader.CurrentVertexProgram->_LinkedShaders[MESA_SHADER_VERTEX]->Program;
- }
-
- if (ctx->Shader.CurrentGeometryProgram &&
- ctx->Shader.CurrentGeometryProgram->LinkStatus) {
- gprog = ctx->Shader.CurrentGeometryProgram->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program;
- }
-
- if (ctx->Shader.CurrentFragmentProgram &&
- ctx->Shader.CurrentFragmentProgram->LinkStatus) {
- fprog = ctx->Shader.CurrentFragmentProgram->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program;
- }
- else if (ctx->FragmentProgram._Enabled) {
- fprog = &ctx->FragmentProgram.Current->Base;
+ int i;
+
+ for (i = 0; i < MESA_SHADER_STAGES; i++) {
+ if (ctx->Shader.CurrentProgram[i] &&
+ ctx->Shader.CurrentProgram[i]->LinkStatus) {
+ prog[i] = ctx->Shader.CurrentProgram[i]->_LinkedShaders[i]->Program;
+ } else {
+ if (i == MESA_SHADER_FRAGMENT && ctx->FragmentProgram._Enabled)
+ prog[i] = &ctx->FragmentProgram.Current->Base;
+ else
+ prog[i] = NULL;
+ }
}
/* TODO: only set this if there are actual changes */
@@ -563,9 +556,7 @@ update_texture_state( struct gl_context *ctx )
*/
for (unit = 0; unit < ctx->Const.MaxCombinedTextureImageUnits; unit++) {
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
- GLbitfield enabledVertTargets = 0x0;
- GLbitfield enabledFragTargets = 0x0;
- GLbitfield enabledGeomTargets = 0x0;
+ GLbitfield enabledTargetsByStage[MESA_SHADER_STAGES];
GLbitfield enabledTargets = 0x0;
GLuint texIndex;
@@ -575,25 +566,16 @@ update_texture_state( struct gl_context *ctx )
* by a fragment program/program. When multiple flags are set, we'll
* settle on the one with highest priority (see below).
*/
- if (vprog) {
- enabledVertTargets |= vprog->TexturesUsed[unit];
+ for (i = 0; i < MESA_SHADER_STAGES; i++) {
+ if (prog[i])
+ enabledTargetsByStage[i] = prog[i]->TexturesUsed[unit];
+ else if (i == MESA_SHADER_FRAGMENT)
+ enabledTargetsByStage[i] = texUnit->Enabled;
+ else
+ enabledTargetsByStage[i] = 0;
+ enabledTargets |= enabledTargetsByStage[i];
}
- if (gprog) {
- enabledGeomTargets |= gprog->TexturesUsed[unit];
- }
-
- if (fprog) {
- enabledFragTargets |= fprog->TexturesUsed[unit];
- }
- else {
- /* fixed-function fragment program */
- enabledFragTargets |= texUnit->Enabled;
- }
-
- enabledTargets = enabledVertTargets | enabledFragTargets |
- enabledGeomTargets;
-
texUnit->_ReallyEnabled = 0x0;
if (enabledTargets == 0x0) {
@@ -625,7 +607,7 @@ update_texture_state( struct gl_context *ctx )
}
if (!texUnit->_ReallyEnabled) {
- if (fprog) {
+ if (prog[MESA_SHADER_FRAGMENT]) {
/* If we get here it means the shader is expecting a texture
* object, but there isn't one (or it's incomplete). Use the
* fallback texture.
@@ -655,25 +637,26 @@ update_texture_state( struct gl_context *ctx )
ctx->Texture._EnabledUnits |= (1 << unit);
- if (enabledFragTargets)
+ if (enabledTargetsByStage[MESA_SHADER_FRAGMENT])
enabledFragUnits |= (1 << unit);
- if (!fprog)
+ if (!prog[MESA_SHADER_FRAGMENT])
update_tex_combine(ctx, texUnit);
}
/* Determine which texture coordinate sets are actually needed */
- if (fprog) {
+ if (prog[MESA_SHADER_FRAGMENT]) {
const GLuint coordMask = (1 << MAX_TEXTURE_COORD_UNITS) - 1;
ctx->Texture._EnabledCoordUnits
- = (fprog->InputsRead >> VARYING_SLOT_TEX0) & coordMask;
+ = (prog[MESA_SHADER_FRAGMENT]->InputsRead >> VARYING_SLOT_TEX0) &
+ coordMask;
}
else {
ctx->Texture._EnabledCoordUnits = enabledFragUnits;
}
- if (!fprog || !vprog)
+ if (!prog[MESA_SHADER_FRAGMENT] || !prog[MESA_SHADER_VERTEX])
update_texgen(ctx);
_mesa_validate_image_units(ctx);
diff --git a/mesalib/src/mesa/main/texstorage.c b/mesalib/src/mesa/main/texstorage.c
index 5062fdb4f..22208572f 100644
--- a/mesalib/src/mesa/main/texstorage.c
+++ b/mesalib/src/mesa/main/texstorage.c
@@ -244,6 +244,10 @@ _mesa_alloc_texture_storage(struct gl_context *ctx,
int face;
int level;
+ (void) width;
+ (void) height;
+ (void) depth;
+
for (face = 0; face < numFaces; face++) {
for (level = 0; level < levels; level++) {
struct gl_texture_image *const texImage = texObj->Image[face][level];
@@ -460,7 +464,16 @@ _mesa_TextureStorage1DEXT(GLuint texture, GLenum target, GLsizei levels,
GLenum internalformat,
GLsizei width)
{
- /* no-op */
+ GET_CURRENT_CONTEXT(ctx);
+
+ (void) texture;
+ (void) target;
+ (void) levels;
+ (void) internalformat;
+ (void) width;
+
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureStorage1DEXT not supported");
}
@@ -469,7 +482,17 @@ _mesa_TextureStorage2DEXT(GLuint texture, GLenum target, GLsizei levels,
GLenum internalformat,
GLsizei width, GLsizei height)
{
- /* no-op */
+ GET_CURRENT_CONTEXT(ctx);
+
+ (void) texture;
+ (void) target;
+ (void) levels;
+ (void) internalformat;
+ (void) width;
+ (void) height;
+
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureStorage2DEXT not supported");
}
@@ -479,5 +502,16 @@ _mesa_TextureStorage3DEXT(GLuint texture, GLenum target, GLsizei levels,
GLenum internalformat,
GLsizei width, GLsizei height, GLsizei depth)
{
- /* no-op */
+ GET_CURRENT_CONTEXT(ctx);
+
+ (void) texture;
+ (void) target;
+ (void) levels;
+ (void) internalformat;
+ (void) width;
+ (void) height;
+ (void) depth;
+
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureStorage3DEXT not supported");
}
diff --git a/mesalib/src/mesa/main/transformfeedback.c b/mesalib/src/mesa/main/transformfeedback.c
index 76d213b16..6b9565ca3 100644
--- a/mesalib/src/mesa/main/transformfeedback.c
+++ b/mesalib/src/mesa/main/transformfeedback.c
@@ -24,7 +24,7 @@
/*
- * Vertex transform feedback support.
+ * Transform feedback support.
*
* Authors:
* Brian Paul
@@ -376,24 +376,48 @@ _mesa_compute_max_transform_feedback_vertices(
**/
+/**
+ * Figure out which stage of the pipeline is the source of transform feedback
+ * data given the current context state, and return its gl_shader_program.
+ *
+ * If no active program can generate transform feedback data (i.e. no vertex
+ * shader is active), returns NULL.
+ */
+static struct gl_shader_program *
+get_xfb_source(struct gl_context *ctx)
+{
+ int i;
+ for (i = MESA_SHADER_GEOMETRY; i >= MESA_SHADER_VERTEX; i--) {
+ if (ctx->Shader.CurrentProgram[i] != NULL)
+ return ctx->Shader.CurrentProgram[i];
+ }
+ return NULL;
+}
+
+
void GLAPIENTRY
_mesa_BeginTransformFeedback(GLenum mode)
{
struct gl_transform_feedback_object *obj;
- struct gl_transform_feedback_info *info;
+ struct gl_transform_feedback_info *info = NULL;
+ struct gl_shader_program *source;
GLuint i;
unsigned vertices_per_prim;
GET_CURRENT_CONTEXT(ctx);
obj = ctx->TransformFeedback.CurrentObject;
- if (ctx->Shader.CurrentVertexProgram == NULL) {
+ /* Figure out what pipeline stage is the source of data for transform
+ * feedback.
+ */
+ source = get_xfb_source(ctx);
+ if (source == NULL) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glBeginTransformFeedback(no program active)");
return;
}
- info = &ctx->Shader.CurrentVertexProgram->LinkedTransformFeedback;
+ info = &source->LinkedTransformFeedback;
if (info->NumOutputs == 0) {
_mesa_error(ctx, GL_INVALID_OPERATION,
@@ -451,7 +475,10 @@ _mesa_BeginTransformFeedback(GLenum mode)
obj->GlesRemainingPrims = max_vertices / vertices_per_prim;
}
- obj->shader_program = ctx->Shader.CurrentVertexProgram;
+ if (obj->shader_program != source) {
+ ctx->NewDriverState |= ctx->DriverFlags.NewTransformFeedbackProg;
+ obj->shader_program = source;
+ }
assert(ctx->Driver.BeginTransformFeedback);
ctx->Driver.BeginTransformFeedback(ctx, mode, obj);
@@ -518,7 +545,7 @@ bind_buffer_range(struct gl_context *ctx, GLuint index,
/**
- * Specify a buffer object to receive vertex shader results. Plus,
+ * Specify a buffer object to receive transform feedback results. Plus,
* specify the starting offset to place the results, and max size.
* Called from the glBindBufferRange() function.
*/
@@ -562,7 +589,7 @@ _mesa_bind_buffer_range_transform_feedback(struct gl_context *ctx,
/**
- * Specify a buffer object to receive vertex shader results.
+ * Specify a buffer object to receive transform feedback results.
* As above, but start at offset = 0.
* Called from the glBindBufferBase() function.
*/
@@ -591,7 +618,7 @@ _mesa_bind_buffer_base_transform_feedback(struct gl_context *ctx,
/**
- * Specify a buffer object to receive vertex shader results, plus the
+ * Specify a buffer object to receive transform feedback results, plus the
* offset in the buffer to start placing results.
* This function is part of GL_EXT_transform_feedback, but not GL3.
*/
@@ -646,7 +673,7 @@ _mesa_BindBufferOffsetEXT(GLenum target, GLuint index, GLuint buffer,
/**
- * This function specifies the vertex shader outputs to be written
+ * This function specifies the transform feedback outputs to be written
* to the feedback buffer(s), and in what order.
*/
void GLAPIENTRY
@@ -756,7 +783,7 @@ _mesa_TransformFeedbackVaryings(GLuint program, GLsizei count,
/**
- * Get info about the vertex shader's outputs which are to be written
+ * Get info about the transform feedback outputs which are to be written
* to the feedback buffer(s).
*/
void GLAPIENTRY
@@ -993,9 +1020,9 @@ _mesa_ResumeTransformFeedback(void)
* the program object being used by the current transform feedback object
* is not active."
*/
- if (obj->shader_program != ctx->Shader.CurrentVertexProgram) {
+ if (obj->shader_program != get_xfb_source(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glResumeTransformFeedback(wrong vertex program bound)");
+ "glResumeTransformFeedback(wrong program bound)");
return;
}
diff --git a/mesalib/src/mesa/main/viewport.c b/mesalib/src/mesa/main/viewport.c
index 3aaab2d46..6545bf68a 100644
--- a/mesalib/src/mesa/main/viewport.c
+++ b/mesalib/src/mesa/main/viewport.c
@@ -34,6 +34,60 @@
#include "mtypes.h"
#include "viewport.h"
+static void
+set_viewport_no_notify(struct gl_context *ctx, unsigned idx,
+ GLfloat x, GLfloat y,
+ GLfloat width, GLfloat height)
+{
+ /* clamp width and height to the implementation dependent range */
+ width = MIN2(width, (GLfloat) ctx->Const.MaxViewportWidth);
+ height = MIN2(height, (GLfloat) ctx->Const.MaxViewportHeight);
+
+ /* The GL_ARB_viewport_array spec says:
+ *
+ * "The location of the viewport's bottom-left corner, given by (x,y),
+ * are clamped to be within the implementation-dependent viewport
+ * bounds range. The viewport bounds range [min, max] tuple may be
+ * determined by calling GetFloatv with the symbolic constant
+ * VIEWPORT_BOUNDS_RANGE (see section 6.1)."
+ */
+ if (ctx->Extensions.ARB_viewport_array) {
+ x = CLAMP(x,
+ ctx->Const.ViewportBounds.Min, ctx->Const.ViewportBounds.Max);
+ y = CLAMP(y,
+ ctx->Const.ViewportBounds.Min, ctx->Const.ViewportBounds.Max);
+ }
+
+ ctx->ViewportArray[idx].X = x;
+ ctx->ViewportArray[idx].Width = width;
+ ctx->ViewportArray[idx].Y = y;
+ ctx->ViewportArray[idx].Height = height;
+ ctx->NewState |= _NEW_VIEWPORT;
+
+#if 1
+ /* XXX remove this someday. Currently the DRI drivers rely on
+ * the WindowMap matrix being up to date in the driver's Viewport
+ * and DepthRange functions.
+ */
+ _math_matrix_viewport(&ctx->ViewportArray[idx]._WindowMap,
+ ctx->ViewportArray[idx].X,
+ ctx->ViewportArray[idx].Y,
+ ctx->ViewportArray[idx].Width,
+ ctx->ViewportArray[idx].Height,
+ ctx->ViewportArray[idx].Near,
+ ctx->ViewportArray[idx].Far,
+ ctx->DrawBuffer->_DepthMaxF);
+#endif
+}
+
+struct gl_viewport_inputs {
+ GLfloat X, Y; /**< position */
+ GLfloat Width, Height; /**< size */
+};
+
+struct gl_depthrange_inputs {
+ GLdouble Near, Far; /**< Depth buffer range */
+};
/**
* Set the viewport.
@@ -45,9 +99,39 @@
void GLAPIENTRY
_mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
{
+ unsigned i;
GET_CURRENT_CONTEXT(ctx);
FLUSH_VERTICES(ctx, 0);
- _mesa_set_viewport(ctx, x, y, width, height);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glViewport %d %d %d %d\n", x, y, width, height);
+
+ if (width < 0 || height < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glViewport(%d, %d, %d, %d)", x, y, width, height);
+ return;
+ }
+
+ /* The GL_ARB_viewport_array spec says:
+ *
+ * "Viewport sets the parameters for all viewports to the same values
+ * and is equivalent (assuming no errors are generated) to:
+ *
+ * for (uint i = 0; i < MAX_VIEWPORTS; i++)
+ * ViewportIndexedf(i, 1, (float)x, (float)y, (float)w, (float)h);"
+ *
+ * Set all of the viewports supported by the implementation, but only
+ * signal the driver once at the end.
+ */
+ for (i = 0; i < ctx->Const.MaxViewports; i++)
+ set_viewport_no_notify(ctx, i, x, y, width, height);
+
+ if (ctx->Driver.Viewport) {
+ /* Many drivers will use this call to check for window size changes
+ * and reallocate the z/stencil/accum/etc buffers if needed.
+ */
+ ctx->Driver.Viewport(ctx);
+ }
}
@@ -56,31 +140,114 @@ _mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
* matrix). Usually called from _mesa_Viewport().
*
* \param ctx GL context.
+ * \param idx Index of the viewport to be updated.
* \param x, y coordinates of the lower left corner of the viewport rectangle.
* \param width width of the viewport rectangle.
* \param height height of the viewport rectangle.
*/
void
-_mesa_set_viewport(struct gl_context *ctx, GLint x, GLint y,
- GLsizei width, GLsizei height)
+_mesa_set_viewport(struct gl_context *ctx, unsigned idx, GLfloat x, GLfloat y,
+ GLfloat width, GLfloat height)
{
+ set_viewport_no_notify(ctx, idx, x, y, width, height);
+
+ if (ctx->Driver.Viewport) {
+ /* Many drivers will use this call to check for window size changes
+ * and reallocate the z/stencil/accum/etc buffers if needed.
+ */
+ ctx->Driver.Viewport(ctx);
+ }
+}
+
+void GLAPIENTRY
+_mesa_ViewportArrayv(GLuint first, GLsizei count, const GLfloat *v)
+{
+ int i;
+ const struct gl_viewport_inputs *const p = (struct gl_viewport_inputs *) v;
+ GET_CURRENT_CONTEXT(ctx);
+
if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(ctx, "glViewport %d %d %d %d\n", x, y, width, height);
+ _mesa_debug(ctx, "glViewportArrayv %d %d\n", first, count);
- if (width < 0 || height < 0) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glViewport(%d, %d, %d, %d)", x, y, width, height);
+ if ((first + count) > ctx->Const.MaxViewports) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glViewportArrayv: first (%d) + count (%d) > MaxViewports "
+ "(%d)",
+ first, count, ctx->Const.MaxViewports);
return;
}
- /* clamp width and height to the implementation dependent range */
- width = MIN2(width, (GLsizei) ctx->Const.MaxViewportWidth);
- height = MIN2(height, (GLsizei) ctx->Const.MaxViewportHeight);
+ /* Verify width & height */
+ for (i = 0; i < count; i++) {
+ if (p[i].Width < 0 || p[i].Height < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glViewportArrayv: index (%d) width or height < 0 "
+ "(%f, %f)",
+ i + first, p[i].Width, p[i].Height);
+ return;
+ }
+ }
+
+ for (i = 0; i < count; i++)
+ set_viewport_no_notify(ctx, i + first,
+ p[i].X, p[i].Y,
+ p[i].Width, p[i].Height);
+
+ if (ctx->Driver.Viewport)
+ ctx->Driver.Viewport(ctx);
+}
- ctx->Viewport.X = x;
- ctx->Viewport.Width = width;
- ctx->Viewport.Y = y;
- ctx->Viewport.Height = height;
+static void
+ViewportIndexedf(GLuint index, GLfloat x, GLfloat y,
+ GLfloat w, GLfloat h, const char *function)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "%s(%d, %f, %f, %f, %f)\n",
+ function, index, x, y, w, h);
+
+ if (index >= ctx->Const.MaxViewports) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s: index (%d) >= MaxViewports (%d)",
+ function, index, ctx->Const.MaxViewports);
+ return;
+ }
+
+ /* Verify width & height */
+ if (w < 0 || h < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s: index (%d) width or height < 0 (%f, %f)",
+ function, index, w, h);
+ return;
+ }
+
+ _mesa_set_viewport(ctx, index, x, y, w, h);
+}
+
+void GLAPIENTRY
+_mesa_ViewportIndexedf(GLuint index, GLfloat x, GLfloat y,
+ GLfloat w, GLfloat h)
+{
+ ViewportIndexedf(index, x, y, w, h, "glViewportIndexedf");
+}
+
+void GLAPIENTRY
+_mesa_ViewportIndexedfv(GLuint index, const GLfloat *v)
+{
+ ViewportIndexedf(index, v[0], v[1], v[2], v[3], "glViewportIndexedfv");
+}
+
+static void
+set_depth_range_no_notify(struct gl_context *ctx, unsigned idx,
+ GLclampd nearval, GLclampd farval)
+{
+ if (ctx->ViewportArray[idx].Near == nearval &&
+ ctx->ViewportArray[idx].Far == farval)
+ return;
+
+ ctx->ViewportArray[idx].Near = CLAMP(nearval, 0.0, 1.0);
+ ctx->ViewportArray[idx].Far = CLAMP(farval, 0.0, 1.0);
ctx->NewState |= _NEW_VIEWPORT;
#if 1
@@ -88,21 +255,26 @@ _mesa_set_viewport(struct gl_context *ctx, GLint x, GLint y,
* the WindowMap matrix being up to date in the driver's Viewport
* and DepthRange functions.
*/
- _math_matrix_viewport(&ctx->Viewport._WindowMap,
- ctx->Viewport.X, ctx->Viewport.Y,
- ctx->Viewport.Width, ctx->Viewport.Height,
- ctx->Viewport.Near, ctx->Viewport.Far,
+ _math_matrix_viewport(&ctx->ViewportArray[idx]._WindowMap,
+ ctx->ViewportArray[idx].X,
+ ctx->ViewportArray[idx].Y,
+ ctx->ViewportArray[idx].Width,
+ ctx->ViewportArray[idx].Height,
+ ctx->ViewportArray[idx].Near,
+ ctx->ViewportArray[idx].Far,
ctx->DrawBuffer->_DepthMaxF);
#endif
-
- if (ctx->Driver.Viewport) {
- /* Many drivers will use this call to check for window size changes
- * and reallocate the z/stencil/accum/etc buffers if needed.
- */
- ctx->Driver.Viewport(ctx);
- }
}
+void
+_mesa_set_depth_range(struct gl_context *ctx, unsigned idx,
+ GLclampd nearval, GLclampd farval)
+{
+ set_depth_range_no_notify(ctx, idx, nearval, farval);
+
+ if (ctx->Driver.DepthRange)
+ ctx->Driver.DepthRange(ctx);
+}
/**
* Called by glDepthRange
@@ -115,6 +287,7 @@ _mesa_set_viewport(struct gl_context *ctx, GLint x, GLint y,
void GLAPIENTRY
_mesa_DepthRange(GLclampd nearval, GLclampd farval)
{
+ unsigned i;
GET_CURRENT_CONTEXT(ctx);
FLUSH_VERTICES(ctx, 0);
@@ -122,25 +295,19 @@ _mesa_DepthRange(GLclampd nearval, GLclampd farval)
if (MESA_VERBOSE&VERBOSE_API)
_mesa_debug(ctx, "glDepthRange %f %f\n", nearval, farval);
- if (ctx->Viewport.Near == nearval &&
- ctx->Viewport.Far == farval)
- return;
-
- ctx->Viewport.Near = (GLfloat) CLAMP(nearval, 0.0, 1.0);
- ctx->Viewport.Far = (GLfloat) CLAMP(farval, 0.0, 1.0);
- ctx->NewState |= _NEW_VIEWPORT;
-
-#if 1
- /* XXX remove this someday. Currently the DRI drivers rely on
- * the WindowMap matrix being up to date in the driver's Viewport
- * and DepthRange functions.
+ /* The GL_ARB_viewport_array spec says:
+ *
+ * "DepthRange sets the depth range for all viewports to the same
+ * values and is equivalent (assuming no errors are generated) to:
+ *
+ * for (uint i = 0; i < MAX_VIEWPORTS; i++)
+ * DepthRangeIndexed(i, n, f);"
+ *
+ * Set the depth range for all of the viewports supported by the
+ * implementation, but only signal the driver once at the end.
*/
- _math_matrix_viewport(&ctx->Viewport._WindowMap,
- ctx->Viewport.X, ctx->Viewport.Y,
- ctx->Viewport.Width, ctx->Viewport.Height,
- ctx->Viewport.Near, ctx->Viewport.Far,
- ctx->DrawBuffer->_DepthMaxF);
-#endif
+ for (i = 0; i < ctx->Const.MaxViewports; i++)
+ set_depth_range_no_notify(ctx, i, nearval, farval);
if (ctx->Driver.DepthRange) {
ctx->Driver.DepthRange(ctx);
@@ -153,6 +320,67 @@ _mesa_DepthRangef(GLclampf nearval, GLclampf farval)
_mesa_DepthRange(nearval, farval);
}
+/**
+ * Update a range DepthRange values
+ *
+ * \param first starting array index
+ * \param count count of DepthRange items to update
+ * \param v pointer to memory containing
+ * GLclampd near and far clip-plane values
+ */
+void GLAPIENTRY
+_mesa_DepthRangeArrayv(GLuint first, GLsizei count, const GLclampd *v)
+{
+ int i;
+ const struct gl_depthrange_inputs *const p =
+ (struct gl_depthrange_inputs *) v;
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glDepthRangeArrayv %d %d\n", first, count);
+
+ if ((first + count) > ctx->Const.MaxViewports) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glDepthRangev: first (%d) + count (%d) >= MaxViewports (%d)",
+ first, count, ctx->Const.MaxViewports);
+ return;
+ }
+
+ for (i = 0; i < count; i++)
+ set_depth_range_no_notify(ctx, i + first, p[i].Near, p[i].Far);
+
+ if (ctx->Driver.DepthRange)
+ ctx->Driver.DepthRange(ctx);
+}
+
+/**
+ * Update a single DepthRange
+ *
+ * \param index array index to update
+ * \param nearval specifies the Z buffer value which should correspond to
+ * the near clip plane
+ * \param farval specifies the Z buffer value which should correspond to
+ * the far clip plane
+ */
+void GLAPIENTRY
+_mesa_DepthRangeIndexed(GLuint index, GLclampd nearval, GLclampd farval)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glDepthRangeIndexed(%d, %f, %f)\n",
+ index, nearval, farval);
+
+ if (index >= ctx->Const.MaxViewports) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glDepthRangeIndexed: index (%d) >= MaxViewports (%d)",
+ index, ctx->Const.MaxViewports);
+ return;
+ }
+
+ _mesa_set_depth_range(ctx, index, nearval, farval);
+}
+
/**
* Initialize the context viewport attribute group.
* \param ctx the GL context.
@@ -160,18 +388,24 @@ _mesa_DepthRangef(GLclampf nearval, GLclampf farval)
void _mesa_init_viewport(struct gl_context *ctx)
{
GLfloat depthMax = 65535.0F; /* sorf of arbitrary */
+ unsigned i;
- /* Viewport group */
- ctx->Viewport.X = 0;
- ctx->Viewport.Y = 0;
- ctx->Viewport.Width = 0;
- ctx->Viewport.Height = 0;
- ctx->Viewport.Near = 0.0;
- ctx->Viewport.Far = 1.0;
- _math_matrix_ctr(&ctx->Viewport._WindowMap);
-
- _math_matrix_viewport(&ctx->Viewport._WindowMap, 0, 0, 0, 0,
- 0.0F, 1.0F, depthMax);
+ /* Note: ctx->Const.MaxViewports may not have been set by the driver yet,
+ * so just initialize all of them.
+ */
+ for (i = 0; i < MAX_VIEWPORTS; i++) {
+ /* Viewport group */
+ ctx->ViewportArray[i].X = 0;
+ ctx->ViewportArray[i].Y = 0;
+ ctx->ViewportArray[i].Width = 0;
+ ctx->ViewportArray[i].Height = 0;
+ ctx->ViewportArray[i].Near = 0.0;
+ ctx->ViewportArray[i].Far = 1.0;
+ _math_matrix_ctr(&ctx->ViewportArray[i]._WindowMap);
+
+ _math_matrix_viewport(&ctx->ViewportArray[i]._WindowMap, 0, 0, 0, 0,
+ 0.0F, 1.0F, depthMax);
+ }
}
@@ -181,6 +415,9 @@ void _mesa_init_viewport(struct gl_context *ctx)
*/
void _mesa_free_viewport_data(struct gl_context *ctx)
{
- _math_matrix_dtr(&ctx->Viewport._WindowMap);
+ unsigned i;
+
+ for (i = 0; i < MAX_VIEWPORTS; i++)
+ _math_matrix_dtr(&ctx->ViewportArray[i]._WindowMap);
}
diff --git a/mesalib/src/mesa/main/viewport.h b/mesalib/src/mesa/main/viewport.h
index ffa3a729c..f2311c02b 100644
--- a/mesalib/src/mesa/main/viewport.h
+++ b/mesalib/src/mesa/main/viewport.h
@@ -34,10 +34,18 @@ struct gl_context;
extern void GLAPIENTRY
_mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height);
+extern void GLAPIENTRY
+_mesa_ViewportArrayv(GLuint first, GLsizei count, const GLfloat * v);
+
+extern void GLAPIENTRY
+_mesa_ViewportIndexedf(GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h);
+
+extern void GLAPIENTRY
+_mesa_ViewportIndexedfv(GLuint index, const GLfloat * v);
extern void
-_mesa_set_viewport(struct gl_context *ctx, GLint x, GLint y,
- GLsizei width, GLsizei height);
+_mesa_set_viewport(struct gl_context *ctx, unsigned idx, GLfloat x, GLfloat y,
+ GLfloat width, GLfloat height);
extern void GLAPIENTRY
@@ -46,6 +54,15 @@ _mesa_DepthRange(GLclampd nearval, GLclampd farval);
extern void GLAPIENTRY
_mesa_DepthRangef(GLclampf nearval, GLclampf farval);
+extern void GLAPIENTRY
+_mesa_DepthRangeArrayv(GLuint first, GLsizei count, const GLclampd * v);
+
+extern void GLAPIENTRY
+_mesa_DepthRangeIndexed(GLuint index, GLclampd n, GLclampd f);
+
+extern void
+_mesa_set_depth_range(struct gl_context *ctx, unsigned idx,
+ GLclampd nearval, GLclampd farval);
extern void
_mesa_init_viewport(struct gl_context *ctx);
diff --git a/mesalib/src/mesa/math/m_matrix.c b/mesalib/src/mesa/math/m_matrix.c
index 274f969d2..e512e456f 100644
--- a/mesalib/src/mesa/math/m_matrix.c
+++ b/mesalib/src/mesa/math/m_matrix.c
@@ -1110,15 +1110,16 @@ _math_matrix_translate( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z )
* Transforms Normalized Device Coords to window/Z values.
*/
void
-_math_matrix_viewport(GLmatrix *m, GLint x, GLint y, GLint width, GLint height,
- GLfloat zNear, GLfloat zFar, GLfloat depthMax)
+_math_matrix_viewport(GLmatrix *m, GLfloat x, GLfloat y,
+ GLfloat width, GLfloat height,
+ GLdouble zNear, GLdouble zFar, GLdouble depthMax)
{
- m->m[MAT_SX] = (GLfloat) width / 2.0F;
+ m->m[MAT_SX] = width / 2.0F;
m->m[MAT_TX] = m->m[MAT_SX] + x;
- m->m[MAT_SY] = (GLfloat) height / 2.0F;
+ m->m[MAT_SY] = height / 2.0F;
m->m[MAT_TY] = m->m[MAT_SY] + y;
- m->m[MAT_SZ] = depthMax * ((zFar - zNear) / 2.0F);
- m->m[MAT_TZ] = depthMax * ((zFar - zNear) / 2.0F + zNear);
+ m->m[MAT_SZ] = (GLfloat) (depthMax * ((zFar - zNear) / 2.0));
+ m->m[MAT_TZ] = (GLfloat) (depthMax * ((zFar - zNear) / 2.0 + zNear));
m->flags = MAT_FLAG_GENERAL_SCALE | MAT_FLAG_TRANSLATION;
m->type = MATRIX_3D_NO_ROT;
}
diff --git a/mesalib/src/mesa/math/m_matrix.h b/mesalib/src/mesa/math/m_matrix.h
index 2b097cb31..dddce7019 100644
--- a/mesalib/src/mesa/math/m_matrix.h
+++ b/mesalib/src/mesa/math/m_matrix.h
@@ -122,8 +122,8 @@ _math_matrix_frustum( GLmatrix *mat,
GLfloat nearval, GLfloat farval );
extern void
-_math_matrix_viewport(GLmatrix *m, GLint x, GLint y, GLint width, GLint height,
- GLfloat zNear, GLfloat zFar, GLfloat depthMax);
+_math_matrix_viewport(GLmatrix *m, GLfloat x, GLfloat y, GLfloat width, GLfloat height,
+ GLdouble zNear, GLdouble zFar, GLdouble depthMax);
extern void
_math_matrix_set_identity( GLmatrix *dest );
diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp
index 85d414259..74c512b33 100644
--- a/mesalib/src/mesa/program/ir_to_mesa.cpp
+++ b/mesalib/src/mesa/program/ir_to_mesa.cpp
@@ -3053,7 +3053,7 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
_mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
linked_prog);
if (!ctx->Driver.ProgramStringNotify(ctx,
- _mesa_program_index_to_target(i),
+ _mesa_shader_stage_to_program(i),
linked_prog)) {
return GL_FALSE;
}
diff --git a/mesalib/src/mesa/program/prog_print.c b/mesalib/src/mesa/program/prog_print.c
index 9391e99ff..02ba01eca 100644
--- a/mesalib/src/mesa/program/prog_print.c
+++ b/mesalib/src/mesa/program/prog_print.c
@@ -144,8 +144,9 @@ arb_input_attrib_string(GLint index, GLenum progType)
"fragment.(eighteen)", /* VARYING_SLOT_CLIP_DIST1 */
"fragment.(nineteen)", /* VARYING_SLOT_PRIMITIVE_ID */
"fragment.(twenty)", /* VARYING_SLOT_LAYER */
- "fragment.(twenty-one)", /* VARYING_SLOT_FACE */
- "fragment.(twenty-two)", /* VARYING_SLOT_PNTC */
+ "fragment.(twenty-one)", /* VARYING_SLOT_VIEWPORT */
+ "fragment.(twenty-two)", /* VARYING_SLOT_FACE */
+ "fragment.(twenty-three)", /* VARYING_SLOT_PNTC */
"fragment.varying[0]",
"fragment.varying[1]",
"fragment.varying[2]",
@@ -268,8 +269,9 @@ arb_output_attrib_string(GLint index, GLenum progType)
"result.(eighteen)", /* VARYING_SLOT_CLIP_DIST1 */
"result.(nineteen)", /* VARYING_SLOT_PRIMITIVE_ID */
"result.(twenty)", /* VARYING_SLOT_LAYER */
- "result.(twenty-one)", /* VARYING_SLOT_FACE */
- "result.(twenty-two)", /* VARYING_SLOT_PNTC */
+ "result.(twenty-one)", /* VARYING_SLOT_VIEWPORT */
+ "result.(twenty-two)", /* VARYING_SLOT_FACE */
+ "result.(twenty-three)", /* VARYING_SLOT_PNTC */
"result.varying[0]",
"result.varying[1]",
"result.varying[2]",
diff --git a/mesalib/src/mesa/program/prog_statevars.c b/mesalib/src/mesa/program/prog_statevars.c
index 58e1f496e..5dda8e28d 100644
--- a/mesalib/src/mesa/program/prog_statevars.c
+++ b/mesalib/src/mesa/program/prog_statevars.c
@@ -353,9 +353,9 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
((int *)value)[0] = ctx->DrawBuffer->Visual.samples;
return;
case STATE_DEPTH_RANGE:
- value[0] = ctx->Viewport.Near; /* near */
- value[1] = ctx->Viewport.Far; /* far */
- value[2] = ctx->Viewport.Far - ctx->Viewport.Near; /* far - near */
+ value[0] = ctx->ViewportArray[0].Near; /* near */
+ value[1] = ctx->ViewportArray[0].Far; /* far */
+ value[2] = ctx->ViewportArray[0].Far - ctx->ViewportArray[0].Near; /* far - near */
value[3] = 1.0;
return;
case STATE_FRAGMENT_PROGRAM:
diff --git a/mesalib/src/mesa/program/program.c b/mesalib/src/mesa/program/program.c
index 3c19e8c60..ea8eb0d3a 100644
--- a/mesalib/src/mesa/program/program.c
+++ b/mesalib/src/mesa/program/program.c
@@ -1023,7 +1023,8 @@ _mesa_postprocess_program(struct gl_context *ctx, struct gl_program *prog)
*/
GLint
_mesa_get_min_invocations_per_fragment(struct gl_context *ctx,
- const struct gl_fragment_program *prog)
+ const struct gl_fragment_program *prog,
+ bool ignore_sample_qualifier)
{
/* From ARB_sample_shading specification:
* "Using gl_SampleID in a fragment shader causes the entire shader
@@ -1041,7 +1042,7 @@ _mesa_get_min_invocations_per_fragment(struct gl_context *ctx,
* "Use of the "sample" qualifier on a fragment shader input
* forces per-sample shading"
*/
- if (prog->IsSample)
+ if (prog->IsSample && !ignore_sample_qualifier)
return MAX2(ctx->DrawBuffer->Visual.samples, 1);
if (prog->Base.SystemValuesRead & (SYSTEM_BIT_SAMPLE_ID |
diff --git a/mesalib/src/mesa/program/program.h b/mesalib/src/mesa/program/program.h
index 0e350cd6f..71b0a4af2 100644
--- a/mesalib/src/mesa/program/program.h
+++ b/mesalib/src/mesa/program/program.h
@@ -189,7 +189,8 @@ _mesa_postprocess_program(struct gl_context *ctx, struct gl_program *prog);
extern GLint
_mesa_get_min_invocations_per_fragment(struct gl_context *ctx,
- const struct gl_fragment_program *prog);
+ const struct gl_fragment_program *prog,
+ bool ignore_sample_qualifier);
static inline GLuint
_mesa_program_enum_to_shader_stage(GLenum v)
@@ -209,7 +210,7 @@ _mesa_program_enum_to_shader_stage(GLenum v)
static inline GLenum
-_mesa_shader_stage_to_program(gl_shader_stage stage)
+_mesa_shader_stage_to_program(unsigned stage)
{
switch (stage) {
case MESA_SHADER_VERTEX:
@@ -225,23 +226,6 @@ _mesa_shader_stage_to_program(gl_shader_stage stage)
}
-static inline GLenum
-_mesa_program_index_to_target(GLuint i)
-{
- static const GLenum enums[] = {
- GL_VERTEX_PROGRAM_ARB,
- GL_GEOMETRY_PROGRAM_NV,
- GL_FRAGMENT_PROGRAM_ARB
- };
- STATIC_ASSERT(Elements(enums) == MESA_SHADER_STAGES);
- if(i >= MESA_SHADER_STAGES) {
- assert(!"Unexpected program index");
- return 0;
- } else
- return enums[i];
-}
-
-
/* Cast wrappers from gl_program to gl_vertex/geometry/fragment_program */
static inline struct gl_fragment_program *
diff --git a/mesalib/src/mesa/program/programopt.c b/mesalib/src/mesa/program/programopt.c
index 7e0057223..92a8831d2 100644
--- a/mesalib/src/mesa/program/programopt.c
+++ b/mesalib/src/mesa/program/programopt.c
@@ -218,7 +218,7 @@ _mesa_insert_mvp_mad_code(struct gl_context *ctx, struct gl_vertex_program *vpro
void
_mesa_insert_mvp_code(struct gl_context *ctx, struct gl_vertex_program *vprog)
{
- if (ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].PreferDP4)
+ if (ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS)
_mesa_insert_mvp_dp4_code( ctx, vprog );
else
_mesa_insert_mvp_mad_code( ctx, vprog );
diff --git a/mesalib/src/mesa/state_tracker/st_atom_clip.c b/mesalib/src/mesa/state_tracker/st_atom_clip.c
index 700899934..274b36a62 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_clip.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_clip.c
@@ -52,7 +52,7 @@ static void update_clip( struct st_context *st )
/* if we have a vertex shader that writes clip vertex we need to pass
the pre-projection transformed coordinates into the driver. */
if (st->vp) {
- if (ctx->Shader.CurrentVertexProgram)
+ if (ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX])
use_eye = TRUE;
}
diff --git a/mesalib/src/mesa/state_tracker/st_atom_constbuf.c b/mesalib/src/mesa/state_tracker/st_atom_constbuf.c
index 14cdfc6f9..a5013ed2c 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_constbuf.c
@@ -218,7 +218,8 @@ static void st_bind_ubos(struct st_context *st,
static void bind_vs_ubos(struct st_context *st)
{
- struct gl_shader_program *prog = st->ctx->Shader.CurrentVertexProgram;
+ struct gl_shader_program *prog =
+ st->ctx->Shader.CurrentProgram[MESA_SHADER_VERTEX];
if (!prog)
return;
@@ -237,7 +238,8 @@ const struct st_tracked_state st_bind_vs_ubos = {
static void bind_fs_ubos(struct st_context *st)
{
- struct gl_shader_program *prog = st->ctx->Shader.CurrentFragmentProgram;
+ struct gl_shader_program *prog =
+ st->ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT];
if (!prog)
return;
@@ -256,7 +258,8 @@ const struct st_tracked_state st_bind_fs_ubos = {
static void bind_gs_ubos(struct st_context *st)
{
- struct gl_shader_program *prog = st->ctx->Shader.CurrentGeometryProgram;
+ struct gl_shader_program *prog =
+ st->ctx->Shader.CurrentProgram[MESA_SHADER_GEOMETRY];
if (!prog)
return;
diff --git a/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c b/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c
index ca227dcfa..a4f3ffee3 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c
@@ -223,7 +223,7 @@ static void update_raster_state( struct st_context *st )
raster->multisample = ctx->Multisample._Enabled;
/* _NEW_SCISSOR */
- raster->scissor = ctx->Scissor.Enabled;
+ raster->scissor = ctx->Scissor.EnableFlags;
/* _NEW_FRAG_CLAMP */
raster->clamp_fragment_color = !st->clamp_frag_color_in_shader &&
diff --git a/mesalib/src/mesa/state_tracker/st_atom_scissor.c b/mesalib/src/mesa/state_tracker/st_atom_scissor.c
index 539c423eb..a1f72da47 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_scissor.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_scissor.c
@@ -53,15 +53,15 @@ update_scissor( struct st_context *st )
scissor.maxx = fb->Width;
scissor.maxy = fb->Height;
- if (ctx->Scissor.Enabled) {
+ if (ctx->Scissor.EnableFlags & 1) {
/* need to be careful here with xmax or ymax < 0 */
- GLint xmax = MAX2(0, ctx->Scissor.X + ctx->Scissor.Width);
- GLint ymax = MAX2(0, ctx->Scissor.Y + ctx->Scissor.Height);
+ GLint xmax = MAX2(0, ctx->Scissor.ScissorArray[0].X + ctx->Scissor.ScissorArray[0].Width);
+ GLint ymax = MAX2(0, ctx->Scissor.ScissorArray[0].Y + ctx->Scissor.ScissorArray[0].Height);
- if (ctx->Scissor.X > (GLint)scissor.minx)
- scissor.minx = ctx->Scissor.X;
- if (ctx->Scissor.Y > (GLint)scissor.miny)
- scissor.miny = ctx->Scissor.Y;
+ if (ctx->Scissor.ScissorArray[0].X > (GLint)scissor.minx)
+ scissor.minx = ctx->Scissor.ScissorArray[0].X;
+ if (ctx->Scissor.ScissorArray[0].Y > (GLint)scissor.miny)
+ scissor.miny = ctx->Scissor.ScissorArray[0].Y;
if (xmax < (GLint) scissor.maxx)
scissor.maxx = xmax;
diff --git a/mesalib/src/mesa/state_tracker/st_atom_viewport.c b/mesalib/src/mesa/state_tracker/st_atom_viewport.c
index 7a1a689b7..8c6d679a0 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_viewport.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_viewport.c
@@ -62,12 +62,12 @@ update_viewport( struct st_context *st )
/* _NEW_VIEWPORT
*/
{
- GLfloat x = (GLfloat)ctx->Viewport.X;
- GLfloat y = (GLfloat)ctx->Viewport.Y;
- GLfloat z = ctx->Viewport.Near;
- GLfloat half_width = (GLfloat)ctx->Viewport.Width * 0.5f;
- GLfloat half_height = (GLfloat)ctx->Viewport.Height * 0.5f;
- GLfloat half_depth = (GLfloat)(ctx->Viewport.Far - ctx->Viewport.Near) * 0.5f;
+ GLfloat x = ctx->ViewportArray[0].X;
+ GLfloat y = ctx->ViewportArray[0].Y;
+ GLfloat z = ctx->ViewportArray[0].Near;
+ GLfloat half_width = ctx->ViewportArray[0].Width * 0.5f;
+ GLfloat half_height = ctx->ViewportArray[0].Height * 0.5f;
+ GLfloat half_depth = (GLfloat)(ctx->ViewportArray[0].Far - ctx->ViewportArray[0].Near) * 0.5f;
st->state.viewport.scale[0] = half_width;
st->state.viewport.scale[1] = half_height * yScale;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_bitmap.c b/mesalib/src/mesa/state_tracker/st_cb_bitmap.c
index 487a46164..874ff77b5 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_bitmap.c
@@ -457,7 +457,7 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
cso_save_aux_vertex_buffer_slot(cso);
/* rasterizer state: just scissor */
- st->bitmap.rasterizer.scissor = ctx->Scissor.Enabled;
+ st->bitmap.rasterizer.scissor = ctx->Scissor.EnableFlags & 1;
cso_set_rasterizer(cso, &st->bitmap.rasterizer);
/* fragment shader state: TEX lookup program */
diff --git a/mesalib/src/mesa/state_tracker/st_cb_clear.c b/mesalib/src/mesa/state_tracker/st_cb_clear.c
index 28f9c83d5..97cc5a232 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_clear.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_clear.c
@@ -364,11 +364,11 @@ clear_with_quad(struct gl_context *ctx, unsigned clear_buffers)
static INLINE GLboolean
is_scissor_enabled(struct gl_context *ctx, struct gl_renderbuffer *rb)
{
- return ctx->Scissor.Enabled &&
- (ctx->Scissor.X > 0 ||
- ctx->Scissor.Y > 0 ||
- (unsigned) ctx->Scissor.Width < rb->Width ||
- (unsigned) ctx->Scissor.Height < rb->Height);
+ return (ctx->Scissor.EnableFlags & 1) &&
+ (ctx->Scissor.ScissorArray[0].X > 0 ||
+ ctx->Scissor.ScissorArray[0].Y > 0 ||
+ (unsigned) ctx->Scissor.ScissorArray[0].Width < rb->Width ||
+ (unsigned) ctx->Scissor.ScissorArray[0].Height < rb->Height);
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
index 72cc9fa54..97f213077 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -713,7 +713,7 @@ draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
rasterizer.half_pixel_center = 1;
rasterizer.bottom_edge_rule = 1;
rasterizer.depth_clip = !ctx->Transform.DepthClamp;
- rasterizer.scissor = ctx->Scissor.Enabled;
+ rasterizer.scissor = ctx->Scissor.EnableFlags;
cso_set_rasterizer(cso, &rasterizer);
}
@@ -1364,7 +1364,7 @@ blit_copy_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
!ctx->Stencil.Enabled &&
!ctx->FragmentProgram.Enabled &&
!ctx->VertexProgram.Enabled &&
- !ctx->Shader.CurrentFragmentProgram &&
+ !ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT] &&
ctx->DrawBuffer->_NumColorDrawBuffers == 1 &&
!ctx->Query.CondRenderQuery &&
!ctx->Query.CurrentOcclusionObject) {
diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.c b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
index 637f7ee98..780148487 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_fbo.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
@@ -544,6 +544,12 @@ st_validate_attachment(struct gl_context *ctx,
gl_format texFormat;
GLboolean valid;
+ /* Sanity check: we must be binding the surface as a (color) render target
+ * or depth/stencil target.
+ */
+ assert(bindings == PIPE_BIND_RENDER_TARGET ||
+ bindings == PIPE_BIND_DEPTH_STENCIL);
+
/* Only validate texture attachments for now, since
* st_renderbuffer_alloc_storage makes sure that
* the format is supported.
@@ -700,7 +706,8 @@ st_ReadBuffer(struct gl_context *ctx, GLenum buffer)
(void) buffer;
/* add the renderbuffer on demand */
- st_manager_add_color_renderbuffer(st, fb, fb->_ColorReadBufferIndex);
+ if (fb->_ColorReadBufferIndex >= 0)
+ st_manager_add_color_renderbuffer(st, fb, fb->_ColorReadBufferIndex);
}
diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c
index 77db6ab39..0ffc76263 100644
--- a/mesalib/src/mesa/state_tracker/st_context.c
+++ b/mesalib/src/mesa/state_tracker/st_context.c
@@ -240,7 +240,7 @@ struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
* driver prefers DP4 or MUL/MAD for vertex transformation.
*/
if (debug_get_option_mesa_mvp_dp4())
- ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].PreferDP4 = GL_TRUE;
+ ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS = GL_TRUE;
return st_create_context_priv(ctx, pipe, options);
}
diff --git a/mesalib/src/mesa/state_tracker/st_draw.c b/mesalib/src/mesa/state_tracker/st_draw.c
index 46257e0f5..355c180f8 100644
--- a/mesalib/src/mesa/state_tracker/st_draw.c
+++ b/mesalib/src/mesa/state_tracker/st_draw.c
@@ -131,11 +131,7 @@ setup_index_buffer(struct st_context *st,
static void
check_uniforms(struct gl_context *ctx)
{
- struct gl_shader_program *shProg[3] = {
- ctx->Shader.CurrentVertexProgram,
- ctx->Shader.CurrentGeometryProgram,
- ctx->Shader.CurrentFragmentProgram,
- };
+ struct gl_shader_program **shProg = ctx->Shader.CurrentProgram;
unsigned j;
for (j = 0; j < 3; j++) {
diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index f1b354429..0871dd064 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -5312,7 +5312,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
_mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
linked_prog);
if (!ctx->Driver.ProgramStringNotify(ctx,
- _mesa_program_index_to_target(i),
+ _mesa_shader_stage_to_program(i),
linked_prog)) {
_mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
NULL);
diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c
index 2d6d43099..7a15b23fa 100644
--- a/mesalib/src/mesa/state_tracker/st_program.c
+++ b/mesalib/src/mesa/state_tracker/st_program.c
@@ -1195,11 +1195,7 @@ st_get_gp_variant(struct st_context *st,
void
st_print_shaders(struct gl_context *ctx)
{
- struct gl_shader_program *shProg[3] = {
- ctx->Shader.CurrentVertexProgram,
- ctx->Shader.CurrentGeometryProgram,
- ctx->Shader.CurrentFragmentProgram,
- };
+ struct gl_shader_program **shProg = ctx->Shader.CurrentProgram;
unsigned j;
for (j = 0; j < 3; j++) {
diff --git a/mesalib/src/mesa/swrast/s_context.c b/mesalib/src/mesa/swrast/s_context.c
index f219d3de0..07485006c 100644
--- a/mesalib/src/mesa/swrast/s_context.c
+++ b/mesalib/src/mesa/swrast/s_context.c
@@ -61,7 +61,7 @@ _swrast_update_rasterflags( struct gl_context *ctx )
if (ctx->Color.BlendEnabled) rasterMask |= BLEND_BIT;
if (ctx->Depth.Test) rasterMask |= DEPTH_BIT;
if (swrast->_FogEnabled) rasterMask |= FOG_BIT;
- if (ctx->Scissor.Enabled) rasterMask |= CLIP_BIT;
+ if (ctx->Scissor.EnableFlags) rasterMask |= CLIP_BIT;
if (ctx->Stencil._Enabled) rasterMask |= STENCIL_BIT;
for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
if (!ctx->Color.ColorMask[i][0] ||
@@ -74,10 +74,10 @@ _swrast_update_rasterflags( struct gl_context *ctx )
}
if (ctx->Color.ColorLogicOpEnabled) rasterMask |= LOGIC_OP_BIT;
if (ctx->Texture._EnabledUnits) rasterMask |= TEXTURE_BIT;
- if ( ctx->Viewport.X < 0
- || ctx->Viewport.X + ctx->Viewport.Width > (GLint) ctx->DrawBuffer->Width
- || ctx->Viewport.Y < 0
- || ctx->Viewport.Y + ctx->Viewport.Height > (GLint) ctx->DrawBuffer->Height) {
+ if ( ctx->ViewportArray[0].X < 0
+ || ctx->ViewportArray[0].X + ctx->ViewportArray[0].Width > (GLfloat) ctx->DrawBuffer->Width
+ || ctx->ViewportArray[0].Y < 0
+ || ctx->ViewportArray[0].Y + ctx->ViewportArray[0].Height > (GLfloat) ctx->DrawBuffer->Height) {
rasterMask |= CLIP_BIT;
}
diff --git a/mesalib/src/mesa/swrast/s_depth.c b/mesalib/src/mesa/swrast/s_depth.c
index 0f4fb9506..7f3c76de4 100644
--- a/mesalib/src/mesa/swrast/s_depth.c
+++ b/mesalib/src/mesa/swrast/s_depth.c
@@ -171,12 +171,12 @@ _swrast_depth_clamp_span( struct gl_context *ctx, SWspan *span )
GLfloat min_f, max_f;
GLuint i;
- if (ctx->Viewport.Near < ctx->Viewport.Far) {
- min_f = ctx->Viewport.Near;
- max_f = ctx->Viewport.Far;
+ if (ctx->ViewportArray[0].Near < ctx->ViewportArray[0].Far) {
+ min_f = ctx->ViewportArray[0].Near;
+ max_f = ctx->ViewportArray[0].Far;
} else {
- min_f = ctx->Viewport.Far;
- max_f = ctx->Viewport.Near;
+ min_f = ctx->ViewportArray[0].Far;
+ max_f = ctx->ViewportArray[0].Near;
}
/* Convert floating point values in [0,1] to device Z coordinates in
diff --git a/mesalib/src/mesa/swrast/s_fragprog.c b/mesalib/src/mesa/swrast/s_fragprog.c
index 4e9ac394e..fa45fa97a 100644
--- a/mesalib/src/mesa/swrast/s_fragprog.c
+++ b/mesalib/src/mesa/swrast/s_fragprog.c
@@ -182,7 +182,7 @@ init_machine(struct gl_context *ctx, struct gl_program_machine *machine,
machine->Samplers = program->Base.SamplerUnits;
/* if running a GLSL program (not ARB_fragment_program) */
- if (ctx->Shader.CurrentFragmentProgram) {
+ if (ctx->Shader.CurrentProgram[MESA_SHADER_FRAGMENT]) {
/* Store front/back facing value */
machine->Attribs[VARYING_SLOT_FACE][col][0] = 1.0F - span->facing;
}
diff --git a/mesalib/src/mesa/swrast_setup/ss_context.c b/mesalib/src/mesa/swrast_setup/ss_context.c
index 1be37d4c8..12a47358f 100644
--- a/mesalib/src/mesa/swrast_setup/ss_context.c
+++ b/mesalib/src/mesa/swrast_setup/ss_context.c
@@ -167,7 +167,7 @@ setup_vertex_format(struct gl_context *ctx)
EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F, pointSize );
_tnl_install_attrs( ctx, map, e,
- ctx->Viewport._WindowMap.m,
+ ctx->ViewportArray[0]._WindowMap.m,
sizeof(SWvertex) );
swsetup->last_index_bitset = index_bitset;
@@ -265,7 +265,7 @@ _swsetup_Wakeup( struct gl_context *ctx )
void
_swsetup_Translate( struct gl_context *ctx, const void *vertex, SWvertex *dest )
{
- const GLfloat *m = ctx->Viewport._WindowMap.m;
+ const GLfloat *m = ctx->ViewportArray[0]._WindowMap.m;
GLfloat tmp[4];
GLuint i;
diff --git a/mesalib/src/mesa/tnl/t_rasterpos.c b/mesalib/src/mesa/tnl/t_rasterpos.c
index 3ee5c4547..e538c348f 100644
--- a/mesalib/src/mesa/tnl/t_rasterpos.c
+++ b/mesalib/src/mesa/tnl/t_rasterpos.c
@@ -409,19 +409,19 @@ _tnl_RasterPos(struct gl_context *ctx, const GLfloat vObj[4])
ndc[1] = clip[1] * d;
ndc[2] = clip[2] * d;
/* wincoord = viewport_mapping(ndc) */
- ctx->Current.RasterPos[0] = (ndc[0] * ctx->Viewport._WindowMap.m[MAT_SX]
- + ctx->Viewport._WindowMap.m[MAT_TX]);
- ctx->Current.RasterPos[1] = (ndc[1] * ctx->Viewport._WindowMap.m[MAT_SY]
- + ctx->Viewport._WindowMap.m[MAT_TY]);
- ctx->Current.RasterPos[2] = (ndc[2] * ctx->Viewport._WindowMap.m[MAT_SZ]
- + ctx->Viewport._WindowMap.m[MAT_TZ])
+ ctx->Current.RasterPos[0] = (ndc[0] * ctx->ViewportArray[0]._WindowMap.m[MAT_SX]
+ + ctx->ViewportArray[0]._WindowMap.m[MAT_TX]);
+ ctx->Current.RasterPos[1] = (ndc[1] * ctx->ViewportArray[0]._WindowMap.m[MAT_SY]
+ + ctx->ViewportArray[0]._WindowMap.m[MAT_TY]);
+ ctx->Current.RasterPos[2] = (ndc[2] * ctx->ViewportArray[0]._WindowMap.m[MAT_SZ]
+ + ctx->ViewportArray[0]._WindowMap.m[MAT_TZ])
/ ctx->DrawBuffer->_DepthMaxF;
ctx->Current.RasterPos[3] = clip[3];
if (ctx->Transform.DepthClamp) {
ctx->Current.RasterPos[3] = CLAMP(ctx->Current.RasterPos[3],
- ctx->Viewport.Near,
- ctx->Viewport.Far);
+ ctx->ViewportArray[0].Near,
+ ctx->ViewportArray[0].Far);
}
/* compute raster distance */
diff --git a/mesalib/src/mesa/x86/read_rgba_span_x86.h b/mesalib/src/mesa/x86/read_rgba_span_x86.h
deleted file mode 100644
index 564b1bb0f..000000000
--- a/mesalib/src/mesa/x86/read_rgba_span_x86.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * (C) Copyright IBM Corporation 2004
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * \file read_rgba_span_x86.h
- *
- * \author Ian Romanick <idr@us.ibm.com>
- */
-
-#ifndef READ_RGBA_SPAN_X86_H
-#define READ_RGBA_SPAN_X86_H
-
-#if defined(USE_SSE_ASM) || defined(USE_MMX_ASM)
-#include "x86/common_x86_asm.h"
-#endif
-
-#if defined(USE_SSE_ASM)
-extern void _generic_read_RGBA_span_BGRA8888_REV_SSE2( const unsigned char *,
- unsigned char *, unsigned );
-#endif
-
-#if defined(USE_SSE_ASM)
-extern void _generic_read_RGBA_span_BGRA8888_REV_SSE( const unsigned char *,
- unsigned char *, unsigned );
-#endif
-
-#if defined(USE_MMX_ASM)
-extern void _generic_read_RGBA_span_BGRA8888_REV_MMX( const unsigned char *,
- unsigned char *, unsigned );
-
-extern void _generic_read_RGBA_span_RGB565_MMX( const unsigned char *,
- unsigned char *, unsigned );
-#endif
-
-#endif /* READ_RGBA_SPAN_X86_H */
diff --git a/xorg-server/Makefile.am b/xorg-server/Makefile.am
index 5bf760b2e..add69d193 100644
--- a/xorg-server/Makefile.am
+++ b/xorg-server/Makefile.am
@@ -1,4 +1,6 @@
AUTOMAKE_OPTIONS=nostdinc
+
+# Required for automake < 1.14
ACLOCAL_AMFLAGS = -I m4
if COMPOSITE
diff --git a/xorg-server/Xi/exevents.c b/xorg-server/Xi/exevents.c
index 9d8416b4a..4ed58eec4 100644
--- a/xorg-server/Xi/exevents.c
+++ b/xorg-server/Xi/exevents.c
@@ -1783,8 +1783,25 @@ ProcessDeviceEvent(InternalEvent *ev, DeviceIntPtr device)
DeliverDeviceEvents(GetSpriteWindow(device), (InternalEvent *) event,
NullGrab, NullWindow, device);
- if (deactivateDeviceGrab == TRUE)
+ if (deactivateDeviceGrab == TRUE) {
(*device->deviceGrab.DeactivateGrab) (device);
+
+ if (!IsMaster (device) && !IsFloating (device)) {
+ int flags, num_events = 0;
+ InternalEvent dce;
+
+ flags = (IsPointerDevice (device)) ?
+ DEVCHANGE_POINTER_EVENT : DEVCHANGE_KEYBOARD_EVENT;
+ UpdateFromMaster (&dce, device, flags, &num_events);
+ BUG_WARN(num_events > 1);
+
+ if (num_events == 1)
+ ChangeMasterDeviceClasses(GetMaster (device, MASTER_ATTACHED),
+ &dce.changed_event);
+ }
+
+ }
+
event->detail.key = key;
}
diff --git a/xorg-server/Xi/grabdev.c b/xorg-server/Xi/grabdev.c
index 9c6c429ed..090043814 100644
--- a/xorg-server/Xi/grabdev.c
+++ b/xorg-server/Xi/grabdev.c
@@ -191,7 +191,7 @@ CreateMaskFromList(ClientPtr client, XEventClass * list, int count,
for (j = 0; j < ExtEventIndex; j++)
if (EventInfo[j].type == (*list & 0xff)) {
mask[device].mask |= EventInfo[j].mask;
- mask[device].dev = (Pointer) tdev;
+ mask[device].dev = (void *) tdev;
break;
}
}
diff --git a/xorg-server/composite/compwindow.c b/xorg-server/composite/compwindow.c
index 8dce21d9b..6c2434959 100644
--- a/xorg-server/composite/compwindow.c
+++ b/xorg-server/composite/compwindow.c
@@ -475,7 +475,6 @@ compCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
* need to be copied to pNewPixmap.
*/
RegionRec rgnDst;
- PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
GCPtr pGC;
dx = ptOldOrg.x - pWin->drawable.x;
diff --git a/xorg-server/configure.ac b/xorg-server/configure.ac
index 234cf21b2..560c46030 100644
--- a/xorg-server/configure.ac
+++ b/xorg-server/configure.ac
@@ -30,6 +30,7 @@ AC_INIT([xorg-server], 1.15.99.900, [https://bugs.freedesktop.org/enter_bug.cgi?
RELEASE_DATE="2014-01-09"
RELEASE_NAME="Golden Gaytime"
AC_CONFIG_SRCDIR([Makefile.am])
+AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([foreign dist-bzip2])
AC_USE_SYSTEM_EXTENSIONS
@@ -74,9 +75,8 @@ AC_CONFIG_HEADERS(include/version-config.h)
AM_PROG_AS
AC_PROG_LN_S
-AC_LIBTOOL_WIN32_DLL
-AC_DISABLE_STATIC
-AC_PROG_LIBTOOL
+LT_PREREQ([2.2])
+LT_INIT([disable-static win32-dll])
PKG_PROG_PKG_CONFIG
AC_PROG_LEX
AC_PROG_YACC
@@ -265,20 +265,20 @@ AM_CONDITIONAL(FREEBSD_KLDLOAD, [test "x$ac_cv_sys_linker_h" = xyes])
AC_CACHE_CHECK([for SYSV IPC],
ac_cv_sysv_ipc,
- [AC_TRY_LINK([
+ [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/stat.h>
-],[
+]],[[
{
int id;
id = shmget(IPC_PRIVATE, 512, S_IRUSR | S_IWUSR);
if (id < 0) return -1;
return shmctl(id, IPC_RMID, 0);
-}],
- [ac_cv_sysv_ipc=yes],
- [ac_cv_sysv_ipc=no])])
+}]])],
+ [ac_cv_sysv_ipc=yes],
+ [ac_cv_sysv_ipc=no])])
if test "x$ac_cv_sysv_ipc" = xyes; then
AC_DEFINE(HAVE_SYSV_IPC, 1, [Define to 1 if SYSV IPC is available])
fi
@@ -437,8 +437,6 @@ VENDOR_NAME="The X.Org Foundation"
VENDOR_NAME_SHORT="X.Org"
VENDOR_WEB="http://wiki.x.org"
-m4_ifdef([AS_HELP_STRING], , [m4_define([AS_HELP_STRING], m4_defn([AC_HELP_STRING]))])
-
dnl Build options.
AC_ARG_ENABLE(werror, AS_HELP_STRING([--enable-werror],
[Obsolete - use --enable-strict-compilation instead]),
@@ -565,7 +563,7 @@ AC_ARG_ENABLE(install-libxf86config,
[Install libxf86config (default: disabled)]),
[INSTALL_LIBXF86CONFIG=$enableval],
[INSTALL_LIBXF86CONFIG=no])
-AC_ARG_ENABLE(visibility, AC_HELP_STRING([--enable-visibility], [Enable symbol visibility (default: auto)]),
+AC_ARG_ENABLE(visibility, AS_HELP_STRING([--enable-visibility], [Enable symbol visibility (default: auto)]),
[SYMBOL_VISIBILITY=$enableval],
[SYMBOL_VISIBILITY=auto])
@@ -627,8 +625,8 @@ AC_ARG_ENABLE(windowswm, AS_HELP_STRING([--enable-windowswm], [Build XWin w
AC_ARG_ENABLE(libdrm, AS_HELP_STRING([--enable-libdrm], [Build Xorg with libdrm support (default: enabled)]), [DRM=$enableval],[DRM=yes])
AC_ARG_ENABLE(clientids, AS_HELP_STRING([--disable-clientids], [Build Xorg with client ID tracking (default: enabled)]), [CLIENTIDS=$enableval], [CLIENTIDS=yes])
AC_ARG_ENABLE(pciaccess, AS_HELP_STRING([--enable-pciaccess], [Build Xorg with pciaccess library (default: enabled)]), [PCI=$enableval], [PCI=yes])
-AC_ARG_ENABLE(linux_acpi, AC_HELP_STRING([--disable-linux-acpi], [Disable building ACPI support on Linux (if available).]), [enable_linux_acpi=$enableval], [enable_linux_acpi=yes])
-AC_ARG_ENABLE(linux_apm, AC_HELP_STRING([--disable-linux-apm], [Disable building APM support on Linux (if available).]), [enable_linux_apm=$enableval], [enable_linux_apm=yes])
+AC_ARG_ENABLE(linux_acpi, AS_HELP_STRING([--disable-linux-acpi], [Disable building ACPI support on Linux (if available).]), [enable_linux_acpi=$enableval], [enable_linux_acpi=yes])
+AC_ARG_ENABLE(linux_apm, AS_HELP_STRING([--disable-linux-apm], [Disable building APM support on Linux (if available).]), [enable_linux_apm=$enableval], [enable_linux_apm=yes])
dnl DDXes.
AC_ARG_ENABLE(xorg, AS_HELP_STRING([--enable-xorg], [Build Xorg server (default: auto)]), [XORG=$enableval], [XORG=auto])
@@ -645,8 +643,8 @@ AC_ARG_ENABLE(xfake, AS_HELP_STRING([--enable-xfake], [Build the kdrive
AC_ARG_ENABLE(xfbdev, AS_HELP_STRING([--enable-xfbdev], [Build the kdrive framebuffer device server (default: auto)]), [XFBDEV=$enableval], [XFBDEV=auto])
dnl kdrive options
AC_ARG_ENABLE(kdrive-kbd, AS_HELP_STRING([--enable-kdrive-kbd], [Build kbd driver for kdrive (default: auto)]), [KDRIVE_KBD=$enableval], [KDRIVE_KBD=auto])
-AC_ARG_ENABLE(kdrive-mouse, AC_HELP_STRING([--enable-kdrive-mouse], [Build mouse driver for kdrive (default: auto)]), [KDRIVE_MOUSE=$enableval], [KDRIVE_MOUSE=auto])
-AC_ARG_ENABLE(kdrive-evdev, AC_HELP_STRING([--enable-kdrive-evdev], [Build evdev driver for kdrive (default: auto)]), [KDRIVE_EVDEV=$enableval], [KDRIVE_EVDEV=auto])
+AC_ARG_ENABLE(kdrive-mouse, AS_HELP_STRING([--enable-kdrive-mouse], [Build mouse driver for kdrive (default: auto)]), [KDRIVE_MOUSE=$enableval], [KDRIVE_MOUSE=auto])
+AC_ARG_ENABLE(kdrive-evdev, AS_HELP_STRING([--enable-kdrive-evdev], [Build evdev driver for kdrive (default: auto)]), [KDRIVE_EVDEV=$enableval], [KDRIVE_EVDEV=auto])
AC_ARG_ENABLE(libunwind, AS_HELP_STRING([--enable-libunwind], [Use libunwind for backtracing (default: auto)]), [LIBUNWIND="$enableval"], [LIBUNWIND="auto"])
@@ -1822,13 +1820,13 @@ if test "x$XORG" = xyes; then
save_CFLAGS="$CFLAGS"
proto_inc=`$PKG_CONFIG --cflags xproto`
CFLAGS="$CFLAGS $VISIBILITY_CFLAGS $proto_inc"
- AC_TRY_COMPILE(
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
[#include <X11/Xfuncproto.h>
extern _X_HIDDEN int hidden_int;
extern _X_EXPORT int public_int;
extern _X_HIDDEN int hidden_int_func(void);
- extern _X_EXPORT int public_int_func(void);],
- [],
+ extern _X_EXPORT int public_int_func(void);]],
+ [])],
have_visibility=yes,
have_visibility=no)
CFLAGS=$save_CFLAGS
@@ -2388,12 +2386,12 @@ dnl though, thanks to the passing of some significant amount of time, the
dnl above is probably a complete fallacy, and you should not rely on it.
dnl but this is still actually better than imake, honest. -daniels
-AC_TRY_COMPILE([
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <features.h>
#ifndef __GLIBC__
#error not glibc
#endif
-], [], [AC_DEFINE(_GNU_SOURCE, 1,
+]], [])], [AC_DEFINE(_GNU_SOURCE, 1,
[ Enable GNU and other extensions to the C environment for glibc])])
AC_DEFINE_DIR(PROJECTROOT, prefix, [Overall prefix])
@@ -2415,7 +2413,7 @@ AC_SUBST([prefix])
AC_CONFIG_COMMANDS([sdksyms], [touch hw/xfree86/sdksyms.dep])
if test "x$CONFIG_HAL" = xno && test "x$CONFIG_UDEV" = xno; then
- AC_WARN([
+ AC_MSG_WARN([
***********************************************
Neither HAL nor udev backend will be enabled.
Input device hotplugging will not be available!
diff --git a/xorg-server/dix/dispatch.c b/xorg-server/dix/dispatch.c
index e28270c16..9a5658db0 100644
--- a/xorg-server/dix/dispatch.c
+++ b/xorg-server/dix/dispatch.c
@@ -260,12 +260,11 @@ SmartScheduleClient(int *clientReady, int nready)
for (i = 0; i < nready; i++) {
client = clientReady[i];
pClient = clients[client];
- /* Praise clients which are idle */
- if ((now - pClient->smart_check_tick) >= idle) {
+ /* Praise clients which haven't run in a while */
+ if ((now - pClient->smart_stop_tick) >= idle) {
if (pClient->smart_priority < 0)
pClient->smart_priority++;
}
- pClient->smart_check_tick = now;
/* check priority to select best client */
robin =
@@ -3424,7 +3423,6 @@ InitClient(ClientPtr client, int i, void *ospriv)
QueryMinMaxKeyCodes(&client->minKC, &client->maxKC);
client->smart_start_tick = SmartScheduleTime;
client->smart_stop_tick = SmartScheduleTime;
- client->smart_check_tick = SmartScheduleTime;
client->clientIds = NULL;
}
diff --git a/xorg-server/dix/events.c b/xorg-server/dix/events.c
index ddbd4d281..f05dada3d 100644
--- a/xorg-server/dix/events.c
+++ b/xorg-server/dix/events.c
@@ -3961,6 +3961,8 @@ CheckPassiveGrabsOnWindow(WindowPtr pWin,
return NULL;
tempGrab = AllocGrab(NULL);
+ if (tempGrab == NULL)
+ return NULL;
/* Fill out the grab details, but leave the type for later before
* comparing */
@@ -5056,7 +5058,7 @@ ProcUngrabPointer(ClientPtr client)
* @param other_mode GrabModeSync or GrabModeAsync
* @param status Return code to be returned to the caller.
*
- * @returns Success or BadValue.
+ * @returns Success or BadValue or BadAlloc.
*/
int
GrabDevice(ClientPtr client, DeviceIntPtr dev,
@@ -5137,6 +5139,8 @@ GrabDevice(ClientPtr client, DeviceIntPtr dev,
GrabPtr tempGrab;
tempGrab = AllocGrab(NULL);
+ if (tempGrab == NULL)
+ return BadAlloc;
tempGrab->next = NULL;
tempGrab->window = pWin;
diff --git a/xorg-server/dix/grabs.c b/xorg-server/dix/grabs.c
index 5fd68202a..e3fc38bf5 100644
--- a/xorg-server/dix/grabs.c
+++ b/xorg-server/dix/grabs.c
@@ -199,12 +199,11 @@ AllocGrab(const GrabPtr src)
free(grab);
grab = NULL;
}
- }
-
- if (src && !CopyGrab(grab, src)) {
- free(grab->xi2mask);
- free(grab);
- grab = NULL;
+ else if (src && !CopyGrab(grab, src)) {
+ free(grab->xi2mask);
+ free(grab);
+ grab = NULL;
+ }
}
return grab;
diff --git a/xorg-server/exa/exa_accel.c b/xorg-server/exa/exa_accel.c
index 0e948f414..9c742bdc9 100644
--- a/xorg-server/exa/exa_accel.c
+++ b/xorg-server/exa/exa_accel.c
@@ -1039,7 +1039,6 @@ exaFillRegionSolid(DrawablePtr pDrawable, RegionPtr pRegion, Pixel pixel,
pExaPixmap->sys_ptr && pDrawable->type == DRAWABLE_PIXMAP &&
pDrawable->width == 1 && pDrawable->height == 1 &&
pDrawable->bitsPerPixel != 24) {
- ExaPixmapPriv(pPixmap);
RegionPtr pending_damage = DamagePendingRegion(pExaPixmap->pDamage);
switch (pDrawable->bitsPerPixel) {
diff --git a/xorg-server/exa/exa_render.c b/xorg-server/exa/exa_render.c
index 172e2b56d..c4edf407e 100644
--- a/xorg-server/exa/exa_render.c
+++ b/xorg-server/exa/exa_render.c
@@ -915,7 +915,7 @@ exaComposite(CARD8 op,
if (!pSrc->repeat && xSrc >= 0 && ySrc >= 0 &&
(xSrc + width <= pSrc->pDrawable->width) &&
(ySrc + height <= pSrc->pDrawable->height)) {
- Bool ret;
+ Bool suc;
xDst += pDst->pDrawable->x;
yDst += pDst->pDrawable->y;
@@ -927,7 +927,7 @@ exaComposite(CARD8 op,
yDst, width, height))
goto done;
- ret = exaHWCopyNtoN(pSrc->pDrawable, pDst->pDrawable, NULL,
+ suc = exaHWCopyNtoN(pSrc->pDrawable, pDst->pDrawable, NULL,
RegionRects(&region),
RegionNumRects(&region), xSrc - xDst,
ySrc - yDst, FALSE, FALSE);
@@ -939,7 +939,7 @@ exaComposite(CARD8 op,
xSrc -= pSrc->pDrawable->x;
ySrc -= pSrc->pDrawable->y;
- if (!ret)
+ if (!suc)
goto fallback;
goto done;
diff --git a/xorg-server/glamor/Makefile.am b/xorg-server/glamor/Makefile.am
new file mode 100644
index 000000000..2fd521f11
--- /dev/null
+++ b/xorg-server/glamor/Makefile.am
@@ -0,0 +1,71 @@
+lib_LTLIBRARIES = libglamor.la
+
+if GLAMOR_GLES2
+libglamor_la_LIBADD = $(GLESV2_LIBS)
+else
+libglamor_la_LIBADD = $(GL_LIBS)
+endif
+
+AM_CFLAGS = $(CWARNFLAGS) $(XORG_CFLAGS) $(LIBDRM_CFLAGS)
+
+libglamor_la_LDFLAGS = -version-info 0:0:0
+
+libglamor_la_SOURCES = \
+ compat-api.h \
+ compiler.h \
+ glamor.c \
+ glamor_copyarea.c \
+ glamor_copywindow.c \
+ glamor_core.c \
+ glamor_debug.h \
+ glamor_gl_dispatch.h \
+ glamor_fill.c \
+ glamor_fillspans.c \
+ glamor_getspans.c \
+ glamor_glext.h \
+ glamor_glyphs.c \
+ glamor_polyfillrect.c \
+ glamor_polylines.c \
+ glamor_putimage.c \
+ glamor_setspans.c \
+ glamor_render.c \
+ glamor_gradient.c \
+ glamor_trapezoid.c \
+ glamor_tile.c \
+ glamor_triangles.c\
+ glamor_addtraps.c\
+ glamor_getimage.c\
+ glamor_copyplane.c\
+ glamor_glyphblt.c\
+ glamor_polyops.c\
+ glamor_priv.h\
+ glamor_pixmap.c\
+ glamor_largepixmap.c\
+ glamor_picture.c\
+ glamor_window.c\
+ glamor_gl_dispatch.c\
+ glamor_fbo.c\
+ glamor_compositerects.c\
+ glamor_xv.c\
+ glamor_utils.h\
+ glamor.h\
+ glapi.h
+
+sdk_HEADERS = glamor.h
+
+if EGL
+LIBGLAMOREGL = libglamoregl.la
+module_LTLIBRARIES = $(LIBGLAMOREGL)
+libglamoregl_la_DEPENDENCIES = libglamor.la
+libglamoregl_la_LDFLAGS = -avoid-version -module
+libglamoregl_la_LIBADD = $(EGL_LIBS) $(GLX_SYS_LIBS) $(GBM_LIBS) libglamor.la
+libglamoregl_la_SOURCES = glamor_eglmodule.c glamor_egl.c
+libglamoregl_la_CFLAGS = \
+ $(AM_CFLAGS) \
+ $(GLX_DEFINES) \
+ $(LIBDRM_CFLAGS) \
+ $(EGL_CFLAGS) \
+ $(GBM_CFLAGS)
+endif
+
+
diff --git a/xorg-server/glamor/compat-api.h b/xorg-server/glamor/compat-api.h
new file mode 100644
index 000000000..1608478f8
--- /dev/null
+++ b/xorg-server/glamor/compat-api.h
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (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.
+ *
+ * Author: Dave Airlie <airlied@redhat.com>
+ */
+
+/* this file provides API compat between server post 1.13 and pre it,
+ it should be reused inside as many drivers as possible */
+#ifndef COMPAT_API_H
+#define COMPAT_API_H
+
+#ifndef GLYPH_HAS_GLYPH_PICTURE_ACCESSOR
+#define GetGlyphPicture(g, s) GlyphPicture((g))[(s)->myNum]
+#define SetGlyphPicture(g, s, p) GlyphPicture((g))[(s)->myNum] = p
+#endif
+
+#ifndef XF86_HAS_SCRN_CONV
+#define xf86ScreenToScrn(s) xf86Screens[(s)->myNum]
+#define xf86ScrnToScreen(s) screenInfo.screens[(s)->scrnIndex]
+#endif
+
+#ifndef XF86_SCRN_INTERFACE
+
+#define SCRN_ARG_TYPE int
+#define SCRN_INFO_PTR(arg1) ScrnInfoPtr scrn = xf86Screens[(arg1)]
+
+#define SCREEN_ARG_TYPE int
+#define SCREEN_PTR(arg1) ScreenPtr screen = screenInfo.screens[(arg1)]
+
+#define SCREEN_INIT_ARGS_DECL int scrnIndex, ScreenPtr screen, int argc, char **argv
+
+#define BLOCKHANDLER_ARGS_DECL int arg, pointer blockData, pointer timeout, pointer read_mask
+#define BLOCKHANDLER_ARGS arg, blockData, timeout, read_mask
+
+#define WAKEUPHANDLER_ARGS_DECL int arg, pointer wakeupData, unsigned long result, pointer read_mask
+#define WAKEUPHANDLER_ARGS arg, wakeupData, result, read_mask
+
+#define CLOSE_SCREEN_ARGS_DECL int scrnIndex, ScreenPtr screen
+#define CLOSE_SCREEN_ARGS scrnIndex, screen
+
+#define ADJUST_FRAME_ARGS_DECL int arg, int x, int y, int flags
+#define ADJUST_FRAME_ARGS(arg, x, y) (arg)->scrnIndex, x, y, 0
+
+#define SWITCH_MODE_ARGS_DECL int arg, DisplayModePtr mode, int flags
+#define SWITCH_MODE_ARGS(arg, m) (arg)->scrnIndex, m, 0
+
+#define FREE_SCREEN_ARGS_DECL int arg, int flags
+#define FREE_SCREEN_ARGS arg, flags
+
+#define VT_FUNC_ARGS_DECL int arg, int flags
+#define VT_FUNC_ARGS(flags) scrn->scrnIndex, (flags)
+
+#define XF86_ENABLEDISABLEFB_ARG(x) ((x)->scrnIndex)
+
+#else
+#define SCRN_ARG_TYPE ScrnInfoPtr
+#define SCRN_INFO_PTR(arg1) ScrnInfoPtr scrn = (arg1)
+
+#define SCREEN_ARG_TYPE ScreenPtr
+#define SCREEN_PTR(arg1) ScreenPtr screen = (arg1)
+
+#define SCREEN_INIT_ARGS_DECL ScreenPtr screen, int argc, char **argv
+
+#define BLOCKHANDLER_ARGS_DECL ScreenPtr arg, pointer timeout, pointer read_mask
+#define BLOCKHANDLER_ARGS arg, timeout, read_mask
+
+#define WAKEUPHANDLER_ARGS_DECL ScreenPtr arg, unsigned long result, pointer read_mask
+#define WAKEUPHANDLER_ARGS arg, result, read_mask
+
+#define CLOSE_SCREEN_ARGS_DECL ScreenPtr screen
+#define CLOSE_SCREEN_ARGS screen
+
+#define ADJUST_FRAME_ARGS_DECL ScrnInfoPtr arg, int x, int y
+#define ADJUST_FRAME_ARGS(arg, x, y) arg, x, y
+
+#define SWITCH_MODE_ARGS_DECL ScrnInfoPtr arg, DisplayModePtr mode
+#define SWITCH_MODE_ARGS(arg, m) arg, m
+
+#define FREE_SCREEN_ARGS_DECL ScrnInfoPtr arg
+#define FREE_SCREEN_ARGS arg
+
+#define VT_FUNC_ARGS_DECL ScrnInfoPtr arg
+#define VT_FUNC_ARGS(flags) scrn
+
+#define XF86_ENABLEDISABLEFB_ARG(x) (x)
+
+#endif
+#endif
diff --git a/xorg-server/glamor/compiler.h b/xorg-server/glamor/compiler.h
new file mode 100644
index 000000000..fa2895976
--- /dev/null
+++ b/xorg-server/glamor/compiler.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2011 Intel Corporation
+ *
+ * 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.
+ *
+ * Authors:
+ * Chris Wilson <chris@chris-wilson.co.uk>
+ *
+ * Copied from sna
+ *
+ */
+
+#ifndef _GLAMOR_COMPILER_H_
+#define _GLAMOR_COMPILER_H_
+
+#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
+#define likely(expr) (__builtin_expect (!!(expr), 1))
+#define unlikely(expr) (__builtin_expect (!!(expr), 0))
+#define noinline __attribute__((noinline))
+#define fastcall __attribute__((regparm(3)))
+#define must_check __attribute__((warn_unused_result))
+#define constant __attribute__((const))
+#else
+#define likely(expr) (expr)
+#define unlikely(expr) (expr)
+#define noinline
+#define fastcall
+#define must_check
+#define constant
+#endif
+
+#ifdef HAVE_VALGRIND
+#define VG(x) x
+#else
+#define VG(x)
+#endif
+
+#define VG_CLEAR(s) VG(memset(&s, 0, sizeof(s)))
+
+#define COMPILE_TIME_ASSERT(E) ((void)sizeof(char[1 - 2*!(E)]))
+
+#endif /* _SNA_COMPILER_H_ */
diff --git a/xorg-server/glamor/glamor.c b/xorg-server/glamor/glamor.c
new file mode 100644
index 000000000..93d3c5e72
--- /dev/null
+++ b/xorg-server/glamor/glamor.c
@@ -0,0 +1,628 @@
+/*
+ * Copyright © 2008 Intel Corporation
+ *
+ * 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.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ * Zhigang Gong <zhigang.gong@linux.intel.com>
+ *
+ */
+
+/** @file glamor.c
+ * This file covers the initialization and teardown of glamor, and has various
+ * functions not responsible for performing rendering.
+ */
+
+#include <stdlib.h>
+
+#include "glamor_priv.h"
+
+static DevPrivateKeyRec glamor_screen_private_key_index;
+DevPrivateKey glamor_screen_private_key = &glamor_screen_private_key_index;
+static DevPrivateKeyRec glamor_pixmap_private_key_index;
+DevPrivateKey glamor_pixmap_private_key = &glamor_pixmap_private_key_index;
+
+/**
+ * glamor_get_drawable_pixmap() returns a backing pixmap for a given drawable.
+ *
+ * @param drawable the drawable being requested.
+ *
+ * This function returns the backing pixmap for a drawable, whether it is a
+ * redirected window, unredirected window, or already a pixmap. Note that
+ * coordinate translation is needed when drawing to the backing pixmap of a
+ * redirected window, and the translation coordinates are provided by calling
+ * exaGetOffscreenPixmap() on the drawable.
+ */
+PixmapPtr
+glamor_get_drawable_pixmap(DrawablePtr drawable)
+{
+ if (drawable->type == DRAWABLE_WINDOW)
+ return drawable->
+ pScreen->GetWindowPixmap((WindowPtr) drawable);
+ else
+ return (PixmapPtr) drawable;
+}
+
+_X_EXPORT void
+glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type)
+{
+ glamor_pixmap_private *pixmap_priv;
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(pixmap->drawable.pScreen);
+
+ pixmap_priv = dixLookupPrivate(&pixmap->devPrivates,
+ glamor_pixmap_private_key);
+ if (pixmap_priv == NULL) {
+ pixmap_priv = calloc(sizeof(*pixmap_priv), 1);
+ glamor_set_pixmap_private(pixmap, pixmap_priv);
+ pixmap_priv->base.pixmap = pixmap;
+ pixmap_priv->base.glamor_priv = glamor_priv;
+ }
+ pixmap_priv->type = type;
+}
+
+_X_EXPORT void
+glamor_set_pixmap_texture(PixmapPtr pixmap, unsigned int tex)
+{
+ ScreenPtr screen = pixmap->drawable.pScreen;
+ glamor_pixmap_private *pixmap_priv;
+ glamor_screen_private *glamor_priv;
+ glamor_pixmap_fbo *fbo;
+ GLenum format;
+
+ glamor_priv = glamor_get_screen_private(screen);
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+
+ if (pixmap_priv->base.fbo) {
+ fbo = glamor_pixmap_detach_fbo(pixmap_priv);
+ glamor_destroy_fbo(fbo);
+ }
+
+ gl_iformat_for_depth(pixmap->drawable.depth, &format);
+ fbo = glamor_create_fbo_from_tex(glamor_priv, pixmap->drawable.width,
+ pixmap->drawable.height,
+ format, tex, 0);
+
+ if (fbo == NULL) {
+ ErrorF("XXX fail to create fbo.\n");
+ return;
+ }
+
+ glamor_pixmap_attach_fbo(pixmap, fbo);
+}
+
+void
+glamor_set_screen_pixmap(PixmapPtr screen_pixmap, PixmapPtr *back_pixmap)
+{
+ glamor_pixmap_private *pixmap_priv;
+ glamor_screen_private *glamor_priv;
+
+ glamor_priv = glamor_get_screen_private(screen_pixmap->drawable.pScreen);
+ pixmap_priv = glamor_get_pixmap_private(screen_pixmap);
+ glamor_priv->screen_fbo = pixmap_priv->base.fbo->fb;
+
+ pixmap_priv->base.fbo->width = screen_pixmap->drawable.width;
+ pixmap_priv->base.fbo->height = screen_pixmap->drawable.height;
+
+ glamor_priv->back_pixmap = back_pixmap;
+}
+
+PixmapPtr
+glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
+ unsigned int usage)
+{
+ PixmapPtr pixmap;
+ glamor_pixmap_type_t type = GLAMOR_TEXTURE_ONLY;
+ glamor_pixmap_private *pixmap_priv;
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(screen);
+ glamor_pixmap_fbo *fbo;
+ int pitch;
+ GLenum format;
+
+ if (w > 32767 || h > 32767)
+ return NullPixmap;
+
+ if ((usage == GLAMOR_CREATE_PIXMAP_CPU
+ || (usage == CREATE_PIXMAP_USAGE_GLYPH_PICTURE && w <= 64 && h <= 64)
+ || (w == 0 && h == 0)
+ || !glamor_check_pixmap_fbo_depth(depth))
+ || (!GLAMOR_TEXTURED_LARGE_PIXMAP &&
+ !glamor_check_fbo_size(glamor_priv, w, h)))
+ return fbCreatePixmap(screen, w, h, depth, usage);
+ else
+ pixmap = fbCreatePixmap(screen, 0, 0, depth, usage);
+
+ pixmap_priv = calloc(1, sizeof(*pixmap_priv));
+
+ if (!pixmap_priv) {
+ fbDestroyPixmap(pixmap);
+ return fbCreatePixmap(screen, w, h, depth, usage);
+ }
+ glamor_set_pixmap_private(pixmap, pixmap_priv);
+
+ if (usage == GLAMOR_CREATE_PIXMAP_MAP)
+ type = GLAMOR_MEMORY_MAP;
+
+ pixmap_priv->base.pixmap = pixmap;
+ pixmap_priv->base.glamor_priv = glamor_priv;
+
+ gl_iformat_for_depth(depth, &format);
+
+ pitch = (((w * pixmap->drawable.bitsPerPixel + 7) / 8) + 3) & ~3;
+ screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, pitch, NULL);
+
+ if (type == GLAMOR_MEMORY_MAP || glamor_check_fbo_size(glamor_priv, w, h)) {
+ pixmap_priv->type = type;
+ fbo = glamor_create_fbo(glamor_priv, w, h, format, usage);
+ }
+ else {
+ DEBUGF("Create LARGE pixmap %p width %d height %d\n", pixmap, w, h);
+ pixmap_priv->type = GLAMOR_TEXTURE_LARGE;
+ fbo = glamor_create_fbo_array(glamor_priv, w, h, format, usage,
+ glamor_priv->max_fbo_size,
+ glamor_priv->max_fbo_size,
+ pixmap_priv);
+ }
+
+ if (fbo == NULL) {
+ fbDestroyPixmap(pixmap);
+ free(pixmap_priv);
+ return fbCreatePixmap(screen, w, h, depth, usage);
+ }
+
+ glamor_pixmap_attach_fbo(pixmap, fbo);
+
+ return pixmap;
+}
+
+void
+glamor_destroy_textured_pixmap(PixmapPtr pixmap)
+{
+ if (pixmap->refcnt == 1) {
+ glamor_pixmap_private *pixmap_priv;
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ if (pixmap_priv != NULL)
+ glamor_pixmap_destroy_fbo(pixmap_priv);
+ }
+}
+
+Bool
+glamor_destroy_pixmap(PixmapPtr pixmap)
+{
+ glamor_screen_private
+ *glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
+ if (glamor_priv->dri3_enabled)
+ glamor_egl_destroy_textured_pixmap(pixmap);
+ else
+ glamor_destroy_textured_pixmap(pixmap);
+ return fbDestroyPixmap(pixmap);
+}
+
+void
+glamor_block_handler(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(screen);
+ glamor_gl_dispatch *dispatch;
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+ glamor_priv->tick++;
+ dispatch->glFlush();
+ glamor_fbo_expire(glamor_priv);
+ glamor_put_dispatch(glamor_priv);
+ if (glamor_priv->state == RENDER_STATE
+ && glamor_priv->render_idle_cnt++ > RENDER_IDEL_MAX) {
+ glamor_priv->state = IDLE_STATE;
+ glamor_priv->render_idle_cnt = 0;
+ }
+}
+
+static void
+_glamor_block_handler(void *data, OSTimePtr timeout,
+ void *last_select_mask)
+{
+ glamor_screen_private *glamor_priv = data;
+ glamor_gl_dispatch *dispatch = glamor_get_dispatch(glamor_priv);
+ dispatch->glFlush();
+ glamor_put_dispatch(glamor_priv);
+}
+
+static void
+_glamor_wakeup_handler(void *data, int result, void *last_select_mask)
+{
+}
+
+static void
+glamor_set_debug_level(int *debug_level)
+{
+ char *debug_level_string;
+ debug_level_string = getenv("GLAMOR_DEBUG");
+ if (debug_level_string
+ && sscanf(debug_level_string, "%d", debug_level) == 1)
+ return;
+ *debug_level = 0;
+}
+
+int glamor_debug_level;
+
+/** Set up glamor for an already-configured GL context. */
+Bool
+glamor_init(ScreenPtr screen, unsigned int flags)
+{
+ glamor_screen_private *glamor_priv;
+ int gl_version;
+
+#ifdef RENDER
+ PictureScreenPtr ps = GetPictureScreenIfSet(screen);
+#endif
+ if (flags & ~GLAMOR_VALID_FLAGS) {
+ ErrorF("glamor_init: Invalid flags %x\n", flags);
+ return FALSE;
+ }
+ glamor_priv = calloc(1, sizeof(*glamor_priv));
+ if (glamor_priv == NULL)
+ return FALSE;
+
+ if (flags & GLAMOR_INVERTED_Y_AXIS) {
+ glamor_priv->yInverted = 1;
+ } else
+ glamor_priv->yInverted = 0;
+
+ if (!dixRegisterPrivateKey
+ (glamor_screen_private_key, PRIVATE_SCREEN, 0)) {
+ LogMessage(X_WARNING,
+ "glamor%d: Failed to allocate screen private\n",
+ screen->myNum);
+ goto fail;
+ }
+
+ glamor_set_screen_private(screen, glamor_priv);
+
+ if (!dixRegisterPrivateKey
+ (glamor_pixmap_private_key, PRIVATE_PIXMAP, 0)) {
+ LogMessage(X_WARNING,
+ "glamor%d: Failed to allocate pixmap private\n",
+ screen->myNum);
+ goto fail;;
+ }
+
+ gl_version = glamor_gl_get_version();
+
+#ifndef GLAMOR_GLES2
+ if (gl_version < GLAMOR_GL_VERSION_ENCODE(1, 3)) {
+ ErrorF("Require OpenGL version 1.3 or latter.\n");
+ goto fail;
+ }
+#else
+ if (gl_version < GLAMOR_GL_VERSION_ENCODE(2, 0)) {
+ ErrorF("Require Open GLES2.0 or latter.\n");
+ goto fail;
+ }
+#endif
+
+ glamor_gl_dispatch_init(screen, &glamor_priv->_dispatch, gl_version);
+
+#ifdef GLAMOR_GLES2
+ if (!glamor_gl_has_extension("GL_EXT_texture_format_BGRA8888")) {
+ ErrorF("GL_EXT_texture_format_BGRA8888 required\n");
+ goto fail;
+ }
+#endif
+
+ glamor_priv->has_pack_invert =
+ glamor_gl_has_extension("GL_MESA_pack_invert");
+ glamor_priv->has_fbo_blit =
+ glamor_gl_has_extension("GL_EXT_framebuffer_blit");
+ glamor_priv->_dispatch.glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE,
+ &glamor_priv->max_fbo_size);
+#ifdef MAX_FBO_SIZE
+ glamor_priv->max_fbo_size = MAX_FBO_SIZE;
+#endif
+
+ glamor_set_debug_level(&glamor_debug_level);
+
+#ifdef GLAMOR_GLES2
+ glamor_priv->gl_flavor = GLAMOR_GL_ES2;
+#else
+ glamor_priv->gl_flavor = GLAMOR_GL_DESKTOP;
+#endif
+ /* If we are using egl screen, call egl screen init to
+ * register correct close screen function. */
+ if (flags & GLAMOR_USE_EGL_SCREEN)
+ glamor_egl_screen_init(screen);
+
+ glamor_priv->saved_procs.close_screen = screen->CloseScreen;
+ screen->CloseScreen = glamor_close_screen;
+
+ if (flags & GLAMOR_USE_SCREEN) {
+ if (!RegisterBlockAndWakeupHandlers(_glamor_block_handler,
+ _glamor_wakeup_handler,
+ glamor_priv)) {
+ goto fail;
+ }
+
+ glamor_priv->saved_procs.create_gc = screen->CreateGC;
+ screen->CreateGC = glamor_create_gc;
+
+ glamor_priv->saved_procs.create_pixmap = screen->CreatePixmap;
+ screen->CreatePixmap = glamor_create_pixmap;
+
+ glamor_priv->saved_procs.destroy_pixmap = screen->DestroyPixmap;
+ screen->DestroyPixmap = glamor_destroy_pixmap;
+
+ glamor_priv->saved_procs.get_spans = screen->GetSpans;
+ screen->GetSpans = glamor_get_spans;
+
+ glamor_priv->saved_procs.get_image = screen->GetImage;
+ screen->GetImage = glamor_get_image;
+
+ glamor_priv->saved_procs.change_window_attributes =
+ screen->ChangeWindowAttributes;
+ screen->ChangeWindowAttributes =
+ glamor_change_window_attributes;
+
+ glamor_priv->saved_procs.copy_window = screen->CopyWindow;
+ screen->CopyWindow = glamor_copy_window;
+
+ glamor_priv->saved_procs.bitmap_to_region =
+ screen->BitmapToRegion;
+ screen->BitmapToRegion = glamor_bitmap_to_region;
+ }
+#ifdef RENDER
+ if (flags & GLAMOR_USE_PICTURE_SCREEN) {
+ glamor_priv->saved_procs.composite = ps->Composite;
+ ps->Composite = glamor_composite;
+
+
+ glamor_priv->saved_procs.trapezoids = ps->Trapezoids;
+ ps->Trapezoids = glamor_trapezoids;
+
+
+ glamor_priv->saved_procs.triangles = ps->Triangles;
+ ps->Triangles = glamor_triangles;
+
+ glamor_priv->saved_procs.addtraps = ps->AddTraps;
+ ps->AddTraps = glamor_add_traps;
+
+ }
+
+ glamor_priv->saved_procs.composite_rects = ps->CompositeRects;
+ ps->CompositeRects = glamor_composite_rectangles;
+
+ glamor_priv->saved_procs.glyphs = ps->Glyphs;
+ ps->Glyphs = glamor_glyphs;
+
+ glamor_priv->saved_procs.unrealize_glyph = ps->UnrealizeGlyph;
+ ps->UnrealizeGlyph = glamor_glyph_unrealize;
+
+ glamor_priv->saved_procs.create_picture = ps->CreatePicture;
+ ps->CreatePicture = glamor_create_picture;
+
+ glamor_priv->saved_procs.set_window_pixmap = screen->SetWindowPixmap;
+ screen->SetWindowPixmap = glamor_set_window_pixmap;
+
+ glamor_priv->saved_procs.destroy_picture = ps->DestroyPicture;
+ ps->DestroyPicture = glamor_destroy_picture;
+ glamor_init_composite_shaders(screen);
+#endif
+ glamor_init_pixmap_fbo(screen);
+ glamor_init_solid_shader(screen);
+ glamor_init_tile_shader(screen);
+#ifdef GLAMOR_TRAPEZOID_SHADER
+ glamor_init_trapezoid_shader(screen);
+#endif
+ glamor_init_putimage_shaders(screen);
+ glamor_init_finish_access_shaders(screen);
+#ifdef GLAMOR_GRADIENT_SHADER
+ glamor_init_gradient_shader(screen);
+#endif
+#ifdef GLAMOR_XV
+ glamor_init_xv_shader(screen);
+#endif
+ glamor_pixmap_init(screen);
+
+ glamor_priv->flags = flags;
+ glamor_priv->screen = screen;
+
+ return TRUE;
+
+ fail:
+ free(glamor_priv);
+ glamor_set_screen_private(screen, NULL);
+ return FALSE;
+}
+
+static void
+glamor_release_screen_priv(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv;
+
+ glamor_priv = glamor_get_screen_private(screen);
+#ifdef GLAMOR_XV
+ glamor_fini_xv_shader(screen);
+#endif
+#ifdef RENDER
+ glamor_fini_composite_shaders(screen);
+#endif
+ glamor_fini_pixmap_fbo(screen);
+ glamor_fini_solid_shader(screen);
+ glamor_fini_tile_shader(screen);
+#ifdef GLAMOR_TRAPEZOID_SHADER
+ glamor_fini_trapezoid_shader(screen);
+#endif
+ glamor_fini_putimage_shaders(screen);
+ glamor_fini_finish_access_shaders(screen);
+#ifdef GLAMOR_GRADIENT_SHADER
+ glamor_fini_gradient_shader(screen);
+#endif
+ glamor_pixmap_fini(screen);
+ free(glamor_priv);
+
+ glamor_set_screen_private(screen, NULL);
+}
+
+_X_EXPORT void
+glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv)
+{
+ glamor_pixmap_private *old_priv;
+ glamor_pixmap_fbo *fbo;
+
+ old_priv = dixGetPrivate(&pixmap->devPrivates, glamor_pixmap_private_key);
+
+ if (priv) {
+ assert(old_priv == NULL);
+ } else {
+ if (old_priv == NULL)
+ return;
+ fbo = glamor_pixmap_detach_fbo(old_priv);
+ glamor_purge_fbo(fbo);
+ free(old_priv);
+ }
+
+ dixSetPrivate(&pixmap->devPrivates,
+ glamor_pixmap_private_key,
+ priv);
+}
+
+Bool
+glamor_close_screen(CLOSE_SCREEN_ARGS_DECL)
+{
+ glamor_screen_private *glamor_priv;
+ PixmapPtr screen_pixmap;
+ int flags;
+#ifdef RENDER
+ PictureScreenPtr ps = GetPictureScreenIfSet(screen);
+#endif
+ glamor_priv = glamor_get_screen_private(screen);
+ flags = glamor_priv->flags;
+ glamor_glyphs_fini(screen);
+ screen->CloseScreen = glamor_priv->saved_procs.close_screen;
+ if (flags & GLAMOR_USE_SCREEN) {
+
+ screen->CreateGC = glamor_priv->saved_procs.create_gc;
+ screen->CreatePixmap = glamor_priv->saved_procs.create_pixmap;
+ screen->DestroyPixmap = glamor_priv->saved_procs.destroy_pixmap;
+ screen->GetSpans = glamor_priv->saved_procs.get_spans;
+ screen->ChangeWindowAttributes =
+ glamor_priv->saved_procs.change_window_attributes;
+ screen->CopyWindow = glamor_priv->saved_procs.copy_window;
+ screen->BitmapToRegion = glamor_priv->saved_procs.bitmap_to_region;
+ }
+#ifdef RENDER
+ if (ps && (flags & GLAMOR_USE_PICTURE_SCREEN)) {
+
+ ps->Composite = glamor_priv->saved_procs.composite;
+ ps->Trapezoids = glamor_priv->saved_procs.trapezoids;
+ ps->Triangles = glamor_priv->saved_procs.triangles;
+ ps->CreatePicture = glamor_priv->saved_procs.create_picture;
+ }
+ ps->CompositeRects = glamor_priv->saved_procs.composite_rects;
+ ps->Glyphs = glamor_priv->saved_procs.glyphs;
+ ps->UnrealizeGlyph = glamor_priv->saved_procs.unrealize_glyph;
+ screen->SetWindowPixmap = glamor_priv->saved_procs.set_window_pixmap;
+#endif
+ screen_pixmap = screen->GetScreenPixmap(screen);
+ glamor_set_pixmap_private(screen_pixmap, NULL);
+ if (glamor_priv->back_pixmap && *glamor_priv->back_pixmap)
+ glamor_set_pixmap_private(*glamor_priv->back_pixmap, NULL);
+
+ glamor_release_screen_priv(screen);
+
+ return screen->CloseScreen(CLOSE_SCREEN_ARGS);
+}
+
+
+void
+glamor_fini(ScreenPtr screen)
+{
+ /* Do nothing currently. */
+}
+
+void glamor_enable_dri3(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(screen);
+ glamor_priv->dri3_enabled = TRUE;
+}
+
+Bool glamor_is_dri3_support_enabled(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(screen);
+ return glamor_priv->dri3_enabled;
+}
+
+int
+glamor_dri3_fd_from_pixmap (ScreenPtr screen,
+ PixmapPtr pixmap,
+ CARD16 *stride,
+ CARD32 *size)
+{
+ glamor_pixmap_private *pixmap_priv;
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(pixmap->drawable.pScreen);
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ if (pixmap_priv == NULL || !glamor_priv->dri3_enabled)
+ return -1;
+ switch (pixmap_priv->type)
+ {
+ case GLAMOR_TEXTURE_DRM:
+ case GLAMOR_TEXTURE_ONLY:
+ glamor_pixmap_ensure_fbo(pixmap, GL_RGBA, 0);
+ return glamor_egl_dri3_fd_name_from_tex(screen,
+ pixmap,
+ pixmap_priv->base.fbo->tex,
+ FALSE,
+ stride,
+ size);
+ default: break;
+ }
+ return -1;
+}
+
+int
+glamor_dri3_name_from_pixmap (PixmapPtr pixmap)
+{
+ glamor_pixmap_private *pixmap_priv;
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(pixmap->drawable.pScreen);
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ if (pixmap_priv == NULL || !glamor_priv->dri3_enabled)
+ return -1;
+ switch (pixmap_priv->type)
+ {
+ case GLAMOR_TEXTURE_DRM:
+ case GLAMOR_TEXTURE_ONLY:
+ glamor_pixmap_ensure_fbo(pixmap, GL_RGBA, 0);
+ return glamor_egl_dri3_fd_name_from_tex(pixmap->drawable.pScreen,
+ pixmap,
+ pixmap_priv->base.fbo->tex,
+ TRUE,
+ NULL,
+ NULL);
+ default: break;
+ }
+ return -1;
+}
diff --git a/xorg-server/glamor/glamor.h b/xorg-server/glamor/glamor.h
new file mode 100644
index 000000000..1bb48ed74
--- /dev/null
+++ b/xorg-server/glamor/glamor.h
@@ -0,0 +1,432 @@
+/*
+ * Copyright © 2008 Intel Corporation
+ *
+ * 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.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ * Zhigang Gong <zhigang.gong@linux.intel.com>
+ *
+ */
+
+#ifndef GLAMOR_H
+#define GLAMOR_H
+
+#include <scrnintstr.h>
+#include <xf86.h>
+#include <xf86str.h>
+#include <pixmapstr.h>
+#include <gcstruct.h>
+#include <picturestr.h>
+#include <fb.h>
+#include <fbpict.h>
+#include <xf86xv.h>
+/*
+ * glamor_pixmap_type : glamor pixmap's type.
+ * @MEMORY: pixmap is in memory.
+ * @TEXTURE_DRM: pixmap is in a texture created from a DRM buffer.
+ * @SEPARATE_TEXTURE: The texture is created from a DRM buffer, but
+ * the format is incompatible, so this type of pixmap
+ * will never fallback to DDX layer.
+ * @DRM_ONLY: pixmap is in a external DRM buffer.
+ * @TEXTURE_ONLY: pixmap is in an internal texture.
+ */
+typedef enum glamor_pixmap_type {
+ GLAMOR_MEMORY,
+ GLAMOR_MEMORY_MAP,
+ GLAMOR_TEXTURE_DRM,
+ GLAMOR_SEPARATE_TEXTURE,
+ GLAMOR_DRM_ONLY,
+ GLAMOR_TEXTURE_ONLY,
+ GLAMOR_TEXTURE_LARGE,
+ GLAMOR_TEXTURE_PACK
+} glamor_pixmap_type_t;
+
+#define GLAMOR_EGL_EXTERNAL_BUFFER 3
+#define GLAMOR_INVERTED_Y_AXIS 1
+#define GLAMOR_USE_SCREEN (1 << 1)
+#define GLAMOR_USE_PICTURE_SCREEN (1 << 2)
+#define GLAMOR_USE_EGL_SCREEN (1 << 3)
+#define GLAMOR_VALID_FLAGS (GLAMOR_INVERTED_Y_AXIS \
+ | GLAMOR_USE_SCREEN \
+ | GLAMOR_USE_PICTURE_SCREEN \
+ | GLAMOR_USE_EGL_SCREEN)
+
+/* @glamor_init: Initialize glamor internal data structure.
+ *
+ * @screen: Current screen pointer.
+ * @flags: Please refer the flags description above.
+ *
+ * @GLAMOR_INVERTED_Y_AXIS:
+ * set 1 means the GL env's origin (0,0) is at top-left.
+ * EGL/DRM platform is an example need to set this bit.
+ * glx platform's origin is at bottom-left thus need to
+ * clear this bit.
+ *
+ * @GLAMOR_USE_SCREEN:
+ * If running in an pre-existing X environment, and the
+ * gl context is GLX, then you should set this bit and
+ * let the glamor to handle all the screen related
+ * functions such as GC ops and CreatePixmap/DestroyPixmap.
+ *
+ * @GLAMOR_USE_PICTURE_SCREEN:
+ * If don't use any other underlying DDX driver to handle
+ * the picture related rendering functions, please set this
+ * bit on. Otherwise, clear this bit. And then it is the DDX
+ * driver's responsibility to determine how/when to jump to
+ * glamor's picture compositing path.
+ *
+ * @GLAMOR_USE_EGL_SCREEN:
+ * If you are using EGL layer, then please set this bit
+ * on, otherwise, clear it.
+ *
+ * This function initializes necessary internal data structure
+ * for glamor. And before calling into this function, the OpenGL
+ * environment should be ready. Should be called before any real
+ * glamor rendering or texture allocation functions. And should
+ * be called after the DDX's screen initialization or at the last
+ * step of the DDX's screen initialization.
+ */
+extern _X_EXPORT Bool glamor_init(ScreenPtr screen, unsigned int flags);
+extern _X_EXPORT void glamor_fini(ScreenPtr screen);
+
+/* This function is used to free the glamor private screen's
+ * resources. If the DDX driver is not set GLAMOR_USE_SCREEN,
+ * then, DDX need to call this function at proper stage, if
+ * it is the xorg DDX driver,then it should be called at free
+ * screen stage not the close screen stage. The reason is after
+ * call to this function, the xorg DDX may need to destroy the
+ * screen pixmap which must be a glamor pixmap and requires
+ * the internal data structure still exist at that time.
+ * Otherwise, the glamor internal structure will not be freed.*/
+#ifndef XF86_SCRN_INTERFACE
+extern _X_EXPORT Bool glamor_close_screen(int scrnIndex, ScreenPtr screen);
+#else
+extern _X_EXPORT Bool glamor_close_screen(ScreenPtr screen);
+#endif
+
+
+/* Let glamor to know the screen's fbo. The low level
+ * driver should already assign a tex
+ * to this pixmap through the set_pixmap_texture. */
+extern _X_EXPORT void glamor_set_screen_pixmap(PixmapPtr screen_pixmap, PixmapPtr *back_pixmap);
+
+/* @glamor_glyphs_init: Initialize glyphs internal data structures.
+ *
+ * @pScreen: Current screen pointer.
+ *
+ * This function must be called after the glamor_init and the texture
+ * can be allocated. An example is to call it when create the screen
+ * resources at DDX layer.
+ */
+extern _X_EXPORT Bool glamor_glyphs_init(ScreenPtr pScreen);
+
+extern _X_EXPORT void glamor_set_pixmap_texture(PixmapPtr pixmap,
+ unsigned int tex);
+
+extern _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type);
+extern _X_EXPORT void glamor_destroy_textured_pixmap(PixmapPtr pixmap);
+extern _X_EXPORT void glamor_block_handler(ScreenPtr screen);
+extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
+ unsigned int usage);
+
+extern _X_EXPORT void glamor_egl_screen_init(ScreenPtr screen);
+
+extern _X_EXPORT void glamor_egl_make_current(ScreenPtr screen);
+extern _X_EXPORT void glamor_egl_restore_context(ScreenPtr screen);
+
+/* @glamor_egl_exchange_buffers: Exchange the underlying buffers(KHR image,fbo).
+ *
+ * @front: front pixmap.
+ * @back: back pixmap.
+ *
+ * Used by the DRI2 page flip. This function will exchange the KHR images and
+ * fbos of the two pixmaps.
+ * */
+extern _X_EXPORT void glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr back);
+
+extern _X_EXPORT void glamor_pixmap_exchange_fbos(PixmapPtr front, PixmapPtr back);
+
+/* The DDX is not supposed to call these three functions */
+extern _X_EXPORT void glamor_enable_dri3(ScreenPtr screen);
+extern _X_EXPORT unsigned int glamor_egl_create_argb8888_based_texture(ScreenPtr screen, int w, int h);
+extern _X_EXPORT int glamor_egl_dri3_fd_name_from_tex(ScreenPtr, PixmapPtr, unsigned int, Bool, CARD16*, CARD32*);
+
+/* @glamor_is_dri3_support_enabled: Returns if DRI3 support is enabled.
+ *
+ * @screen: Current screen pointer.
+ *
+ * To have DRI3 support enabled, glamor and glamor_egl need to be initialized,
+ * and glamor_egl_init_textured_pixmap need to be called. glamor also
+ * has to be compiled with gbm support.
+ * The EGL layer need to have the following extensions working:
+ * .EGL_KHR_gl_texture_2D_image
+ * .EGL_EXT_image_dma_buf_import
+ * If DRI3 support is not enabled, the following helpers will return an error.
+ * */
+extern _X_EXPORT Bool glamor_is_dri3_support_enabled(ScreenPtr screen);
+
+/* @glamor_dri3_fd_from_pixmap: DRI3 helper to get a dma-buf fd from a pixmap.
+ *
+ * @screen: Current screen pointer.
+ * @pixmap: The pixmap from which we want the fd.
+ * @stride, @size: Pointers to fill the stride and size of the
+ * buffer associated to the fd.
+ *
+ * the pixmap and the buffer associated by the fd will share the same
+ * content.
+ * Returns the fd on success, -1 on error.
+ * */
+extern _X_EXPORT int glamor_dri3_fd_from_pixmap (ScreenPtr screen,
+ PixmapPtr pixmap,
+ CARD16 *stride,
+ CARD32 *size);
+
+/* @glamor_dri3_name_from_pixmap: helper to get an gem name from a pixmap.
+ *
+ * @pixmap: The pixmap from which we want the gem name.
+ *
+ * the pixmap and the buffer associated by the gem name will share the same
+ * content. This function can be used by the DDX to support DRI2, but needs
+ * glamor DRI3 support to be activated.
+ * Returns the name on success, -1 on error.
+ * */
+extern _X_EXPORT int glamor_dri3_name_from_pixmap (PixmapPtr pixmap);
+
+/* @glamor_egl_dri3_pixmap_from_fd: DRI3 helper to get a pixmap from a dma-buf fd.
+ *
+ * @screen: Current screen pointer.
+ * @fd: The dma-buf fd to import.
+ * @width: The width of the buffer.
+ * @height: The height of the buffer.
+ * @stride: The stride of the buffer.
+ * @depth: The depth of the buffer.
+ * @bpp: The number of bpp of the buffer.
+ *
+ * Returns a valid pixmap if the import succeeded, else NULL.
+ * */
+extern _X_EXPORT PixmapPtr glamor_egl_dri3_pixmap_from_fd (ScreenPtr screen,
+ int fd,
+ CARD16 width,
+ CARD16 height,
+ CARD16 stride,
+ CARD8 depth,
+ CARD8 bpp);
+
+#ifdef GLAMOR_FOR_XORG
+
+#define GLAMOR_EGL_MODULE_NAME "glamoregl"
+
+/* @glamor_egl_init: Initialize EGL environment.
+ *
+ * @scrn: Current screen info pointer.
+ * @fd: Current drm fd.
+ *
+ * This function creates and intialize EGL contexts.
+ * Should be called from DDX's preInit function.
+ * Return TRUE if success, otherwise return FALSE.
+ * */
+extern _X_EXPORT Bool glamor_egl_init(ScrnInfoPtr scrn, int fd);
+
+/* @glamor_egl_init_textured_pixmap: Initialization for textured pixmap allocation.
+ *
+ * @screen: Current screen pointer.
+ *
+ * This function must be called before any textured pixmap's creation including
+ * the screen pixmap. Could be called from DDX's screenInit function after the calling
+ * to glamor_init..
+ */
+extern _X_EXPORT Bool glamor_egl_init_textured_pixmap(ScreenPtr screen);
+
+/* @glamor_egl_create_textured_screen: Create textured screen pixmap.
+ *
+ * @screen: screen pointer to be processed.
+ * @handle: screen pixmap's BO handle.
+ * @stride: screen pixmap's stride in bytes.
+ *
+ * This function is similar with the create_textured_pixmap. As the
+ * screen pixmap is a special, we handle it separately in this function.
+ */
+extern _X_EXPORT Bool glamor_egl_create_textured_screen(ScreenPtr screen,
+ int handle,
+ int stride);
+
+/* @glamor_egl_create_textured_screen_ext:
+ *
+ * extent one parameter to track the pointer of the DDX layer's back pixmap.
+ * We need this pointer during the closing screen stage. As before back to
+ * the DDX's close screen, we have to free all the glamor related resources.
+ */
+extern _X_EXPORT Bool glamor_egl_create_textured_screen_ext(ScreenPtr screen,
+ int handle,
+ int stride,
+ PixmapPtr *back_pixmap);
+
+/*
+ * @glamor_egl_create_textured_pixmap: Try to create a textured pixmap from
+ * a BO handle.
+ *
+ * @pixmap: The pixmap need to be processed.
+ * @handle: The BO's handle attached to this pixmap at DDX layer.
+ * @stride: Stride in bytes for this pixmap.
+ *
+ * This function try to create a texture from the handle and attach
+ * the texture to the pixmap , thus glamor can render to this pixmap
+ * as well. Return true if successful, otherwise return FALSE.
+ */
+extern _X_EXPORT Bool glamor_egl_create_textured_pixmap(PixmapPtr pixmap,
+ int handle,
+ int stride);
+
+/*
+ * @glamor_egl_create_textured_pixmap_from_bo: Try to create a textured pixmap
+ * from a gbm_bo.
+ *
+ * @pixmap: The pixmap need to be processed.
+ * @bo: a pointer on a gbm_bo structure attached to this pixmap at DDX layer.
+ *
+ * This function is similar to glamor_egl_create_textured_pixmap.
+ */
+extern _X_EXPORT Bool
+ glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap,
+ void *bo);
+
+#endif
+
+extern _X_EXPORT void glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap);
+
+extern _X_EXPORT int glamor_create_gc(GCPtr gc);
+
+extern _X_EXPORT void glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable);
+/* Glamor rendering/drawing functions with XXX_nf.
+ * nf means no fallback within glamor internal if possible. If glamor
+ * fail to accelerate the operation, glamor will return a false, and the
+ * caller need to implement fallback method. Return a true means the
+ * rendering request get done successfully. */
+extern _X_EXPORT Bool glamor_fill_spans_nf(DrawablePtr drawable,
+ GCPtr gc,
+ int n, DDXPointPtr points,
+ int *widths, int sorted);
+
+extern _X_EXPORT Bool glamor_poly_fill_rect_nf(DrawablePtr drawable,
+ GCPtr gc,
+ int nrect,
+ xRectangle * prect);
+
+extern _X_EXPORT Bool glamor_put_image_nf(DrawablePtr drawable,
+ GCPtr gc, int depth, int x, int y,
+ int w, int h, int left_pad,
+ int image_format, char *bits);
+
+extern _X_EXPORT Bool glamor_copy_n_to_n_nf(DrawablePtr src,
+ DrawablePtr dst,
+ GCPtr gc,
+ BoxPtr box,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown, Pixel bitplane,
+ void *closure);
+
+extern _X_EXPORT Bool glamor_composite_nf(CARD8 op,
+ PicturePtr source,
+ PicturePtr mask,
+ PicturePtr dest,
+ INT16 x_source,
+ INT16 y_source,
+ INT16 x_mask,
+ INT16 y_mask,
+ INT16 x_dest, INT16 y_dest,
+ CARD16 width, CARD16 height);
+
+extern _X_EXPORT Bool glamor_trapezoids_nf(CARD8 op,
+ PicturePtr src, PicturePtr dst,
+ PictFormatPtr mask_format,
+ INT16 x_src, INT16 y_src,
+ int ntrap, xTrapezoid * traps);
+
+extern _X_EXPORT Bool glamor_glyphs_nf(CARD8 op,
+ PicturePtr src,
+ PicturePtr dst,
+ PictFormatPtr mask_format,
+ INT16 x_src,
+ INT16 y_src, int nlist,
+ GlyphListPtr list, GlyphPtr * glyphs);
+
+extern _X_EXPORT Bool glamor_triangles_nf(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc, INT16 ySrc,
+ int ntris, xTriangle * tris);
+
+
+extern _X_EXPORT void glamor_glyph_unrealize(ScreenPtr screen, GlyphPtr glyph);
+
+extern _X_EXPORT Bool glamor_set_spans_nf(DrawablePtr drawable, GCPtr gc, char *src,
+ DDXPointPtr points, int *widths, int n, int sorted);
+
+extern _X_EXPORT Bool glamor_get_spans_nf(DrawablePtr drawable, int wmax,
+ DDXPointPtr points, int *widths, int count, char *dst);
+
+extern _X_EXPORT Bool glamor_composite_rects_nf (CARD8 op,
+ PicturePtr pDst,
+ xRenderColor *color,
+ int nRect,
+ xRectangle *rects);
+
+extern _X_EXPORT Bool glamor_get_image_nf(DrawablePtr pDrawable, int x, int y, int w, int h,
+ unsigned int format, unsigned long planeMask, char *d);
+
+extern _X_EXPORT Bool glamor_add_traps_nf(PicturePtr pPicture,
+ INT16 x_off,
+ INT16 y_off, int ntrap, xTrap * traps);
+
+extern _X_EXPORT Bool glamor_copy_plane_nf(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int w, int h, int dstx, int dsty,
+ unsigned long bitPlane, RegionPtr *pRegion);
+
+extern _X_EXPORT Bool glamor_image_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase);
+
+extern _X_EXPORT Bool glamor_poly_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase);
+
+extern _X_EXPORT Bool glamor_push_pixels_nf(GCPtr pGC, PixmapPtr pBitmap,
+ DrawablePtr pDrawable, int w, int h, int x, int y);
+
+extern _X_EXPORT Bool glamor_poly_point_nf(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
+ DDXPointPtr ppt);
+
+extern _X_EXPORT Bool glamor_poly_segment_nf(DrawablePtr pDrawable, GCPtr pGC, int nseg,
+ xSegment *pSeg);
+
+extern _X_EXPORT Bool glamor_poly_line_nf(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
+ DDXPointPtr ppt);
+
+extern _X_EXPORT Bool glamor_poly_lines_nf(DrawablePtr drawable, GCPtr gc, int mode, int n,
+ DDXPointPtr points);
+
+extern _X_EXPORT XF86VideoAdaptorPtr glamor_xv_init(ScreenPtr pScreen, int num_texture_ports);
+
+#endif /* GLAMOR_H */
diff --git a/xorg-server/glamor/glamor_addtraps.c b/xorg-server/glamor/glamor_addtraps.c
new file mode 100644
index 000000000..ac852963c
--- /dev/null
+++ b/xorg-server/glamor/glamor_addtraps.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ * Copyright © 1998 Keith Packard
+ *
+ * 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.
+ *
+ * Authors:
+ * Zhigang Gong <zhigang.gong@gmail.com>
+ *
+ */
+
+#include "glamor_priv.h"
+
+static Bool
+_glamor_add_traps(PicturePtr pPicture,
+ INT16 x_off,
+ INT16 y_off, int ntrap, xTrap * traps,
+ Bool fallback)
+{
+ if (!fallback
+ && ( !pPicture->pDrawable
+ || glamor_ddx_fallback_check_pixmap(pPicture->pDrawable)))
+ return FALSE;
+
+ if (glamor_prepare_access_picture(pPicture, GLAMOR_ACCESS_RW)) {
+ fbAddTraps(pPicture, x_off, y_off, ntrap, traps);
+ glamor_finish_access_picture(pPicture, GLAMOR_ACCESS_RW);
+ }
+
+ return TRUE;
+}
+
+void
+glamor_add_traps(PicturePtr pPicture,
+ INT16 x_off,
+ INT16 y_off, int ntrap, xTrap * traps)
+{
+ _glamor_add_traps(pPicture, x_off, y_off, ntrap, traps, TRUE);
+}
+
+Bool
+glamor_add_traps_nf(PicturePtr pPicture,
+ INT16 x_off,
+ INT16 y_off, int ntrap, xTrap * traps)
+{
+ return _glamor_add_traps(pPicture, x_off, y_off, ntrap, traps, FALSE);
+}
+
diff --git a/xorg-server/glamor/glamor_compositerects.c b/xorg-server/glamor/glamor_compositerects.c
new file mode 100644
index 000000000..1a5769958
--- /dev/null
+++ b/xorg-server/glamor/glamor_compositerects.c
@@ -0,0 +1,278 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ *
+ * 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.
+ *
+ * Authors:
+ * Zhigang Gong <zhigang.gong@linux.intel.com>
+ *
+ * original author is Chris Wilson at sna.
+ *
+ */
+
+#include "glamor_priv.h"
+#include "mipict.h"
+#include "damage.h"
+
+/** @file glamor_compositerects.
+ *
+ * compositeRects acceleration implementation
+ */
+
+static int16_t bound(int16_t a, uint16_t b)
+{
+ int v = (int)a + (int)b;
+ if (v > MAXSHORT)
+ return MAXSHORT;
+ return v;
+}
+
+static Bool
+_pixman_region_init_clipped_rectangles(pixman_region16_t *region,
+ unsigned int num_rects,
+ xRectangle *rects,
+ int tx, int ty,
+ BoxPtr extents)
+{
+ pixman_box16_t stack_boxes[64], *boxes = stack_boxes;
+ pixman_bool_t ret;
+ unsigned int i, j;
+
+ if (num_rects > ARRAY_SIZE(stack_boxes)) {
+ boxes = malloc(sizeof(pixman_box16_t) * num_rects);
+ if (boxes == NULL)
+ return FALSE;
+ }
+
+ for (i = j = 0; i < num_rects; i++) {
+ boxes[j].x1 = rects[i].x + tx;
+ if (boxes[j].x1 < extents->x1)
+ boxes[j].x1 = extents->x1;
+
+ boxes[j].y1 = rects[i].y + ty;
+ if (boxes[j].y1 < extents->y1)
+ boxes[j].y1 = extents->y1;
+
+ boxes[j].x2 = bound(rects[i].x + tx, rects[i].width);
+ if (boxes[j].x2 > extents->x2)
+ boxes[j].x2 = extents->x2;
+
+ boxes[j].y2 = bound(rects[i].y + ty, rects[i].height);
+ if (boxes[j].y2 > extents->y2)
+ boxes[j].y2 = extents->y2;
+
+ if (boxes[j].x2 > boxes[j].x1 && boxes[j].y2 > boxes[j].y1)
+ j++;
+ }
+
+ ret = FALSE;
+ if (j)
+ ret = pixman_region_init_rects(region, boxes, j);
+
+ if (boxes != stack_boxes)
+ free(boxes);
+
+ DEBUGF("%s: nrects=%d, region=(%d, %d), (%d, %d) x %d\n",
+ __FUNCTION__, num_rects,
+ region->extents.x1, region->extents.y1,
+ region->extents.x2, region->extents.y2,
+ j);
+ return ret;
+}
+
+
+void
+glamor_composite_rectangles(CARD8 op,
+ PicturePtr dst,
+ xRenderColor *color,
+ int num_rects,
+ xRectangle *rects)
+{
+ PixmapPtr pixmap;
+ struct glamor_pixmap_private *priv;
+ pixman_region16_t region;
+ pixman_box16_t *boxes;
+ int dst_x, dst_y;
+ int num_boxes;
+ PicturePtr source = NULL;
+ Bool need_free_region = FALSE;
+
+ DEBUGF("%s(op=%d, %08x x %d [(%d, %d)x(%d, %d) ...])\n",
+ __FUNCTION__, op,
+ (color->alpha >> 8 << 24) |
+ (color->red >> 8 << 16) |
+ (color->green >> 8 << 8) |
+ (color->blue >> 8 << 0),
+ num_rects,
+ rects[0].x, rects[0].y, rects[0].width, rects[0].height);
+
+ if (!num_rects)
+ return;
+
+ if (region_is_empty(dst->pCompositeClip)) {
+ DEBUGF("%s: empty clip, skipping\n", __FUNCTION__);
+ return;
+ }
+
+ if ((color->red|color->green|color->blue|color->alpha) <= 0x00ff) {
+ switch (op) {
+ case PictOpOver:
+ case PictOpOutReverse:
+ case PictOpAdd:
+ return;
+ case PictOpInReverse:
+ case PictOpSrc:
+ op = PictOpClear;
+ break;
+ case PictOpAtopReverse:
+ op = PictOpOut;
+ break;
+ case PictOpXor:
+ op = PictOpOverReverse;
+ break;
+ }
+ }
+ if (color->alpha <= 0x00ff) {
+ switch (op) {
+ case PictOpOver:
+ case PictOpOutReverse:
+ return;
+ case PictOpInReverse:
+ op = PictOpClear;
+ break;
+ case PictOpAtopReverse:
+ op = PictOpOut;
+ break;
+ case PictOpXor:
+ op = PictOpOverReverse;
+ break;
+ }
+ } else if (color->alpha >= 0xff00) {
+ switch (op) {
+ case PictOpOver:
+ op = PictOpSrc;
+ break;
+ case PictOpInReverse:
+ return;
+ case PictOpOutReverse:
+ op = PictOpClear;
+ break;
+ case PictOpAtopReverse:
+ op = PictOpOverReverse;
+ break;
+ case PictOpXor:
+ op = PictOpOut;
+ break;
+ }
+ }
+ DEBUGF("%s: converted to op %d\n", __FUNCTION__, op);
+
+ if (!_pixman_region_init_clipped_rectangles(&region,
+ num_rects, rects,
+ dst->pDrawable->x,
+ dst->pDrawable->y,
+ &dst->pCompositeClip->extents))
+ {
+ DEBUGF("%s: allocation failed for region\n", __FUNCTION__);
+ return;
+ }
+
+ pixmap = glamor_get_drawable_pixmap(dst->pDrawable);
+ priv = glamor_get_pixmap_private(pixmap);
+
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(priv))
+ goto fallback;
+ if (dst->alphaMap) {
+ DEBUGF("%s: fallback, dst has an alpha-map\n", __FUNCTION__);
+ goto fallback;
+ }
+
+ need_free_region = TRUE;
+
+ DEBUGF("%s: drawable extents (%d, %d),(%d, %d) x %d\n",
+ __FUNCTION__,
+ RegionExtents(&region)->x1, RegionExtents(&region)->y1,
+ RegionExtents(&region)->x2, RegionExtents(&region)->y2,
+ RegionNumRects(&region));
+
+ if (dst->pCompositeClip->data &&
+ (!pixman_region_intersect(&region, &region, dst->pCompositeClip) ||
+ region_is_empty(&region))) {
+ DEBUGF("%s: zero-intersection between rectangles and clip\n",
+ __FUNCTION__);
+ pixman_region_fini(&region);
+ return;
+ }
+
+ DEBUGF("%s: clipped extents (%d, %d),(%d, %d) x %d\n",
+ __FUNCTION__,
+ RegionExtents(&region)->x1, RegionExtents(&region)->y1,
+ RegionExtents(&region)->x2, RegionExtents(&region)->y2,
+ RegionNumRects(&region));
+
+ glamor_get_drawable_deltas(dst->pDrawable, pixmap, &dst_x, &dst_y);
+ pixman_region_translate(&region, dst_x, dst_y);
+
+ DEBUGF("%s: pixmap +(%d, %d) extents (%d, %d),(%d, %d)\n",
+ __FUNCTION__, dst_x, dst_y,
+ RegionExtents(&region)->x1, RegionExtents(&region)->y1,
+ RegionExtents(&region)->x2, RegionExtents(&region)->y2);
+
+
+ boxes = pixman_region_rectangles(&region, &num_boxes);
+ if (op == PictOpSrc || op == PictOpClear) {
+ CARD32 pixel;
+ if (op == PictOpClear)
+ pixel = 0;
+ else
+ miRenderColorToPixel(dst->pFormat, color, &pixel);
+ glamor_solid_boxes(pixmap, boxes, num_boxes, pixel);
+
+ goto done;
+ } else {
+ if (likely(priv->type != GLAMOR_TEXTURE_LARGE)) {
+ int error;
+
+ source = CreateSolidPicture(0, color, &error);
+ if (!source)
+ goto done;
+ if (glamor_composite_clipped_region(op, source,
+ NULL, dst,
+ NULL, NULL, priv,
+ &region,
+ 0,0,0,0,0,0))
+ goto done;
+ }
+ }
+fallback:
+ miCompositeRects(op, dst, color, num_rects, rects);
+done:
+ /* XXX xserver-1.8: CompositeRects is not tracked by Damage, so we must
+ * manually append the damaged regions ourselves.
+ */
+ DamageRegionAppend(&pixmap->drawable, &region);
+ DamageRegionProcessPending(&pixmap->drawable);
+
+ if (need_free_region)
+ pixman_region_fini(&region);
+ if (source)
+ FreePicture(source, 0);
+ return;
+}
diff --git a/xorg-server/glamor/glamor_copyarea.c b/xorg-server/glamor/glamor_copyarea.c
new file mode 100644
index 000000000..4e6f953d2
--- /dev/null
+++ b/xorg-server/glamor/glamor_copyarea.c
@@ -0,0 +1,676 @@
+/*
+ * Copyright © 2008 Intel Corporation
+ * Copyright © 1998 Keith Packard
+ *
+ * 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 Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ * Zhigang Gong <zhigang.gong@linux.intel.com>
+ */
+
+#include "glamor_priv.h"
+
+/** @file glamor_copyarea.c
+ *
+ * GC CopyArea implementation
+ */
+#ifndef GLAMOR_GLES2
+static Bool
+glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
+ DrawablePtr dst,
+ GCPtr gc, BoxPtr box, int nbox, int dx, int dy)
+{
+ ScreenPtr screen = dst->pScreen;
+ PixmapPtr dst_pixmap = glamor_get_drawable_pixmap(dst);
+ PixmapPtr src_pixmap = glamor_get_drawable_pixmap(src);
+ glamor_pixmap_private *src_pixmap_priv, *dst_pixmap_priv;
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(screen);
+ glamor_gl_dispatch *dispatch;
+ int dst_x_off, dst_y_off, src_x_off, src_y_off, i;
+ int fbo_x_off, fbo_y_off;
+ int src_fbo_x_off, src_fbo_y_off;
+
+ if (!glamor_priv->has_fbo_blit) {
+ glamor_delayed_fallback(screen,
+ "no EXT_framebuffer_blit\n");
+ return FALSE;
+ }
+ src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
+ dst_pixmap_priv = glamor_get_pixmap_private(dst_pixmap);
+
+ if (gc) {
+ if (gc->alu != GXcopy) {
+ glamor_delayed_fallback(screen, "non-copy ALU\n");
+ return FALSE;
+ }
+ }
+
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(src_pixmap_priv)) {
+ glamor_delayed_fallback(screen, "no src fbo\n");
+ return FALSE;
+ }
+
+ if (glamor_set_destination_pixmap(dst_pixmap))
+ return FALSE;
+
+ pixmap_priv_get_fbo_off(dst_pixmap_priv, &fbo_x_off, &fbo_y_off);
+ pixmap_priv_get_fbo_off(src_pixmap_priv, &src_fbo_x_off, &src_fbo_y_off);
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+ dispatch->glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT,
+ src_pixmap_priv->base.fbo->fb);
+ glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off,
+ &dst_y_off);
+ glamor_get_drawable_deltas(src, src_pixmap, &src_x_off,
+ &src_y_off);
+ dst_x_off += fbo_x_off;
+ dst_y_off += fbo_y_off;
+ src_y_off += dy + src_fbo_y_off;
+ src_x_off += src_fbo_x_off;
+
+ for (i = 0; i < nbox; i++) {
+ if (glamor_priv->yInverted) {
+ dispatch->glBlitFramebuffer((box[i].x1 + dx +
+ src_x_off),
+ (box[i].y1 +
+ src_y_off),
+ (box[i].x2 + dx +
+ src_x_off),
+ (box[i].y2 +
+ src_y_off),
+ (box[i].x1 +
+ dst_x_off),
+ (box[i].y1 +
+ dst_y_off),
+ (box[i].x2 +
+ dst_x_off),
+ (box[i].y2 +
+ dst_y_off),
+ GL_COLOR_BUFFER_BIT,
+ GL_NEAREST);
+ } else {
+ int flip_dst_y1 =
+ dst_pixmap->drawable.height - (box[i].y2 +
+ dst_y_off);
+ int flip_dst_y2 =
+ dst_pixmap->drawable.height - (box[i].y1 +
+ dst_y_off);
+ int flip_src_y1 =
+ src_pixmap->drawable.height - (box[i].y2 +
+ src_y_off);
+ int flip_src_y2 =
+ src_pixmap->drawable.height - (box[i].y1 +
+ src_y_off);
+
+ dispatch->glBlitFramebuffer(box[i].x1 + dx +
+ src_x_off,
+ flip_src_y1,
+ box[i].x2 + dx +
+ src_x_off,
+ flip_src_y2,
+ box[i].x1 +
+ dst_x_off,
+ flip_dst_y1,
+ box[i].x2 +
+ dst_x_off,
+ flip_dst_y2,
+ GL_COLOR_BUFFER_BIT,
+ GL_NEAREST);
+ }
+ }
+ glamor_put_dispatch(glamor_priv);
+ glamor_priv->state = BLIT_STATE;
+ return TRUE;
+}
+#endif
+
+static Bool
+glamor_copy_n_to_n_textured(DrawablePtr src,
+ DrawablePtr dst,
+ GCPtr gc, BoxPtr box, int nbox, int dx, int dy)
+{
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(dst->pScreen);
+ glamor_gl_dispatch *dispatch;
+ PixmapPtr src_pixmap = glamor_get_drawable_pixmap(src);
+ PixmapPtr dst_pixmap = glamor_get_drawable_pixmap(dst);
+ int i;
+ float vertices[8], texcoords[8];
+ glamor_pixmap_private *src_pixmap_priv;
+ glamor_pixmap_private *dst_pixmap_priv;
+ int src_x_off, src_y_off, dst_x_off, dst_y_off;
+ enum glamor_pixmap_status src_status = GLAMOR_NONE;
+ GLfloat dst_xscale, dst_yscale, src_xscale, src_yscale;
+
+ src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
+ dst_pixmap_priv = glamor_get_pixmap_private(dst_pixmap);
+
+ if (!src_pixmap_priv->base.gl_fbo) {
+#ifndef GLAMOR_PIXMAP_DYNAMIC_UPLOAD
+ glamor_delayed_fallback(dst->pScreen, "src has no fbo.\n");
+ return FALSE;
+#else
+ src_status = glamor_upload_pixmap_to_texture(src_pixmap);
+ if (src_status != GLAMOR_UPLOAD_DONE)
+ return FALSE;
+
+ src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
+#endif
+ }
+
+
+ pixmap_priv_get_dest_scale(dst_pixmap_priv, &dst_xscale, &dst_yscale);
+ pixmap_priv_get_scale(src_pixmap_priv, &src_xscale, &src_yscale);
+
+ glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off,
+ &dst_y_off);
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+
+
+ glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv);
+ dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
+ GL_FALSE, 2 * sizeof(float),
+ vertices);
+ dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+
+ glamor_get_drawable_deltas(src, src_pixmap, &src_x_off,
+ &src_y_off);
+ dx += src_x_off;
+ dy += src_y_off;
+
+ dispatch->glActiveTexture(GL_TEXTURE0);
+ dispatch->glBindTexture(GL_TEXTURE_2D,
+ src_pixmap_priv->base.fbo->tex);
+#ifndef GLAMOR_GLES2
+ dispatch->glEnable(GL_TEXTURE_2D);
+ dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_WRAP_S,
+ GL_CLAMP_TO_BORDER);
+ dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_WRAP_T,
+ GL_CLAMP_TO_BORDER);
+#endif
+ dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_MIN_FILTER,
+ GL_NEAREST);
+ dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_MAG_FILTER,
+ GL_NEAREST);
+
+ dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
+ GL_FLOAT, GL_FALSE,
+ 2 * sizeof(float),
+ texcoords);
+ dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+ dispatch->glUseProgram(glamor_priv->finish_access_prog[0]);
+ dispatch->glUniform1i(glamor_priv->finish_access_revert[0],
+ REVERT_NONE);
+ dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[0],
+ SWAP_NONE_UPLOADING);
+
+ for (i = 0; i < nbox; i++) {
+
+ glamor_set_normalize_vcoords(dst_pixmap_priv,
+ dst_xscale, dst_yscale,
+ box[i].x1 + dst_x_off,
+ box[i].y1 + dst_y_off,
+ box[i].x2 + dst_x_off,
+ box[i].y2 + dst_y_off,
+ glamor_priv->yInverted,
+ vertices);
+
+ glamor_set_normalize_tcoords(src_pixmap_priv,
+ src_xscale,
+ src_yscale,
+ box[i].x1 + dx,
+ box[i].y1 + dy,
+ box[i].x2 + dx,
+ box[i].y2 + dy,
+ glamor_priv->yInverted,
+ texcoords);
+ dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+ }
+
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+#ifndef GLAMOR_GLES2
+ dispatch->glDisable(GL_TEXTURE_2D);
+#endif
+ dispatch->glUseProgram(0);
+ /* The source texture is bound to a fbo, we have to flush it here. */
+ glamor_put_dispatch(glamor_priv);
+ glamor_priv->state = RENDER_STATE;
+ glamor_priv->render_idle_cnt = 0;
+ return TRUE;
+}
+
+static Bool
+__glamor_copy_n_to_n(DrawablePtr src,
+ DrawablePtr dst,
+ GCPtr gc,
+ BoxPtr box,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown, Pixel bitplane,
+ void *closure)
+{
+ PixmapPtr dst_pixmap, src_pixmap, temp_pixmap = NULL;
+ DrawablePtr temp_src = src;
+ glamor_pixmap_private *dst_pixmap_priv, *src_pixmap_priv;
+ glamor_screen_private *glamor_priv;
+ BoxRec bound;
+ ScreenPtr screen;
+ int temp_dx = dx;
+ int temp_dy = dy;
+ int src_x_off, src_y_off, dst_x_off, dst_y_off;
+ int i;
+ int overlaped = 0;
+ Bool ret = FALSE;
+
+ dst_pixmap = glamor_get_drawable_pixmap(dst);
+ dst_pixmap_priv = glamor_get_pixmap_private(dst_pixmap);
+ src_pixmap = glamor_get_drawable_pixmap(src);
+ src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
+ screen = dst_pixmap->drawable.pScreen;
+ glamor_priv = glamor_get_screen_private(dst->pScreen);
+ glamor_get_drawable_deltas(src, src_pixmap, &src_x_off,
+ &src_y_off);
+
+ glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off,
+ &dst_y_off);
+
+ if (src_pixmap_priv->base.fbo
+ && src_pixmap_priv->base.fbo->fb == dst_pixmap_priv->base.fbo->fb) {
+ int x_shift = abs(src_x_off - dx - dst_x_off);
+ int y_shift = abs(src_y_off - dy - dst_y_off);
+ for (i = 0; i < nbox; i++) {
+ if (x_shift < abs(box[i].x2 - box[i].x1)
+ && y_shift < abs(box[i].y2 - box[i].y1)) {
+ overlaped = 1;
+ break;
+ }
+ }
+ }
+ DEBUGF("Copy %d %d %dx%d dx %d dy %d from %p to %p \n",
+ box[0].x1, box[0].y1,
+ box[0].x2 - box[0].x1, box[0].y2 - box[0].y1,
+ dx, dy,
+ src_pixmap, dst_pixmap);
+#ifndef GLAMOR_GLES2
+ if (!overlaped &&
+ (glamor_priv->state != RENDER_STATE
+ || !src_pixmap_priv->base.gl_tex || !dst_pixmap_priv->base.gl_tex)
+ && glamor_copy_n_to_n_fbo_blit(src, dst, gc, box, nbox, dx,
+ dy)) {
+ ret = TRUE;
+ goto done;
+ }
+#endif
+ glamor_calculate_boxes_bound(&bound, box, nbox);
+
+ /* Overlaped indicate the src and dst are the same pixmap. */
+ if (overlaped || (!GLAMOR_PIXMAP_PRIV_HAS_FBO(src_pixmap_priv)
+ && (((bound.x2 - bound.x1) * (bound.y2 - bound.y1)
+ * 4 >
+ src_pixmap->drawable.width *
+ src_pixmap->drawable.height)
+ || !(glamor_check_fbo_size(glamor_priv,
+ src_pixmap->drawable.width,
+ src_pixmap->drawable.height))))) {
+
+ temp_pixmap = glamor_create_pixmap(screen,
+ bound.x2 - bound.x1,
+ bound.y2 - bound.y1,
+ src_pixmap->
+ drawable.depth,
+ overlaped ? 0 :
+ GLAMOR_CREATE_PIXMAP_CPU);
+ assert(bound.x2 - bound.x1 <= glamor_priv->max_fbo_size);
+ assert(bound.y2 - bound.y1 <= glamor_priv->max_fbo_size);
+ if (!temp_pixmap)
+ goto done;
+ glamor_translate_boxes(box, nbox, -bound.x1, -bound.y1);
+ temp_src = &temp_pixmap->drawable;
+
+ if (overlaped)
+ glamor_copy_n_to_n_textured(src, temp_src, gc, box,
+ nbox,
+ temp_dx + bound.x1,
+ temp_dy + bound.y1);
+ else
+ fbCopyNtoN(src, temp_src, gc, box, nbox,
+ temp_dx + bound.x1, temp_dy + bound.y1,
+ reverse, upsidedown, bitplane, closure);
+ glamor_translate_boxes(box, nbox, bound.x1, bound.y1);
+ temp_dx = -bound.x1;
+ temp_dy = -bound.y1;
+ } else {
+ temp_dx = dx;
+ temp_dy = dy;
+ temp_src = src;
+ }
+
+ if (glamor_copy_n_to_n_textured
+ (temp_src, dst, gc, box, nbox, temp_dx, temp_dy)) {
+ ret = TRUE;
+ }
+done:
+ if (temp_src != src)
+ glamor_destroy_pixmap(temp_pixmap);
+ return ret;
+}
+
+static Bool
+_glamor_copy_n_to_n(DrawablePtr src,
+ DrawablePtr dst,
+ GCPtr gc,
+ BoxPtr box,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown, Pixel bitplane,
+ void *closure, Bool fallback)
+{
+ PixmapPtr dst_pixmap, src_pixmap;
+ glamor_pixmap_private *dst_pixmap_priv, *src_pixmap_priv;
+ glamor_screen_private *glamor_priv;
+ glamor_gl_dispatch *dispatch;
+ BoxPtr extent;
+ RegionRec region;
+ int src_x_off, src_y_off, dst_x_off, dst_y_off;
+ Bool ok = FALSE;
+ int force_clip = 0;
+
+ if (nbox == 0)
+ return TRUE;
+ dst_pixmap = glamor_get_drawable_pixmap(dst);
+ dst_pixmap_priv = glamor_get_pixmap_private(dst_pixmap);
+ src_pixmap = glamor_get_drawable_pixmap(src);
+ src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
+
+ glamor_priv = glamor_get_screen_private(dst->pScreen);
+
+ DEBUGF("Copy %d %d %dx%d dx %d dy %d from %p to %p \n",
+ box[0].x1, box[0].y1,
+ box[0].x2 - box[0].x1, box[0].y2 - box[0].y1,
+ dx, dy,
+ src_pixmap, dst_pixmap);
+
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dst_pixmap_priv))
+ goto fall_back;
+
+ if (gc) {
+ if (!glamor_set_planemask(dst_pixmap, gc->planemask))
+ goto fall_back;
+ dispatch = glamor_get_dispatch(glamor_priv);
+ if (!glamor_set_alu(dispatch, gc->alu)) {
+ glamor_put_dispatch(glamor_priv);
+ goto fail;
+ }
+ glamor_put_dispatch(glamor_priv);
+ }
+
+ if (!src_pixmap_priv) {
+ glamor_set_pixmap_type(src_pixmap, GLAMOR_MEMORY);
+ src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
+ }
+
+ glamor_get_drawable_deltas(src, src_pixmap, &src_x_off,
+ &src_y_off);
+ glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off,
+ &dst_y_off);
+
+ RegionInitBoxes(&region, box, nbox);
+ extent = RegionExtents(&region);
+
+ if (!glamor_check_fbo_size(glamor_priv,
+ extent->x2 - extent->x1, extent->y2 - extent->y1)
+ && (src_pixmap_priv->type == GLAMOR_MEMORY
+ || (src_pixmap_priv == dst_pixmap_priv))) {
+ force_clip = 1;
+ }
+
+ if (force_clip || dst_pixmap_priv->type == GLAMOR_TEXTURE_LARGE
+ || src_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
+ glamor_pixmap_clipped_regions *clipped_dst_regions;
+ int n_dst_region, i, j;
+ PixmapPtr temp_source_pixmap;
+ glamor_pixmap_private *temp_source_priv = NULL;
+
+ RegionTranslate(&region, dst_x_off, dst_y_off);
+ if (!force_clip)
+ clipped_dst_regions = glamor_compute_clipped_regions(dst_pixmap_priv,
+ &region, &n_dst_region, 0,
+ reverse, upsidedown);
+ else
+ clipped_dst_regions = glamor_compute_clipped_regions_ext(dst_pixmap_priv,
+ &region, &n_dst_region,
+ glamor_priv->max_fbo_size,
+ glamor_priv->max_fbo_size,
+ reverse, upsidedown);
+ for(i = 0; i < n_dst_region; i++)
+ {
+ int n_src_region;
+ glamor_pixmap_clipped_regions *clipped_src_regions;
+ BoxPtr current_boxes;
+ int n_current_boxes;
+
+ SET_PIXMAP_FBO_CURRENT(dst_pixmap_priv, clipped_dst_regions[i].block_idx);
+
+ temp_source_pixmap = NULL;
+ if (src_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
+ RegionTranslate(clipped_dst_regions[i].region,
+ -dst_x_off + src_x_off + dx, -dst_y_off + src_y_off + dy);
+ clipped_src_regions = glamor_compute_clipped_regions(src_pixmap_priv,
+ clipped_dst_regions[i].region,
+ &n_src_region, 0,
+ reverse, upsidedown);
+ DEBUGF("Source is large pixmap.\n");
+ for (j = 0; j < n_src_region; j++)
+ {
+ if (src_pixmap_priv != dst_pixmap_priv)
+ SET_PIXMAP_FBO_CURRENT(src_pixmap_priv, clipped_src_regions[j].block_idx);
+ else if (src_pixmap_priv == dst_pixmap_priv &&
+ clipped_src_regions[j].block_idx != clipped_dst_regions[i].block_idx) {
+ /* source and the dest are the same, but need different block_idx.
+ * we create a empty pixmap and fill the required source fbo and box to
+ * it. It's a little hacky, but avoid extra copy. */
+ temp_source_pixmap = glamor_create_pixmap(src->pScreen, 0, 0,
+ src->depth, 0);
+ if (!temp_source_pixmap) {
+ ok = FALSE;
+ goto fail;
+ }
+ src->pScreen->ModifyPixmapHeader(temp_source_pixmap,
+ src_pixmap->drawable.width,
+ src_pixmap->drawable.height,
+ 0, 0, src_pixmap->devKind, NULL);
+ temp_source_priv = glamor_get_pixmap_private(temp_source_pixmap);
+ *temp_source_priv = *src_pixmap_priv;
+ temp_source_priv->large.box = src_pixmap_priv->large.box_array[clipped_src_regions[j].block_idx];
+ temp_source_priv->base.fbo = src_pixmap_priv->large.fbo_array[clipped_src_regions[j].block_idx];
+ temp_source_priv->base.pixmap = temp_source_pixmap;
+ }
+ assert(temp_source_pixmap || !(src_pixmap_priv == dst_pixmap_priv
+ && (clipped_src_regions[j].block_idx != clipped_dst_regions[i].block_idx)));
+
+ RegionTranslate(clipped_src_regions[j].region,
+ -src_x_off - dx,
+ -src_y_off - dy);
+ current_boxes = RegionRects(clipped_src_regions[j].region);
+ n_current_boxes = RegionNumRects(clipped_src_regions[j].region);
+ DEBUGF("dst pixmap fbo idx %d src pixmap fbo idx %d \n",
+ clipped_dst_regions[i].block_idx,
+ clipped_src_regions[j].block_idx);
+ DEBUGF("Copy %d %d %d %d dx %d dy %d from %p to %p \n",
+ current_boxes[0].x1, current_boxes[0].y1,
+ current_boxes[0].x2, current_boxes[0].y2,
+ dx, dy, src_pixmap, dst_pixmap);
+ if (!temp_source_pixmap)
+ ok = __glamor_copy_n_to_n(src, dst, gc, current_boxes,
+ n_current_boxes, dx, dy, reverse,
+ upsidedown, bitplane, closure);
+ else {
+ ok = __glamor_copy_n_to_n(&temp_source_pixmap->drawable,
+ dst, gc, current_boxes,
+ n_current_boxes, dx, dy, reverse,
+ upsidedown, bitplane, closure);
+ temp_source_priv->type = GLAMOR_MEMORY;
+ temp_source_priv->base.fbo = NULL;
+ glamor_destroy_pixmap(temp_source_pixmap);
+ temp_source_pixmap = NULL;
+ }
+
+ RegionDestroy(clipped_src_regions[j].region);
+ if (!ok) {
+ assert(0);
+ goto fail;
+ }
+ }
+
+ if (n_src_region == 0)
+ ok = TRUE;
+ free(clipped_src_regions);
+ } else {
+ RegionTranslate(clipped_dst_regions[i].region,
+ - dst_x_off,
+ - dst_y_off);
+ current_boxes = RegionRects(clipped_dst_regions[i].region);
+ n_current_boxes = RegionNumRects(clipped_dst_regions[i].region);
+
+ DEBUGF("dest pixmap fbo idx %d \n",
+ clipped_dst_regions[i].block_idx);
+ DEBUGF("Copy %d %d %d %d dx %d dy %d from %p to %p \n",
+ current_boxes[0].x1, current_boxes[0].y1,
+ current_boxes[0].x2, current_boxes[0].y2,
+ dx, dy, src_pixmap, dst_pixmap);
+
+ ok = __glamor_copy_n_to_n(src, dst, gc, current_boxes,
+ n_current_boxes, dx, dy, reverse,
+ upsidedown, bitplane, closure);
+
+ }
+ RegionDestroy(clipped_dst_regions[i].region);
+ }
+ if (n_dst_region == 0)
+ ok = TRUE;
+ free(clipped_dst_regions);
+ RegionUninit(&region);
+ } else {
+ ok = __glamor_copy_n_to_n(src, dst, gc, box, nbox, dx, dy,
+ reverse, upsidedown, bitplane,
+ closure);
+ }
+
+fail:
+ dispatch = glamor_get_dispatch(glamor_priv);
+ glamor_set_alu(dispatch, GXcopy);
+ glamor_put_dispatch(glamor_priv);
+
+ if (ok)
+ return TRUE;
+fall_back:
+ if (!fallback
+ && glamor_ddx_fallback_check_pixmap(src)
+ && glamor_ddx_fallback_check_pixmap(dst))
+ goto done;
+
+ if (src_pixmap_priv->type == GLAMOR_DRM_ONLY
+ || dst_pixmap_priv->type == GLAMOR_DRM_ONLY) {
+ LogMessage(X_WARNING,
+ "Access a DRM only pixmap is not allowed within glamor.\n");
+ return TRUE;
+ }
+ glamor_report_delayed_fallbacks(src->pScreen);
+ glamor_report_delayed_fallbacks(dst->pScreen);
+
+ glamor_fallback("from %p to %p (%c,%c)\n", src, dst,
+ glamor_get_drawable_location(src),
+ glamor_get_drawable_location(dst));
+
+ if (glamor_prepare_access(dst, GLAMOR_ACCESS_RW)) {
+ if (dst == src
+ || glamor_prepare_access(src, GLAMOR_ACCESS_RO)) {
+ fbCopyNtoN(src, dst, gc, box, nbox,
+ dx, dy, reverse, upsidedown, bitplane,
+ closure);
+ if (dst != src)
+ glamor_finish_access(src, GLAMOR_ACCESS_RO);
+ }
+ glamor_finish_access(dst, GLAMOR_ACCESS_RW);
+ }
+ ok = TRUE;
+
+ done:
+ glamor_clear_delayed_fallbacks(src->pScreen);
+ glamor_clear_delayed_fallbacks(dst->pScreen);
+ return ok;
+}
+
+RegionPtr
+glamor_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc,
+ int srcx, int srcy, int width, int height, int dstx,
+ int dsty)
+{
+ RegionPtr region;
+ region = miDoCopy(src, dst, gc,
+ srcx, srcy, width, height,
+ dstx, dsty, glamor_copy_n_to_n, 0, NULL);
+
+ return region;
+}
+
+void
+glamor_copy_n_to_n(DrawablePtr src,
+ DrawablePtr dst,
+ GCPtr gc,
+ BoxPtr box,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown, Pixel bitplane,
+ void *closure)
+{
+ _glamor_copy_n_to_n(src, dst, gc, box, nbox, dx,
+ dy, reverse, upsidedown, bitplane, closure, TRUE);
+}
+
+Bool
+glamor_copy_n_to_n_nf(DrawablePtr src,
+ DrawablePtr dst,
+ GCPtr gc,
+ BoxPtr box,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown, Pixel bitplane,
+ void *closure)
+{
+ return _glamor_copy_n_to_n(src, dst, gc, box, nbox, dx,
+ dy, reverse, upsidedown, bitplane, closure, FALSE);
+}
+
diff --git a/xorg-server/glamor/glamor_copyplane.c b/xorg-server/glamor/glamor_copyplane.c
new file mode 100644
index 000000000..3f2652ac7
--- /dev/null
+++ b/xorg-server/glamor/glamor_copyplane.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ * Copyright © 1998 Keith Packard
+ *
+ * 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.
+ *
+ * Authors:
+ * Zhigang Gong <zhigang.gong@gmail.com>
+ *
+ */
+
+#include "glamor_priv.h"
+
+static Bool
+_glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int w, int h, int dstx, int dsty,
+ unsigned long bitPlane, RegionPtr *pRegion, Bool fallback)
+{
+ if (!fallback
+ && glamor_ddx_fallback_check_gc(pGC)
+ && glamor_ddx_fallback_check_pixmap(pSrc)
+ && glamor_ddx_fallback_check_pixmap(pDst))
+ goto fail;
+
+ glamor_prepare_access(pDst, GLAMOR_ACCESS_RW);
+ glamor_prepare_access(pSrc, GLAMOR_ACCESS_RO);
+ *pRegion = fbCopyPlane(pSrc, pDst, pGC, srcx, srcy, w, h,
+ dstx, dsty, bitPlane);
+ glamor_finish_access(pSrc, GLAMOR_ACCESS_RO);
+ glamor_finish_access(pDst, GLAMOR_ACCESS_RW);
+ return TRUE;
+
+ fail:
+ return FALSE;
+}
+
+RegionPtr
+glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int w, int h, int dstx, int dsty,
+ unsigned long bitPlane)
+{
+ RegionPtr ret;
+ _glamor_copy_plane(pSrc, pDst, pGC, srcx, srcy, w, h,
+ dstx, dsty, bitPlane, &ret, TRUE);
+ return ret;
+}
+
+Bool
+glamor_copy_plane_nf(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int w, int h, int dstx, int dsty,
+ unsigned long bitPlane, RegionPtr *pRegion)
+{
+ return _glamor_copy_plane(pSrc, pDst, pGC, srcx, srcy, w, h,
+ dstx, dsty, bitPlane, pRegion, FALSE);
+}
diff --git a/xorg-server/glamor/glamor_copywindow.c b/xorg-server/glamor/glamor_copywindow.c
new file mode 100644
index 000000000..b181ff529
--- /dev/null
+++ b/xorg-server/glamor/glamor_copywindow.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright © 2008 Intel Corporation
+ * Copyright © 1998 Keith Packard
+ *
+ * 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 Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#include "glamor_priv.h"
+
+/** @file glamor_copywindow.c
+ *
+ * Screen CopyWindow implementation.
+ */
+
+void
+glamor_copy_window(WindowPtr win, DDXPointRec old_origin,
+ RegionPtr src_region)
+{
+ RegionRec dst_region;
+ int dx, dy;
+ PixmapPtr pixmap = win->drawable.pScreen->GetWindowPixmap(win);
+
+ dx = old_origin.x - win->drawable.x;
+ dy = old_origin.y - win->drawable.y;
+ REGION_TRANSLATE(win->drawable.pScreen, src_region, -dx, -dy);
+
+ REGION_INIT(win->drawable.pScreen, &dst_region, NullBox, 0);
+
+ REGION_INTERSECT(win->drawable.pScreen, &dst_region,
+ &win->borderClip, src_region);
+#ifdef COMPOSITE
+ if (pixmap->screen_x || pixmap->screen_y)
+ REGION_TRANSLATE(win->drawable.pScreen, &dst_region,
+ -pixmap->screen_x, -pixmap->screen_y);
+#endif
+
+ miCopyRegion(&pixmap->drawable, &pixmap->drawable,
+ NULL, &dst_region, dx, dy, glamor_copy_n_to_n, 0,
+ NULL);
+
+ REGION_UNINIT(win->drawable.pScreen, &dst_region);
+}
diff --git a/xorg-server/glamor/glamor_core.c b/xorg-server/glamor/glamor_core.c
new file mode 100644
index 000000000..eb1a08d43
--- /dev/null
+++ b/xorg-server/glamor/glamor_core.c
@@ -0,0 +1,612 @@
+/*
+ * Copyright © 2001 Keith Packard
+ * Copyright © 2008 Intel Corporation
+ *
+ * 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.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+
+/** @file glamor_core.c
+ *
+ * This file covers core X rendering in glamor.
+ */
+
+#include <stdlib.h>
+
+#include "glamor_priv.h"
+
+const Bool
+glamor_get_drawable_location(const DrawablePtr drawable)
+{
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_pixmap_private *pixmap_priv =
+ glamor_get_pixmap_private(pixmap);
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(drawable->pScreen);
+ if (pixmap_priv == NULL || pixmap_priv->base.gl_fbo == 0)
+ return 'm';
+ if (pixmap_priv->base.fbo->fb == glamor_priv->screen_fbo)
+ return 's';
+ else
+ return 'f';
+}
+
+GLint
+glamor_compile_glsl_prog(glamor_gl_dispatch * dispatch, GLenum type,
+ const char *source)
+{
+ GLint ok;
+ GLint prog;
+
+ prog = dispatch->glCreateShader(type);
+ dispatch->glShaderSource(prog, 1, (const GLchar **) &source, NULL);
+ dispatch->glCompileShader(prog);
+ dispatch->glGetShaderiv(prog, GL_COMPILE_STATUS, &ok);
+ if (!ok) {
+ GLchar *info;
+ GLint size;
+
+ dispatch->glGetShaderiv(prog, GL_INFO_LOG_LENGTH, &size);
+ info = malloc(size);
+ if (info) {
+ dispatch->glGetShaderInfoLog(prog, size, NULL, info);
+ ErrorF("Failed to compile %s: %s\n",
+ type == GL_FRAGMENT_SHADER ? "FS" : "VS", info);
+ ErrorF("Program source:\n%s", source);
+ free(info);
+ } else
+ ErrorF("Failed to get shader compilation info.\n");
+ FatalError("GLSL compile failure\n");
+ }
+
+ return prog;
+}
+
+void
+glamor_link_glsl_prog(glamor_gl_dispatch * dispatch, GLint prog)
+{
+ GLint ok;
+
+ dispatch->glLinkProgram(prog);
+ dispatch->glGetProgramiv(prog, GL_LINK_STATUS, &ok);
+ if (!ok) {
+ GLchar *info;
+ GLint size;
+
+ dispatch->glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &size);
+ info = malloc(size);
+
+ dispatch->glGetProgramInfoLog(prog, size, NULL, info);
+ ErrorF("Failed to link: %s\n", info);
+ FatalError("GLSL link failure\n");
+ }
+}
+
+
+Bool
+glamor_prepare_access(DrawablePtr drawable, glamor_access_t access)
+{
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+ return glamor_download_pixmap_to_cpu(pixmap, access);
+}
+
+/*
+ * When downloading a unsupported color format to CPU memory,
+ we need to shuffle the color elements and then use a supported
+ color format to read it back to CPU memory.
+
+ For an example, the picture's format is PICT_b8g8r8a8,
+ Then the expecting color layout is as below (little endian):
+ 0 1 2 3 : address
+ a r g b
+
+ Now the in GLES2 the supported color format is GL_RGBA, type is
+ GL_UNSIGNED_TYPE, then we need to shuffle the fragment
+ color as :
+ frag_color = sample(texture).argb;
+ before we use glReadPixel to get it back.
+
+ For the uploading process, the shuffle is a revert shuffle.
+ We still use GL_RGBA, GL_UNSIGNED_BYTE to upload the color
+ to a texture, then let's see
+ 0 1 2 3 : address
+ a r g b : correct colors
+ R G B A : GL_RGBA with GL_UNSIGNED_BYTE
+
+ Now we need to shuffle again, the mapping rule is
+ r = G, g = B, b = A, a = R. Then the uploading shuffle is as
+ below:
+ frag_color = sample(texture).gbar;
+*/
+
+void
+glamor_init_finish_access_shaders(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv;
+ glamor_gl_dispatch *dispatch;
+ const char *vs_source =
+ "attribute vec4 v_position;\n"
+ "attribute vec4 v_texcoord0;\n"
+ "varying vec2 source_texture;\n"
+ "void main()\n"
+ "{\n"
+ " gl_Position = v_position;\n"
+ " source_texture = v_texcoord0.xy;\n" "}\n";
+
+ const char *common_source =
+ GLAMOR_DEFAULT_PRECISION
+ "varying vec2 source_texture;\n"
+ "uniform sampler2D sampler;\n"
+ "uniform int revert;\n"
+ "uniform int swap_rb;\n"
+
+ "#define REVERT_NONE 0\n"
+ "#define REVERT_NORMAL 1\n"
+ "#define SWAP_NONE_DOWNLOADING 0\n"
+ "#define SWAP_DOWNLOADING 1\n"
+ "#define SWAP_UPLOADING 2\n"
+ "#define SWAP_NONE_UPLOADING 3\n";
+
+ const char *fs_source =
+ "void main()\n"
+ "{\n"
+ " if (revert == REVERT_NONE) \n"
+ " { \n"
+ " if ((swap_rb != SWAP_NONE_DOWNLOADING) && (swap_rb != SWAP_NONE_UPLOADING)) \n"
+ " gl_FragColor = texture2D(sampler, source_texture).bgra;\n"
+ " else \n"
+ " gl_FragColor = texture2D(sampler, source_texture).rgba;\n"
+ " } \n"
+ " else \n"
+ " { \n"
+ " if (swap_rb == SWAP_DOWNLOADING) \n"
+ " gl_FragColor = texture2D(sampler, source_texture).argb;\n"
+ " else if (swap_rb == SWAP_NONE_DOWNLOADING)\n"
+ " gl_FragColor = texture2D(sampler, source_texture).abgr;\n"
+ " else if (swap_rb == SWAP_UPLOADING)\n"
+ " gl_FragColor = texture2D(sampler, source_texture).gbar;\n"
+ " else if (swap_rb == SWAP_NONE_UPLOADING)\n"
+ " gl_FragColor = texture2D(sampler, source_texture).abgr;\n"
+ " } \n" "}\n";
+
+ const char *set_alpha_source =
+ "void main()\n"
+ "{\n"
+ " if (revert == REVERT_NONE) \n"
+ " { \n"
+ " if ((swap_rb != SWAP_NONE_DOWNLOADING) && (swap_rb != SWAP_NONE_UPLOADING)) \n"
+ " gl_FragColor = vec4(texture2D(sampler, source_texture).bgr, 1);\n"
+ " else \n"
+ " gl_FragColor = vec4(texture2D(sampler, source_texture).rgb, 1);\n"
+ " } \n"
+ " else \n"
+ " { \n"
+ " if (swap_rb == SWAP_DOWNLOADING) \n"
+ " gl_FragColor = vec4(1, texture2D(sampler, source_texture).rgb);\n"
+ " else if (swap_rb == SWAP_NONE_DOWNLOADING)\n"
+ " gl_FragColor = vec4(1, texture2D(sampler, source_texture).bgr);\n"
+ " else if (swap_rb == SWAP_UPLOADING)\n"
+ " gl_FragColor = vec4(texture2D(sampler, source_texture).gba, 1);\n"
+ " else if (swap_rb == SWAP_NONE_UPLOADING)\n"
+ " gl_FragColor = vec4(texture2D(sampler, source_texture).abg, 1);\n"
+ " } \n"
+ "}\n";
+ GLint fs_prog, vs_prog, avs_prog, set_alpha_prog;
+ GLint sampler_uniform_location;
+ char *source;
+
+ glamor_priv = glamor_get_screen_private(screen);
+ dispatch = glamor_get_dispatch(glamor_priv);
+ glamor_priv->finish_access_prog[0] = dispatch->glCreateProgram();
+ glamor_priv->finish_access_prog[1] = dispatch->glCreateProgram();
+
+ vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER,
+ vs_source);
+
+ XNFasprintf(&source, "%s%s", common_source, fs_source);
+ fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
+ source);
+ free(source);
+
+ dispatch->glAttachShader(glamor_priv->finish_access_prog[0],
+ vs_prog);
+ dispatch->glAttachShader(glamor_priv->finish_access_prog[0],
+ fs_prog);
+
+ avs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER,
+ vs_source);
+
+ XNFasprintf(&source, "%s%s", common_source, set_alpha_source);
+ set_alpha_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
+ source);
+ free(source);
+
+ dispatch->glAttachShader(glamor_priv->finish_access_prog[1],
+ avs_prog);
+ dispatch->glAttachShader(glamor_priv->finish_access_prog[1],
+ set_alpha_prog);
+
+ dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[0],
+ GLAMOR_VERTEX_POS, "v_position");
+ dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[0],
+ GLAMOR_VERTEX_SOURCE,
+ "v_texcoord0");
+ glamor_link_glsl_prog(dispatch,
+ glamor_priv->finish_access_prog[0]);
+
+ dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[1],
+ GLAMOR_VERTEX_POS, "v_position");
+ dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[1],
+ GLAMOR_VERTEX_SOURCE,
+ "v_texcoord0");
+ glamor_link_glsl_prog(dispatch,
+ glamor_priv->finish_access_prog[1]);
+
+ glamor_priv->finish_access_revert[0] =
+ dispatch->
+ glGetUniformLocation(glamor_priv->finish_access_prog[0],
+ "revert");
+
+ glamor_priv->finish_access_swap_rb[0] =
+ dispatch->
+ glGetUniformLocation(glamor_priv->finish_access_prog[0],
+ "swap_rb");
+ sampler_uniform_location =
+ dispatch->
+ glGetUniformLocation(glamor_priv->finish_access_prog[0],
+ "sampler");
+ dispatch->glUseProgram(glamor_priv->finish_access_prog[0]);
+ dispatch->glUniform1i(sampler_uniform_location, 0);
+ dispatch->glUniform1i(glamor_priv->finish_access_revert[0], 0);
+ dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[0], 0);
+ dispatch->glUseProgram(0);
+
+ glamor_priv->finish_access_revert[1] =
+ dispatch->
+ glGetUniformLocation(glamor_priv->finish_access_prog[1],
+ "revert");
+ glamor_priv->finish_access_swap_rb[1] =
+ dispatch->
+ glGetUniformLocation(glamor_priv->finish_access_prog[1],
+ "swap_rb");
+ sampler_uniform_location =
+ dispatch->
+ glGetUniformLocation(glamor_priv->finish_access_prog[1],
+ "sampler");
+ dispatch->glUseProgram(glamor_priv->finish_access_prog[1]);
+ dispatch->glUniform1i(glamor_priv->finish_access_revert[1], 0);
+ dispatch->glUniform1i(sampler_uniform_location, 0);
+ dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[1], 0);
+ dispatch->glUseProgram(0);
+ glamor_put_dispatch(glamor_priv);
+}
+
+void
+glamor_fini_finish_access_shaders(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv;
+ glamor_gl_dispatch *dispatch;
+
+ glamor_priv = glamor_get_screen_private(screen);
+ dispatch = glamor_get_dispatch(glamor_priv);
+ dispatch->glDeleteProgram(glamor_priv->finish_access_prog[0]);
+ dispatch->glDeleteProgram(glamor_priv->finish_access_prog[1]);
+ glamor_put_dispatch(glamor_priv);
+}
+
+void
+glamor_finish_access(DrawablePtr drawable, glamor_access_t access_mode)
+{
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_pixmap_private *pixmap_priv =
+ glamor_get_pixmap_private(pixmap);
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(drawable->pScreen);
+
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO_DOWNLOADED(pixmap_priv))
+ return;
+
+ if (access_mode != GLAMOR_ACCESS_RO) {
+ glamor_restore_pixmap_to_texture(pixmap);
+ }
+
+ if (pixmap_priv->base.fbo->pbo != 0 && pixmap_priv->base.fbo->pbo_valid) {
+ glamor_gl_dispatch *dispatch;
+
+ assert(glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP);
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+ dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
+ dispatch->glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
+ dispatch->glDeleteBuffers(1, &pixmap_priv->base.fbo->pbo);
+ glamor_put_dispatch(glamor_priv);
+
+ pixmap_priv->base.fbo->pbo_valid = FALSE;
+ pixmap_priv->base.fbo->pbo = 0;
+ } else {
+ free(pixmap->devPrivate.ptr);
+ }
+
+ if (pixmap_priv->type == GLAMOR_TEXTURE_DRM)
+ pixmap->devKind = pixmap_priv->base.drm_stride;
+
+ if (pixmap_priv->base.gl_fbo == GLAMOR_FBO_DOWNLOADED)
+ pixmap_priv->base.gl_fbo = GLAMOR_FBO_NORMAL;
+
+ pixmap->devPrivate.ptr = NULL;
+}
+
+
+/**
+ * Calls uxa_prepare_access with UXA_PREPARE_SRC for the tile, if that is the
+ * current fill style.
+ *
+ * Solid doesn't use an extra pixmap source, so we don't worry about them.
+ * Stippled/OpaqueStippled are 1bpp and can be in fb, so we should worry
+ * about them.
+ */
+Bool
+glamor_prepare_access_gc(GCPtr gc)
+{
+ if (gc->stipple) {
+ if (!glamor_prepare_access
+ (&gc->stipple->drawable, GLAMOR_ACCESS_RO))
+ return FALSE;
+ }
+ if (gc->fillStyle == FillTiled) {
+ if (!glamor_prepare_access(&gc->tile.pixmap->drawable,
+ GLAMOR_ACCESS_RO)) {
+ if (gc->stipple)
+ glamor_finish_access(&gc->
+ stipple->drawable,
+ GLAMOR_ACCESS_RO);
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+/**
+ * Finishes access to the tile in the GC, if used.
+ */
+void
+glamor_finish_access_gc(GCPtr gc)
+{
+ if (gc->fillStyle == FillTiled)
+ glamor_finish_access(&gc->tile.pixmap->drawable, GLAMOR_ACCESS_RO);
+ if (gc->stipple)
+ glamor_finish_access(&gc->stipple->drawable, GLAMOR_ACCESS_RO);
+}
+
+Bool
+glamor_stipple(PixmapPtr pixmap, PixmapPtr stipple,
+ int x, int y, int width, int height,
+ unsigned char alu, unsigned long planemask,
+ unsigned long fg_pixel, unsigned long bg_pixel,
+ int stipple_x, int stipple_y)
+{
+ glamor_fallback("stubbed out stipple depth %d\n",
+ pixmap->drawable.depth);
+ return FALSE;
+}
+
+GCOps glamor_gc_ops = {
+ .FillSpans = glamor_fill_spans,
+ .SetSpans = glamor_set_spans,
+ .PutImage = glamor_put_image,
+ .CopyArea = glamor_copy_area,
+ .CopyPlane = glamor_copy_plane,
+ .PolyPoint = glamor_poly_point,
+ .Polylines = glamor_poly_lines,
+ .PolySegment = glamor_poly_segment,
+ .PolyRectangle = miPolyRectangle,
+ .PolyArc = miPolyArc,
+ .FillPolygon = miFillPolygon,
+ .PolyFillRect = glamor_poly_fill_rect,
+ .PolyFillArc = miPolyFillArc,
+ .PolyText8 = miPolyText8,
+ .PolyText16 = miPolyText16,
+ .ImageText8 = miImageText8,
+ .ImageText16 = miImageText16,
+ .ImageGlyphBlt = glamor_image_glyph_blt, //miImageGlyphBlt,
+ .PolyGlyphBlt = glamor_poly_glyph_blt, //miPolyGlyphBlt,
+ .PushPixels = glamor_push_pixels, //miPushPixels,
+};
+
+/**
+ * uxa_validate_gc() sets the ops to glamor's implementations, which may be
+ * accelerated or may sync the card and fall back to fb.
+ */
+void
+glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable)
+{
+ /* fbValidateGC will do direct access to pixmaps if the tiling has changed.
+ * Preempt fbValidateGC by doing its work and masking the change out, so
+ * that we can do the Prepare/finish_access.
+ */
+#ifdef FB_24_32BIT
+ if ((changes & GCTile) && fbGetRotatedPixmap(gc)) {
+ gc->pScreen->DestroyPixmap(fbGetRotatedPixmap(gc));
+ fbGetRotatedPixmap(gc) = 0;
+ }
+
+ if (gc->fillStyle == FillTiled) {
+ PixmapPtr old_tile, new_tile;
+
+ old_tile = gc->tile.pixmap;
+ if (old_tile->drawable.bitsPerPixel !=
+ drawable->bitsPerPixel) {
+ new_tile = fbGetRotatedPixmap(gc);
+ if (!new_tile ||
+ new_tile->drawable.bitsPerPixel !=
+ drawable->bitsPerPixel) {
+ if (new_tile)
+ gc->pScreen->DestroyPixmap
+ (new_tile);
+ /* fb24_32ReformatTile will do direct access of a newly-
+ * allocated pixmap.
+ */
+ glamor_fallback
+ ("GC %p tile FB_24_32 transformat %p.\n",
+ gc, old_tile);
+
+ if (glamor_prepare_access
+ (&old_tile->drawable,
+ GLAMOR_ACCESS_RO)) {
+ new_tile =
+ fb24_32ReformatTile
+ (old_tile,
+ drawable->bitsPerPixel);
+ glamor_finish_access
+ (&old_tile->drawable, GLAMOR_ACCESS_RO);
+ }
+ }
+ if (new_tile) {
+ fbGetRotatedPixmap(gc) = old_tile;
+ gc->tile.pixmap = new_tile;
+ changes |= GCTile;
+ }
+ }
+ }
+#endif
+ if (changes & GCTile) {
+ if (!gc->tileIsPixel) {
+ glamor_pixmap_private *pixmap_priv =
+ glamor_get_pixmap_private(gc->tile.pixmap);
+ if ((!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+ && FbEvenTile(gc->tile.pixmap->drawable.width *
+ drawable->bitsPerPixel)) {
+ glamor_fallback
+ ("GC %p tile changed %p.\n", gc,
+ gc->tile.pixmap);
+ if (glamor_prepare_access
+ (&gc->tile.pixmap->drawable,
+ GLAMOR_ACCESS_RW)) {
+ fbPadPixmap(gc->tile.pixmap);
+ glamor_finish_access
+ (&gc->tile.pixmap->drawable, GLAMOR_ACCESS_RW);
+ }
+ }
+ }
+ /* Mask out the GCTile change notification, now that we've done FB's
+ * job for it.
+ */
+ changes &= ~GCTile;
+ }
+
+ if (changes & GCStipple && gc->stipple) {
+ /* We can't inline stipple handling like we do for GCTile because
+ * it sets fbgc privates.
+ */
+ if (glamor_prepare_access
+ (&gc->stipple->drawable, GLAMOR_ACCESS_RW)) {
+ fbValidateGC(gc, changes, drawable);
+ glamor_finish_access(&gc->stipple->drawable, GLAMOR_ACCESS_RW);
+ }
+ } else {
+ fbValidateGC(gc, changes, drawable);
+ }
+
+ gc->ops = &glamor_gc_ops;
+}
+
+static GCFuncs glamor_gc_funcs = {
+ glamor_validate_gc,
+ miChangeGC,
+ miCopyGC,
+ miDestroyGC,
+ miChangeClip,
+ miDestroyClip,
+ miCopyClip
+};
+
+/**
+ * exaCreateGC makes a new GC and hooks up its funcs handler, so that
+ * exaValidateGC() will get called.
+ */
+int
+glamor_create_gc(GCPtr gc)
+{
+ if (!fbCreateGC(gc))
+ return FALSE;
+
+ gc->funcs = &glamor_gc_funcs;
+
+ return TRUE;
+}
+
+RegionPtr
+glamor_bitmap_to_region(PixmapPtr pixmap)
+{
+ RegionPtr ret;
+ glamor_fallback("pixmap %p \n", pixmap);
+ if (!glamor_prepare_access(&pixmap->drawable, GLAMOR_ACCESS_RO))
+ return NULL;
+ ret = fbPixmapToRegion(pixmap);
+ glamor_finish_access(&pixmap->drawable, GLAMOR_ACCESS_RO);
+ return ret;
+}
+
+/* Borrow from cairo. */
+Bool
+glamor_gl_has_extension(const char *extension)
+{
+ const char *pext;
+ int ext_len;
+ ext_len = strlen(extension);
+
+ pext = (const char*)glGetString(GL_EXTENSIONS);
+
+ if (pext == NULL || extension == NULL)
+ return FALSE;
+
+ while ((pext = strstr(pext, extension)) != NULL) {
+ if (pext[ext_len] == ' ' || pext[ext_len] == '\0')
+ return TRUE;
+ pext += ext_len;
+ }
+ return FALSE;
+}
+
+int
+glamor_gl_get_version(void)
+{
+ int major, minor;
+ const char *version = (const char *) glGetString(GL_VERSION);
+ const char *dot = version == NULL ? NULL : strchr(version, '.');
+ const char *major_start = dot;
+
+ /* Sanity check */
+ if (dot == NULL || dot == version || *(dot + 1) == '\0') {
+ major = 0;
+ minor = 0;
+ } else {
+ /* Find the start of the major version in the string */
+ while (major_start > version && *major_start != ' ')
+ --major_start;
+ major = strtol(major_start, NULL, 10);
+ minor = strtol(dot + 1, NULL, 10);
+ }
+
+ return GLAMOR_GL_VERSION_ENCODE(major, minor);
+}
diff --git a/xorg-server/glamor/glamor_debug.h b/xorg-server/glamor/glamor_debug.h
new file mode 100644
index 000000000..f0c969b11
--- /dev/null
+++ b/xorg-server/glamor/glamor_debug.h
@@ -0,0 +1,116 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ * Copyright © 1998 Keith Packard
+ *
+ * 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.
+ *
+ * Authors:
+ * Zhigang Gong <zhigang.gong@gmail.com>
+ *
+ */
+
+#ifndef __GLAMOR_DEBUG_H__
+#define __GLAMOR_DEBUG_H__
+
+
+#define GLAMOR_DELAYED_STRING_MAX 64
+
+#define GLAMOR_DEBUG_NONE 0
+#define GLAMOR_DEBUG_UNIMPL 0
+#define GLAMOR_DEBUG_FALLBACK 1
+#define GLAMOR_DEBUG_TEXTURE_DOWNLOAD 2
+#define GLAMOR_DEBUG_TEXTURE_DYNAMIC_UPLOAD 3
+
+extern void
+AbortServer(void)
+ _X_NORETURN;
+
+#define GLAMOR_PANIC(_format_, ...) \
+ do { \
+ LogMessageVerb(X_NONE, 0, "Glamor Fatal Error" \
+ " at %32s line %d: " _format_ "\n", \
+ __FUNCTION__, __LINE__, \
+ ##__VA_ARGS__ ); \
+ exit(1); \
+ } while(0)
+
+
+
+
+#define __debug_output_message(_format_, _prefix_, ...) \
+ LogMessageVerb(X_NONE, 0, \
+ "%32s:\t" _format_ , \
+ /*_prefix_,*/ \
+ __FUNCTION__, \
+ ##__VA_ARGS__)
+
+#define glamor_debug_output(_level_, _format_,...) \
+ do { \
+ if (glamor_debug_level >= _level_) \
+ __debug_output_message(_format_, \
+ "Glamor debug", \
+ ##__VA_ARGS__); \
+ } while(0)
+
+
+#define glamor_fallback(_format_,...) \
+ do { \
+ if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) \
+ __debug_output_message(_format_, \
+ "Glamor fallback", \
+ ##__VA_ARGS__);} while(0)
+
+
+
+#define glamor_delayed_fallback(_screen_, _format_,...) \
+ do { \
+ if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) { \
+ glamor_screen_private *_glamor_priv_; \
+ _glamor_priv_ = glamor_get_screen_private(_screen_); \
+ _glamor_priv_->delayed_fallback_pending = 1; \
+ snprintf(_glamor_priv_->delayed_fallback_string, \
+ GLAMOR_DELAYED_STRING_MAX, \
+ "glamor delayed fallback: \t%s " _format_ , \
+ __FUNCTION__, ##__VA_ARGS__); } } while(0)
+
+
+#define glamor_clear_delayed_fallbacks(_screen_) \
+ do { \
+ if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) { \
+ glamor_screen_private *_glamor_priv_; \
+ _glamor_priv_ = glamor_get_screen_private(_screen_); \
+ _glamor_priv_->delayed_fallback_pending = 0; } } while(0)
+
+#define glamor_report_delayed_fallbacks(_screen_) \
+ do { \
+ if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) { \
+ glamor_screen_private *_glamor_priv_; \
+ _glamor_priv_ = glamor_get_screen_private(_screen_); \
+ LogMessageVerb(X_INFO, 0, "%s", \
+ _glamor_priv_->delayed_fallback_string); \
+ _glamor_priv_->delayed_fallback_pending = 0; } } while(0)
+
+#define DEBUGF(str, ...) do {} while(0)
+//#define DEBUGF(str, ...) ErrorF(str, ##__VA_ARGS__)
+#define DEBUGRegionPrint(x) do {} while (0)
+//#define DEBUGRegionPrint RegionPrint
+
+
+#endif
diff --git a/xorg-server/glamor/glamor_egl.c b/xorg-server/glamor/glamor_egl.c
new file mode 100644
index 000000000..ff4c0bdd9
--- /dev/null
+++ b/xorg-server/glamor/glamor_egl.c
@@ -0,0 +1,860 @@
+/*
+ * Copyright © 2010 Intel Corporation.
+ *
+ * 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.
+ *
+ * Authors:
+ * Zhigang Gong <zhigang.gong@linux.intel.com>
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define GLAMOR_FOR_XORG
+#include <xorg-server.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <xf86.h>
+#include <xf86drm.h>
+#define GL_GLEXT_PROTOTYPES
+#define EGL_EGLEXT_PROTOTYPES
+#define EGL_DISPLAY_NO_X_MESA
+
+#ifdef GLAMOR_HAS_GBM
+#include <gbm.h>
+#include <drm_fourcc.h>
+#endif
+
+#if GLAMOR_GLES2
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#else
+#include <GL/gl.h>
+#endif
+
+#define MESA_EGL_NO_X11_HEADERS
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+
+#include "glamor.h"
+#include "compat-api.h"
+#include "glamor_gl_dispatch.h"
+#ifdef GLX_USE_SHARED_DISPATCH
+#include "glapi.h"
+#endif
+
+static const char glamor_name[] = "glamor";
+
+static DevPrivateKeyRec glamor_egl_pixmap_private_key_index;
+DevPrivateKey glamor_egl_pixmap_private_key = &glamor_egl_pixmap_private_key_index;
+
+static void
+glamor_identify(int flags)
+{
+ xf86Msg(X_INFO, "%s: OpenGL accelerated X.org driver based.\n",
+ glamor_name);
+}
+
+struct glamor_egl_screen_private {
+ EGLDisplay display;
+ EGLContext context;
+ EGLint major, minor;
+
+ CreateScreenResourcesProcPtr CreateScreenResources;
+ CloseScreenProcPtr CloseScreen;
+ int fd;
+ EGLImageKHR front_image;
+ PixmapPtr *back_pixmap;
+ int cpp;
+#ifdef GLAMOR_HAS_GBM
+ struct gbm_device *gbm;
+#endif
+ int has_gem;
+ void *glamor_context;
+ void *current_context;
+ int gl_context_depth;
+ int dri3_capable;
+
+ PFNEGLCREATEIMAGEKHRPROC egl_create_image_khr;
+ PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image_khr;
+ PFNGLEGLIMAGETARGETTEXTURE2DOESPROC egl_image_target_texture2d_oes;
+ struct glamor_gl_dispatch *dispatch;
+ CloseScreenProcPtr saved_close_screen;
+ xf86FreeScreenProc *saved_free_screen;
+};
+
+int xf86GlamorEGLPrivateIndex = -1;
+
+static struct glamor_egl_screen_private *
+glamor_egl_get_screen_private(ScrnInfoPtr scrn)
+{
+ return (struct glamor_egl_screen_private *)
+ scrn->privates[xf86GlamorEGLPrivateIndex].ptr;
+}
+#ifdef GLX_USE_SHARED_DISPATCH
+_X_EXPORT void
+glamor_egl_make_current(ScreenPtr screen)
+{
+ ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+ struct glamor_egl_screen_private *glamor_egl =
+ glamor_egl_get_screen_private(scrn);
+
+ if (glamor_egl->gl_context_depth++)
+ return;
+
+ GET_CURRENT_CONTEXT(glamor_egl->current_context);
+
+ if (glamor_egl->glamor_context != glamor_egl->current_context) {
+ eglMakeCurrent(glamor_egl->display, EGL_NO_SURFACE,
+ EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ if (!eglMakeCurrent(glamor_egl->display,
+ EGL_NO_SURFACE, EGL_NO_SURFACE,
+ glamor_egl->context)) {
+ FatalError("Failed to make EGL context current\n");
+ }
+ }
+}
+
+_X_EXPORT void
+glamor_egl_restore_context(ScreenPtr screen)
+{
+ ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+ struct glamor_egl_screen_private *glamor_egl =
+ glamor_egl_get_screen_private(scrn);
+
+ if (--glamor_egl->gl_context_depth)
+ return;
+
+ if (glamor_egl->current_context &&
+ glamor_egl->glamor_context != glamor_egl->current_context)
+ SET_CURRENT_CONTEXT(glamor_egl->current_context);
+}
+#else
+#define glamor_egl_make_current(x)
+#define glamor_egl_restore_context(s)
+#endif
+
+static EGLImageKHR
+_glamor_egl_create_image(struct glamor_egl_screen_private *glamor_egl,
+ int width, int height, int stride, int name, int depth)
+{
+ EGLImageKHR image;
+ EGLint attribs[] = {
+ EGL_WIDTH, 0,
+ EGL_HEIGHT, 0,
+ EGL_DRM_BUFFER_STRIDE_MESA, 0,
+ EGL_DRM_BUFFER_FORMAT_MESA,
+ EGL_DRM_BUFFER_FORMAT_ARGB32_MESA,
+ EGL_DRM_BUFFER_USE_MESA,
+ EGL_DRM_BUFFER_USE_SHARE_MESA |
+ EGL_DRM_BUFFER_USE_SCANOUT_MESA,
+ EGL_NONE
+ };
+ attribs[1] = width;
+ attribs[3] = height;
+ attribs[5] = stride;
+ if (depth != 32 && depth != 24)
+ return EGL_NO_IMAGE_KHR;
+ image = glamor_egl->egl_create_image_khr(glamor_egl->display,
+ glamor_egl->context,
+ EGL_DRM_BUFFER_MESA,
+ (void *) (uintptr_t)name, attribs);
+ if (image == EGL_NO_IMAGE_KHR)
+ return EGL_NO_IMAGE_KHR;
+
+
+ return image;
+}
+
+static int
+glamor_get_flink_name(int fd, int handle, int *name)
+{
+ struct drm_gem_flink flink;
+ flink.handle = handle;
+ if (ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink) < 0)
+ return FALSE;
+ *name = flink.name;
+ return TRUE;
+}
+
+static Bool
+glamor_create_texture_from_image(struct glamor_egl_screen_private
+ *glamor_egl,
+ EGLImageKHR image, GLuint * texture)
+{
+ glamor_egl->dispatch->glGenTextures(1, texture);
+ glamor_egl->dispatch->glBindTexture(GL_TEXTURE_2D, *texture);
+ glamor_egl->dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_MIN_FILTER,
+ GL_NEAREST);
+ glamor_egl->dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_MAG_FILTER,
+ GL_NEAREST);
+
+ (glamor_egl->egl_image_target_texture2d_oes) (GL_TEXTURE_2D,
+ image);
+ glamor_egl->dispatch->glBindTexture(GL_TEXTURE_2D, 0);
+ return TRUE;
+}
+
+unsigned int
+glamor_egl_create_argb8888_based_texture(ScreenPtr screen,
+ int w,
+ int h)
+{
+ ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+ struct glamor_egl_screen_private *glamor_egl;
+ EGLImageKHR image;
+ GLuint texture;
+#ifdef GLAMOR_HAS_DRI3_SUPPORT
+ struct gbm_bo *bo;
+ EGLNativePixmapType native_pixmap;
+ glamor_egl = glamor_egl_get_screen_private(scrn);
+ bo = gbm_bo_create (glamor_egl->gbm, w, h, GBM_FORMAT_ARGB8888,
+ GBM_BO_USE_RENDERING |
+ GBM_BO_USE_SCANOUT);
+ if (!bo)
+ return 0;
+
+ /* If the following assignment raises an error or a warning
+ * then that means EGLNativePixmapType is not struct gbm_bo *
+ * on your platform: This code won't work and you should not
+ * compile with dri3 support enabled */
+ native_pixmap = bo;
+
+ image = glamor_egl->egl_create_image_khr(glamor_egl->display,
+ EGL_NO_CONTEXT,
+ EGL_NATIVE_PIXMAP_KHR,
+ native_pixmap, NULL);
+ gbm_bo_destroy(bo);
+ if (image == EGL_NO_IMAGE_KHR)
+ return 0;
+ glamor_create_texture_from_image(glamor_egl, image, &texture);
+ glamor_egl->egl_destroy_image_khr(glamor_egl->display, image);
+
+ return texture;
+#else
+ return 0; /* this path should never happen */
+#endif
+}
+
+Bool
+glamor_egl_create_textured_screen(ScreenPtr screen, int handle, int stride)
+{
+ ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+ struct glamor_egl_screen_private *glamor_egl;
+ PixmapPtr screen_pixmap;
+
+ glamor_egl = glamor_egl_get_screen_private(scrn);
+ screen_pixmap = screen->GetScreenPixmap(screen);
+
+ if (!glamor_egl_create_textured_pixmap(screen_pixmap, handle, stride)) {
+ xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to create textured screen.");
+ return FALSE;
+ }
+
+ glamor_egl->front_image = dixLookupPrivate(&screen_pixmap->devPrivates,
+ glamor_egl_pixmap_private_key);
+ glamor_set_screen_pixmap(screen_pixmap, glamor_egl->back_pixmap);
+ return TRUE;
+}
+
+Bool
+glamor_egl_create_textured_screen_ext(ScreenPtr screen,
+ int handle,
+ int stride,
+ PixmapPtr *back_pixmap)
+{
+ ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+ struct glamor_egl_screen_private *glamor_egl;
+
+ glamor_egl = glamor_egl_get_screen_private(scrn);
+
+ glamor_egl->back_pixmap = back_pixmap;
+ if (!glamor_egl_create_textured_screen(screen, handle, stride))
+ return FALSE;
+ return TRUE;
+}
+
+static Bool
+glamor_egl_check_has_gem(int fd)
+{
+ struct drm_gem_flink flink;
+ flink.handle = 0;
+
+ ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink);
+ if (errno == ENOENT || errno == EINVAL)
+ return TRUE;
+ return FALSE;
+}
+
+Bool
+glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
+{
+ ScreenPtr screen = pixmap->drawable.pScreen;
+ ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+ struct glamor_egl_screen_private *glamor_egl;
+ EGLImageKHR image;
+ GLuint texture;
+ int name;
+ Bool ret = FALSE;
+
+ glamor_egl = glamor_egl_get_screen_private(scrn);
+
+ glamor_egl_make_current(screen);
+ if (glamor_egl->has_gem) {
+ if (!glamor_get_flink_name(glamor_egl->fd, handle, &name)) {
+ xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+ "Couldn't flink pixmap handle\n");
+ glamor_set_pixmap_type(pixmap, GLAMOR_DRM_ONLY);
+ assert(0);
+ return FALSE;
+ }
+ } else
+ name = handle;
+
+ image = _glamor_egl_create_image(glamor_egl,
+ pixmap->drawable.width,
+ pixmap->drawable.height,
+ ((stride * 8 + 7) / pixmap->drawable.bitsPerPixel),
+ name,
+ pixmap->drawable.depth);
+ if (image == EGL_NO_IMAGE_KHR) {
+ glamor_set_pixmap_type(pixmap, GLAMOR_DRM_ONLY);
+ goto done;
+ }
+ glamor_create_texture_from_image(glamor_egl, image, &texture);
+ glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
+ glamor_set_pixmap_texture(pixmap, texture);
+ dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key,
+ image);
+ ret = TRUE;
+
+done:
+ glamor_egl_restore_context(screen);
+ return ret;
+}
+
+Bool
+glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo)
+{
+ ScreenPtr screen = pixmap->drawable.pScreen;
+ ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+ struct glamor_egl_screen_private *glamor_egl;
+ EGLImageKHR image;
+ GLuint texture;
+ Bool ret = FALSE;
+
+ glamor_egl = glamor_egl_get_screen_private(scrn);
+
+ glamor_egl_make_current(screen);
+
+ image = glamor_egl->egl_create_image_khr(glamor_egl->display,
+ glamor_egl->context,
+ EGL_NATIVE_PIXMAP_KHR,
+ bo, NULL);
+ if (image == EGL_NO_IMAGE_KHR) {
+ glamor_set_pixmap_type(pixmap, GLAMOR_DRM_ONLY);
+ goto done;
+ }
+ glamor_create_texture_from_image(glamor_egl, image, &texture);
+ glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
+ glamor_set_pixmap_texture(pixmap, texture);
+ dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key,
+ image);
+ ret = TRUE;
+
+done:
+ glamor_egl_restore_context(screen);
+ return ret;
+}
+
+#ifdef GLAMOR_HAS_DRI3_SUPPORT
+int glamor_get_fd_from_bo (int gbm_fd, struct gbm_bo *bo, int *fd);
+void glamor_get_name_from_bo (int gbm_fd, struct gbm_bo *bo, int *name);
+int
+glamor_get_fd_from_bo (int gbm_fd, struct gbm_bo *bo, int *fd)
+{
+ union gbm_bo_handle handle;
+ struct drm_prime_handle args;
+
+ handle = gbm_bo_get_handle(bo);
+ args.handle = handle.u32;
+ args.flags = DRM_CLOEXEC;
+ if (ioctl (gbm_fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args))
+ return FALSE;
+ *fd = args.fd;
+ return TRUE;
+}
+
+void
+glamor_get_name_from_bo (int gbm_fd, struct gbm_bo *bo, int *name)
+{
+ union gbm_bo_handle handle;
+
+ handle = gbm_bo_get_handle(bo);
+ if (!glamor_get_flink_name(gbm_fd, handle.u32, name))
+ *name = -1;
+}
+#endif
+
+int glamor_egl_dri3_fd_name_from_tex (ScreenPtr screen,
+ PixmapPtr pixmap,
+ unsigned int tex,
+ Bool want_name,
+ CARD16 *stride,
+ CARD32 *size)
+{
+#ifdef GLAMOR_HAS_DRI3_SUPPORT
+ ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+ struct glamor_egl_screen_private *glamor_egl;
+ EGLImageKHR image;
+ struct gbm_bo* bo;
+ int fd = -1;
+
+ EGLint attribs[] = {
+ EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
+ EGL_GL_TEXTURE_LEVEL_KHR, 0,
+ EGL_NONE
+ };
+
+ glamor_egl = glamor_egl_get_screen_private(scrn);
+
+ glamor_egl_make_current(screen);
+
+ image = dixLookupPrivate(&pixmap->devPrivates,
+ glamor_egl_pixmap_private_key);
+
+ if (image == EGL_NO_IMAGE_KHR || image == NULL)
+ {
+ image = glamor_egl->egl_create_image_khr(glamor_egl->display,
+ glamor_egl->context,
+ EGL_GL_TEXTURE_2D_KHR,
+ (EGLClientBuffer)(uintptr_t)tex, attribs);
+ if (image == EGL_NO_IMAGE_KHR)
+ goto failure;
+
+ dixSetPrivate(&pixmap->devPrivates,
+ glamor_egl_pixmap_private_key,
+ image);
+ glamor_set_pixmap_type(pixmap, GLAMOR_TEXTURE_DRM);
+ }
+
+ bo = gbm_bo_import(glamor_egl->gbm, GBM_BO_IMPORT_EGL_IMAGE, image, 0);
+ if (!bo)
+ goto failure;
+
+ pixmap->devKind = gbm_bo_get_stride(bo);
+
+ if (want_name)
+ {
+ if (glamor_egl->has_gem)
+ glamor_get_name_from_bo(glamor_egl->fd, bo, &fd);
+ }
+ else
+ {
+ if (glamor_get_fd_from_bo(glamor_egl->fd, bo, &fd))
+ {
+ *stride = pixmap->devKind;
+ *size = pixmap->devKind * gbm_bo_get_height(bo);
+ }
+ }
+
+ gbm_bo_destroy(bo);
+failure:
+ glamor_egl_restore_context(screen);
+ return fd;
+#else
+ return -1;
+#endif
+}
+
+PixmapPtr glamor_egl_dri3_pixmap_from_fd (ScreenPtr screen,
+ int fd,
+ CARD16 width,
+ CARD16 height,
+ CARD16 stride,
+ CARD8 depth,
+ CARD8 bpp)
+{
+#ifdef GLAMOR_HAS_DRI3_SUPPORT
+ ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+ struct glamor_egl_screen_private *glamor_egl;
+ struct gbm_bo* bo;
+ EGLImageKHR image;
+ PixmapPtr pixmap;
+ Bool ret = FALSE;
+ EGLint attribs[] = {
+ EGL_WIDTH, 0,
+ EGL_HEIGHT, 0,
+ EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_ARGB8888,
+ EGL_DMA_BUF_PLANE0_FD_EXT, 0,
+ EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
+ EGL_DMA_BUF_PLANE0_PITCH_EXT, 0,
+ EGL_NONE
+ };
+
+ glamor_egl = glamor_egl_get_screen_private(scrn);
+
+ if (!glamor_egl->dri3_capable)
+ return NULL;
+
+ if (bpp != 32 || !(depth == 24 || depth == 32) || width == 0 || height == 0)
+ return NULL;
+
+ attribs[1] = width;
+ attribs[3] = height;
+ attribs[7] = fd;
+ attribs[11] = stride;
+ image = glamor_egl->egl_create_image_khr(glamor_egl->display,
+ EGL_NO_CONTEXT,
+ EGL_LINUX_DMA_BUF_EXT,
+ NULL, attribs);
+
+ if (image == EGL_NO_IMAGE_KHR)
+ return NULL;
+
+ /* EGL_EXT_image_dma_buf_import can impose restrictions on the
+ * usage of the image. Use gbm_bo to bypass the limitations. */
+
+ bo = gbm_bo_import(glamor_egl->gbm, GBM_BO_IMPORT_EGL_IMAGE, image, 0);
+ glamor_egl->egl_destroy_image_khr(glamor_egl->display, image);
+
+ if (!bo)
+ return NULL;
+
+ pixmap = screen->CreatePixmap(screen, 0, 0, depth, 0);
+ screen->ModifyPixmapHeader (pixmap, width, height, 0, 0, stride, NULL);
+
+ ret = glamor_egl_create_textured_pixmap_from_gbm_bo(pixmap, bo);
+ gbm_bo_destroy(bo);
+
+ if (ret)
+ return pixmap;
+ else
+ {
+ screen->DestroyPixmap(pixmap);
+ return NULL;
+ }
+#else
+ return NULL;
+#endif
+}
+
+static void
+_glamor_egl_destroy_pixmap_image(PixmapPtr pixmap)
+{
+ ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
+ EGLImageKHR image;
+ struct glamor_egl_screen_private *glamor_egl =
+ glamor_egl_get_screen_private(scrn);
+
+ image = dixLookupPrivate(&pixmap->devPrivates,
+ glamor_egl_pixmap_private_key);
+ if (image != EGL_NO_IMAGE_KHR && image != NULL) {
+ /* Before destroy an image which was attached to
+ * a texture. we must call glFlush to make sure the
+ * operation on that texture has been done.*/
+ glamor_block_handler(pixmap->drawable.pScreen);
+ glamor_egl->egl_destroy_image_khr(glamor_egl->display, image);
+ dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key, NULL);
+ }
+}
+
+_X_EXPORT void
+glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr back)
+{
+ ScrnInfoPtr scrn = xf86ScreenToScrn(front->drawable.pScreen);
+ struct glamor_egl_screen_private *glamor_egl =
+ glamor_egl_get_screen_private(scrn);
+ EGLImageKHR old_front_image;
+ EGLImageKHR new_front_image;
+
+ glamor_pixmap_exchange_fbos(front, back);
+ new_front_image = dixLookupPrivate(&back->devPrivates, glamor_egl_pixmap_private_key);
+ old_front_image = dixLookupPrivate(&front->devPrivates, glamor_egl_pixmap_private_key);
+ dixSetPrivate(&front->devPrivates, glamor_egl_pixmap_private_key, new_front_image);
+ dixSetPrivate(&back->devPrivates, glamor_egl_pixmap_private_key, old_front_image);
+ glamor_set_pixmap_type(front, GLAMOR_TEXTURE_DRM);
+ glamor_set_pixmap_type(back, GLAMOR_TEXTURE_DRM);
+ glamor_egl->front_image = new_front_image;
+
+}
+
+void
+glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap)
+{
+ if (pixmap->refcnt == 1)
+ _glamor_egl_destroy_pixmap_image(pixmap);
+ glamor_destroy_textured_pixmap(pixmap);
+}
+
+static Bool
+glamor_egl_close_screen(CLOSE_SCREEN_ARGS_DECL)
+{
+ ScrnInfoPtr scrn;
+ struct glamor_egl_screen_private *glamor_egl;
+ PixmapPtr screen_pixmap;
+ EGLImageKHR back_image;
+
+ scrn = xf86ScreenToScrn(screen);
+ glamor_egl = glamor_egl_get_screen_private(scrn);
+ screen_pixmap = screen->GetScreenPixmap(screen);
+
+ glamor_egl->egl_destroy_image_khr(glamor_egl->display, glamor_egl->front_image);
+ dixSetPrivate(&screen_pixmap->devPrivates, glamor_egl_pixmap_private_key, NULL);
+ glamor_egl->front_image = NULL;
+ if (glamor_egl->back_pixmap && *glamor_egl->back_pixmap) {
+ back_image = dixLookupPrivate(&(*glamor_egl->back_pixmap)->devPrivates,
+ glamor_egl_pixmap_private_key);
+ if (back_image != NULL && back_image != EGL_NO_IMAGE_KHR) {
+ glamor_egl->egl_destroy_image_khr(glamor_egl->display, back_image);
+ dixSetPrivate(&(*glamor_egl->back_pixmap)->devPrivates,
+ glamor_egl_pixmap_private_key, NULL);
+ }
+ }
+
+ screen->CloseScreen = glamor_egl->saved_close_screen;
+
+ return screen->CloseScreen(CLOSE_SCREEN_ARGS);
+}
+
+static Bool
+glamor_egl_has_extension(struct glamor_egl_screen_private *glamor_egl,
+ const char *extension)
+{
+ const char *pext;
+ int ext_len;
+
+ ext_len = strlen(extension);
+ pext =
+ (const char *) eglQueryString(glamor_egl->display,
+ EGL_EXTENSIONS);
+ if (pext == NULL || extension == NULL)
+ return FALSE;
+ while ((pext = strstr(pext, extension)) != NULL) {
+ if (pext[ext_len] == ' ' || pext[ext_len] == '\0')
+ return TRUE;
+ pext += ext_len;
+ }
+ return FALSE;
+}
+
+void
+glamor_egl_screen_init(ScreenPtr screen)
+{
+ ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+ struct glamor_egl_screen_private *glamor_egl =
+ glamor_egl_get_screen_private(scrn);
+
+ glamor_egl->saved_close_screen = screen->CloseScreen;
+ screen->CloseScreen = glamor_egl_close_screen;
+}
+
+static void
+glamor_egl_free_screen(FREE_SCREEN_ARGS_DECL)
+{
+ ScrnInfoPtr scrn;
+ struct glamor_egl_screen_private *glamor_egl;
+#ifndef XF86_SCRN_INTERFACE
+ scrn = xf86Screens[arg];
+#else
+ scrn = arg;
+#endif
+
+ glamor_egl = glamor_egl_get_screen_private(scrn);
+ if (glamor_egl != NULL) {
+
+ eglMakeCurrent(glamor_egl->display,
+ EGL_NO_SURFACE, EGL_NO_SURFACE,
+ EGL_NO_CONTEXT);
+#ifdef GLAMOR_HAS_GBM
+ if (glamor_egl->gbm)
+ gbm_device_destroy(glamor_egl->gbm);
+#endif
+ scrn->FreeScreen = glamor_egl->saved_free_screen;
+ free(glamor_egl);
+ scrn->FreeScreen(FREE_SCREEN_ARGS);
+ }
+}
+
+Bool
+glamor_egl_init(ScrnInfoPtr scrn, int fd)
+{
+ struct glamor_egl_screen_private *glamor_egl;
+ const char *version;
+ EGLint config_attribs[] = {
+#ifdef GLAMOR_GLES2
+ EGL_CONTEXT_CLIENT_VERSION, 2,
+#endif
+ EGL_NONE
+ };
+
+ glamor_identify(0);
+ glamor_egl = calloc(sizeof(*glamor_egl), 1);
+ if (glamor_egl == NULL)
+ return FALSE;
+ if (xf86GlamorEGLPrivateIndex == -1)
+ xf86GlamorEGLPrivateIndex =
+ xf86AllocateScrnInfoPrivateIndex();
+
+ scrn->privates[xf86GlamorEGLPrivateIndex].ptr = glamor_egl;
+ glamor_egl->fd = fd;
+#ifdef GLAMOR_HAS_GBM
+ glamor_egl->gbm = gbm_create_device(glamor_egl->fd);
+ if (glamor_egl->gbm == NULL) {
+ ErrorF("couldn't get display device\n");
+ return FALSE;
+ }
+ glamor_egl->display = eglGetDisplay(glamor_egl->gbm);
+#else
+ glamor_egl->display = eglGetDisplay((EGLNativeDisplayType)(intptr_t)fd);
+#endif
+
+ glamor_egl->has_gem = glamor_egl_check_has_gem(fd);
+
+#ifndef GLAMOR_GLES2
+ eglBindAPI(EGL_OPENGL_API);
+#else
+ eglBindAPI(EGL_OPENGL_ES_API);
+#endif
+ if (!eglInitialize
+ (glamor_egl->display, &glamor_egl->major, &glamor_egl->minor))
+ {
+ xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+ "eglInitialize() failed\n");
+ return FALSE;
+ }
+
+ version = eglQueryString(glamor_egl->display, EGL_VERSION);
+ xf86Msg(X_INFO, "%s: EGL version %s:\n", glamor_name, version);
+
+#define GLAMOR_CHECK_EGL_EXTENSION(EXT) \
+ if (!glamor_egl_has_extension(glamor_egl, "EGL_" #EXT)) { \
+ ErrorF("EGL_" #EXT " required.\n"); \
+ return FALSE; \
+ }
+
+#define GLAMOR_CHECK_EGL_EXTENSIONS(EXT1, EXT2) \
+ if (!glamor_egl_has_extension(glamor_egl, "EGL_" #EXT1) && \
+ !glamor_egl_has_extension(glamor_egl, "EGL_" #EXT2)) { \
+ ErrorF("EGL_" #EXT1 " or EGL_" #EXT2 " required.\n"); \
+ return FALSE; \
+ }
+
+ GLAMOR_CHECK_EGL_EXTENSION(MESA_drm_image);
+ GLAMOR_CHECK_EGL_EXTENSION(KHR_gl_renderbuffer_image);
+#ifdef GLAMOR_GLES2
+ GLAMOR_CHECK_EGL_EXTENSIONS(KHR_surfaceless_context, KHR_surfaceless_gles2);
+#else
+ GLAMOR_CHECK_EGL_EXTENSIONS(KHR_surfaceless_context, KHR_surfaceless_opengl);
+#endif
+
+#ifdef GLAMOR_HAS_DRI3_SUPPORT
+ if (glamor_egl_has_extension(glamor_egl, "EGL_KHR_gl_texture_2D_image") &&
+ glamor_egl_has_extension(glamor_egl, "EGL_EXT_image_dma_buf_import") )
+ glamor_egl->dri3_capable = TRUE;
+#endif
+ glamor_egl->egl_create_image_khr = (PFNEGLCREATEIMAGEKHRPROC)
+ eglGetProcAddress("eglCreateImageKHR");
+
+ glamor_egl->egl_destroy_image_khr = (PFNEGLDESTROYIMAGEKHRPROC)
+ eglGetProcAddress("eglDestroyImageKHR");
+
+ glamor_egl->egl_image_target_texture2d_oes =
+ (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)
+ eglGetProcAddress("glEGLImageTargetTexture2DOES");
+
+ if (!glamor_egl->egl_create_image_khr
+ || !glamor_egl->egl_image_target_texture2d_oes) {
+ xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+ "eglGetProcAddress() failed\n");
+ return FALSE;
+ }
+
+ glamor_egl->context = eglCreateContext(glamor_egl->display,
+ NULL, EGL_NO_CONTEXT,
+ config_attribs);
+ if (glamor_egl->context == EGL_NO_CONTEXT) {
+ xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+ "Failed to create EGL context\n");
+ return FALSE;
+ }
+
+ if (!eglMakeCurrent(glamor_egl->display,
+ EGL_NO_SURFACE, EGL_NO_SURFACE,
+ glamor_egl->context)) {
+ xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+ "Failed to make EGL context current\n");
+ return FALSE;
+ }
+#ifdef GLX_USE_SHARED_DISPATCH
+ GET_CURRENT_CONTEXT(glamor_egl->glamor_context);
+#endif
+ glamor_egl->saved_free_screen = scrn->FreeScreen;
+ scrn->FreeScreen = glamor_egl_free_screen;
+#ifdef GLAMOR_GLES2
+ xf86DrvMsg(scrn->scrnIndex, X_INFO, "Using GLES2.\n");
+#ifdef GLX_USE_SHARED_DISPATCH
+ xf86DrvMsg(scrn->scrnIndex, X_WARNING, "Glamor is using GLES2 but GLX needs GL. "
+ "Indirect GLX may not work correctly.\n");
+#endif
+#endif
+ return TRUE;
+}
+
+Bool
+glamor_egl_init_textured_pixmap(ScreenPtr screen)
+{
+ ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+ struct glamor_egl_screen_private *glamor_egl =
+ glamor_egl_get_screen_private(scrn);
+ if (!dixRegisterPrivateKey
+ (glamor_egl_pixmap_private_key, PRIVATE_PIXMAP, 0)) {
+ LogMessage(X_WARNING,
+ "glamor%d: Failed to allocate egl pixmap private\n",
+ screen->myNum);
+ return FALSE;
+ }
+ if (glamor_egl->dri3_capable)
+ glamor_enable_dri3(screen);
+ return TRUE;
+}
+
+Bool
+glamor_gl_dispatch_init(ScreenPtr screen,
+ struct glamor_gl_dispatch *dispatch,
+ int gl_version)
+{
+ ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+ struct glamor_egl_screen_private *glamor_egl =
+ glamor_egl_get_screen_private(scrn);
+ if (!glamor_gl_dispatch_init_impl
+ (dispatch, gl_version, (get_proc_address_t)eglGetProcAddress))
+ return FALSE;
+ glamor_egl->dispatch = dispatch;
+ return TRUE;
+}
diff --git a/xorg-server/glamor/glamor_eglmodule.c b/xorg-server/glamor/glamor_eglmodule.c
new file mode 100644
index 000000000..9a0dec9f2
--- /dev/null
+++ b/xorg-server/glamor/glamor_eglmodule.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * XFREE86 PROJECT 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.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall
+ * not be used in advertising or otherwise to promote the sale, use or other
+ * dealings in this Software without prior written authorization from the
+ * XFree86 Project.
+ *
+ * Authors:
+ * Zhigang Gong <zhigang.gong@gmail.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <xorg-server.h>
+#define GLAMOR_FOR_XORG
+#include <xf86Module.h>
+#include "glamor.h"
+
+static XF86ModuleVersionInfo VersRec = {
+ GLAMOR_EGL_MODULE_NAME,
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ PACKAGE_VERSION_MAJOR, PACKAGE_VERSION_MINOR, PACKAGE_VERSION_PATCHLEVEL,
+ ABI_CLASS_ANSIC, /* Only need the ansic layer */
+ ABI_ANSIC_VERSION,
+ MOD_CLASS_NONE,
+ {0, 0, 0, 0} /* signature, to be patched into the file by a tool */
+};
+
+_X_EXPORT XF86ModuleData glamoreglModuleData = { &VersRec, NULL, NULL };
diff --git a/xorg-server/glamor/glamor_fbo.c b/xorg-server/glamor/glamor_fbo.c
new file mode 100644
index 000000000..d1b087ebe
--- /dev/null
+++ b/xorg-server/glamor/glamor_fbo.c
@@ -0,0 +1,590 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ * Copyright © 1998 Keith Packard
+ *
+ * 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.
+ *
+ * Authors:
+ * Zhigang Gong <zhigang.gong@gmail.com>
+ *
+ */
+
+#include <stdlib.h>
+
+#include "glamor_priv.h"
+
+#define GLAMOR_CACHE_EXPIRE_MAX 100
+
+#define GLAMOR_CACHE_DEFAULT 0
+#define GLAMOR_CACHE_EXACT_SIZE 1
+
+//#define NO_FBO_CACHE 1
+#define FBO_CACHE_THRESHOLD (256*1024*1024)
+
+/* Loop from the tail to the head. */
+#define xorg_list_for_each_entry_reverse(pos, head, member) \
+ for (pos = __container_of((head)->prev, pos, member); \
+ &pos->member != (head); \
+ pos = __container_of(pos->member.prev, pos, member))
+
+
+#define xorg_list_for_each_entry_safe_reverse(pos, tmp, head, member) \
+ for (pos = __container_of((head)->prev, pos, member), \
+ tmp = __container_of(pos->member.prev, pos, member); \
+ &pos->member != (head); \
+ pos = tmp, tmp = __container_of(pos->member.prev, tmp, member))
+
+inline static int cache_wbucket(int size)
+{
+ int order = __fls(size / 32);
+ if (order >= CACHE_BUCKET_WCOUNT)
+ order = CACHE_BUCKET_WCOUNT - 1;
+ return order;
+}
+
+inline static int cache_hbucket(int size)
+{
+ int order = __fls(size / 32);
+ if (order >= CACHE_BUCKET_HCOUNT)
+ order = CACHE_BUCKET_HCOUNT - 1;
+ return order;
+}
+
+static glamor_pixmap_fbo *
+glamor_pixmap_fbo_cache_get(glamor_screen_private *glamor_priv,
+ int w, int h, GLenum format, int flag)
+{
+ struct xorg_list *cache;
+ glamor_pixmap_fbo *fbo_entry, *ret_fbo = NULL;
+ int n_format;
+#ifdef NO_FBO_CACHE
+ return NULL;
+#else
+ n_format = cache_format(format);
+ if (n_format == -1)
+ return NULL;
+ cache = &glamor_priv->fbo_cache[n_format]
+ [cache_wbucket(w)]
+ [cache_hbucket(h)];
+ if (!(flag & GLAMOR_CACHE_EXACT_SIZE)) {
+ xorg_list_for_each_entry(fbo_entry, cache, list) {
+ if (fbo_entry->width >= w && fbo_entry->height >= h) {
+
+ DEBUGF("Request w %d h %d format %x \n", w, h, format);
+ DEBUGF("got cache entry %p w %d h %d fbo %d tex %d format %x\n",
+ fbo_entry, fbo_entry->width, fbo_entry->height,
+ fbo_entry->fb, fbo_entry->tex);
+ xorg_list_del(&fbo_entry->list);
+ ret_fbo = fbo_entry;
+ break;
+ }
+ }
+ }
+ else {
+ xorg_list_for_each_entry(fbo_entry, cache, list) {
+ if (fbo_entry->width == w && fbo_entry->height == h) {
+
+ DEBUGF("Request w %d h %d format %x \n", w, h, format);
+ DEBUGF("got cache entry %p w %d h %d fbo %d tex %d format %x\n",
+ fbo_entry, fbo_entry->width, fbo_entry->height,
+ fbo_entry->fb, fbo_entry->tex, fbo_entry->format);
+ assert(format == fbo_entry->format);
+ xorg_list_del(&fbo_entry->list);
+ ret_fbo = fbo_entry;
+ break;
+ }
+ }
+ }
+
+ if (ret_fbo)
+ glamor_priv->fbo_cache_watermark -= ret_fbo->width * ret_fbo->height;
+
+ assert(glamor_priv->fbo_cache_watermark >= 0);
+
+ return ret_fbo;
+#endif
+}
+
+void
+glamor_purge_fbo(glamor_pixmap_fbo *fbo)
+{
+ glamor_gl_dispatch *dispatch = glamor_get_dispatch(fbo->glamor_priv);
+ if (fbo->fb)
+ dispatch->glDeleteFramebuffers(1, &fbo->fb);
+ if (fbo->tex)
+ dispatch->glDeleteTextures(1, &fbo->tex);
+ if (fbo->pbo)
+ dispatch->glDeleteBuffers(1, &fbo->pbo);
+ glamor_put_dispatch(fbo->glamor_priv);
+
+ free(fbo);
+}
+
+static void
+glamor_pixmap_fbo_cache_put(glamor_pixmap_fbo *fbo)
+{
+ struct xorg_list *cache;
+ int n_format;
+
+#ifdef NO_FBO_CACHE
+ glamor_purge_fbo(fbo);
+ return;
+#else
+ n_format = cache_format(fbo->format);
+
+ if (fbo->fb == 0 || n_format == -1
+ || fbo->glamor_priv->fbo_cache_watermark >= FBO_CACHE_THRESHOLD) {
+ fbo->glamor_priv->tick += GLAMOR_CACHE_EXPIRE_MAX;
+ glamor_fbo_expire(fbo->glamor_priv);
+ glamor_purge_fbo(fbo);
+ return;
+ }
+
+ cache = &fbo->glamor_priv->fbo_cache[n_format]
+ [cache_wbucket(fbo->width)]
+ [cache_hbucket(fbo->height)];
+ DEBUGF("Put cache entry %p to cache %p w %d h %d format %x fbo %d tex %d \n", fbo, cache,
+ fbo->width, fbo->height, fbo->format, fbo->fb, fbo->tex);
+
+ fbo->glamor_priv->fbo_cache_watermark += fbo->width * fbo->height;
+ xorg_list_add(&fbo->list, cache);
+ fbo->expire = fbo->glamor_priv->tick + GLAMOR_CACHE_EXPIRE_MAX;
+#endif
+}
+
+static void
+glamor_pixmap_ensure_fb(glamor_pixmap_fbo *fbo)
+{
+ glamor_gl_dispatch *dispatch;
+ int status;
+
+ dispatch = glamor_get_dispatch(fbo->glamor_priv);
+
+ if (fbo->fb == 0)
+ dispatch->glGenFramebuffers(1, &fbo->fb);
+ assert(fbo->tex != 0);
+ dispatch->glBindFramebuffer(GL_FRAMEBUFFER, fbo->fb);
+ dispatch->glFramebufferTexture2D(GL_FRAMEBUFFER,
+ GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_2D, fbo->tex,
+ 0);
+ status = dispatch->glCheckFramebufferStatus(GL_FRAMEBUFFER);
+ if (status != GL_FRAMEBUFFER_COMPLETE) {
+ const char *str;
+ switch (status) {
+ case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
+ str = "incomplete attachment";
+ break;
+ case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
+ str = "incomplete/missing attachment";
+ break;
+ case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
+ str = "incomplete draw buffer";
+ break;
+ case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
+ str = "incomplete read buffer";
+ break;
+ case GL_FRAMEBUFFER_UNSUPPORTED:
+ str = "unsupported";
+ break;
+ case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
+ str = "incomplete multiple";
+ break;
+ default:
+ str = "unknown error";
+ break;
+ }
+
+ FatalError("destination is framebuffer incomplete: %s [%x]\n",
+ str, status);
+ }
+ glamor_put_dispatch(fbo->glamor_priv);
+}
+
+glamor_pixmap_fbo *
+glamor_create_fbo_from_tex(glamor_screen_private *glamor_priv,
+ int w, int h, GLenum format, GLint tex, int flag)
+{
+ glamor_pixmap_fbo *fbo;
+
+ fbo = calloc(1, sizeof(*fbo));
+ if (fbo == NULL)
+ return NULL;
+
+ xorg_list_init(&fbo->list);
+
+ fbo->tex = tex;
+ fbo->width = w;
+ fbo->height = h;
+ fbo->format = format;
+ fbo->glamor_priv = glamor_priv;
+
+ if (flag == GLAMOR_CREATE_PIXMAP_MAP) {
+ glamor_gl_dispatch *dispatch;
+ dispatch = glamor_get_dispatch(glamor_priv);
+ dispatch->glGenBuffers(1, &fbo->pbo);
+ glamor_put_dispatch(glamor_priv);
+ goto done;
+ }
+
+ if (flag != GLAMOR_CREATE_FBO_NO_FBO)
+ glamor_pixmap_ensure_fb(fbo);
+
+done:
+ return fbo;
+}
+
+
+void
+glamor_fbo_expire(glamor_screen_private *glamor_priv)
+{
+ struct xorg_list *cache;
+ glamor_pixmap_fbo *fbo_entry, *tmp;
+ int i,j,k;
+
+ for(i = 0; i < CACHE_FORMAT_COUNT; i++)
+ for(j = 0; j < CACHE_BUCKET_WCOUNT; j++)
+ for(k = 0; k < CACHE_BUCKET_HCOUNT; k++) {
+ cache = &glamor_priv->fbo_cache[i][j][k];
+ xorg_list_for_each_entry_safe_reverse(fbo_entry, tmp, cache, list) {
+ if (GLAMOR_TICK_AFTER(fbo_entry->expire, glamor_priv->tick)) {
+ break;
+ }
+
+ glamor_priv->fbo_cache_watermark -= fbo_entry->width * fbo_entry->height;
+ xorg_list_del(&fbo_entry->list);
+ DEBUGF("cache %p fbo %p expired %d current %d \n", cache, fbo_entry,
+ fbo_entry->expire, glamor_priv->tick);
+ glamor_purge_fbo(fbo_entry);
+ }
+ }
+
+}
+
+void
+glamor_init_pixmap_fbo(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv;
+ int i,j,k;
+
+ glamor_priv = glamor_get_screen_private(screen);
+ for(i = 0; i < CACHE_FORMAT_COUNT; i++)
+ for(j = 0; j < CACHE_BUCKET_WCOUNT; j++)
+ for(k = 0; k < CACHE_BUCKET_HCOUNT; k++)
+ {
+ xorg_list_init(&glamor_priv->fbo_cache[i][j][k]);
+ }
+ glamor_priv->fbo_cache_watermark = 0;
+}
+
+void
+glamor_fini_pixmap_fbo(ScreenPtr screen)
+{
+ struct xorg_list *cache;
+ glamor_screen_private *glamor_priv;
+ glamor_pixmap_fbo *fbo_entry, *tmp;
+ int i,j,k;
+
+ glamor_priv = glamor_get_screen_private(screen);
+ for(i = 0; i < CACHE_FORMAT_COUNT; i++)
+ for(j = 0; j < CACHE_BUCKET_WCOUNT; j++)
+ for(k = 0; k < CACHE_BUCKET_HCOUNT; k++)
+ {
+ cache = &glamor_priv->fbo_cache[i][j][k];
+ xorg_list_for_each_entry_safe_reverse(fbo_entry, tmp, cache, list) {
+ xorg_list_del(&fbo_entry->list);
+ glamor_purge_fbo(fbo_entry);
+ }
+ }
+}
+
+void
+glamor_destroy_fbo(glamor_pixmap_fbo *fbo)
+{
+ xorg_list_del(&fbo->list);
+ glamor_pixmap_fbo_cache_put(fbo);
+
+}
+
+static int
+_glamor_create_tex(glamor_screen_private *glamor_priv,
+ int w, int h, GLenum format)
+{
+ glamor_gl_dispatch *dispatch;
+ unsigned int tex = 0;
+
+ /* With dri3, we want to allocate ARGB8888 pixmaps only.
+ * Depending on the implementation, GL_RGBA might not
+ * give us ARGB8888. We ask glamor_egl to use get
+ * an ARGB8888 based texture for us. */
+ if (glamor_priv->dri3_enabled && format == GL_RGBA)
+ {
+ tex = glamor_egl_create_argb8888_based_texture(glamor_priv->screen,
+ w, h);
+ }
+ if (!tex)
+ {
+ dispatch = glamor_get_dispatch(glamor_priv);
+ dispatch->glGenTextures(1, &tex);
+ dispatch->glBindTexture(GL_TEXTURE_2D, tex);
+ dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ GL_NEAREST);
+ dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
+ GL_NEAREST);
+ dispatch->glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0,
+ format, GL_UNSIGNED_BYTE, NULL);
+ glamor_put_dispatch(glamor_priv);
+ }
+ return tex;
+}
+
+glamor_pixmap_fbo *
+glamor_create_fbo(glamor_screen_private *glamor_priv,
+ int w, int h,
+ GLenum format,
+ int flag)
+{
+ glamor_pixmap_fbo *fbo;
+ GLint tex = 0;
+ int cache_flag;
+
+ if (!glamor_check_fbo_size(glamor_priv, w, h))
+ return NULL;
+
+ if (flag == GLAMOR_CREATE_FBO_NO_FBO)
+ goto new_fbo;
+
+ if (flag == GLAMOR_CREATE_PIXMAP_MAP)
+ goto no_tex;
+
+ if (flag == GLAMOR_CREATE_PIXMAP_FIXUP)
+ cache_flag = GLAMOR_CACHE_EXACT_SIZE;
+ else
+ cache_flag = 0;
+
+ fbo = glamor_pixmap_fbo_cache_get(glamor_priv, w, h,
+ format, cache_flag);
+ if (fbo)
+ return fbo;
+new_fbo:
+ tex = _glamor_create_tex(glamor_priv, w, h, format);
+no_tex:
+ fbo = glamor_create_fbo_from_tex(glamor_priv, w, h, format, tex, flag);
+
+ return fbo;
+}
+
+static glamor_pixmap_fbo *
+_glamor_create_fbo_array(glamor_screen_private *glamor_priv,
+ int w, int h, GLenum format, int flag,
+ int block_w, int block_h,
+ glamor_pixmap_private *pixmap_priv,
+ int has_fbo)
+{
+ int block_wcnt;
+ int block_hcnt;
+ glamor_pixmap_fbo **fbo_array;
+ BoxPtr box_array;
+ int i,j;
+ glamor_pixmap_private_large_t *priv;
+
+ priv = &pixmap_priv->large;
+
+ block_wcnt = (w + block_w - 1) / block_w;
+ block_hcnt = (h + block_h - 1) / block_h;
+
+ box_array = calloc(block_wcnt * block_hcnt, sizeof(box_array[0]));
+ if (box_array == NULL)
+ return NULL;
+
+ fbo_array = calloc(block_wcnt * block_hcnt, sizeof(glamor_pixmap_fbo*));
+ if (fbo_array == NULL) {
+ free(box_array);
+ return FALSE;
+ }
+ for(i = 0; i < block_hcnt; i++)
+ {
+ int block_y1, block_y2;
+ int fbo_w, fbo_h;
+
+ block_y1 = i * block_h;
+ block_y2 = (block_y1 + block_h) > h ? h : (block_y1 + block_h);
+ fbo_h = block_y2 - block_y1;
+
+ for (j = 0; j < block_wcnt; j++)
+ {
+ box_array[i * block_wcnt + j].x1 = j * block_w;
+ box_array[i * block_wcnt + j].y1 = block_y1;
+ box_array[i * block_wcnt + j].x2 = (j + 1) * block_w > w ? w : (j + 1) * block_w;
+ box_array[i * block_wcnt + j].y2 = block_y2;
+ fbo_w = box_array[i * block_wcnt + j].x2 - box_array[i * block_wcnt + j].x1;
+ if (!has_fbo)
+ fbo_array[i * block_wcnt + j] = glamor_create_fbo(glamor_priv,
+ fbo_w, fbo_h, format,
+ GLAMOR_CREATE_PIXMAP_FIXUP);
+ else
+ fbo_array[i * block_wcnt + j] = priv->base.fbo;
+ if (fbo_array[i * block_wcnt + j] == NULL)
+ goto cleanup;
+ }
+ }
+
+ priv->box = box_array[0];
+ priv->box_array = box_array;
+ priv->fbo_array = fbo_array;
+ priv->block_wcnt = block_wcnt;
+ priv->block_hcnt = block_hcnt;
+ return fbo_array[0];
+
+cleanup:
+ for(i = 0; i < block_wcnt * block_hcnt; i++)
+ if ((fbo_array)[i])
+ glamor_destroy_fbo((fbo_array)[i]);
+ free(box_array);
+ free(fbo_array);
+ return NULL;
+}
+
+
+/* Create a fbo array to cover the w*h region, by using block_w*block_h
+ * block.*/
+glamor_pixmap_fbo *
+glamor_create_fbo_array(glamor_screen_private *glamor_priv,
+ int w, int h, GLenum format, int flag,
+ int block_w, int block_h,
+ glamor_pixmap_private *pixmap_priv)
+{
+ pixmap_priv->large.block_w = block_w;
+ pixmap_priv->large.block_h = block_h;
+ return _glamor_create_fbo_array(glamor_priv, w, h, format, flag,
+ block_w, block_h, pixmap_priv, 0);
+}
+
+glamor_pixmap_fbo *
+glamor_pixmap_detach_fbo(glamor_pixmap_private *pixmap_priv)
+{
+ glamor_pixmap_fbo *fbo;
+
+ if (pixmap_priv == NULL)
+ return NULL;
+
+ fbo = pixmap_priv->base.fbo;
+ if (fbo == NULL)
+ return NULL;
+
+ pixmap_priv->base.fbo = NULL;
+ return fbo;
+}
+
+/* The pixmap must not be attached to another fbo. */
+void
+glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo *fbo)
+{
+ glamor_pixmap_private *pixmap_priv;
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+
+ if (pixmap_priv->base.fbo)
+ return;
+
+ pixmap_priv->base.fbo = fbo;
+
+ switch (pixmap_priv->type) {
+ case GLAMOR_TEXTURE_LARGE:
+ case GLAMOR_TEXTURE_ONLY:
+ case GLAMOR_TEXTURE_DRM:
+ pixmap_priv->base.gl_fbo = 1;
+ if (fbo->tex != 0)
+ pixmap_priv->base.gl_tex = 1;
+ else {
+ /* XXX For the Xephyr only, may be broken now.*/
+ pixmap_priv->base.gl_tex = 0;
+ }
+ case GLAMOR_MEMORY_MAP:
+ pixmap->devPrivate.ptr = NULL;
+ break;
+ default:
+ break;
+ }
+}
+
+void
+glamor_pixmap_destroy_fbo(glamor_pixmap_private *priv)
+{
+ glamor_pixmap_fbo *fbo;
+ if (priv->type == GLAMOR_TEXTURE_LARGE) {
+ int i;
+ glamor_pixmap_private_large_t *large = &priv->large;
+ for(i = 0; i < large->block_wcnt * large->block_hcnt; i++)
+ glamor_destroy_fbo(large->fbo_array[i]);
+ free(large->fbo_array);
+ } else {
+ fbo = glamor_pixmap_detach_fbo(priv);
+ if (fbo)
+ glamor_destroy_fbo(fbo);
+ }
+
+ free(priv);
+}
+
+Bool
+glamor_pixmap_ensure_fbo(PixmapPtr pixmap, GLenum format, int flag)
+{
+ glamor_screen_private *glamor_priv;
+ glamor_pixmap_private *pixmap_priv;
+ glamor_pixmap_fbo *fbo;
+
+ glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ if (pixmap_priv->base.fbo == NULL) {
+
+ fbo = glamor_create_fbo(glamor_priv, pixmap->drawable.width,
+ pixmap->drawable.height,
+ format,
+ flag);
+ if (fbo == NULL)
+ return FALSE;
+
+ glamor_pixmap_attach_fbo(pixmap, fbo);
+ } else {
+ /* We do have a fbo, but it may lack of fb or tex. */
+ if (!pixmap_priv->base.fbo->tex)
+ pixmap_priv->base.fbo->tex = _glamor_create_tex(glamor_priv, pixmap->drawable.width,
+ pixmap->drawable.height, format);
+
+ if (flag != GLAMOR_CREATE_FBO_NO_FBO && pixmap_priv->base.fbo->fb == 0)
+ glamor_pixmap_ensure_fb(pixmap_priv->base.fbo);
+ }
+
+ return TRUE;
+}
+
+_X_EXPORT void
+glamor_pixmap_exchange_fbos(PixmapPtr front, PixmapPtr back)
+{
+ glamor_pixmap_private *front_priv, *back_priv;
+ glamor_pixmap_fbo *temp_fbo;
+
+ front_priv = glamor_get_pixmap_private(front);
+ back_priv = glamor_get_pixmap_private(back);
+ temp_fbo = front_priv->base.fbo;
+ front_priv->base.fbo = back_priv->base.fbo;
+ back_priv->base.fbo = temp_fbo;
+}
diff --git a/xorg-server/glamor/glamor_fill.c b/xorg-server/glamor/glamor_fill.c
new file mode 100644
index 000000000..fbc87392e
--- /dev/null
+++ b/xorg-server/glamor/glamor_fill.c
@@ -0,0 +1,364 @@
+/*
+ * Copyright © 2008 Intel Corporation
+ * Copyright © 1998 Keith Packard
+ *
+ * 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 Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ * Zhigang Gong <zhigang.gong@linux.intel.com>
+ */
+
+#include "glamor_priv.h"
+
+/** @file glamor_fillspans.c
+ *
+ * GC fill implementation, based loosely on fb_fill.c
+ */
+Bool
+glamor_fill(DrawablePtr drawable,
+ GCPtr gc, int x, int y, int width, int height, Bool fallback)
+{
+ PixmapPtr dst_pixmap = glamor_get_drawable_pixmap(drawable);
+ int off_x, off_y;
+ PixmapPtr sub_pixmap = NULL;
+ glamor_access_t sub_pixmap_access;
+ DrawablePtr saved_drawable = NULL;
+ int saved_x = x, saved_y = y;
+
+ glamor_get_drawable_deltas(drawable, dst_pixmap, &off_x, &off_y);
+
+ switch (gc->fillStyle) {
+ case FillSolid:
+ if (!glamor_solid(dst_pixmap,
+ x + off_x,
+ y + off_y,
+ width, height, gc->alu, gc->planemask,
+ gc->fgPixel))
+ goto fail;
+ break;
+ case FillStippled:
+ case FillOpaqueStippled:
+ if (!glamor_stipple(dst_pixmap,
+ gc->stipple,
+ x + off_x,
+ y + off_y,
+ width,
+ height,
+ gc->alu,
+ gc->planemask,
+ gc->fgPixel,
+ gc->bgPixel, gc->patOrg.x,
+ gc->patOrg.y))
+ goto fail;
+ break;
+ case FillTiled:
+ if (!glamor_tile(dst_pixmap,
+ gc->tile.pixmap,
+ x + off_x,
+ y + off_y,
+ width,
+ height,
+ gc->alu,
+ gc->planemask,
+ x - drawable->x - gc->patOrg.x,
+ y - drawable->y - gc->patOrg.y))
+ goto fail;
+ break;
+ }
+ return TRUE;
+
+ fail:
+ if (!fallback) {
+ if (glamor_ddx_fallback_check_pixmap(&dst_pixmap->drawable)
+ && glamor_ddx_fallback_check_gc(gc))
+ return FALSE;
+ }
+ /* Is it possible to set the access as WO? */
+
+ sub_pixmap_access = GLAMOR_ACCESS_RW;
+
+ sub_pixmap = glamor_get_sub_pixmap(dst_pixmap, x + off_x,
+ y + off_y, width, height,
+ sub_pixmap_access);
+
+ if (sub_pixmap != NULL) {
+ if (gc->fillStyle != FillSolid) {
+ gc->patOrg.x += (drawable->x - x);
+ gc->patOrg.y += (drawable->y - y);
+ }
+ saved_drawable = drawable;
+ drawable = &sub_pixmap->drawable;
+ saved_x = x;
+ saved_y = y;
+ x = 0;
+ y = 0;
+ }
+ if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
+ if (glamor_prepare_access_gc(gc)) {
+ fbFill(drawable, gc, x, y, width, height);
+ glamor_finish_access_gc(gc);
+ }
+ glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
+ }
+
+ if (sub_pixmap != NULL) {
+ if (gc->fillStyle != FillSolid) {
+ gc->patOrg.x -= (saved_drawable->x - saved_x);
+ gc->patOrg.y -= (saved_drawable->y - saved_y);
+ }
+
+ x = saved_x;
+ y = saved_y;
+
+ glamor_put_sub_pixmap(sub_pixmap, dst_pixmap,
+ x + off_x, y + off_y,
+ width, height, sub_pixmap_access);
+ }
+
+ return TRUE;
+}
+
+void
+glamor_init_solid_shader(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv;
+ glamor_gl_dispatch *dispatch;
+ const char *solid_vs =
+ "attribute vec4 v_position;"
+ "void main()\n" "{\n" " gl_Position = v_position;\n"
+ "}\n";
+ const char *solid_fs =
+ GLAMOR_DEFAULT_PRECISION "uniform vec4 color;\n"
+ "void main()\n" "{\n" " gl_FragColor = color;\n" "}\n";
+ GLint fs_prog, vs_prog;
+
+ glamor_priv = glamor_get_screen_private(screen);
+ dispatch = glamor_get_dispatch(glamor_priv);
+ glamor_priv->solid_prog = dispatch->glCreateProgram();
+ vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, solid_vs);
+ fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
+ solid_fs);
+ dispatch->glAttachShader(glamor_priv->solid_prog, vs_prog);
+ dispatch->glAttachShader(glamor_priv->solid_prog, fs_prog);
+
+ dispatch->glBindAttribLocation(glamor_priv->solid_prog,
+ GLAMOR_VERTEX_POS, "v_position");
+ glamor_link_glsl_prog(dispatch, glamor_priv->solid_prog);
+
+ glamor_priv->solid_color_uniform_location =
+ dispatch->glGetUniformLocation(glamor_priv->solid_prog,
+ "color");
+ glamor_put_dispatch(glamor_priv);
+}
+
+void
+glamor_fini_solid_shader(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv;
+ glamor_gl_dispatch *dispatch;
+
+ glamor_priv = glamor_get_screen_private(screen);
+ dispatch = glamor_get_dispatch(glamor_priv);
+ dispatch->glDeleteProgram(glamor_priv->solid_prog);
+ glamor_put_dispatch(glamor_priv);
+}
+
+static void
+_glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
+{
+ ScreenPtr screen = pixmap->drawable.pScreen;
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(screen);
+ glamor_pixmap_private *pixmap_priv =
+ glamor_get_pixmap_private(pixmap);
+ glamor_gl_dispatch *dispatch;
+ GLfloat xscale, yscale;
+ float vertices[32];
+ float *pvertices = vertices;
+ int valid_nbox = ARRAY_SIZE(vertices);
+
+ glamor_set_destination_pixmap_priv_nc(pixmap_priv);
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+ dispatch->glUseProgram(glamor_priv->solid_prog);
+
+ dispatch->glUniform4fv(glamor_priv->solid_color_uniform_location,
+ 1, color);
+
+ pixmap_priv_get_dest_scale(pixmap_priv, &xscale, &yscale);
+
+ if (unlikely(nbox*4*2 > ARRAY_SIZE(vertices))) {
+ int allocated_box;
+
+ if (nbox * 6 > GLAMOR_COMPOSITE_VBO_VERT_CNT) {
+ allocated_box = GLAMOR_COMPOSITE_VBO_VERT_CNT / 6;
+ } else
+ allocated_box = nbox;
+ pvertices = malloc(allocated_box * 4 * 2 * sizeof(float));
+ if (pvertices)
+ valid_nbox = allocated_box;
+ else {
+ pvertices = vertices;
+ valid_nbox = ARRAY_SIZE(vertices) / (4*2);
+ }
+ }
+
+ if (unlikely(nbox > 1))
+ dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);
+
+ dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
+ GL_FALSE, 2 * sizeof(float),
+ pvertices);
+ dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+
+ while(nbox) {
+ int box_cnt, i;
+ float *valid_vertices;
+ valid_vertices = pvertices;
+ box_cnt = nbox > valid_nbox ? valid_nbox : nbox;
+ for (i = 0; i < box_cnt; i++) {
+ glamor_set_normalize_vcoords(pixmap_priv, xscale, yscale,
+ box[i].x1, box[i].y1,
+ box[i].x2, box[i].y2,
+ glamor_priv->yInverted,
+ valid_vertices);
+ valid_vertices += 4*2;
+ }
+ if (box_cnt == 1)
+ dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, box_cnt * 4);
+ else
+#ifndef GLAMOR_GLES2
+ dispatch->glDrawRangeElements(GL_TRIANGLES,
+ 0,
+ box_cnt * 4,
+ box_cnt * 6,
+ GL_UNSIGNED_SHORT,
+ NULL);
+#else
+ dispatch->glDrawElements(GL_TRIANGLES,
+ box_cnt * 6,
+ GL_UNSIGNED_SHORT,
+ NULL);
+#endif
+ nbox -= box_cnt;
+ box += box_cnt;
+ }
+
+ if (pvertices != vertices)
+ free(pvertices);
+
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+ dispatch->glUseProgram(0);
+ glamor_put_dispatch(glamor_priv);
+ glamor_priv->state = RENDER_STATE;
+ glamor_priv->render_idle_cnt = 0;
+}
+
+Bool
+glamor_solid_boxes(PixmapPtr pixmap,
+ BoxPtr box, int nbox,
+ unsigned long fg_pixel)
+{
+ glamor_pixmap_private *pixmap_priv;
+ GLfloat color[4];
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+ return FALSE;
+
+ glamor_get_rgba_from_pixel(fg_pixel,
+ &color[0],
+ &color[1],
+ &color[2],
+ &color[3], format_for_pixmap(pixmap));
+
+ if (pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
+ RegionRec region;
+ int n_region;
+ glamor_pixmap_clipped_regions *clipped_regions;
+ int i;
+
+ RegionInitBoxes(&region, box, nbox);
+ clipped_regions = glamor_compute_clipped_regions(pixmap_priv, &region, &n_region, 0, 0, 0);
+ for(i = 0; i < n_region; i++)
+ {
+ BoxPtr inner_box;
+ int inner_nbox;
+ SET_PIXMAP_FBO_CURRENT(pixmap_priv, clipped_regions[i].block_idx);
+
+ inner_box = RegionRects(clipped_regions[i].region);
+ inner_nbox = RegionNumRects(clipped_regions[i].region);
+ _glamor_solid_boxes(pixmap, inner_box, inner_nbox, color);
+ RegionDestroy(clipped_regions[i].region);
+ }
+ free(clipped_regions);
+ RegionUninit(&region);
+ } else
+ _glamor_solid_boxes(pixmap, box, nbox, color);
+
+ return TRUE;
+}
+
+Bool
+glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
+ unsigned char alu, unsigned long planemask,
+ unsigned long fg_pixel)
+{
+ ScreenPtr screen = pixmap->drawable.pScreen;
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(screen);
+ glamor_pixmap_private *pixmap_priv;
+ glamor_gl_dispatch *dispatch;
+ BoxRec box;
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+ return FALSE;
+
+ if (!glamor_set_planemask(pixmap, planemask)) {
+ glamor_fallback
+ ("Failedto set planemask in glamor_solid.\n");
+ return FALSE;
+ }
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+ if (!glamor_set_alu(dispatch, alu)) {
+ if (alu == GXclear)
+ fg_pixel = 0;
+ else {
+ glamor_fallback("unsupported alu %x\n", alu);
+ glamor_put_dispatch(glamor_priv);
+ return FALSE;
+ }
+ }
+ box.x1 = x;
+ box.y1 = y;
+ box.x2 = x + width;
+ box.y2 = y + height;
+ glamor_solid_boxes(pixmap, &box, 1, fg_pixel);
+
+ glamor_set_alu(dispatch, GXcopy);
+ glamor_put_dispatch(glamor_priv);
+
+ return TRUE;
+}
+
diff --git a/xorg-server/glamor/glamor_fillspans.c b/xorg-server/glamor/glamor_fillspans.c
new file mode 100644
index 000000000..35e881f61
--- /dev/null
+++ b/xorg-server/glamor/glamor_fillspans.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright © 1998 Keith Packard
+ *
+ * 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 Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+/** @file glamor_fillspans.c
+ *
+ * FillSpans implementation, taken from fb_fillsp.c
+ */
+#include "glamor_priv.h"
+
+static Bool
+_glamor_fill_spans(DrawablePtr drawable,
+ GCPtr gc,
+ int n, DDXPointPtr points, int *widths, int sorted, Bool fallback)
+{
+ DDXPointPtr ppt;
+ int nbox;
+ BoxPtr pbox;
+ int x1, x2, y;
+ RegionPtr pClip = fbGetCompositeClip(gc);
+ Bool ret = FALSE;
+
+ if (gc->fillStyle != FillSolid && gc->fillStyle != FillTiled)
+ goto fail;
+
+ ppt = points;
+ while (n--) {
+ x1 = ppt->x;
+ y = ppt->y;
+ x2 = x1 + (int) *widths;
+ ppt++;
+ widths++;
+
+ nbox = REGION_NUM_RECTS(pClip);
+ pbox = REGION_RECTS(pClip);
+ while (nbox--) {
+ int real_x1 = x1, real_x2 = x2;
+
+ if (real_x1 < pbox->x1)
+ real_x1 = pbox->x1;
+
+ if (real_x2 > pbox->x2)
+ real_x2 = pbox->x2;
+
+ if (real_x2 > real_x1 && pbox->y1 <= y && pbox->y2 > y) {
+ if (!glamor_fill(drawable, gc, real_x1, y,
+ real_x2 - real_x1, 1, fallback))
+ goto fail;
+ }
+ pbox++;
+ }
+ }
+ ret = TRUE;
+ goto done;
+
+fail:
+ if (!fallback
+ && glamor_ddx_fallback_check_pixmap(drawable)
+ && glamor_ddx_fallback_check_gc(gc)) {
+ goto done;
+ }
+ glamor_fallback("to %p (%c)\n", drawable,
+ glamor_get_drawable_location(drawable));
+ if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
+ if (glamor_prepare_access_gc(gc)) {
+ fbFillSpans(drawable, gc, n, points, widths,
+ sorted);
+ glamor_finish_access_gc(gc);
+ }
+ glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
+ }
+ ret = TRUE;
+
+done:
+ return ret;
+}
+
+
+void
+glamor_fill_spans(DrawablePtr drawable,
+ GCPtr gc,
+ int n, DDXPointPtr points, int *widths, int sorted)
+{
+ _glamor_fill_spans(drawable, gc, n, points, widths, sorted, TRUE);
+}
+
+Bool
+glamor_fill_spans_nf(DrawablePtr drawable,
+ GCPtr gc,
+ int n, DDXPointPtr points, int *widths, int sorted)
+{
+ return _glamor_fill_spans(drawable, gc, n, points, widths, sorted, FALSE);
+}
+
+
diff --git a/xorg-server/glamor/glamor_getimage.c b/xorg-server/glamor/glamor_getimage.c
new file mode 100644
index 000000000..5df576c45
--- /dev/null
+++ b/xorg-server/glamor/glamor_getimage.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ * Copyright © 1998 Keith Packard
+ *
+ * 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.
+ *
+ * Authors:
+ * Zhigang Gong <zhigang.gong@gmail.com>
+ *
+ */
+
+#include "glamor_priv.h"
+
+
+static Bool
+_glamor_get_image(DrawablePtr drawable, int x, int y, int w, int h,
+ unsigned int format, unsigned long planeMask, char *d,
+ Bool fallback)
+{
+ PixmapPtr pixmap, sub_pixmap;
+ struct glamor_pixmap_private *pixmap_priv;
+ int x_off, y_off;
+ int stride;
+ void *data;
+
+ pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
+
+ if (format != ZPixmap)
+ goto fall_back;
+ pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
+
+ if (!glamor_set_planemask(pixmap, planeMask)) {
+ glamor_fallback
+ ("Failedto set planemask in glamor_solid.\n");
+ goto fall_back;
+ }
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+
+
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+ goto fall_back;
+ stride = PixmapBytePad(w, drawable->depth);
+
+ x += drawable->x + x_off;
+ y += drawable->y + y_off;
+
+ data = glamor_download_sub_pixmap_to_cpu(pixmap, x, y, w, h, stride,
+ d, 0, GLAMOR_ACCESS_RO);
+ if (data != NULL) {
+ assert(data == d);
+ return TRUE;
+ }
+fall_back:
+ sub_pixmap = glamor_get_sub_pixmap(pixmap, x + x_off + drawable->x,
+ y + y_off + drawable->y, w, h,
+ GLAMOR_ACCESS_RO);
+ if (sub_pixmap) {
+ fbGetImage(&sub_pixmap->drawable, 0, 0, w, h, format, planeMask, d);
+ glamor_put_sub_pixmap(sub_pixmap, pixmap,
+ x + x_off + drawable->x,
+ y + y_off + drawable->y,
+ w, h, GLAMOR_ACCESS_RO);
+ } else
+ miGetImage(drawable, x, y, w, h, format, planeMask, d);
+
+ return TRUE;
+}
+
+void
+glamor_get_image(DrawablePtr pDrawable, int x, int y, int w, int h,
+ unsigned int format, unsigned long planeMask, char *d)
+{
+ _glamor_get_image(pDrawable, x, y, w, h, format, planeMask, d, TRUE);
+}
+
+Bool
+glamor_get_image_nf(DrawablePtr pDrawable, int x, int y, int w, int h,
+ unsigned int format, unsigned long planeMask, char *d)
+{
+ return _glamor_get_image(pDrawable, x, y, w,
+ h, format, planeMask, d, FALSE);
+}
diff --git a/xorg-server/glamor/glamor_getspans.c b/xorg-server/glamor/glamor_getspans.c
new file mode 100644
index 000000000..6d6c8e9a4
--- /dev/null
+++ b/xorg-server/glamor/glamor_getspans.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ *
+ * 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.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ * Zhigang Gong <zhigang.gong@linux.intel.com>
+ *
+ */
+
+#include "glamor_priv.h"
+
+static Bool
+_glamor_get_spans(DrawablePtr drawable,
+ int wmax,
+ DDXPointPtr points, int *widths, int count, char *dst,
+ Bool fallback)
+{
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_pixmap_private *pixmap_priv =
+ glamor_get_pixmap_private(pixmap);
+ int i;
+ uint8_t *readpixels_dst = (uint8_t *) dst;
+ void *data;
+ int x_off, y_off;
+ Bool ret = FALSE;
+
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+ goto fail;
+
+ glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
+ for (i = 0; i < count; i++) {
+ data = glamor_download_sub_pixmap_to_cpu(pixmap, points[i].x + x_off,
+ points[i].y + y_off, widths[i], 1,
+ PixmapBytePad(widths[i], drawable->depth),
+ readpixels_dst, 0, GLAMOR_ACCESS_RO);
+ assert(data == readpixels_dst);
+ readpixels_dst += PixmapBytePad(widths[i], drawable->depth);
+ }
+
+ ret = TRUE;
+ goto done;
+fail:
+
+ if (!fallback
+ && glamor_ddx_fallback_check_pixmap(drawable))
+ goto done;
+
+ ret = TRUE;
+ if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RO)) {
+ fbGetSpans(drawable, wmax, points, widths, count, dst);
+ glamor_finish_access(drawable, GLAMOR_ACCESS_RO);
+ }
+done:
+ return ret;
+}
+
+void
+glamor_get_spans(DrawablePtr drawable,
+ int wmax,
+ DDXPointPtr points, int *widths, int count, char *dst)
+{
+ _glamor_get_spans(drawable, wmax, points,
+ widths, count, dst, TRUE);
+}
+
+Bool
+glamor_get_spans_nf(DrawablePtr drawable,
+ int wmax,
+ DDXPointPtr points, int *widths, int count, char *dst)
+{
+ return _glamor_get_spans(drawable, wmax, points,
+ widths, count, dst, FALSE);
+}
+
+
+
diff --git a/xorg-server/glamor/glamor_gl_dispatch.c b/xorg-server/glamor/glamor_gl_dispatch.c
new file mode 100644
index 000000000..da99e2627
--- /dev/null
+++ b/xorg-server/glamor/glamor_gl_dispatch.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ * Copyright © 1998 Keith Packard
+ *
+ * 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.
+ *
+ * Authors:
+ * Zhigang Gong <zhigang.gong@gmail.com>
+ *
+ */
+
+#include "glamor_priv.h"
+#include <dlfcn.h>
+
+#define INIT_FUNC(dst,func_name,get) \
+ dst->func_name = get(#func_name); \
+ if (dst->func_name == NULL) { \
+ dst->func_name = (void *)dlsym(NULL, #func_name); \
+ if (dst->func_name == NULL) { \
+ ErrorF("Failed to get function %s\n", #func_name);\
+ goto fail; \
+ } \
+ } \
+
+_X_EXPORT Bool
+glamor_gl_dispatch_init_impl(struct glamor_gl_dispatch *dispatch,
+ int gl_version,
+ void *(*get_proc_address) (const char *))
+{
+#ifndef GLAMOR_GLES2
+ INIT_FUNC(dispatch, glMatrixMode, get_proc_address);
+ INIT_FUNC(dispatch, glLoadIdentity, get_proc_address);
+ INIT_FUNC(dispatch, glRasterPos2i, get_proc_address);
+ INIT_FUNC(dispatch, glDrawPixels, get_proc_address);
+ INIT_FUNC(dispatch, glLogicOp, get_proc_address);
+ INIT_FUNC(dispatch, glMapBuffer, get_proc_address);
+ INIT_FUNC(dispatch, glMapBufferRange, get_proc_address);
+ INIT_FUNC(dispatch, glUnmapBuffer, get_proc_address);
+ INIT_FUNC(dispatch, glBlitFramebuffer, get_proc_address);
+ INIT_FUNC(dispatch, glDrawRangeElements, get_proc_address);
+#endif
+ INIT_FUNC(dispatch, glViewport, get_proc_address);
+ INIT_FUNC(dispatch, glDrawArrays, get_proc_address);
+ INIT_FUNC(dispatch, glDrawElements, get_proc_address);
+ INIT_FUNC(dispatch, glReadPixels, get_proc_address);
+ INIT_FUNC(dispatch, glPixelStorei, get_proc_address);
+ INIT_FUNC(dispatch, glTexParameteri, get_proc_address);
+ INIT_FUNC(dispatch, glTexImage2D, get_proc_address);
+ INIT_FUNC(dispatch, glGenTextures, get_proc_address);
+ INIT_FUNC(dispatch, glDeleteTextures, get_proc_address);
+ INIT_FUNC(dispatch, glBindTexture, get_proc_address);
+ INIT_FUNC(dispatch, glTexSubImage2D, get_proc_address);
+ INIT_FUNC(dispatch, glFlush, get_proc_address);
+ INIT_FUNC(dispatch, glFinish, get_proc_address);
+ INIT_FUNC(dispatch, glGetIntegerv, get_proc_address);
+ INIT_FUNC(dispatch, glGetString, get_proc_address);
+ INIT_FUNC(dispatch, glScissor, get_proc_address);
+ INIT_FUNC(dispatch, glEnable, get_proc_address);
+ INIT_FUNC(dispatch, glDisable, get_proc_address);
+ INIT_FUNC(dispatch, glBlendFunc, get_proc_address);
+ INIT_FUNC(dispatch, glActiveTexture, get_proc_address);
+ INIT_FUNC(dispatch, glGenBuffers, get_proc_address);
+ INIT_FUNC(dispatch, glBufferData, get_proc_address);
+ INIT_FUNC(dispatch, glBindBuffer, get_proc_address);
+ INIT_FUNC(dispatch, glDeleteBuffers, get_proc_address);
+ INIT_FUNC(dispatch, glFramebufferTexture2D, get_proc_address);
+ INIT_FUNC(dispatch, glBindFramebuffer, get_proc_address);
+ INIT_FUNC(dispatch, glDeleteFramebuffers, get_proc_address);
+ INIT_FUNC(dispatch, glGenFramebuffers, get_proc_address);
+ INIT_FUNC(dispatch, glCheckFramebufferStatus, get_proc_address);
+ INIT_FUNC(dispatch, glVertexAttribPointer, get_proc_address);
+ INIT_FUNC(dispatch, glDisableVertexAttribArray, get_proc_address);
+ INIT_FUNC(dispatch, glEnableVertexAttribArray, get_proc_address);
+ INIT_FUNC(dispatch, glBindAttribLocation, get_proc_address);
+ INIT_FUNC(dispatch, glLinkProgram, get_proc_address);
+ INIT_FUNC(dispatch, glShaderSource, get_proc_address);
+
+ INIT_FUNC(dispatch, glUseProgram, get_proc_address);
+ INIT_FUNC(dispatch, glUniform1i, get_proc_address);
+ INIT_FUNC(dispatch, glUniform1f, get_proc_address);
+ INIT_FUNC(dispatch, glUniform4f, get_proc_address);
+ INIT_FUNC(dispatch, glUniform4fv, get_proc_address);
+ INIT_FUNC(dispatch, glUniform1fv, get_proc_address);
+ INIT_FUNC(dispatch, glUniform2fv, get_proc_address);
+ INIT_FUNC(dispatch, glUniformMatrix3fv, get_proc_address);
+ INIT_FUNC(dispatch, glCreateProgram, get_proc_address);
+ INIT_FUNC(dispatch, glDeleteProgram, get_proc_address);
+ INIT_FUNC(dispatch, glCreateShader, get_proc_address);
+ INIT_FUNC(dispatch, glCompileShader, get_proc_address);
+ INIT_FUNC(dispatch, glAttachShader, get_proc_address);
+ INIT_FUNC(dispatch, glDeleteShader, get_proc_address);
+ INIT_FUNC(dispatch, glGetShaderiv, get_proc_address);
+ INIT_FUNC(dispatch, glGetShaderInfoLog, get_proc_address);
+ INIT_FUNC(dispatch, glGetProgramiv, get_proc_address);
+ INIT_FUNC(dispatch, glGetProgramInfoLog, get_proc_address);
+ INIT_FUNC(dispatch, glGetUniformLocation, get_proc_address);
+
+ return TRUE;
+ fail:
+ return FALSE;
+}
diff --git a/xorg-server/glamor/glamor_gl_dispatch.h b/xorg-server/glamor/glamor_gl_dispatch.h
new file mode 100644
index 000000000..76dadd49e
--- /dev/null
+++ b/xorg-server/glamor/glamor_gl_dispatch.h
@@ -0,0 +1,138 @@
+typedef struct glamor_gl_dispatch {
+ /* Transformation functions */
+ void (*glMatrixMode) (GLenum mode);
+ void (*glLoadIdentity) (void);
+ void (*glViewport) (GLint x, GLint y, GLsizei width,
+ GLsizei height);
+ /* Drawing functions */
+ void (*glRasterPos2i) (GLint x, GLint y);
+
+ /* Vertex Array */
+ void (*glDrawArrays) (GLenum mode, GLint first, GLsizei count);
+
+ /* Elements Array*/
+ void (*glDrawElements) (GLenum mode, GLsizei count, GLenum type, const GLvoid * indices);
+ void (*glDrawRangeElements) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid * indices);
+
+ /* Raster functions */
+ void (*glReadPixels) (GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type, GLvoid * pixels);
+
+ void (*glDrawPixels) (GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const GLvoid * pixels);
+ void (*glPixelStorei) (GLenum pname, GLint param);
+ /* Texture Mapping */
+
+ void (*glTexParameteri) (GLenum target, GLenum pname, GLint param);
+ void (*glTexImage2D) (GLenum target, GLint level,
+ GLint internalFormat,
+ GLsizei width, GLsizei height,
+ GLint border, GLenum format, GLenum type,
+ const GLvoid * pixels);
+ /* 1.1 */
+ void (*glGenTextures) (GLsizei n, GLuint * textures);
+ void (*glDeleteTextures) (GLsizei n, const GLuint * textures);
+ void (*glBindTexture) (GLenum target, GLuint texture);
+ void (*glTexSubImage2D) (GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const GLvoid * pixels);
+ /* MISC */
+ void (*glFlush) (void);
+ void (*glFinish) (void);
+ void (*glGetIntegerv) (GLenum pname, GLint * params);
+ const GLubyte *(*glGetString) (GLenum name);
+ void (*glScissor) (GLint x, GLint y, GLsizei width,
+ GLsizei height);
+ void (*glEnable) (GLenum cap);
+ void (*glDisable) (GLenum cap);
+ void (*glBlendFunc) (GLenum sfactor, GLenum dfactor);
+ void (*glLogicOp) (GLenum opcode);
+
+ /* 1.3 */
+ void (*glActiveTexture) (GLenum texture);
+
+ /* GL Extentions */
+ void (*glGenBuffers) (GLsizei n, GLuint * buffers);
+ void (*glBufferData) (GLenum target, GLsizeiptr size,
+ const GLvoid * data, GLenum usage);
+ GLvoid *(*glMapBuffer) (GLenum target, GLenum access);
+ GLvoid *(*glMapBufferRange) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+ GLboolean (*glUnmapBuffer) (GLenum target);
+ void (*glBindBuffer) (GLenum target, GLuint buffer);
+ void (*glDeleteBuffers) (GLsizei n, const GLuint * buffers);
+
+ void (*glFramebufferTexture2D) (GLenum target, GLenum attachment,
+ GLenum textarget, GLuint texture,
+ GLint level);
+ void (*glBindFramebuffer) (GLenum target, GLuint framebuffer);
+ void (*glDeleteFramebuffers) (GLsizei n,
+ const GLuint * framebuffers);
+ void (*glGenFramebuffers) (GLsizei n, GLuint * framebuffers);
+ GLenum (*glCheckFramebufferStatus) (GLenum target);
+ void (*glBlitFramebuffer) (GLint srcX0, GLint srcY0, GLint srcX1,
+ GLint srcY1, GLint dstX0, GLint dstY0,
+ GLint dstX1, GLint dstY1,
+ GLbitfield mask, GLenum filter);
+
+ void (*glVertexAttribPointer) (GLuint index, GLint size,
+ GLenum type, GLboolean normalized,
+ GLsizei stride,
+ const GLvoid * pointer);
+ void (*glDisableVertexAttribArray) (GLuint index);
+ void (*glEnableVertexAttribArray) (GLuint index);
+ void (*glBindAttribLocation) (GLuint program, GLuint index,
+ const GLchar * name);
+
+ void (*glLinkProgram) (GLuint program);
+ void (*glShaderSource) (GLuint shader, GLsizei count,
+ const GLchar * *string,
+ const GLint * length);
+ void (*glUseProgram) (GLuint program);
+ void (*glUniform1i) (GLint location, GLint v0);
+ void (*glUniform1f) (GLint location, GLfloat v0);
+ void (*glUniform4f) (GLint location, GLfloat v0, GLfloat v1,
+ GLfloat v2, GLfloat v3);
+ void (*glUniform1fv) (GLint location, GLsizei count,
+ const GLfloat * value);
+ void (*glUniform2fv) (GLint location, GLsizei count,
+ const GLfloat * value);
+ void (*glUniform4fv) (GLint location, GLsizei count,
+ const GLfloat * value);
+ void (*glUniformMatrix3fv) (GLint location, GLsizei count,
+ GLboolean transpose, const GLfloat* value);
+ GLuint (*glCreateProgram) (void);
+ GLuint (*glDeleteProgram) (GLuint);
+ GLuint (*glCreateShader) (GLenum type);
+ void (*glCompileShader) (GLuint shader);
+ void (*glAttachShader) (GLuint program, GLuint shader);
+ void (*glDeleteShader) (GLuint shader);
+ void (*glGetShaderiv) (GLuint shader, GLenum pname,
+ GLint * params);
+ void (*glGetShaderInfoLog) (GLuint shader, GLsizei bufSize,
+ GLsizei * length, GLchar * infoLog);
+ void (*glGetProgramiv) (GLuint program, GLenum pname,
+ GLint * params);
+ void (*glGetProgramInfoLog) (GLuint program, GLsizei bufSize,
+ GLsizei * length, GLchar * infoLog);
+ GLint (*glGetUniformLocation) (GLuint program,
+ const GLchar * name);
+
+} glamor_gl_dispatch;
+
+
+typedef void *(*get_proc_address_t) (const char *);
+
+_X_EXPORT Bool
+glamor_gl_dispatch_init_impl(struct glamor_gl_dispatch *dispatch,
+ int gl_version,
+ get_proc_address_t get_proc_address);
+
+
+_X_EXPORT Bool
+glamor_gl_dispatch_init(ScreenPtr screen,
+ struct glamor_gl_dispatch *dispatch,
+ int gl_version);
diff --git a/xorg-server/glamor/glamor_glext.h b/xorg-server/glamor/glamor_glext.h
new file mode 100644
index 000000000..1f7206b99
--- /dev/null
+++ b/xorg-server/glamor/glamor_glext.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright © 2001 Keith Packard
+ * Copyright © 2008 Intel Corporation
+ *
+ * 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.
+ *
+ * Authors:
+ * Zhigang Gong <zhigang.gong@linux.intel.com>
+ *
+ */
+
+
+#ifdef GLAMOR_GLES2
+
+#define GL_BGRA GL_BGRA_EXT
+#define GL_COLOR_INDEX 0x1900
+#define GL_BITMAP 0x1A00
+#define GL_UNSIGNED_INT_8_8_8_8 0x8035
+#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
+#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
+#define GL_UNSIGNED_INT_10_10_10_2 0x8036
+#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
+#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
+
+#define GL_PIXEL_PACK_BUFFER 0x88EB
+#define GL_PIXEL_UNPACK_BUFFER 0x88EC
+#define GL_CLAMP_TO_BORDER 0x812D
+
+#define GL_READ_WRITE 0x88BA
+#define GL_READ_ONLY 0x88B8
+#define GL_WRITE_ONLY 0x88B9
+#define GL_STREAM_DRAW 0x88E0
+#define GL_STREAM_READ 0x88E1
+#define GL_PACK_ROW_LENGTH 0x0D02
+#define GL_UNPACK_ROW_LENGTH 0x0CF2
+
+#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB
+#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
+
+#define GL_PACK_INVERT_MESA 0x8758
+#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020
+#define GL_MAP_READ_BIT 0x0001
+#define GL_MAP_WRITE_BIT 0x0002
+
+#endif
diff --git a/xorg-server/glamor/glamor_glyphblt.c b/xorg-server/glamor/glamor_glyphblt.c
new file mode 100644
index 000000000..b55327c4b
--- /dev/null
+++ b/xorg-server/glamor/glamor_glyphblt.c
@@ -0,0 +1,118 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ * Copyright © 1998 Keith Packard
+ *
+ * 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.
+ *
+ * Authors:
+ * Zhigang Gong <zhigang.gong@gmail.com>
+ *
+ */
+
+#include "glamor_priv.h"
+
+static Bool
+_glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase, Bool fallback)
+{
+ if (!fallback
+ && glamor_ddx_fallback_check_pixmap(pDrawable)
+ && glamor_ddx_fallback_check_gc(pGC))
+ return FALSE;
+
+ miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+ return TRUE;
+}
+
+void
+glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase)
+{
+ _glamor_image_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase, TRUE);
+}
+
+Bool
+glamor_image_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase)
+{
+ return _glamor_image_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase, FALSE);
+}
+
+static Bool
+_glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase, Bool fallback)
+{
+ if (!fallback
+ && glamor_ddx_fallback_check_pixmap(pDrawable)
+ && glamor_ddx_fallback_check_gc(pGC))
+ return FALSE;
+
+ miPolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+ return TRUE;
+}
+
+void
+glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase)
+{
+ _glamor_poly_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase, TRUE);
+}
+
+Bool
+glamor_poly_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase)
+{
+ return _glamor_poly_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase, FALSE);
+}
+
+static Bool
+_glamor_push_pixels(GCPtr pGC, PixmapPtr pBitmap,
+ DrawablePtr pDrawable, int w, int h, int x, int y, Bool fallback)
+{
+ if (!fallback
+ && glamor_ddx_fallback_check_pixmap(pDrawable)
+ && glamor_ddx_fallback_check_pixmap(&pBitmap->drawable)
+ && glamor_ddx_fallback_check_gc(pGC))
+ return FALSE;
+
+ miPushPixels(pGC, pBitmap, pDrawable, w, h, x, y);
+ return TRUE;
+}
+
+void
+glamor_push_pixels(GCPtr pGC, PixmapPtr pBitmap,
+ DrawablePtr pDrawable, int w, int h, int x, int y)
+{
+ _glamor_push_pixels(pGC, pBitmap, pDrawable, w, h, x, y, TRUE);
+}
+
+Bool
+glamor_push_pixels_nf(GCPtr pGC, PixmapPtr pBitmap,
+ DrawablePtr pDrawable, int w, int h, int x, int y)
+{
+ return _glamor_push_pixels(pGC, pBitmap, pDrawable, w, h, x, y, FALSE);
+}
+
diff --git a/xorg-server/glamor/glamor_glyphs.c b/xorg-server/glamor/glamor_glyphs.c
new file mode 100644
index 000000000..fc361df42
--- /dev/null
+++ b/xorg-server/glamor/glamor_glyphs.c
@@ -0,0 +1,1806 @@
+/*
+ * Copyright © 2008 Red Hat, Inc.
+ * Partly based on code Copyright © 2000 SuSE, Inc.
+ *
+ * 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 Red Hat not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. Red Hat makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * Red Hat DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL Red Hat
+ * 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.
+ *
+ * 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 SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * 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.
+ *
+ * Author: Owen Taylor <otaylor@fishsoup.net>
+ * Based on code by: Keith Packard
+ */
+
+#include <stdlib.h>
+
+#include "glamor_priv.h"
+
+#include <mipict.h>
+
+#if DEBUG_GLYPH_CACHE
+#define DBG_GLYPH_CACHE(a) ErrorF a
+#else
+#define DBG_GLYPH_CACHE(a)
+#endif
+
+/* Width of the pixmaps we use for the caches; this should be less than
+ * max texture size of the driver; this may need to actually come from
+ * the driver.
+ */
+
+/* Maximum number of glyphs we buffer on the stack before flushing
+ * rendering to the mask or destination surface.
+ */
+#define GLYPH_BUFFER_SIZE 1024
+
+#define CACHE_PICTURE_SIZE 1024
+#define GLYPH_MIN_SIZE 8
+#define GLYPH_MAX_SIZE 64
+#define GLYPH_CACHE_SIZE ((CACHE_PICTURE_SIZE) * CACHE_PICTURE_SIZE / (GLYPH_MIN_SIZE * GLYPH_MIN_SIZE))
+#define MASK_CACHE_MAX_SIZE 32
+#define MASK_CACHE_WIDTH (CACHE_PICTURE_SIZE / MASK_CACHE_MAX_SIZE)
+#define MASK_CACHE_MASK ((1LL << (MASK_CACHE_WIDTH)) - 1)
+
+typedef struct {
+ PicturePtr source;
+ glamor_composite_rect_t rects[GLYPH_BUFFER_SIZE + 4];
+ int count;
+} glamor_glyph_buffer_t;
+
+struct glamor_glyph {
+ glamor_glyph_cache_t *cache;
+ uint16_t x, y;
+ uint16_t size, pos;
+ unsigned long long left_x1_map, left_x2_map;
+ unsigned long long right_x1_map, right_x2_map; /* Use to check real intersect or not. */
+ Bool has_edge_map;
+ Bool cached;
+};
+
+typedef enum {
+ GLAMOR_GLYPH_SUCCESS, /* Glyph added to render buffer */
+ GLAMOR_GLYPH_FAIL, /* out of memory, etc */
+ GLAMOR_GLYPH_NEED_FLUSH, /* would evict a glyph already in the buffer */
+} glamor_glyph_cache_result_t;
+
+#define NeedsComponent(f) (PICT_FORMAT_A(f) != 0 && PICT_FORMAT_RGB(f) != 0)
+static DevPrivateKeyRec glamor_glyph_key;
+
+static inline struct glamor_glyph *
+glamor_glyph_get_private(GlyphPtr glyph)
+{
+ return (struct glamor_glyph*)glyph->devPrivates;
+}
+
+/*
+ * Mask cache is located at the corresponding cache picture's last row.
+ * and is deadicated for the mask picture when do the glyphs_via_mask.
+ *
+ * As we split the glyphs list according to its overlapped or non-overlapped,
+ * we can reduce the length of glyphs to do the glyphs_via_mask to 2 or 3
+ * glyphs one time for most cases. Thus it give us a case to allocate a
+ * small portion of the corresponding cache directly as the mask picture.
+ * Then we can rendering the glyphs to this mask picture, and latter we
+ * can accumulate the second steps, composite the mask to the dest with
+ * the other non-overlapped glyphs's rendering process.
+ * Another major benefit is we now only need to clear a relatively small mask
+ * region then before. It also make us implement a bunch mask picture clearing
+ * algorithm to avoid too frequently small region clearing.
+ *
+ * If there is no any overlapping, this method will not get performance gain.
+ * If there is some overlapping, then this algorithm can get about 15% performance
+ * gain.
+ */
+
+struct glamor_glyph_mask_cache_entry {
+ int idx;
+ int width;
+ int height;
+ int x;
+ int y;
+};
+
+static struct glamor_glyph_mask_cache {
+ PixmapPtr pixmap;
+ struct glamor_glyph_mask_cache_entry mcache[MASK_CACHE_WIDTH];
+ unsigned int free_bitmap;
+ unsigned int cleared_bitmap;
+}*mask_cache[GLAMOR_NUM_GLYPH_CACHE_FORMATS] = {NULL};
+
+static void
+clear_mask_cache_bitmap(struct glamor_glyph_mask_cache *maskcache,
+ unsigned int clear_mask_bits)
+{
+ unsigned int i = 0;
+ BoxRec box[MASK_CACHE_WIDTH];
+ int box_cnt = 0;
+
+ assert((clear_mask_bits & ~MASK_CACHE_MASK) == 0);
+ for(i = 0; i < MASK_CACHE_WIDTH;i++)
+ {
+ if (clear_mask_bits & (1 << i)) {
+ box[box_cnt].x1 = maskcache->mcache[i].x;
+ box[box_cnt].x2 = maskcache->mcache[i].x + MASK_CACHE_MAX_SIZE;
+ box[box_cnt].y1 = maskcache->mcache[i].y;
+ box[box_cnt].y2 = maskcache->mcache[i].y + MASK_CACHE_MAX_SIZE;
+ box_cnt++;
+ }
+ }
+ glamor_solid_boxes(maskcache->pixmap, box, box_cnt, 0);
+ maskcache->cleared_bitmap |= clear_mask_bits;
+}
+
+static void
+clear_mask_cache(struct glamor_glyph_mask_cache *maskcache)
+{
+ int x = 0;
+ int cnt = MASK_CACHE_WIDTH;
+ unsigned int i = 0;
+ struct glamor_glyph_mask_cache_entry *mce;
+ glamor_solid(maskcache->pixmap, 0, CACHE_PICTURE_SIZE, CACHE_PICTURE_SIZE,
+ MASK_CACHE_MAX_SIZE, GXcopy, 0xFFFFFFFF, 0);
+ mce = &maskcache->mcache[0];
+ while(cnt--) {
+ mce->width = 0;
+ mce->height = 0;
+ mce->x = x;
+ mce->y = CACHE_PICTURE_SIZE;
+ mce->idx = i++;
+ x += MASK_CACHE_MAX_SIZE;
+ mce++;
+ }
+ maskcache->free_bitmap = MASK_CACHE_MASK;
+ maskcache->cleared_bitmap = MASK_CACHE_MASK;
+}
+
+static int
+find_continuous_bits(unsigned int bits, int bits_cnt, unsigned int *pbits_mask)
+{
+ int idx = 0;
+ unsigned int bits_mask;
+ bits_mask = ((1LL << bits_cnt) - 1);
+
+ if (unlikely(bits_cnt > 56)) {
+ while(bits) {
+ if ((bits & bits_mask) == bits_mask) {
+ *pbits_mask = bits_mask << idx;
+ return idx;
+ }
+ bits >>= 1;
+ idx++;
+ }
+ } else {
+ idx = __fls(bits);
+ while(bits) {
+ unsigned int temp_bits;
+ temp_bits = bits_mask << (idx - bits_cnt + 1);
+ if ((bits & temp_bits) == temp_bits) {
+ *pbits_mask = temp_bits;
+ return (idx - bits_cnt + 1);
+ }
+ /* Find first zero. And clear the tested bit.*/
+ bits &= ~(1LL<<idx);
+ idx = __fls(~bits);
+ bits &= ~((1LL << idx) - 1);
+ idx--;
+ }
+ }
+ return -1;
+}
+
+static struct glamor_glyph_mask_cache_entry *
+get_mask_cache(struct glamor_glyph_mask_cache *maskcache, int blocks)
+{
+ int free_cleared_bit, idx = -1;
+ int retry_cnt = 0;
+ unsigned int bits_mask = 0;
+
+ if (maskcache->free_bitmap == 0)
+ return NULL;
+retry:
+ free_cleared_bit = maskcache->free_bitmap & maskcache->cleared_bitmap;
+ if (free_cleared_bit && blocks == 1) {
+ idx = __fls(free_cleared_bit);
+ bits_mask = 1 << idx;
+ } else if (free_cleared_bit && blocks > 1) {
+ idx = find_continuous_bits(free_cleared_bit, blocks, &bits_mask);
+ }
+
+ if (idx < 0) {
+ clear_mask_cache_bitmap(maskcache, maskcache->free_bitmap);
+ if (retry_cnt++ > 2)
+ return NULL;
+ goto retry;
+ }
+
+ maskcache->cleared_bitmap &= ~bits_mask;
+ maskcache->free_bitmap &= ~bits_mask;
+ DEBUGF("get idx %d free %x clear %x \n",
+ idx, maskcache->free_bitmap, maskcache->cleared_bitmap);
+ return &maskcache->mcache[idx];
+}
+
+static void
+put_mask_cache_bitmap(struct glamor_glyph_mask_cache *maskcache,
+ unsigned int bitmap)
+{
+ maskcache->free_bitmap |= bitmap;
+ DEBUGF("put bitmap %x free %x clear %x \n",
+ bitmap, maskcache->free_bitmap, maskcache->cleared_bitmap);
+}
+
+static void
+glamor_unrealize_glyph_caches(ScreenPtr pScreen)
+{
+ glamor_screen_private *glamor = glamor_get_screen_private(pScreen);
+ int i;
+
+ if (!glamor->glyph_cache_initialized)
+ return;
+
+ for (i = 0; i < GLAMOR_NUM_GLYPH_CACHE_FORMATS; i++) {
+ glamor_glyph_cache_t *cache = &glamor->glyphCaches[i];
+
+ if (cache->picture)
+ FreePicture(cache->picture, 0);
+
+ if (cache->glyphs)
+ free(cache->glyphs);
+
+ if (mask_cache[i])
+ free(mask_cache[i]);
+ }
+ glamor->glyph_cache_initialized = FALSE;
+}
+
+void
+glamor_glyphs_fini(ScreenPtr pScreen)
+{
+ glamor_unrealize_glyph_caches(pScreen);
+}
+
+/* All caches for a single format share a single pixmap for glyph storage,
+ * allowing mixing glyphs of different sizes without paying a penalty
+ * for switching between source pixmaps. (Note that for a size of font
+ * right at the border between two sizes, we might be switching for almost
+ * every glyph.)
+ *
+ * This function allocates the storage pixmap, and then fills in the
+ * rest of the allocated structures for all caches with the given format.
+ */
+
+static Bool
+glamor_realize_glyph_caches(ScreenPtr pScreen)
+{
+ glamor_screen_private *glamor = glamor_get_screen_private(pScreen);
+ unsigned int formats[] = {
+ PIXMAN_a8,
+ PIXMAN_a8r8g8b8,
+ };
+ int i;
+
+ if (glamor->glyph_cache_initialized)
+ return TRUE;
+
+ glamor->glyph_cache_initialized = TRUE;
+ memset(glamor->glyphCaches, 0, sizeof(glamor->glyphCaches));
+
+ for (i = 0; i < sizeof(formats) / sizeof(formats[0]); i++) {
+ glamor_glyph_cache_t *cache = &glamor->glyphCaches[i];
+ PixmapPtr pixmap;
+ PicturePtr picture;
+ XID component_alpha;
+ int depth = PIXMAN_FORMAT_DEPTH(formats[i]);
+ int error;
+ PictFormatPtr pPictFormat =
+ PictureMatchFormat(pScreen, depth, formats[i]);
+ if (!pPictFormat)
+ goto bail;
+
+ /* Now allocate the pixmap and picture */
+ pixmap = pScreen->CreatePixmap(pScreen,
+ CACHE_PICTURE_SIZE,
+ CACHE_PICTURE_SIZE + MASK_CACHE_MAX_SIZE, depth,
+ 0);
+ if (!pixmap)
+ goto bail;
+
+ component_alpha = NeedsComponent(pPictFormat->format);
+ picture = CreatePicture(0, &pixmap->drawable, pPictFormat,
+ CPComponentAlpha, &component_alpha,
+ serverClient, &error);
+
+ pScreen->DestroyPixmap(pixmap);
+ if (!picture)
+ goto bail;
+
+ ValidatePicture(picture);
+
+ cache->picture = picture;
+ cache->glyphs = calloc(sizeof(GlyphPtr), GLYPH_CACHE_SIZE);
+ if (!cache->glyphs)
+ goto bail;
+
+ cache->evict = rand() % GLYPH_CACHE_SIZE;
+ mask_cache[i] = calloc(1, sizeof(*mask_cache[i]));
+ mask_cache[i]->pixmap = pixmap;
+ clear_mask_cache(mask_cache[i]);
+ }
+ assert(i == GLAMOR_NUM_GLYPH_CACHE_FORMATS);
+
+ return TRUE;
+
+ bail:
+ glamor_unrealize_glyph_caches(pScreen);
+ return FALSE;
+}
+
+
+Bool
+glamor_glyphs_init(ScreenPtr pScreen)
+{
+ if (!dixRegisterPrivateKey(&glamor_glyph_key,
+ PRIVATE_GLYPH, sizeof(struct glamor_glyph)))
+ return FALSE;
+
+ /* Skip pixmap creation if we don't intend to use it. */
+
+ return glamor_realize_glyph_caches(pScreen);
+}
+
+/* The most efficient thing to way to upload the glyph to the screen
+ * is to use CopyArea; glamor pixmaps are always offscreen.
+ */
+static void
+glamor_glyph_cache_upload_glyph(ScreenPtr screen,
+ glamor_glyph_cache_t * cache,
+ GlyphPtr glyph, int x, int y)
+{
+ PicturePtr pGlyphPicture = GlyphPicture(glyph)[screen->myNum];
+ PixmapPtr pGlyphPixmap = (PixmapPtr) pGlyphPicture->pDrawable;
+ PixmapPtr pCachePixmap = (PixmapPtr) cache->picture->pDrawable;
+ PixmapPtr scratch;
+ BoxRec box;
+ GCPtr gc;
+
+ gc = GetScratchGC(pCachePixmap->drawable.depth, screen);
+ if (!gc)
+ return;
+
+ ValidateGC(&pCachePixmap->drawable, gc);
+
+ scratch = pGlyphPixmap;
+ if (pGlyphPixmap->drawable.depth != pCachePixmap->drawable.depth) {
+
+ scratch = glamor_create_pixmap(screen,
+ glyph->info.width,
+ glyph->info.height,
+ pCachePixmap->
+ drawable.depth, 0);
+ if (scratch) {
+ PicturePtr picture;
+ int error;
+
+ picture =
+ CreatePicture(0,
+ &scratch->drawable,
+ PictureMatchFormat
+ (screen,
+ pCachePixmap->
+ drawable.depth,
+ cache->picture->format),
+ 0, NULL, serverClient,
+ &error);
+ if (picture) {
+ ValidatePicture(picture);
+ glamor_composite(PictOpSrc,
+ pGlyphPicture,
+ NULL, picture,
+ 0, 0, 0, 0, 0,
+ 0,
+ glyph->info.width,
+ glyph->info.height);
+ FreePicture(picture, 0);
+ }
+ } else {
+ scratch = pGlyphPixmap;
+ }
+ }
+
+ box.x1 = x;
+ box.y1 = y;
+ box.x2 = x + glyph->info.width;
+ box.y2 = y + glyph->info.height;
+ glamor_copy_n_to_n_nf(&scratch->drawable,
+ &pCachePixmap->drawable, NULL,
+ &box, 1,
+ -x, -y,
+ FALSE, FALSE, 0, NULL);
+ if (scratch != pGlyphPixmap)
+ screen->DestroyPixmap(scratch);
+
+ FreeScratchGC(gc);
+}
+
+
+void
+glamor_glyph_unrealize(ScreenPtr screen, GlyphPtr glyph)
+{
+ struct glamor_glyph *priv;
+
+ /* Use Lookup in case we have not attached to this glyph. */
+ priv = glamor_glyph_get_private(glyph);
+
+ if (priv->cached)
+ priv->cache->glyphs[priv->pos] = NULL;
+}
+
+/* Cut and paste from render/glyph.c - probably should export it instead */
+static void
+glamor_glyph_extents(int nlist,
+ GlyphListPtr list, GlyphPtr * glyphs, BoxPtr extents)
+{
+ int x1, x2, y1, y2;
+ int x, y, n;
+
+ x1 = y1 = MAXSHORT;
+ x2 = y2 = MINSHORT;
+ x = y = 0;
+ while (nlist--) {
+ x += list->xOff;
+ y += list->yOff;
+ n = list->len;
+ list++;
+ while (n--) {
+ GlyphPtr glyph = *glyphs++;
+ int v;
+
+ v = x - glyph->info.x;
+ if (v < x1)
+ x1 = v;
+ v += glyph->info.width;
+ if (v > x2)
+ x2 = v;
+
+ v = y - glyph->info.y;
+ if (v < y1)
+ y1 = v;
+ v += glyph->info.height;
+ if (v > y2)
+ y2 = v;
+
+ x += glyph->info.xOff;
+ y += glyph->info.yOff;
+ }
+ }
+
+ extents->x1 = x1 < MINSHORT ? MINSHORT : x1;
+ extents->x2 = x2 > MAXSHORT ? MAXSHORT : x2;
+ extents->y1 = y1 < MINSHORT ? MINSHORT : y1;
+ extents->y2 = y2 > MAXSHORT ? MAXSHORT : y2;
+}
+
+static void
+glamor_glyph_priv_get_edge_map(GlyphPtr glyph, struct glamor_glyph *priv,
+ PicturePtr glyph_picture)
+{
+ PixmapPtr glyph_pixmap = (PixmapPtr) glyph_picture->pDrawable;
+ int j;
+ unsigned long long left_x1_map = 0, left_x2_map = 0;
+ unsigned long long right_x1_map = 0, right_x2_map = 0;
+ int bitsPerPixel;
+ int stride;
+ void *bits;
+ int width;
+ unsigned int left_x1_data = 0, left_x2_data = 0;
+ unsigned int right_x1_data = 0, right_x2_data = 0;
+
+ bitsPerPixel = glyph_pixmap->drawable.bitsPerPixel;
+ stride = glyph_pixmap->devKind;
+ bits = glyph_pixmap->devPrivate.ptr;
+ width = glyph->info.width;
+
+ if (glyph_pixmap->drawable.width < 2
+ || !(glyph_pixmap->drawable.depth == 8
+ || glyph_pixmap->drawable.depth == 1
+ || glyph_pixmap->drawable.depth == 32)) {
+ priv->has_edge_map = FALSE;
+ return;
+ }
+
+ left_x1_map = left_x2_map = 0;
+ right_x1_map = right_x2_map = 0;
+
+ for(j = 0; j < glyph_pixmap->drawable.height; j++)
+ {
+ if (bitsPerPixel == 8) {
+ unsigned char *data;
+ data = (unsigned char*)((unsigned char*)bits + stride * j);
+ left_x1_data = *data++;
+ left_x2_data = *data;
+ data = (unsigned char*)((unsigned char*)bits + stride * j + width - 2);
+ right_x1_data = *data++;
+ right_x2_data = *data;
+ } else if (bitsPerPixel == 32) {
+ left_x1_data = *((unsigned int*)bits + stride/4 * j);
+ left_x2_data = *((unsigned int*)bits + stride/4 * j + 1);
+ right_x1_data = *((unsigned int*)bits + stride/4 * j + width - 2);
+ right_x2_data = *((unsigned int*)bits + stride/4 * j + width - 1);
+ } else if (bitsPerPixel == 1) {
+ unsigned char temp;
+ temp = *((unsigned char*)glyph_pixmap->devPrivate.ptr
+ + glyph_pixmap->devKind * j) & 0x3;
+ left_x1_data = temp & 0x1;
+ left_x2_data = temp & 0x2;
+
+ temp = *((unsigned char*)glyph_pixmap->devPrivate.ptr
+ + glyph_pixmap->devKind * j
+ + (glyph_pixmap->drawable.width - 2)/8);
+ right_x1_data = temp
+ & (1 << ((glyph_pixmap->drawable.width - 2) % 8));
+ temp = *((unsigned char*)glyph_pixmap->devPrivate.ptr
+ + glyph_pixmap->devKind * j
+ + (glyph_pixmap->drawable.width - 1)/8);
+ right_x2_data = temp
+ & (1 << ((glyph_pixmap->drawable.width - 1) % 8));
+ }
+ left_x1_map |= (left_x1_data !=0) << j;
+ left_x2_map |= (left_x2_data !=0) << j;
+ right_x1_map |= (right_x1_data !=0) << j;
+ right_x2_map |= (right_x2_data !=0) << j;
+ }
+
+ priv->left_x1_map = left_x1_map;
+ priv->left_x2_map = left_x2_map;
+ priv->right_x1_map = right_x1_map;
+ priv->right_x2_map = right_x2_map;
+ priv->has_edge_map = TRUE;
+ return;
+}
+
+/**
+ * Returns TRUE if the glyphs in the lists intersect. Only checks based on
+ * bounding box, which appears to be good enough to catch most cases at least.
+ */
+
+#define INTERSECTED_TYPE_MASK 1
+#define NON_INTERSECTED 0
+#define INTERSECTED 1
+
+struct glamor_glyph_list {
+ int nlist;
+ GlyphListPtr list;
+ GlyphPtr *glyphs;
+ int type;
+};
+
+static Bool
+glyph_new_fixed_list(struct glamor_glyph_list *fixed_list,
+ GlyphPtr *cur_glyphs,
+ GlyphPtr **head_glyphs,
+ GlyphListPtr cur_list,
+ int cur_pos, int cur_x, int cur_y,
+ int x1, int y1, int x2, int y2,
+ GlyphListPtr *head_list,
+ int *head_pos,
+ int *head_x,
+ int *head_y,
+ int *fixed_cnt,
+ int type,
+ BoxPtr prev_extents
+ )
+{
+ int x_off = 0;
+ int y_off = 0;
+ int n_off = 0;
+ int list_cnt;
+ if (type == NON_INTERSECTED) {
+ if (x1 < prev_extents->x2 && x2 > prev_extents->x1
+ && y1 < prev_extents->y2 && y2 > prev_extents->y1)
+ return FALSE;
+ x_off = (*(cur_glyphs-1))->info.xOff;
+ y_off = (*(cur_glyphs-1))->info.yOff;
+ n_off = 1;
+ }
+
+ list_cnt = cur_list - *head_list + 1;
+ if (cur_pos <= n_off) {
+ DEBUGF("break at %d n_off %d\n", cur_pos, n_off);
+ list_cnt--;
+ if (cur_pos < n_off) {
+ /* we overlap with previous list's last glyph. */
+ x_off += cur_list->xOff;
+ y_off += cur_list->yOff;
+ cur_list--;
+ cur_pos = cur_list->len;
+ if (cur_pos <= n_off) {
+ list_cnt--;
+ }
+ }
+ }
+ DEBUGF("got %d lists\n", list_cnt);
+ if (list_cnt != 0) {
+ fixed_list->list = malloc(list_cnt * sizeof(*cur_list));
+ memcpy(fixed_list->list, *head_list, list_cnt * sizeof(*cur_list));
+ fixed_list->list[0].xOff = *head_x;
+ fixed_list->list[0].yOff = *head_y;
+ fixed_list->glyphs = *head_glyphs;
+ fixed_list->type = type & INTERSECTED_TYPE_MASK;
+ fixed_list->nlist = list_cnt;
+ if (cur_list != *head_list) {
+ fixed_list->list[0].len = (*head_list)->len - *head_pos;
+ if (cur_pos != n_off)
+ fixed_list->list[list_cnt - 1].len = cur_pos - n_off;
+ } else
+ fixed_list->list[0].len = cur_pos - *head_pos - n_off;
+ (*fixed_cnt)++;
+ }
+
+ if (type <= INTERSECTED) {
+ *head_list = cur_list;
+ *head_pos = cur_pos - n_off;
+ *head_x = cur_x - x_off;
+ *head_y = cur_y - y_off;
+ *head_glyphs = cur_glyphs - n_off;
+ }
+ return TRUE;
+}
+
+/*
+ * This function detects glyph lists's overlapping.
+ *
+ * If check_fake_overlap is set, then it will check the glyph's left
+ * and right small boxes's real overlapping pixels. And if there is
+ * no real pixel overlapping, then it will not be treated as overlapped
+ * case. And we also can configured it to ignore less than 2 pixels
+ * overlappig.
+ *
+ * This function analyzes all the lists and split the list to multiple
+ * lists which are pure overlapped glyph lists or pure non-overlapped
+ * list if the overlapping only ocurr on the two adjacent glyphs.
+ * Otherwise, it return -1.
+ *
+ **/
+
+static int
+glamor_glyphs_intersect(int nlist, GlyphListPtr list, GlyphPtr * glyphs,
+ PictFormatShort mask_format,
+ ScreenPtr screen, Bool check_fake_overlap,
+ struct glamor_glyph_list * fixed_list,
+ int fixed_size)
+{
+ int x1, x2, y1, y2;
+ int n;
+ int x, y;
+ BoxPtr extents;
+ BoxRec prev_extents;
+ Bool first = TRUE, first_list = TRUE;
+ Bool need_free_list_region = FALSE;
+ Bool need_free_fixed_list = FALSE;
+ struct glamor_glyph *priv = NULL;
+ Bool in_non_intersected_list = -1;
+ GlyphListPtr head_list;
+ int head_x, head_y, head_pos;
+ int fixed_cnt = 0;
+ GlyphPtr *head_glyphs;
+ GlyphListPtr cur_list = list;
+ RegionRec list_region;
+ RegionRec current_region;
+ BoxRec current_box;
+
+ if (nlist > 1) {
+ pixman_region_init(&list_region);
+ need_free_list_region = TRUE;
+ }
+
+ pixman_region_init(&current_region);
+
+ extents = pixman_region_extents(&current_region);
+
+ x = 0;
+ y = 0;
+ x1 = x2 = y1 = y2 = 0;
+ n = 0;
+ extents->x1 = 0;
+ extents->y1 = 0;
+ extents->x2 = 0;
+ extents->y2 = 0;
+
+ head_list = list;
+ DEBUGF("has %d lists.\n", nlist);
+ while (nlist--) {
+ BoxRec left_box, right_box = {0};
+ Bool has_left_edge_box = FALSE, has_right_edge_box = FALSE;
+ Bool left_to_right;
+ struct glamor_glyph *left_priv = NULL, *right_priv = NULL;
+
+ x += list->xOff;
+ y += list->yOff;
+ n = list->len;
+ left_to_right = TRUE;
+ cur_list = list++;
+
+ if (unlikely(!first_list)) {
+ pixman_region_init_with_extents(&current_region, extents);
+ pixman_region_union(&list_region, &list_region, &current_region);
+ first = TRUE;
+ } else {
+ head_list = cur_list;
+ head_pos = cur_list->len - n;
+ head_x = x;
+ head_y = y;
+ head_glyphs = glyphs;
+ }
+
+ DEBUGF("current list %p has %d glyphs\n", cur_list, n);
+ while (n--) {
+ GlyphPtr glyph = *glyphs++;
+
+ DEBUGF("the %dth glyph\n", cur_list->len - n - 1);
+ if (glyph->info.width == 0
+ || glyph->info.height == 0) {
+ x += glyph->info.xOff;
+ y += glyph->info.yOff;
+ continue;
+ }
+ if (mask_format
+ && mask_format != GlyphPicture(glyph)[screen->myNum]->format) {
+ need_free_fixed_list = TRUE;
+ goto done;
+ }
+
+ x1 = x - glyph->info.x;
+ if (x1 < MINSHORT)
+ x1 = MINSHORT;
+ y1 = y - glyph->info.y;
+ if (y1 < MINSHORT)
+ y1 = MINSHORT;
+ if (check_fake_overlap)
+ priv = glamor_glyph_get_private(glyph);
+
+ x2 = x1 + glyph->info.width;
+ y2 = y1 + glyph->info.height;
+
+ if (x2 > MAXSHORT)
+ x2 = MAXSHORT;
+ if (y2 > MAXSHORT)
+ y2 = MAXSHORT;
+
+ if (first) {
+ extents->x1 = x1;
+ extents->y1 = y1;
+ extents->x2 = x2;
+ extents->y2 = y2;
+
+ prev_extents = *extents;
+
+ first = FALSE;
+ if (check_fake_overlap && priv
+ && priv->has_edge_map && glyph->info.yOff == 0) {
+ left_box.x1 = x1;
+ left_box.x2 = x1 + 1;
+ left_box.y1 = y1;
+
+ right_box.x1 = x2 - 2;
+ right_box.x2 = x2 - 1;
+ right_box.y1 = y1;
+ left_priv = right_priv = priv;
+ has_left_edge_box = TRUE;
+ has_right_edge_box = TRUE;
+ }
+ } else {
+ if (unlikely(!first_list)) {
+ current_box.x1 = x1;
+ current_box.y1 = y1;
+ current_box.x2 = x2;
+ current_box.y2 = y2;
+ if (pixman_region_contains_rectangle(&list_region, &current_box) != PIXMAN_REGION_OUT) {
+ need_free_fixed_list = TRUE;
+ goto done;
+ }
+ }
+
+ if (x1 < extents->x2 && x2 > extents->x1
+ && y1 < extents->y2
+ && y2 > extents->y1) {
+
+ if (check_fake_overlap && (has_left_edge_box || has_right_edge_box)
+ && priv->has_edge_map && glyph->info.yOff == 0) {
+ int left_dx, right_dx;
+ unsigned long long intersected;
+
+ left_dx = has_left_edge_box ? 1 : 0;
+ right_dx = has_right_edge_box ? 1 : 0;
+ if (x1 + 1 < extents->x2 - right_dx && x2 - 1 > extents->x1 + left_dx)
+ goto real_intersected;
+
+ if (left_to_right && has_right_edge_box) {
+ if (x1 == right_box.x1) {
+ intersected = ((priv->left_x1_map & right_priv->right_x1_map)
+ | (priv->left_x2_map & right_priv->right_x2_map));
+ if (intersected)
+ goto real_intersected;
+ } else if (x1 == right_box.x2) {
+ intersected = (priv->left_x1_map & right_priv->right_x2_map);
+ if (intersected) {
+ #ifdef GLYPHS_EDEGE_OVERLAP_LOOSE_CHECK
+ /* tolerate with two pixels overlap. */
+ intersected &= ~(1<<__fls(intersected));
+ if ((intersected & (intersected - 1)))
+ #endif
+ goto real_intersected;
+ }
+ }
+ } else if (!left_to_right && has_left_edge_box) {
+ if (x2 - 1 == left_box.x1) {
+ intersected = (priv->right_x2_map & left_priv->left_x1_map);
+ if (intersected) {
+ #ifdef GLYPHS_EDEGE_OVERLAP_LOOSE_CHECK
+ /* tolerate with two pixels overlap. */
+ intersected &= ~(1<<__fls(intersected));
+ if ((intersected & (intersected - 1)))
+ #endif
+ goto real_intersected;
+ }
+ } else if (x2 - 1 == right_box.x2) {
+ if ((priv->right_x1_map & left_priv->left_x1_map)
+ || (priv->right_x2_map & left_priv->left_x2_map))
+ goto real_intersected;
+ }
+ } else {
+ if (x1 < extents->x2 && x1 + 2 > extents->x1)
+ goto real_intersected;
+ }
+ goto non_intersected;
+ } else {
+real_intersected:
+ DEBUGF("overlap with previous glyph.\n");
+ if (in_non_intersected_list == 1) {
+ if (fixed_cnt >= fixed_size) {
+ need_free_fixed_list = TRUE;
+ goto done;
+ }
+ if (!glyph_new_fixed_list(&fixed_list[fixed_cnt],
+ glyphs - 1,
+ &head_glyphs,
+ cur_list,
+ cur_list->len - (n + 1), x, y,
+ x1, y1, x2, y2,
+ &head_list,
+ &head_pos,
+ &head_x,
+ &head_y, &fixed_cnt,
+ NON_INTERSECTED,
+ &prev_extents
+ )){
+ need_free_fixed_list = TRUE;
+ goto done;
+ }
+ }
+
+ in_non_intersected_list = 0;
+
+ }
+ } else {
+non_intersected:
+ DEBUGF("doesn't overlap with previous glyph.\n");
+ if (in_non_intersected_list == 0) {
+ if (fixed_cnt >= fixed_size) {
+ need_free_fixed_list = TRUE;
+ goto done;
+ }
+ if (!glyph_new_fixed_list(&fixed_list[fixed_cnt],
+ glyphs - 1,
+ &head_glyphs,
+ cur_list,
+ cur_list->len - (n + 1), x, y,
+ x1, y1, x2, y2,
+ &head_list,
+ &head_pos,
+ &head_x,
+ &head_y, &fixed_cnt,
+ INTERSECTED,
+ &prev_extents
+ )) {
+ need_free_fixed_list = TRUE;
+ goto done;
+ }
+ }
+ in_non_intersected_list = 1;
+ }
+ prev_extents = *extents;
+ }
+
+ if (check_fake_overlap && priv
+ && priv->has_edge_map && glyph->info.yOff == 0) {
+ if (!has_left_edge_box || x1 < extents->x1) {
+ left_box.x1 = x1;
+ left_box.x2 = x1 + 1;
+ left_box.y1 = y1;
+ has_left_edge_box = TRUE;
+ left_priv = priv;
+ }
+
+ if (!has_right_edge_box || x2 > extents->x2) {
+ right_box.x1 = x2 - 2;
+ right_box.x2 = x2 - 1;
+ right_box.y1 = y1;
+ has_right_edge_box = TRUE;
+ right_priv = priv;
+ }
+ }
+
+ if (x1 < extents->x1)
+ extents->x1 = x1;
+ if (x2 > extents->x2)
+ extents->x2 = x2;
+
+ if (y1 < extents->y1)
+ extents->y1 = y1;
+ if (y2 > extents->y2)
+ extents->y2 = y2;
+
+ x += glyph->info.xOff;
+ y += glyph->info.yOff;
+ }
+ first_list = FALSE;
+ }
+
+ if (in_non_intersected_list == 0 && fixed_cnt == 0) {
+ fixed_cnt = -1;
+ goto done;
+ }
+
+ if ((in_non_intersected_list != -1
+ || head_pos != n) && (fixed_cnt > 0)) {
+ if (fixed_cnt >= fixed_size) {
+ need_free_fixed_list = TRUE;
+ goto done;
+ }
+ if (!glyph_new_fixed_list(&fixed_list[fixed_cnt],
+ glyphs - 1,
+ &head_glyphs,
+ cur_list,
+ cur_list->len - (n + 1), x, y,
+ x1, y1, x2, y2,
+ &head_list,
+ &head_pos,
+ &head_x,
+ &head_y, &fixed_cnt,
+ (!in_non_intersected_list) | 0x80,
+ &prev_extents
+ )) {
+ need_free_fixed_list = TRUE;
+ goto done;
+ }
+ }
+
+done:
+ if (need_free_list_region)
+ pixman_region_fini(&list_region);
+ pixman_region_fini(&current_region);
+
+ if (need_free_fixed_list && fixed_cnt >= 0) {
+ while(fixed_cnt--) {
+ free(fixed_list[fixed_cnt].list);
+ }
+ }
+
+ DEBUGF("Got %d fixed list \n", fixed_cnt);
+ return fixed_cnt;
+}
+
+static inline unsigned int
+glamor_glyph_size_to_count(int size)
+{
+ size /= GLYPH_MIN_SIZE;
+ return size * size;
+}
+
+static inline unsigned int
+glamor_glyph_count_to_mask(int count)
+{
+ return ~(count - 1);
+}
+
+static inline unsigned int
+glamor_glyph_size_to_mask(int size)
+{
+ return
+ glamor_glyph_count_to_mask(glamor_glyph_size_to_count(size));
+}
+
+static PicturePtr
+glamor_glyph_cache(glamor_screen_private *glamor, GlyphPtr glyph, int *out_x,
+ int *out_y)
+{
+ ScreenPtr screen = glamor->screen;
+ PicturePtr glyph_picture = GlyphPicture(glyph)[screen->myNum];
+ glamor_glyph_cache_t *cache =
+ &glamor->glyphCaches[PICT_FORMAT_RGB(glyph_picture->format) !=
+ 0];
+ struct glamor_glyph *priv = NULL, *evicted_priv = NULL;
+ int size, mask, pos, s;
+
+ if (glyph->info.width > GLYPH_MAX_SIZE
+ || glyph->info.height > GLYPH_MAX_SIZE)
+ return NULL;
+
+ for (size = GLYPH_MIN_SIZE; size <= GLYPH_MAX_SIZE; size *= 2)
+ if (glyph->info.width <= size
+ && glyph->info.height <= size)
+ break;
+
+ s = glamor_glyph_size_to_count(size);
+ mask = glamor_glyph_count_to_mask(s);
+ pos = (cache->count + s - 1) & mask;
+
+ priv = glamor_glyph_get_private(glyph);
+ if (pos < GLYPH_CACHE_SIZE) {
+ cache->count = pos + s;
+ } else {
+ for (s = size; s <= GLYPH_MAX_SIZE; s *= 2) {
+ int i =
+ cache->evict & glamor_glyph_size_to_mask(s);
+ GlyphPtr evicted = cache->glyphs[i];
+ if (evicted == NULL)
+ continue;
+
+ evicted_priv = glamor_glyph_get_private(evicted);
+ assert(evicted_priv->pos == i);
+ if (evicted_priv->size >= s) {
+ cache->glyphs[i] = NULL;
+ evicted_priv->cached = FALSE;
+ pos = cache->evict &
+ glamor_glyph_size_to_mask(size);
+ } else
+ evicted_priv = NULL;
+ break;
+ }
+ if (evicted_priv == NULL) {
+ int count = glamor_glyph_size_to_count(size);
+ mask = glamor_glyph_count_to_mask(count);
+ pos = cache->evict & mask;
+ for (s = 0; s < count; s++) {
+ GlyphPtr evicted = cache->glyphs[pos + s];
+ if (evicted != NULL) {
+
+ evicted_priv =
+ glamor_glyph_get_private
+ (evicted);
+
+ assert(evicted_priv->pos == pos + s);
+ evicted_priv->cached = FALSE;
+ cache->glyphs[pos + s] = NULL;
+ }
+ }
+
+ }
+ /* And pick a new eviction position */
+ cache->evict = rand() % GLYPH_CACHE_SIZE;
+ }
+
+
+ cache->glyphs[pos] = glyph;
+
+ priv->cache = cache;
+ priv->size = size;
+ priv->pos = pos;
+ s = pos / ((GLYPH_MAX_SIZE / GLYPH_MIN_SIZE) *
+ (GLYPH_MAX_SIZE / GLYPH_MIN_SIZE));
+ priv->x =
+ s % (CACHE_PICTURE_SIZE / GLYPH_MAX_SIZE) * GLYPH_MAX_SIZE;
+ priv->y =
+ (s / (CACHE_PICTURE_SIZE / GLYPH_MAX_SIZE)) * GLYPH_MAX_SIZE;
+ for (s = GLYPH_MIN_SIZE; s < GLYPH_MAX_SIZE; s *= 2) {
+ if (pos & 1)
+ priv->x += s;
+ if (pos & 2)
+ priv->y += s;
+ pos >>= 2;
+ }
+
+ glamor_glyph_cache_upload_glyph(screen, cache, glyph, priv->x,
+ priv->y);
+#ifndef GLYPHS_NO_EDEGEMAP_OVERLAP_CHECK
+ if (priv->has_edge_map == FALSE && glyph->info.width >= 2)
+ glamor_glyph_priv_get_edge_map(glyph, priv, glyph_picture);
+#endif
+ priv->cached = TRUE;
+
+ *out_x = priv->x;
+ *out_y = priv->y;
+ return cache->picture;
+}
+typedef void (*glyphs_flush_func)(void * arg);
+struct glyphs_flush_dst_arg {
+ CARD8 op;
+ PicturePtr src;
+ PicturePtr dst;
+ glamor_glyph_buffer_t * buffer;
+ int x_src,y_src;
+ int x_dst, y_dst;
+};
+
+static struct glyphs_flush_dst_arg dst_arg;
+static struct glyphs_flush_mask_arg mask_arg;
+static glamor_glyph_buffer_t dst_buffer;
+static glamor_glyph_buffer_t mask_buffer;
+unsigned long long mask_glyphs_cnt = 0;
+unsigned long long dst_glyphs_cnt = 0;
+#define GLYPHS_DST_MODE_VIA_MASK 0
+#define GLYPHS_DST_MODE_VIA_MASK_CACHE 1
+#define GLYPHS_DST_MODE_TO_DST 2
+#define GLYPHS_DST_MODE_MASK_TO_DST 3
+
+struct glyphs_flush_mask_arg {
+ PicturePtr mask;
+ glamor_glyph_buffer_t *buffer;
+ struct glamor_glyph_mask_cache *maskcache;
+ unsigned int used_bitmap;
+};
+
+static void
+glamor_glyphs_flush_mask(struct glyphs_flush_mask_arg *arg)
+{
+ if (arg->buffer->count>0) {
+#ifdef RENDER
+ glamor_composite_glyph_rects(PictOpAdd, arg->buffer->source,
+ NULL, arg->mask,
+ arg->buffer->count,
+ arg->buffer->rects);
+#endif
+ }
+ arg->buffer->count = 0;
+ arg->buffer->source = NULL;
+
+}
+
+static void
+glamor_glyphs_flush_dst(struct glyphs_flush_dst_arg * arg)
+{
+ if (!arg->buffer)
+ return;
+
+ if (mask_buffer.count > 0) {
+ glamor_glyphs_flush_mask(&mask_arg);
+ }
+ if (mask_arg.used_bitmap) {
+ put_mask_cache_bitmap(mask_arg.maskcache, mask_arg.used_bitmap);
+ mask_arg.used_bitmap = 0;
+ }
+
+ if (arg->buffer->count > 0) {
+ glamor_composite_glyph_rects(arg->op, arg->src,
+ arg->buffer->source, arg->dst,
+ arg->buffer->count,
+ &arg->buffer->rects[0]);
+ arg->buffer->count = 0;
+ arg->buffer->source = NULL;
+ }
+}
+
+
+static glamor_glyph_cache_result_t
+glamor_buffer_glyph(glamor_screen_private *glamor_priv,
+ glamor_glyph_buffer_t * buffer,
+ PictFormatShort format,
+ GlyphPtr glyph, struct glamor_glyph *priv,
+ int x_glyph, int y_glyph,
+ int dx, int dy, int w, int h,
+ int glyphs_dst_mode,
+ glyphs_flush_func glyphs_flush, void *flush_arg)
+{
+ ScreenPtr screen = glamor_priv->screen;
+ glamor_composite_rect_t *rect;
+ PicturePtr source;
+ int x, y;
+ glamor_glyph_cache_t *cache;
+
+ if (glyphs_dst_mode != GLYPHS_DST_MODE_MASK_TO_DST)
+ priv = glamor_glyph_get_private(glyph);
+
+ if (PICT_FORMAT_BPP(format) == 1)
+ format = PICT_a8;
+
+ cache =
+ &glamor_priv->glyphCaches[PICT_FORMAT_RGB(format) != 0];
+
+ if (buffer->source
+ && buffer->source != cache->picture
+ && glyphs_flush) {
+ (*glyphs_flush)(flush_arg);
+ glyphs_flush = NULL;
+ }
+
+ if (buffer->count == GLYPH_BUFFER_SIZE
+ && glyphs_flush) {
+ (*glyphs_flush)(flush_arg);
+ glyphs_flush = NULL;
+ }
+
+ if (priv && priv->cached) {
+ rect = &buffer->rects[buffer->count++];
+ rect->x_src = priv->x + dx;
+ rect->y_src = priv->y + dy;
+ if (buffer->source == NULL)
+ buffer->source = priv->cache->picture;
+ if (glyphs_dst_mode <= GLYPHS_DST_MODE_VIA_MASK_CACHE)
+ assert(priv->cache->glyphs[priv->pos] == glyph);
+ } else {
+ assert(glyphs_dst_mode != GLYPHS_DST_MODE_MASK_TO_DST);
+ if (glyphs_flush)
+ (*glyphs_flush)(flush_arg);
+ source = glamor_glyph_cache(glamor_priv, glyph, &x, &y);
+
+ if (source != NULL) {
+ rect = &buffer->rects[buffer->count++];
+ rect->x_src = x + dx;
+ rect->y_src = y + dy;
+ if (buffer->source == NULL)
+ buffer->source = source;
+ if (glyphs_dst_mode == GLYPHS_DST_MODE_VIA_MASK_CACHE) {
+ glamor_gl_dispatch *dispatch;
+ /* mode 1 means we are using global mask cache,
+ * thus we have to composite from the cache picture
+ * to the cache picture, we need a flush here to make
+ * sure latter we get the corret glyphs data.*/
+ dispatch = glamor_get_dispatch(glamor_priv);
+ dispatch->glFlush();
+ glamor_put_dispatch(glamor_priv);
+ }
+ } else {
+ /* Couldn't find the glyph in the cache, use the glyph picture directly */
+ source = GlyphPicture(glyph)[screen->myNum];
+ if (buffer->source
+ && buffer->source != source
+ && glyphs_flush)
+ (*glyphs_flush)(flush_arg);
+ buffer->source = source;
+
+ rect = &buffer->rects[buffer->count++];
+ rect->x_src = 0 + dx;
+ rect->y_src = 0 + dy;
+ }
+ priv = glamor_glyph_get_private(glyph);
+ }
+
+ rect->x_dst = x_glyph;
+ rect->y_dst = y_glyph;
+ if (glyphs_dst_mode != GLYPHS_DST_MODE_MASK_TO_DST) {
+ rect->x_dst -= glyph->info.x;
+ rect->y_dst -= glyph->info.y;
+ }
+ rect->width = w;
+ rect->height = h;
+ if (glyphs_dst_mode > GLYPHS_DST_MODE_VIA_MASK_CACHE) {
+ rect->x_mask = rect->x_src;
+ rect->y_mask = rect->y_src;
+ rect->x_src = dst_arg.x_src + rect->x_dst - dst_arg.x_dst;
+ rect->y_src = dst_arg.y_src + rect->y_dst - dst_arg.y_dst;
+ }
+
+ return GLAMOR_GLYPH_SUCCESS;
+}
+
+
+static void
+glamor_buffer_glyph_clip(glamor_screen_private *glamor_priv,
+ BoxPtr rects,
+ int nrect, PictFormatShort format,
+ GlyphPtr glyph, struct glamor_glyph *priv,
+ int glyph_x, int glyph_y,
+ int glyph_dx, int glyph_dy,
+ int width, int height,
+ int glyphs_mode,
+ glyphs_flush_func flush_func,
+ void *arg
+ )
+{
+ int i;
+ for (i = 0; i < nrect; i++) {
+ int dst_x, dst_y;
+ int dx, dy;
+ int x2, y2;
+
+ dst_x = glyph_x - glyph_dx;
+ dst_y = glyph_y - glyph_dy;
+ x2 = dst_x + width;
+ y2 = dst_y + height;
+ dx = dy = 0;
+ if (rects[i].y1 >= y2)
+ break;
+
+ if (dst_x < rects[i].x1)
+ dx = rects[i].x1 - dst_x, dst_x = rects[i].x1;
+ if (x2 > rects[i].x2)
+ x2 = rects[i].x2;
+ if (dst_y < rects[i].y1)
+ dy = rects[i].y1 - dst_y, dst_y = rects[i].y1;
+ if (y2 > rects[i].y2)
+ y2 = rects[i].y2;
+ if (dst_x < x2 && dst_y < y2) {
+
+ glamor_buffer_glyph(glamor_priv,
+ &dst_buffer,
+ format,
+ glyph, priv,
+ dst_x + glyph_dx,
+ dst_y + glyph_dy,
+ dx, dy,
+ x2 - dst_x, y2 - dst_y,
+ glyphs_mode,
+ flush_func,
+ arg);
+ }
+ }
+}
+
+
+static void
+glamor_glyphs_via_mask(CARD8 op,
+ PicturePtr src,
+ PicturePtr dst,
+ PictFormatPtr mask_format,
+ INT16 x_src,
+ INT16 y_src,
+ int nlist, GlyphListPtr list, GlyphPtr * glyphs,
+ Bool use_mask_cache)
+{
+ PixmapPtr mask_pixmap = 0;
+ PicturePtr mask;
+ ScreenPtr screen = dst->pDrawable->pScreen;
+ int width = 0, height = 0;
+ int x, y;
+ int x_dst = list->xOff, y_dst = list->yOff;
+ int n;
+ GlyphPtr glyph;
+ int error;
+ BoxRec extents = { 0, 0, 0, 0 };
+ XID component_alpha;
+ glamor_screen_private *glamor_priv;
+ int need_free_mask = FALSE;
+ glamor_glyph_buffer_t buffer;
+ struct glyphs_flush_mask_arg arg;
+ glamor_glyph_buffer_t *pmask_buffer;
+ struct glyphs_flush_mask_arg *pmask_arg;
+ struct glamor_glyph_mask_cache_entry *mce = NULL;
+ struct glamor_glyph_mask_cache *maskcache;
+ glamor_glyph_cache_t *cache;
+ int glyphs_dst_mode;
+
+ glamor_glyph_extents(nlist, list, glyphs, &extents);
+
+ if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1)
+ return;
+ glamor_priv = glamor_get_screen_private(screen);
+ width = extents.x2 - extents.x1;
+ height = extents.y2 - extents.y1;
+
+ if (mask_format->depth == 1) {
+ PictFormatPtr a8Format =
+ PictureMatchFormat(screen, 8, PICT_a8);
+
+ if (a8Format)
+ mask_format = a8Format;
+ }
+
+ cache = &glamor_priv->glyphCaches
+ [PICT_FORMAT_RGB(mask_format->format) != 0];
+ maskcache = mask_cache[PICT_FORMAT_RGB(mask_format->format) != 0];
+
+ x = -extents.x1;
+ y = -extents.y1;
+ if (!use_mask_cache
+ || width > (CACHE_PICTURE_SIZE/4)
+ || height > MASK_CACHE_MAX_SIZE) {
+new_mask_pixmap:
+ mask_pixmap = glamor_create_pixmap(screen, width, height,
+ mask_format->depth,
+ CREATE_PIXMAP_USAGE_SCRATCH);
+ if (!mask_pixmap) {
+ glamor_destroy_pixmap(mask_pixmap);
+ return;
+ }
+ glamor_solid(mask_pixmap, 0, 0, width, height, GXcopy, 0xFFFFFFFF, 0);
+ component_alpha = NeedsComponent(mask_format->format);
+ mask = CreatePicture(0, &mask_pixmap->drawable,
+ mask_format, CPComponentAlpha,
+ &component_alpha, serverClient, &error);
+ if (!mask)
+ return;
+ need_free_mask = TRUE;
+ pmask_arg = &arg;
+ pmask_buffer = &buffer;
+ pmask_buffer->count = 0;
+ pmask_buffer->source = NULL;
+ pmask_arg->used_bitmap = 0;
+ glyphs_dst_mode = GLYPHS_DST_MODE_VIA_MASK;
+ } else {
+ int retry_cnt = 0;
+retry:
+ mce = get_mask_cache(maskcache,
+ (width + MASK_CACHE_MAX_SIZE - 1) / MASK_CACHE_MAX_SIZE);
+
+ if (mce == NULL) {
+ glamor_glyphs_flush_dst(&dst_arg);
+ retry_cnt++;
+ if (retry_cnt > 2) {
+ assert(0);
+ goto new_mask_pixmap;
+ }
+ goto retry;
+ }
+
+ mask = cache->picture;
+ x += mce->x;
+ y += mce->y;
+ mce->width = (width + MASK_CACHE_MAX_SIZE - 1) / MASK_CACHE_MAX_SIZE;
+ mce->height = 1;
+ if (mask_arg.mask && mask_arg.mask != mask
+ && mask_buffer.count != 0)
+ glamor_glyphs_flush_dst(&dst_arg);
+ pmask_arg = &mask_arg;
+ pmask_buffer = &mask_buffer;
+ pmask_arg->maskcache = maskcache;
+ glyphs_dst_mode = GLYPHS_DST_MODE_VIA_MASK_CACHE;
+ }
+ pmask_arg->mask = mask;
+ pmask_arg->buffer = pmask_buffer;
+ while (nlist--) {
+ x += list->xOff;
+ y += list->yOff;
+ n = list->len;
+ mask_glyphs_cnt += n;
+ while (n--) {
+ glyph = *glyphs++;
+ if (glyph->info.width > 0
+ && glyph->info.height > 0) {
+ glyphs_flush_func flush_func;
+ void *temp_arg;
+ if (need_free_mask) {
+ if (pmask_buffer->count)
+ flush_func = (glyphs_flush_func)glamor_glyphs_flush_mask;
+ else
+ flush_func = NULL;
+ temp_arg = pmask_arg;
+ } else {
+ /* If we are using global mask cache, then we need to
+ * flush dst instead of mask. As some dst depends on the
+ * previous mask result. Just flush mask can't get all previous's
+ * overlapped glyphs.*/
+ if (dst_buffer.count || mask_buffer.count)
+ flush_func = (glyphs_flush_func)glamor_glyphs_flush_dst;
+ else
+ flush_func = NULL;
+ temp_arg = &dst_arg;
+ }
+ glamor_buffer_glyph(glamor_priv, pmask_buffer,
+ mask_format->format,
+ glyph, NULL, x, y,
+ 0, 0,
+ glyph->info.width, glyph->info.height,
+ glyphs_dst_mode,
+ flush_func,
+ (void*)temp_arg);
+ }
+ x += glyph->info.xOff;
+ y += glyph->info.yOff;
+ }
+ list++;
+ }
+
+ x = extents.x1;
+ y = extents.y1;
+ if (need_free_mask) {
+ glamor_glyphs_flush_mask(pmask_arg);
+ CompositePicture(op,
+ src,
+ mask,
+ dst,
+ x_src + x - x_dst,
+ y_src + y - y_dst, 0, 0, x, y, width, height);
+ FreePicture(mask, 0);
+ glamor_destroy_pixmap(mask_pixmap);
+ } else {
+ struct glamor_glyph priv;
+ glyphs_flush_func flush_func;
+ BoxPtr rects;
+ int nrect;
+
+ priv.cache = cache;
+ priv.x = mce->x;
+ priv.y = mce->y;
+ priv.cached = TRUE;
+ rects = REGION_RECTS(dst->pCompositeClip);
+ nrect = REGION_NUM_RECTS(dst->pCompositeClip);
+
+ pmask_arg->used_bitmap |= ((1 << mce->width) - 1) << mce->idx;
+ dst_arg.op = op;
+ dst_arg.src = src;
+ dst_arg.dst = dst;
+ dst_arg.buffer = &dst_buffer;
+ dst_arg.x_src = x_src;
+ dst_arg.y_src = y_src;
+ dst_arg.x_dst = x_dst;
+ dst_arg.y_dst = y_dst;
+
+ if (dst_buffer.source == NULL) {
+ dst_buffer.source = cache->picture;
+ } else if (dst_buffer.source != cache->picture) {
+ glamor_glyphs_flush_dst(&dst_arg);
+ dst_buffer.source = cache->picture;
+ }
+
+ x += dst->pDrawable->x;
+ y += dst->pDrawable->y;
+
+ if (dst_buffer.count || mask_buffer.count)
+ flush_func = (glyphs_flush_func)glamor_glyphs_flush_dst;
+ else
+ flush_func = NULL;
+
+ glamor_buffer_glyph_clip(glamor_priv,
+ rects, nrect,
+ mask_format->format,
+ NULL, &priv,
+ x, y,
+ 0, 0,
+ width, height,
+ GLYPHS_DST_MODE_MASK_TO_DST,
+ flush_func,
+ (void *)&dst_arg
+ );
+ }
+}
+
+static void
+glamor_glyphs_to_dst(CARD8 op,
+ PicturePtr src,
+ PicturePtr dst,
+ INT16 x_src,
+ INT16 y_src,
+ int nlist, GlyphListPtr list,
+ GlyphPtr * glyphs)
+{
+ ScreenPtr screen = dst->pDrawable->pScreen;
+ int x = 0, y = 0;
+ int x_dst = list->xOff, y_dst = list->yOff;
+ int n;
+ GlyphPtr glyph;
+ BoxPtr rects;
+ int nrect;
+ glamor_screen_private *glamor_priv;
+
+ rects = REGION_RECTS(dst->pCompositeClip);
+ nrect = REGION_NUM_RECTS(dst->pCompositeClip);
+
+ glamor_priv = glamor_get_screen_private(screen);
+
+ dst_arg.op = op;
+ dst_arg.src = src;
+ dst_arg.dst = dst;
+ dst_arg.buffer = &dst_buffer;
+ dst_arg.x_src = x_src;
+ dst_arg.y_src = y_src;
+ dst_arg.x_dst = x_dst;
+ dst_arg.y_dst = y_dst;
+
+ x = dst->pDrawable->x;
+ y = dst->pDrawable->y;
+
+ while (nlist--) {
+ x += list->xOff;
+ y += list->yOff;
+ n = list->len;
+ dst_glyphs_cnt += n;
+ while (n--) {
+ glyph = *glyphs++;
+
+ if (glyph->info.width > 0
+ && glyph->info.height > 0) {
+ glyphs_flush_func flush_func;
+
+ if (dst_buffer.count || mask_buffer.count)
+ flush_func = (glyphs_flush_func)glamor_glyphs_flush_dst;
+ else
+ flush_func = NULL;
+ glamor_buffer_glyph_clip(glamor_priv,
+ rects, nrect,
+ (GlyphPicture(glyph)[screen->myNum])->format,
+ glyph, NULL,
+ x, y,
+ glyph->info.x, glyph->info.y,
+ glyph->info.width, glyph->info.height,
+ GLYPHS_DST_MODE_TO_DST,
+ flush_func,
+ (void *)&dst_arg
+ );
+ }
+
+ x += glyph->info.xOff;
+ y += glyph->info.yOff;
+ }
+ list++;
+ }
+}
+#define MAX_FIXED_SIZE
+static void
+glamor_glyphs_reset_buffer(glamor_glyph_buffer_t *buffer)
+{
+ buffer->count = 0;
+ buffer->source = NULL;
+}
+
+static Bool
+_glamor_glyphs(CARD8 op,
+ PicturePtr src,
+ PicturePtr dst,
+ PictFormatPtr mask_format,
+ INT16 x_src,
+ INT16 y_src, int nlist, GlyphListPtr list,
+ GlyphPtr * glyphs, Bool fallback)
+{
+ PictFormatShort format;
+ int fixed_size, fixed_cnt = 0;
+ struct glamor_glyph_list *fixed_list = NULL;
+ Bool need_free_list = FALSE;
+#ifndef GLYPHS_NO_EDEGEMAP_OVERLAP_CHECK
+ Bool check_fake_overlap = TRUE;
+ if (!(op == PictOpOver
+ || op == PictOpAdd
+ || op == PictOpXor)) {
+ /* C = (0,0,0,0) D = glyphs , SRC = A, DEST = B (faked overlapped glyphs, overlapped with (0,0,0,0)).
+ * For those op, (A IN (C ADD D)) OP B != (A IN D) OP ((A IN C) OP B)
+ * or (A IN (D ADD C)) OP B != (A IN C) OP ((A IN D) OP B)
+ * We need to split the faked regions to three or two, and composite the disoverlapped small
+ * boxes one by one. For other Ops, it's safe to composite the whole box. */
+ check_fake_overlap = FALSE;
+ }
+#else
+ Bool check_fake_overlap = FALSE;
+#endif
+ if (mask_format)
+ format = mask_format->depth << 24 | mask_format->format;
+ else
+ format = 0;
+
+ fixed_size = 32;
+ glamor_glyphs_reset_buffer(&dst_buffer);
+
+ if (!mask_format || (((nlist == 1 && list->len == 1) || op == PictOpAdd)
+ && (dst->format == ((mask_format->depth << 24) | mask_format->format)))) {
+ glamor_glyphs_to_dst(op, src, dst, x_src, y_src, nlist,
+ list, glyphs);
+ goto last_flush;
+ }
+
+ glamor_glyphs_reset_buffer(&mask_buffer);
+
+ /* We have mask_format. Need to check the real overlap or not.*/
+ format = mask_format->depth << 24 | mask_format->format;
+
+ fixed_list = calloc(fixed_size, sizeof(*fixed_list));
+ if (unlikely(fixed_list == NULL))
+ fixed_size = 0;
+ fixed_cnt = glamor_glyphs_intersect(nlist, list, glyphs,
+ format, dst->pDrawable->pScreen,
+ check_fake_overlap,
+ fixed_list, fixed_size);
+ if (fixed_cnt == 0)
+ mask_format = NULL;
+ need_free_list = TRUE;
+
+ if (fixed_cnt <= 0) {
+ if (mask_format == NULL) {
+ glamor_glyphs_to_dst(op, src, dst, x_src, y_src, nlist,
+ list, glyphs);
+ goto last_flush;
+ } else {
+ glamor_glyphs_via_mask(op, src, dst, mask_format,
+ x_src, y_src, nlist, list, glyphs,
+ FALSE);
+ goto free_fixed_list;
+ }
+ } else {
+
+ /* We have splitted the original list to serval list, some are overlapped
+ * and some are non-overlapped. For the non-overlapped, we render it to
+ * dst directly. For the overlapped, we render it to mask picture firstly,
+ * then render the mask to dst. If we can use mask cache which is in the
+ * glyphs cache's last row, we can accumulate the rendering of mask to dst
+ * with the other dst_buffer's rendering operations thus can reduce the call
+ * of glDrawElements.
+ *
+ * */
+ struct glamor_glyph_list *saved_list;
+
+ saved_list = fixed_list;
+ mask_arg.used_bitmap = 0;
+ while(fixed_cnt--) {
+ if (fixed_list->type == NON_INTERSECTED) {
+ glamor_glyphs_to_dst(op, src, dst,
+ x_src, y_src,
+ fixed_list->nlist,
+ fixed_list->list,
+ fixed_list->glyphs);
+ }
+ else
+ glamor_glyphs_via_mask(op, src, dst,
+ mask_format, x_src, y_src,
+ fixed_list->nlist,
+ fixed_list->list,
+ fixed_list->glyphs, TRUE);
+
+ free(fixed_list->list);
+ fixed_list++;
+ }
+ free(saved_list);
+ need_free_list = FALSE;
+ }
+
+last_flush:
+ if (dst_buffer.count || mask_buffer.count)
+ glamor_glyphs_flush_dst(&dst_arg);
+free_fixed_list:
+ if(need_free_list) {
+ assert(fixed_cnt <= 0);
+ free(fixed_list);
+ }
+ return TRUE;
+}
+
+void
+glamor_glyphs(CARD8 op,
+ PicturePtr src,
+ PicturePtr dst,
+ PictFormatPtr mask_format,
+ INT16 x_src,
+ INT16 y_src, int nlist, GlyphListPtr list, GlyphPtr * glyphs)
+{
+ _glamor_glyphs(op, src, dst, mask_format, x_src,
+ y_src, nlist, list, glyphs, TRUE);
+}
+
+Bool
+glamor_glyphs_nf(CARD8 op,
+ PicturePtr src,
+ PicturePtr dst,
+ PictFormatPtr mask_format,
+ INT16 x_src,
+ INT16 y_src, int nlist,
+ GlyphListPtr list, GlyphPtr * glyphs)
+{
+ return _glamor_glyphs(op, src, dst, mask_format, x_src,
+ y_src, nlist, list, glyphs, FALSE);
+}
+
diff --git a/xorg-server/glamor/glamor_gradient.c b/xorg-server/glamor/glamor_gradient.c
new file mode 100644
index 000000000..4abc82d74
--- /dev/null
+++ b/xorg-server/glamor/glamor_gradient.c
@@ -0,0 +1,1584 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ *
+ * 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.
+ *
+ * Authors:
+ * Junyan He <junyan.he@linux.intel.com>
+ *
+ */
+
+/** @file glamor_gradient.c
+ *
+ * Gradient acceleration implementation
+ */
+
+#include "glamor_priv.h"
+
+#ifdef RENDER
+
+#define LINEAR_SMALL_STOPS (6 + 2)
+#define LINEAR_LARGE_STOPS (16 + 2)
+
+#define RADIAL_SMALL_STOPS (6 + 2)
+#define RADIAL_LARGE_STOPS (16 + 2)
+
+#ifdef GLAMOR_GRADIENT_SHADER
+
+static GLint
+_glamor_create_getcolor_fs_program(ScreenPtr screen, int stops_count, int use_array)
+{
+ glamor_screen_private *glamor_priv;
+ glamor_gl_dispatch *dispatch;
+
+ char *gradient_fs = NULL;
+ GLint fs_getcolor_prog;
+
+ #define gradient_fs_getcolor\
+ GLAMOR_DEFAULT_PRECISION\
+ "uniform int n_stop;\n"\
+ "uniform float stops[%d];\n"\
+ "uniform vec4 stop_colors[%d];\n"\
+ "vec4 get_color(float stop_len)\n"\
+ "{\n"\
+ " int i = 0;\n"\
+ " float new_alpha; \n"\
+ " vec4 gradient_color;\n"\
+ " float percentage; \n"\
+ " for(i = 0; i < n_stop - 1; i++) {\n"\
+ " if(stop_len < stops[i])\n"\
+ " break; \n"\
+ " }\n"\
+ " \n"\
+ " if(stops[i] - stops[i-1] > 2.0)\n"\
+ " percentage = 0.0;\n" /*For comply with pixman, walker->stepper overflow.*/\
+ " else if(stops[i] - stops[i-1] < 0.000001)\n"\
+ " percentage = 0.0;\n"\
+ " else \n"\
+ " percentage = (stop_len - stops[i-1])/(stops[i] - stops[i-1]);\n"\
+ " new_alpha = percentage * stop_colors[i].a + \n"\
+ " (1.0-percentage) * stop_colors[i-1].a; \n"\
+ " gradient_color = vec4((percentage * stop_colors[i].rgb \n"\
+ " + (1.0-percentage) * stop_colors[i-1].rgb)*new_alpha, \n"\
+ " new_alpha);\n"\
+ " \n"\
+ " return gradient_color;\n"\
+ "}\n"
+
+ /* Because the array access for shader is very slow, the performance is very low
+ if use array. So use global uniform to replace for it if the number of n_stops is small.*/
+ const char *gradient_fs_getcolor_no_array =
+ GLAMOR_DEFAULT_PRECISION
+ "uniform int n_stop;\n"
+ "uniform float stop0;\n"
+ "uniform float stop1;\n"
+ "uniform float stop2;\n"
+ "uniform float stop3;\n"
+ "uniform float stop4;\n"
+ "uniform float stop5;\n"
+ "uniform float stop6;\n"
+ "uniform float stop7;\n"
+ "uniform vec4 stop_color0;\n"
+ "uniform vec4 stop_color1;\n"
+ "uniform vec4 stop_color2;\n"
+ "uniform vec4 stop_color3;\n"
+ "uniform vec4 stop_color4;\n"
+ "uniform vec4 stop_color5;\n"
+ "uniform vec4 stop_color6;\n"
+ "uniform vec4 stop_color7;\n"
+ "\n"
+ "vec4 get_color(float stop_len)\n"
+ "{\n"
+ " float stop_after;\n"
+ " float stop_before;\n"
+ " vec4 stop_color_before;\n"
+ " vec4 stop_color_after;\n"
+ " float new_alpha; \n"
+ " vec4 gradient_color;\n"
+ " float percentage; \n"
+ " \n"
+ " if((stop_len < stop0) && (n_stop >= 1)) {\n"
+ " stop_color_before = stop_color0;\n"
+ " stop_color_after = stop_color0;\n"
+ " stop_after = stop0;\n"
+ " stop_before = stop0;\n"
+ " } else if((stop_len < stop1) && (n_stop >= 2)) {\n"
+ " stop_color_before = stop_color0;\n"
+ " stop_color_after = stop_color1;\n"
+ " stop_after = stop1;\n"
+ " stop_before = stop0;\n"
+ " } else if((stop_len < stop2) && (n_stop >= 3)) {\n"
+ " stop_color_before = stop_color1;\n"
+ " stop_color_after = stop_color2;\n"
+ " stop_after = stop2;\n"
+ " stop_before = stop1;\n"
+ " } else if((stop_len < stop3) && (n_stop >= 4)){\n"
+ " stop_color_before = stop_color2;\n"
+ " stop_color_after = stop_color3;\n"
+ " stop_after = stop3;\n"
+ " stop_before = stop2;\n"
+ " } else if((stop_len < stop4) && (n_stop >= 5)){\n"
+ " stop_color_before = stop_color3;\n"
+ " stop_color_after = stop_color4;\n"
+ " stop_after = stop4;\n"
+ " stop_before = stop3;\n"
+ " } else if((stop_len < stop5) && (n_stop >= 6)){\n"
+ " stop_color_before = stop_color4;\n"
+ " stop_color_after = stop_color5;\n"
+ " stop_after = stop5;\n"
+ " stop_before = stop4;\n"
+ " } else if((stop_len < stop6) && (n_stop >= 7)){\n"
+ " stop_color_before = stop_color5;\n"
+ " stop_color_after = stop_color6;\n"
+ " stop_after = stop6;\n"
+ " stop_before = stop5;\n"
+ " } else if((stop_len < stop7) && (n_stop >= 8)){\n"
+ " stop_color_before = stop_color6;\n"
+ " stop_color_after = stop_color7;\n"
+ " stop_after = stop7;\n"
+ " stop_before = stop6;\n"
+ " } else {\n"
+ " stop_color_before = stop_color7;\n"
+ " stop_color_after = stop_color7;\n"
+ " stop_after = stop7;\n"
+ " stop_before = stop7;\n"
+ " }\n"
+ " if(stop_after - stop_before > 2.0)\n"
+ " percentage = 0.0;\n"//For comply with pixman, walker->stepper overflow.
+ " else if(stop_after - stop_before < 0.000001)\n"
+ " percentage = 0.0;\n"
+ " else \n"
+ " percentage = (stop_len - stop_before)/(stop_after - stop_before);\n"
+ " new_alpha = percentage * stop_color_after.a + \n"
+ " (1.0-percentage) * stop_color_before.a; \n"
+ " gradient_color = vec4((percentage * stop_color_after.rgb \n"
+ " + (1.0-percentage) * stop_color_before.rgb)*new_alpha, \n"
+ " new_alpha);\n"
+ " \n"
+ " return gradient_color;\n"
+ "}\n";
+
+ glamor_priv = glamor_get_screen_private(screen);
+ dispatch = glamor_get_dispatch(glamor_priv);
+
+ if(use_array) {
+ XNFasprintf(&gradient_fs,
+ gradient_fs_getcolor, stops_count, stops_count);
+ fs_getcolor_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
+ gradient_fs);
+ free(gradient_fs);
+ } else {
+ fs_getcolor_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
+ gradient_fs_getcolor_no_array);
+ }
+
+ return fs_getcolor_prog;
+}
+
+static void
+_glamor_create_radial_gradient_program(ScreenPtr screen, int stops_count, int dyn_gen)
+{
+ glamor_screen_private *glamor_priv;
+ glamor_gl_dispatch *dispatch;
+ int index;
+
+ GLint gradient_prog = 0;
+ char *gradient_fs = NULL;
+ GLint fs_main_prog, fs_getcolor_prog, vs_prog;
+
+ const char *gradient_vs =
+ GLAMOR_DEFAULT_PRECISION
+ "attribute vec4 v_position;\n"
+ "attribute vec4 v_texcoord;\n"
+ "varying vec2 source_texture;\n"
+ "\n"
+ "void main()\n"
+ "{\n"
+ " gl_Position = v_position;\n"
+ " source_texture = v_texcoord.xy;\n"
+ "}\n";
+
+ /*
+ * Refer to pixman radial gradient.
+ *
+ * The problem is given the two circles of c1 and c2 with the radius of r1 and
+ * r1, we need to caculate the t, which is used to do interpolate with stops,
+ * using the fomula:
+ * length((1-t)*c1 + t*c2 - p) = (1-t)*r1 + t*r2
+ * expand the fomula with xy coond, get the following:
+ * sqrt(sqr((1-t)*c1.x + t*c2.x - p.x) + sqr((1-t)*c1.y + t*c2.y - p.y))
+ * = (1-t)r1 + t*r2
+ * <====> At*t- 2Bt + C = 0
+ * where A = sqr(c2.x - c1.x) + sqr(c2.y - c1.y) - sqr(r2 -r1)
+ * B = (p.x - c1.x)*(c2.x - c1.x) + (p.y - c1.y)*(c2.y - c1.y) + r1*(r2 -r1)
+ * C = sqr(p.x - c1.x) + sqr(p.y - c1.y) - r1*r1
+ *
+ * solve the fomula and we get the result of
+ * t = (B + sqrt(B*B - A*C)) / A or
+ * t = (B - sqrt(B*B - A*C)) / A (quadratic equation have two solutions)
+ *
+ * The solution we are going to prefer is the bigger one, unless the
+ * radius associated to it is negative (or it falls outside the valid t range)
+ */
+
+ #define gradient_radial_fs_template\
+ GLAMOR_DEFAULT_PRECISION\
+ "uniform mat3 transform_mat;\n"\
+ "uniform int repeat_type;\n"\
+ "uniform float A_value;\n"\
+ "uniform vec2 c1;\n"\
+ "uniform float r1;\n"\
+ "uniform vec2 c2;\n"\
+ "uniform float r2;\n"\
+ "varying vec2 source_texture;\n"\
+ "\n"\
+ "vec4 get_color(float stop_len);\n"\
+ "\n"\
+ "int t_invalid;\n"\
+ "\n"\
+ "float get_stop_len()\n"\
+ "{\n"\
+ " float t = 0.0;\n"\
+ " float sqrt_value;\n"\
+ " int revserse = 0;\n"\
+ " t_invalid = 0;\n"\
+ " \n"\
+ " vec3 tmp = vec3(source_texture.x, source_texture.y, 1.0);\n"\
+ " vec3 source_texture_trans = transform_mat * tmp;\n"\
+ " source_texture_trans.xy = source_texture_trans.xy/source_texture_trans.z;\n"\
+ " float B_value = (source_texture_trans.x - c1.x) * (c2.x - c1.x)\n"\
+ " + (source_texture_trans.y - c1.y) * (c2.y - c1.y)\n"\
+ " + r1 * (r2 - r1);\n"\
+ " float C_value = (source_texture_trans.x - c1.x) * (source_texture_trans.x - c1.x)\n"\
+ " + (source_texture_trans.y - c1.y) * (source_texture_trans.y - c1.y)\n"\
+ " - r1*r1;\n"\
+ " if(abs(A_value) < 0.00001) {\n"\
+ " if(B_value == 0.0) {\n"\
+ " t_invalid = 1;\n"\
+ " return t;\n"\
+ " }\n"\
+ " t = 0.5 * C_value / B_value;"\
+ " } else {\n"\
+ " sqrt_value = B_value * B_value - A_value * C_value;\n"\
+ " if(sqrt_value < 0.0) {\n"\
+ " t_invalid = 1;\n"\
+ " return t;\n"\
+ " }\n"\
+ " sqrt_value = sqrt(sqrt_value);\n"\
+ " t = (B_value + sqrt_value) / A_value;\n"\
+ " }\n"\
+ " if(repeat_type == %d) {\n" /* RepeatNone case. */\
+ " if((t <= 0.0) || (t > 1.0))\n"\
+ /* try another if first one invalid*/\
+ " t = (B_value - sqrt_value) / A_value;\n"\
+ " \n"\
+ " if((t <= 0.0) || (t > 1.0)) {\n" /*still invalid, return.*/\
+ " t_invalid = 1;\n"\
+ " return t;\n"\
+ " }\n"\
+ " } else {\n"\
+ " if(t * (r2 - r1) <= -1.0 * r1)\n"\
+ /* try another if first one invalid*/\
+ " t = (B_value - sqrt_value) / A_value;\n"\
+ " \n"\
+ " if(t * (r2 -r1) <= -1.0 * r1) {\n" /*still invalid, return.*/\
+ " t_invalid = 1;\n"\
+ " return t;\n"\
+ " }\n"\
+ " }\n"\
+ " \n"\
+ " if(repeat_type == %d){\n" /* repeat normal*/\
+ " while(t > 1.0) \n"\
+ " t = t - 1.0; \n"\
+ " while(t < 0.0) \n"\
+ " t = t + 1.0; \n"\
+ " }\n"\
+ " \n"\
+ " if(repeat_type == %d) {\n" /* repeat reflect*/\
+ " while(t > 1.0) {\n"\
+ " t = t - 1.0; \n"\
+ " if(revserse == 0)\n"\
+ " revserse = 1;\n"\
+ " else\n"\
+ " revserse = 0;\n"\
+ " }\n"\
+ " while(t < 0.0) {\n"\
+ " t = t + 1.0; \n"\
+ " if(revserse == 0)\n"\
+ " revserse = 1;\n"\
+ " else\n"\
+ " revserse = 0;\n"\
+ " }\n"\
+ " if(revserse == 1) {\n"\
+ " t = 1.0 - t; \n"\
+ " }\n"\
+ " }\n"\
+ " \n"\
+ " return t;\n"\
+ "}\n"\
+ "\n"\
+ "void main()\n"\
+ "{\n"\
+ " float stop_len = get_stop_len();\n"\
+ " if(t_invalid == 1) {\n"\
+ " gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);\n"\
+ " } else {\n"\
+ " gl_FragColor = get_color(stop_len);\n"\
+ " }\n"\
+ "}\n"
+
+ glamor_priv = glamor_get_screen_private(screen);
+
+ if ((glamor_priv->radial_max_nstops >= stops_count) && (dyn_gen)) {
+ /* Very Good, not to generate again. */
+ return;
+ }
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+
+ if (dyn_gen && glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][2]) {
+ dispatch->glDeleteShader(
+ glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_VS_PROG][2]);
+ glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_VS_PROG][2] = 0;
+
+ dispatch->glDeleteShader(
+ glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][2]);
+ glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][2] = 0;
+
+ dispatch->glDeleteShader(
+ glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][2]);
+ glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][2] = 0;
+
+ dispatch->glDeleteProgram(glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][2]);
+ glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][2] = 0;
+ }
+
+ gradient_prog = dispatch->glCreateProgram();
+
+ vs_prog = glamor_compile_glsl_prog(dispatch,
+ GL_VERTEX_SHADER, gradient_vs);
+
+ XNFasprintf(&gradient_fs,
+ gradient_radial_fs_template,
+ PIXMAN_REPEAT_NONE, PIXMAN_REPEAT_NORMAL, PIXMAN_REPEAT_REFLECT);
+
+ fs_main_prog = glamor_compile_glsl_prog(dispatch,
+ GL_FRAGMENT_SHADER, gradient_fs);
+
+ free(gradient_fs);
+
+ fs_getcolor_prog =
+ _glamor_create_getcolor_fs_program(screen, stops_count, (stops_count > 0));
+
+ dispatch->glAttachShader(gradient_prog, vs_prog);
+ dispatch->glAttachShader(gradient_prog, fs_getcolor_prog);
+ dispatch->glAttachShader(gradient_prog, fs_main_prog);
+
+ dispatch->glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_POS, "v_positionsition");
+ dispatch->glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_SOURCE, "v_texcoord");
+
+ glamor_link_glsl_prog(dispatch, gradient_prog);
+
+ dispatch->glUseProgram(0);
+
+ if (dyn_gen) {
+ index = 2;
+ glamor_priv->radial_max_nstops = stops_count;
+ } else if (stops_count) {
+ index = 1;
+ } else {
+ index = 0;
+ }
+
+ glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][index] = gradient_prog;
+ glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_VS_PROG][index] = vs_prog;
+ glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][index] = fs_main_prog;
+ glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][index] = fs_getcolor_prog;
+
+ glamor_put_dispatch(glamor_priv);
+}
+
+static void
+_glamor_create_linear_gradient_program(ScreenPtr screen, int stops_count, int dyn_gen)
+{
+ glamor_screen_private *glamor_priv;
+ glamor_gl_dispatch *dispatch;
+
+ int index = 0;
+ GLint gradient_prog = 0;
+ char *gradient_fs = NULL;
+ GLint fs_main_prog, fs_getcolor_prog, vs_prog;
+
+ const char *gradient_vs =
+ GLAMOR_DEFAULT_PRECISION
+ "attribute vec4 v_position;\n"
+ "attribute vec4 v_texcoord;\n"
+ "varying vec2 source_texture;\n"
+ "\n"
+ "void main()\n"
+ "{\n"
+ " gl_Position = v_position;\n"
+ " source_texture = v_texcoord.xy;\n"
+ "}\n";
+
+ /*
+ * |
+ * |\
+ * | \
+ * | \
+ * | \
+ * |\ \
+ * | \ \
+ * cos_val = |\ p1d \ /
+ * sqrt(1/(slope*slope+1.0)) ------>\ \ \ /
+ * | \ \ \
+ * | \ \ / \
+ * | \ *Pt1\
+ * *p1 | \ \ *P
+ * \ | / \ \ /
+ * \ | / \ \ /
+ * \ | pd \
+ * \ | \ / \
+ * p2* | \ / \ /
+ * slope = (p2.y - p1.y) / | / p2d /
+ * (p2.x - p1.x) | / \ /
+ * | / \ /
+ * | / /
+ * | / /
+ * | / *Pt2
+ * | /
+ * | /
+ * | /
+ * | /
+ * | /
+ * -------+---------------------------------
+ * O|
+ * |
+ * |
+ *
+ * step 1: compute the distance of p, pt1 and pt2 in the slope direction.
+ * Caculate the distance on Y axis first and multiply cos_val to
+ * get the value on slope direction(pd, p1d and p2d represent the
+ * distance of p, pt1, and pt2 respectively).
+ *
+ * step 2: caculate the percentage of (pd - p1d)/(p2d - p1d).
+ * If (pd - p1d) > (p2d - p1d) or < 0, then sub or add (p2d - p1d)
+ * to make it in the range of [0, (p2d - p1d)].
+ *
+ * step 3: compare the percentage to every stop and find the stpos just
+ * before and after it. Use the interpolation fomula to compute RGBA.
+ */
+
+ #define gradient_fs_template \
+ GLAMOR_DEFAULT_PRECISION\
+ "uniform mat3 transform_mat;\n"\
+ "uniform int repeat_type;\n"\
+ "uniform int hor_ver;\n"\
+ "uniform float pt_slope;\n"\
+ "uniform float cos_val;\n"\
+ "uniform float p1_distance;\n"\
+ "uniform float pt_distance;\n"\
+ "varying vec2 source_texture;\n"\
+ "\n"\
+ "vec4 get_color(float stop_len);\n"\
+ "\n"\
+ "float get_stop_len()\n"\
+ "{\n"\
+ " vec3 tmp = vec3(source_texture.x, source_texture.y, 1.0);\n"\
+ " float len_percentage;\n"\
+ " float distance;\n"\
+ " float _p1_distance;\n"\
+ " float _pt_distance;\n"\
+ " float y_dist;\n"\
+ " float stop_after;\n"\
+ " float stop_before;\n"\
+ " vec4 stop_color_before;\n"\
+ " vec4 stop_color_after;\n"\
+ " float new_alpha; \n"\
+ " int revserse = 0;\n"\
+ " vec4 gradient_color;\n"\
+ " float percentage; \n"\
+ " vec3 source_texture_trans = transform_mat * tmp;\n"\
+ " \n"\
+ " if(hor_ver == 0) { \n" /*Normal case.*/\
+ " y_dist = source_texture_trans.y - source_texture_trans.x*pt_slope;\n"\
+ " distance = y_dist * cos_val;\n"\
+ " _p1_distance = p1_distance * source_texture_trans.z;\n"\
+ " _pt_distance = pt_distance * source_texture_trans.z;\n"\
+ " \n"\
+ " } else if (hor_ver == 1) {\n"/*horizontal case.*/\
+ " distance = source_texture_trans.x;\n"\
+ " _p1_distance = p1_distance * source_texture_trans.z;\n"\
+ " _pt_distance = pt_distance * source_texture_trans.z;\n"\
+ " } \n"\
+ " \n"\
+ " distance = distance - _p1_distance; \n"\
+ " \n"\
+ " if(repeat_type == %d){\n" /* repeat normal*/\
+ " while(distance > _pt_distance) \n"\
+ " distance = distance - (_pt_distance); \n"\
+ " while(distance < 0.0) \n"\
+ " distance = distance + (_pt_distance); \n"\
+ " }\n"\
+ " \n"\
+ " if(repeat_type == %d) {\n" /* repeat reflect*/\
+ " while(distance > _pt_distance) {\n"\
+ " distance = distance - (_pt_distance); \n"\
+ " if(revserse == 0)\n"\
+ " revserse = 1;\n"\
+ " else\n"\
+ " revserse = 0;\n"\
+ " }\n"\
+ " while(distance < 0.0) {\n"\
+ " distance = distance + (_pt_distance); \n"\
+ " if(revserse == 0)\n"\
+ " revserse = 1;\n"\
+ " else\n"\
+ " revserse = 0;\n"\
+ " }\n"\
+ " if(revserse == 1) {\n"\
+ " distance = (_pt_distance) - distance; \n"\
+ " }\n"\
+ " }\n"\
+ " \n"\
+ " len_percentage = distance/(_pt_distance);\n"\
+ " \n"\
+ " return len_percentage;\n"\
+ "}\n"\
+ "\n"\
+ "void main()\n"\
+ "{\n"\
+ " float stop_len = get_stop_len();\n"\
+ " gl_FragColor = get_color(stop_len);\n"\
+ "}\n"
+
+ glamor_priv = glamor_get_screen_private(screen);
+
+ if ((glamor_priv->linear_max_nstops >= stops_count) && (dyn_gen)) {
+ /* Very Good, not to generate again. */
+ return;
+ }
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+ if (dyn_gen && glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][2]) {
+ dispatch->glDeleteShader(
+ glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_VS_PROG][2]);
+ glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_VS_PROG][2] = 0;
+
+ dispatch->glDeleteShader(
+ glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][2]);
+ glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][2] = 0;
+
+ dispatch->glDeleteShader(
+ glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][2]);
+ glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][2] = 0;
+
+ dispatch->glDeleteProgram(glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][2]);
+ glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][2] = 0;
+ }
+
+ gradient_prog = dispatch->glCreateProgram();
+
+ vs_prog = glamor_compile_glsl_prog(dispatch,
+ GL_VERTEX_SHADER, gradient_vs);
+
+ XNFasprintf(&gradient_fs,
+ gradient_fs_template,
+ PIXMAN_REPEAT_NORMAL, PIXMAN_REPEAT_REFLECT);
+
+ fs_main_prog = glamor_compile_glsl_prog(dispatch,
+ GL_FRAGMENT_SHADER, gradient_fs);
+ free(gradient_fs);
+
+ fs_getcolor_prog =
+ _glamor_create_getcolor_fs_program(screen, stops_count, (stops_count > 0));
+
+ dispatch->glAttachShader(gradient_prog, vs_prog);
+ dispatch->glAttachShader(gradient_prog, fs_getcolor_prog);
+ dispatch->glAttachShader(gradient_prog, fs_main_prog);
+
+ dispatch->glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_POS, "v_position");
+ dispatch->glBindAttribLocation(gradient_prog, GLAMOR_VERTEX_SOURCE, "v_texcoord");
+
+ glamor_link_glsl_prog(dispatch, gradient_prog);
+
+ dispatch->glUseProgram(0);
+
+ if (dyn_gen) {
+ index = 2;
+ glamor_priv->linear_max_nstops = stops_count;
+ } else if (stops_count) {
+ index = 1;
+ } else {
+ index = 0;
+ }
+
+ glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][index] = gradient_prog;
+ glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_VS_PROG][index] = vs_prog;
+ glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][index] = fs_main_prog;
+ glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][index] = fs_getcolor_prog;
+
+ glamor_put_dispatch(glamor_priv);
+}
+
+void
+glamor_init_gradient_shader(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv;
+ int i;
+
+ glamor_priv = glamor_get_screen_private(screen);
+
+ for (i = 0; i < 3; i++) {
+ glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][i] = 0;
+ glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_VS_PROG][i] = 0;
+ glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][i] = 0;
+ glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][i] = 0;
+
+ glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][i] = 0;
+ glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_VS_PROG][i] = 0;
+ glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][i] = 0;
+ glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][i] = 0;
+ }
+ glamor_priv->linear_max_nstops = 0;
+ glamor_priv->radial_max_nstops = 0;
+
+ _glamor_create_linear_gradient_program(screen, 0, 0);
+ _glamor_create_linear_gradient_program(screen, LINEAR_LARGE_STOPS, 0);
+
+ _glamor_create_radial_gradient_program(screen, 0, 0);
+ _glamor_create_radial_gradient_program(screen, RADIAL_LARGE_STOPS, 0);
+}
+
+void
+glamor_fini_gradient_shader(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv;
+ glamor_gl_dispatch *dispatch;
+ int i = 0;
+
+ glamor_priv = glamor_get_screen_private(screen);
+ dispatch = glamor_get_dispatch(glamor_priv);
+
+ for (i = 0; i < 3; i++) {
+ /* Linear Gradient */
+ if (glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_VS_PROG][i])
+ dispatch->glDeleteShader(
+ glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_VS_PROG][i]);
+
+ if (glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][i])
+ dispatch->glDeleteShader(
+ glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][i]);
+
+ if (glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][i])
+ dispatch->glDeleteShader(
+ glamor_priv->linear_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][i]);
+
+ if (glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][i])
+ dispatch->glDeleteProgram(glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][i]);
+
+ /* Radial Gradient */
+ if (glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_VS_PROG][i])
+ dispatch->glDeleteShader(
+ glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_VS_PROG][i]);
+
+ if (glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][i])
+ dispatch->glDeleteShader(
+ glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_MAIN_PROG][i]);
+
+ if (glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][i])
+ dispatch->glDeleteShader(
+ glamor_priv->radial_gradient_shaders[SHADER_GRADIENT_FS_GETCOLOR_PROG][i]);
+
+ if (glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][i])
+ dispatch->glDeleteProgram(glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][i]);
+ }
+
+ glamor_put_dispatch(glamor_priv);
+}
+
+static void
+_glamor_gradient_convert_trans_matrix(PictTransform *from, float to[3][3],
+ int width, int height, int normalize)
+{
+ /*
+ * Because in the shader program, we normalize all the pixel cood to [0, 1],
+ * so with the transform matrix, the correct logic should be:
+ * v_s = A*T*v
+ * v_s: point vector in shader after normalized.
+ * A: The transition matrix from width X height --> 1.0 X 1.0
+ * T: The transform matrix.
+ * v: point vector in width X height space.
+ *
+ * result is OK if we use this fomula. But for every point in width X height space,
+ * we can just use their normalized point vector in shader, namely we can just
+ * use the result of A*v in shader. So we have no chance to insert T in A*v.
+ * We can just convert v_s = A*T*v to v_s = A*T*inv(A)*A*v, where inv(A) is the
+ * inverse matrix of A. Now, v_s = (A*T*inv(A)) * (A*v)
+ * So, to get the correct v_s, we need to cacula1 the matrix: (A*T*inv(A)), and
+ * we name this matrix T_s.
+ *
+ * Firstly, because A is for the scale convertion, we find
+ * -- --
+ * |1/w 0 0 |
+ * A = | 0 1/h 0 |
+ * | 0 0 1.0|
+ * -- --
+ * so T_s = A*T*inv(a) and result
+ *
+ * -- --
+ * | t11 h*t12/w t13/w|
+ * T_s = | w*t21/h t22 t23/h|
+ * | w*t31 h*t32 t33 |
+ * -- --
+ */
+
+ to[0][0] = (float)pixman_fixed_to_double(from->matrix[0][0]);
+ to[0][1] = (float)pixman_fixed_to_double(from->matrix[0][1])
+ * (normalize ? (((float)height) / ((float)width)) : 1.0);
+ to[0][2] = (float)pixman_fixed_to_double(from->matrix[0][2])
+ / (normalize ? ((float)width) : 1.0);
+
+ to[1][0] = (float)pixman_fixed_to_double(from->matrix[1][0])
+ * (normalize ? (((float)width) / ((float)height)) : 1.0);
+ to[1][1] = (float)pixman_fixed_to_double(from->matrix[1][1]);
+ to[1][2] = (float)pixman_fixed_to_double(from->matrix[1][2])
+ / (normalize ? ((float)height) : 1.0);
+
+ to[2][0] = (float)pixman_fixed_to_double(from->matrix[2][0])
+ * (normalize ? ((float)width) : 1.0);
+ to[2][1] = (float)pixman_fixed_to_double(from->matrix[2][1])
+ * (normalize ? ((float)height) : 1.0);
+ to[2][2] = (float)pixman_fixed_to_double(from->matrix[2][2]);
+
+ DEBUGF("the transform matrix is:\n%f\t%f\t%f\n%f\t%f\t%f\n%f\t%f\t%f\n",
+ to[0][0], to[0][1], to[0][2],
+ to[1][0], to[1][1], to[1][2],
+ to[2][0], to[2][1], to[2][2]);
+}
+
+static int
+_glamor_gradient_set_pixmap_destination(ScreenPtr screen,
+ glamor_screen_private *glamor_priv,
+ PicturePtr dst_picture,
+ GLfloat *xscale, GLfloat *yscale,
+ int x_source, int y_source,
+ float vertices[8],
+ float tex_vertices[8],
+ int tex_normalize)
+{
+ glamor_pixmap_private *pixmap_priv;
+ PixmapPtr pixmap = NULL;
+ glamor_gl_dispatch *dispatch = NULL;
+
+ pixmap = glamor_get_drawable_pixmap(dst_picture->pDrawable);
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) { /* should always have here. */
+ return 0;
+ }
+
+ glamor_set_destination_pixmap_priv_nc(pixmap_priv);
+
+ pixmap_priv_get_dest_scale(pixmap_priv, xscale, yscale);
+
+ DEBUGF("xscale = %f, yscale = %f,"
+ " x_source = %d, y_source = %d, width = %d, height = %d\n",
+ *xscale, *yscale, x_source, y_source,
+ dst_picture->pDrawable->width, dst_picture->pDrawable->height);
+
+ glamor_set_normalize_vcoords_tri_strip(*xscale, *yscale,
+ 0, 0,
+ (INT16)(dst_picture->pDrawable->width),
+ (INT16)(dst_picture->pDrawable->height),
+ glamor_priv->yInverted, vertices);
+
+ if (tex_normalize) {
+ glamor_set_normalize_tcoords_tri_stripe(*xscale, *yscale,
+ x_source, y_source,
+ (INT16)(dst_picture->pDrawable->width + x_source),
+ (INT16)(dst_picture->pDrawable->height + y_source),
+ glamor_priv->yInverted, tex_vertices);
+ } else {
+ glamor_set_tcoords_tri_strip((INT16)(dst_picture->pDrawable->width),
+ (INT16)(dst_picture->pDrawable->height),
+ x_source, y_source,
+ (INT16)(dst_picture->pDrawable->width) + x_source,
+ (INT16)(dst_picture->pDrawable->height) + y_source,
+ glamor_priv->yInverted, tex_vertices);
+ }
+
+ DEBUGF("vertices --> leftup : %f X %f, rightup: %f X %f,"
+ "rightbottom: %f X %f, leftbottom : %f X %f\n",
+ vertices[0], vertices[1], vertices[2], vertices[3],
+ vertices[4], vertices[5], vertices[6], vertices[7]);
+ DEBUGF("tex_vertices --> leftup : %f X %f, rightup: %f X %f,"
+ "rightbottom: %f X %f, leftbottom : %f X %f\n",
+ tex_vertices[0], tex_vertices[1], tex_vertices[2], tex_vertices[3],
+ tex_vertices[4], tex_vertices[5], tex_vertices[6], tex_vertices[7]);
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+
+ dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
+ GL_FALSE, 0, vertices);
+ dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
+ GL_FALSE, 0, tex_vertices);
+
+ dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+ dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+
+ glamor_put_dispatch(glamor_priv);
+
+ return 1;
+}
+
+static int
+_glamor_gradient_set_stops(PicturePtr src_picture, PictGradient * pgradient,
+ GLfloat *stop_colors, GLfloat *n_stops)
+{
+ int i;
+ int count = 1;
+
+ for (i = 0; i < pgradient->nstops; i++) {
+ stop_colors[count*4] = pixman_fixed_to_double(
+ pgradient->stops[i].color.red);
+ stop_colors[count*4+1] = pixman_fixed_to_double(
+ pgradient->stops[i].color.green);
+ stop_colors[count*4+2] = pixman_fixed_to_double(
+ pgradient->stops[i].color.blue);
+ stop_colors[count*4+3] = pixman_fixed_to_double(
+ pgradient->stops[i].color.alpha);
+
+ n_stops[count] = (GLfloat)pixman_fixed_to_double(
+ pgradient->stops[i].x);
+ count++;
+ }
+
+ /* for the end stop. */
+ count++;
+
+ switch (src_picture->repeatType) {
+#define REPEAT_FILL_STOPS(m, n) \
+ stop_colors[(m)*4 + 0] = stop_colors[(n)*4 + 0]; \
+ stop_colors[(m)*4 + 1] = stop_colors[(n)*4 + 1]; \
+ stop_colors[(m)*4 + 2] = stop_colors[(n)*4 + 2]; \
+ stop_colors[(m)*4 + 3] = stop_colors[(n)*4 + 3];
+
+ default:
+ case PIXMAN_REPEAT_NONE:
+ stop_colors[0] = 0.0; //R
+ stop_colors[1] = 0.0; //G
+ stop_colors[2] = 0.0; //B
+ stop_colors[3] = 0.0; //Alpha
+ n_stops[0] = -(float)INT_MAX; //should be small enough.
+
+ stop_colors[0 + (count-1)*4] = 0.0; //R
+ stop_colors[1 + (count-1)*4] = 0.0; //G
+ stop_colors[2 + (count-1)*4] = 0.0; //B
+ stop_colors[3 + (count-1)*4] = 0.0; //Alpha
+ n_stops[count-1] = (float)INT_MAX; //should be large enough.
+ break;
+ case PIXMAN_REPEAT_NORMAL:
+ REPEAT_FILL_STOPS(0, count - 2);
+ n_stops[0] = n_stops[count-2] - 1.0;
+
+ REPEAT_FILL_STOPS(count - 1, 1);
+ n_stops[count-1] = n_stops[1] + 1.0;
+ break;
+ case PIXMAN_REPEAT_REFLECT:
+ REPEAT_FILL_STOPS(0, 1);
+ n_stops[0] = -n_stops[1];
+
+ REPEAT_FILL_STOPS(count - 1, count - 2);
+ n_stops[count-1] = 1.0 + 1.0 - n_stops[count-2];
+ break;
+ case PIXMAN_REPEAT_PAD:
+ REPEAT_FILL_STOPS(0, 1);
+ n_stops[0] = -(float)INT_MAX;
+
+ REPEAT_FILL_STOPS(count - 1, count - 2);
+ n_stops[count-1] = (float)INT_MAX;
+ break;
+#undef REPEAT_FILL_STOPS
+ }
+
+ for (i = 0; i < count; i++) {
+ DEBUGF("n_stops[%d] = %f, color = r:%f g:%f b:%f a:%f\n",
+ i, n_stops[i],
+ stop_colors[i*4], stop_colors[i*4+1],
+ stop_colors[i*4+2], stop_colors[i*4+3]);
+ }
+
+ return count;
+}
+
+PicturePtr
+glamor_generate_radial_gradient_picture(ScreenPtr screen,
+ PicturePtr src_picture,
+ int x_source, int y_source,
+ int width, int height,
+ PictFormatShort format)
+{
+ glamor_screen_private *glamor_priv;
+ glamor_gl_dispatch *dispatch;
+ PicturePtr dst_picture = NULL;
+ PixmapPtr pixmap = NULL;
+ GLint gradient_prog = 0;
+ int error;
+ float tex_vertices[8];
+ int stops_count = 0;
+ int count = 0;
+ GLfloat *stop_colors = NULL;
+ GLfloat *n_stops = NULL;
+ GLfloat xscale, yscale;
+ float vertices[8];
+ float transform_mat[3][3];
+ static const float identity_mat[3][3] = {{1.0, 0.0, 0.0},
+ {0.0, 1.0, 0.0},
+ {0.0, 0.0, 1.0}};
+ GLfloat stop_colors_st[RADIAL_SMALL_STOPS*4];
+ GLfloat n_stops_st[RADIAL_SMALL_STOPS];
+ GLfloat A_value;
+ GLfloat cxy[4];
+ float c1x, c1y, c2x, c2y, r1, r2;
+
+ GLint transform_mat_uniform_location = 0;
+ GLint repeat_type_uniform_location = 0;
+ GLint n_stop_uniform_location = 0;
+ GLint stops_uniform_location = 0;
+ GLint stop_colors_uniform_location = 0;
+ GLint stop0_uniform_location = 0;
+ GLint stop1_uniform_location = 0;
+ GLint stop2_uniform_location = 0;
+ GLint stop3_uniform_location = 0;
+ GLint stop4_uniform_location = 0;
+ GLint stop5_uniform_location = 0;
+ GLint stop6_uniform_location = 0;
+ GLint stop7_uniform_location = 0;
+ GLint stop_color0_uniform_location = 0;
+ GLint stop_color1_uniform_location = 0;
+ GLint stop_color2_uniform_location = 0;
+ GLint stop_color3_uniform_location = 0;
+ GLint stop_color4_uniform_location = 0;
+ GLint stop_color5_uniform_location = 0;
+ GLint stop_color6_uniform_location = 0;
+ GLint stop_color7_uniform_location = 0;
+ GLint A_value_uniform_location = 0;
+ GLint c1_uniform_location = 0;
+ GLint r1_uniform_location = 0;
+ GLint c2_uniform_location = 0;
+ GLint r2_uniform_location = 0;
+
+ glamor_priv = glamor_get_screen_private(screen);
+ dispatch = glamor_get_dispatch(glamor_priv);
+
+ /* Create a pixmap with VBO. */
+ pixmap = glamor_create_pixmap(screen,
+ width, height,
+ PIXMAN_FORMAT_DEPTH(format),
+ 0);
+ if (!pixmap)
+ goto GRADIENT_FAIL;
+
+ dst_picture = CreatePicture(0, &pixmap->drawable,
+ PictureMatchFormat(screen,
+ PIXMAN_FORMAT_DEPTH(format), format),
+ 0, 0, serverClient, &error);
+
+ /* Release the reference, picture will hold the last one. */
+ glamor_destroy_pixmap(pixmap);
+
+ if (!dst_picture)
+ goto GRADIENT_FAIL;
+
+ ValidatePicture(dst_picture);
+
+ stops_count = src_picture->pSourcePict->radial.nstops + 2;
+
+ /* Because the max value of nstops is unkown, so create a program
+ when nstops > LINEAR_LARGE_STOPS.*/
+ if (stops_count <= RADIAL_SMALL_STOPS) {
+ gradient_prog = glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][0];
+ } else if (stops_count <= RADIAL_LARGE_STOPS) {
+ gradient_prog = glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][1];
+ } else {
+ _glamor_create_radial_gradient_program(screen,
+ src_picture->pSourcePict->linear.nstops + 2,
+ 1);
+ gradient_prog = glamor_priv->gradient_prog[SHADER_GRADIENT_RADIAL][2];
+ }
+
+ /* Bind all the uniform vars .*/
+ transform_mat_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "transform_mat");
+ repeat_type_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "repeat_type");
+ n_stop_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "n_stop");
+ A_value_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "A_value");
+ repeat_type_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "repeat_type");
+ c1_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "c1");
+ r1_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "r1");
+ c2_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "c2");
+ r2_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "r2");
+
+ if (src_picture->pSourcePict->radial.nstops + 2 <= RADIAL_SMALL_STOPS) {
+ stop0_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop0");
+ stop1_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop1");
+ stop2_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop2");
+ stop3_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop3");
+ stop4_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop4");
+ stop5_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop5");
+ stop6_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop6");
+ stop7_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop7");
+
+ stop_color0_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop_color0");
+ stop_color1_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop_color1");
+ stop_color2_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop_color2");
+ stop_color3_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop_color3");
+ stop_color4_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop_color4");
+ stop_color5_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop_color5");
+ stop_color6_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop_color6");
+ stop_color7_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop_color7");
+ } else {
+ stops_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stops");
+ stop_colors_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop_colors");
+ }
+
+ dispatch->glUseProgram(gradient_prog);
+
+ dispatch->glUniform1i(repeat_type_uniform_location, src_picture->repeatType);
+
+
+ if (src_picture->transform) {
+ _glamor_gradient_convert_trans_matrix(src_picture->transform,
+ transform_mat,
+ width, height, 0);
+ dispatch->glUniformMatrix3fv(transform_mat_uniform_location,
+ 1, 1, &transform_mat[0][0]);
+ } else {
+ dispatch->glUniformMatrix3fv(transform_mat_uniform_location,
+ 1, 1, &identity_mat[0][0]);
+ }
+
+ if (!_glamor_gradient_set_pixmap_destination(screen, glamor_priv, dst_picture,
+ &xscale, &yscale, x_source, y_source,
+ vertices, tex_vertices, 0))
+ goto GRADIENT_FAIL;
+
+ /* Set all the stops and colors to shader. */
+ if (stops_count > RADIAL_SMALL_STOPS) {
+ stop_colors = malloc(4 * stops_count * sizeof(float));
+ if (stop_colors == NULL) {
+ ErrorF("Failed to allocate stop_colors memory.\n");
+ goto GRADIENT_FAIL;
+ }
+
+ n_stops = malloc(stops_count * sizeof(float));
+ if (n_stops == NULL) {
+ ErrorF("Failed to allocate n_stops memory.\n");
+ goto GRADIENT_FAIL;
+ }
+ } else {
+ stop_colors = stop_colors_st;
+ n_stops = n_stops_st;
+ }
+
+ count = _glamor_gradient_set_stops(src_picture, &src_picture->pSourcePict->gradient,
+ stop_colors, n_stops);
+
+ if (src_picture->pSourcePict->linear.nstops + 2 <= RADIAL_SMALL_STOPS) {
+ int j = 0;
+ dispatch->glUniform4f(stop_color0_uniform_location,
+ stop_colors[4*j+0], stop_colors[4*j+1],
+ stop_colors[4*j+2], stop_colors[4*j+3]);
+ j++;
+ dispatch->glUniform4f(stop_color1_uniform_location,
+ stop_colors[4*j+0], stop_colors[4*j+1],
+ stop_colors[4*j+2], stop_colors[4*j+3]);
+ j++;
+ dispatch->glUniform4f(stop_color2_uniform_location,
+ stop_colors[4*j+0], stop_colors[4*j+1],
+ stop_colors[4*j+2], stop_colors[4*j+3]);
+ j++;
+ dispatch->glUniform4f(stop_color3_uniform_location,
+ stop_colors[4*j+0], stop_colors[4*j+1],
+ stop_colors[4*j+2], stop_colors[4*j+3]);
+ j++;
+ dispatch->glUniform4f(stop_color4_uniform_location,
+ stop_colors[4*j+0], stop_colors[4*j+1],
+ stop_colors[4*j+2], stop_colors[4*j+3]);
+ j++;
+ dispatch->glUniform4f(stop_color5_uniform_location,
+ stop_colors[4*j+0], stop_colors[4*j+1],
+ stop_colors[4*j+2], stop_colors[4*j+3]);
+ j++;
+ dispatch->glUniform4f(stop_color6_uniform_location,
+ stop_colors[4*j+0], stop_colors[4*j+1],
+ stop_colors[4*j+2], stop_colors[4*j+3]);
+ j++;
+ dispatch->glUniform4f(stop_color7_uniform_location,
+ stop_colors[4*j+0], stop_colors[4*j+1],
+ stop_colors[4*j+2], stop_colors[4*j+3]);
+
+ j = 0;
+ dispatch->glUniform1f(stop0_uniform_location, n_stops[j++]);
+ dispatch->glUniform1f(stop1_uniform_location, n_stops[j++]);
+ dispatch->glUniform1f(stop2_uniform_location, n_stops[j++]);
+ dispatch->glUniform1f(stop3_uniform_location, n_stops[j++]);
+ dispatch->glUniform1f(stop4_uniform_location, n_stops[j++]);
+ dispatch->glUniform1f(stop5_uniform_location, n_stops[j++]);
+ dispatch->glUniform1f(stop6_uniform_location, n_stops[j++]);
+ dispatch->glUniform1f(stop7_uniform_location, n_stops[j++]);
+ dispatch->glUniform1i(n_stop_uniform_location, count);
+ } else {
+ dispatch->glUniform4fv(stop_colors_uniform_location, count, stop_colors);
+ dispatch->glUniform1fv(stops_uniform_location, count, n_stops);
+ dispatch->glUniform1i(n_stop_uniform_location, count);
+ }
+
+ c1x = (float)pixman_fixed_to_double(src_picture->pSourcePict->radial.c1.x);
+ c1y = (float)pixman_fixed_to_double(src_picture->pSourcePict->radial.c1.y);
+ c2x = (float)pixman_fixed_to_double(src_picture->pSourcePict->radial.c2.x);
+ c2y = (float)pixman_fixed_to_double(src_picture->pSourcePict->radial.c2.y);
+
+ r1 = (float)pixman_fixed_to_double(src_picture->pSourcePict->radial.c1.radius);
+ r2 = (float)pixman_fixed_to_double(src_picture->pSourcePict->radial.c2.radius);
+
+ glamor_set_circle_centre(width, height, c1x, c1y, glamor_priv->yInverted, cxy);
+ dispatch->glUniform2fv(c1_uniform_location, 1, cxy);
+ dispatch->glUniform1f(r1_uniform_location, r1);
+
+ glamor_set_circle_centre(width, height, c2x, c2y, glamor_priv->yInverted, cxy);
+ dispatch->glUniform2fv(c2_uniform_location, 1, cxy);
+ dispatch->glUniform1f(r2_uniform_location, r2);
+
+ A_value = (c2x - c1x) * (c2x - c1x) + (c2y - c1y) * (c2y - c1y) - (r2 - r1) * (r2 - r1);
+ dispatch->glUniform1f(A_value_uniform_location, A_value);
+
+ DEBUGF("C1:(%f, %f) R1:%f\nC2:(%f, %f) R2:%f\nA = %f\n",
+ c1x, c1y, r1, c2x, c2y, r2, A_value);
+
+ /* Now rendering. */
+ dispatch->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+ /* Do the clear logic.*/
+ if (stops_count > RADIAL_SMALL_STOPS) {
+ free(n_stops);
+ free(stop_colors);
+ }
+
+ dispatch->glBindBuffer(GL_ARRAY_BUFFER, 0);
+ dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+ dispatch->glUseProgram(0);
+
+ glamor_put_dispatch(glamor_priv);
+ return dst_picture;
+
+GRADIENT_FAIL:
+ if (dst_picture) {
+ FreePicture(dst_picture, 0);
+ }
+
+ if (stops_count > RADIAL_SMALL_STOPS) {
+ if (n_stops)
+ free(n_stops);
+ if (stop_colors)
+ free(stop_colors);
+ }
+
+ dispatch->glBindBuffer(GL_ARRAY_BUFFER, 0);
+ dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+ dispatch->glUseProgram(0);
+ glamor_put_dispatch(glamor_priv);
+ return NULL;
+}
+
+PicturePtr
+glamor_generate_linear_gradient_picture(ScreenPtr screen,
+ PicturePtr src_picture,
+ int x_source, int y_source,
+ int width, int height,
+ PictFormatShort format)
+{
+ glamor_screen_private *glamor_priv;
+ glamor_gl_dispatch *dispatch;
+ PicturePtr dst_picture = NULL;
+ PixmapPtr pixmap = NULL;
+ GLint gradient_prog = 0;
+ int error;
+ float pt_distance;
+ float p1_distance;
+ GLfloat cos_val;
+ float tex_vertices[8];
+ int stops_count = 0;
+ GLfloat *stop_colors = NULL;
+ GLfloat *n_stops = NULL;
+ int count = 0;
+ float slope;
+ GLfloat xscale, yscale;
+ GLfloat pt1[2], pt2[2];
+ float vertices[8];
+ float transform_mat[3][3];
+ static const float identity_mat[3][3] = {{1.0, 0.0, 0.0},
+ {0.0, 1.0, 0.0},
+ {0.0, 0.0, 1.0}};
+ GLfloat stop_colors_st[LINEAR_SMALL_STOPS*4];
+ GLfloat n_stops_st[LINEAR_SMALL_STOPS];
+
+ GLint transform_mat_uniform_location = 0;
+ GLint n_stop_uniform_location = 0;
+ GLint stops_uniform_location = 0;
+ GLint stop0_uniform_location = 0;
+ GLint stop1_uniform_location = 0;
+ GLint stop2_uniform_location = 0;
+ GLint stop3_uniform_location = 0;
+ GLint stop4_uniform_location = 0;
+ GLint stop5_uniform_location = 0;
+ GLint stop6_uniform_location = 0;
+ GLint stop7_uniform_location = 0;
+ GLint stop_colors_uniform_location = 0;
+ GLint stop_color0_uniform_location = 0;
+ GLint stop_color1_uniform_location = 0;
+ GLint stop_color2_uniform_location = 0;
+ GLint stop_color3_uniform_location = 0;
+ GLint stop_color4_uniform_location = 0;
+ GLint stop_color5_uniform_location = 0;
+ GLint stop_color6_uniform_location = 0;
+ GLint stop_color7_uniform_location = 0;
+ GLint pt_slope_uniform_location = 0;
+ GLint repeat_type_uniform_location = 0;
+ GLint hor_ver_uniform_location = 0;
+ GLint cos_val_uniform_location = 0;
+ GLint p1_distance_uniform_location = 0;
+ GLint pt_distance_uniform_location = 0;
+
+ glamor_priv = glamor_get_screen_private(screen);
+ dispatch = glamor_get_dispatch(glamor_priv);
+
+ /* Create a pixmap with VBO. */
+ pixmap = glamor_create_pixmap(screen,
+ width, height,
+ PIXMAN_FORMAT_DEPTH(format),
+ 0);
+
+ if (!pixmap)
+ goto GRADIENT_FAIL;
+
+ dst_picture = CreatePicture(0, &pixmap->drawable,
+ PictureMatchFormat(screen,
+ PIXMAN_FORMAT_DEPTH(format), format),
+ 0, 0, serverClient, &error);
+
+ /* Release the reference, picture will hold the last one. */
+ glamor_destroy_pixmap(pixmap);
+
+ if (!dst_picture)
+ goto GRADIENT_FAIL;
+
+ ValidatePicture(dst_picture);
+
+ stops_count = src_picture->pSourcePict->linear.nstops + 2;
+
+ /* Because the max value of nstops is unkown, so create a program
+ when nstops > LINEAR_LARGE_STOPS.*/
+ if (stops_count <= LINEAR_SMALL_STOPS) {
+ gradient_prog = glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][0];
+ } else if (stops_count <= LINEAR_LARGE_STOPS) {
+ gradient_prog = glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][1];
+ } else {
+ _glamor_create_linear_gradient_program(screen,
+ src_picture->pSourcePict->linear.nstops + 2, 1);
+ gradient_prog = glamor_priv->gradient_prog[SHADER_GRADIENT_LINEAR][2];
+ }
+
+ /* Bind all the uniform vars .*/
+ n_stop_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "n_stop");
+ pt_slope_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "pt_slope");
+ repeat_type_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "repeat_type");
+ hor_ver_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "hor_ver");
+ transform_mat_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "transform_mat");
+ cos_val_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "cos_val");
+ p1_distance_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "p1_distance");
+ pt_distance_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "pt_distance");
+
+ if (src_picture->pSourcePict->linear.nstops + 2 <= LINEAR_SMALL_STOPS) {
+ stop0_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop0");
+ stop1_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop1");
+ stop2_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop2");
+ stop3_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop3");
+ stop4_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop4");
+ stop5_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop5");
+ stop6_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop6");
+ stop7_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop7");
+
+ stop_color0_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop_color0");
+ stop_color1_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop_color1");
+ stop_color2_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop_color2");
+ stop_color3_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop_color3");
+ stop_color4_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop_color4");
+ stop_color5_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop_color5");
+ stop_color6_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop_color6");
+ stop_color7_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop_color7");
+ } else {
+ stops_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stops");
+ stop_colors_uniform_location =
+ dispatch->glGetUniformLocation(gradient_prog, "stop_colors");
+ }
+
+ dispatch->glUseProgram(gradient_prog);
+
+ dispatch->glUniform1i(repeat_type_uniform_location, src_picture->repeatType);
+
+ /* set the transform matrix. */
+ if (src_picture->transform) {
+ _glamor_gradient_convert_trans_matrix(src_picture->transform,
+ transform_mat,
+ width, height, 1);
+ dispatch->glUniformMatrix3fv(transform_mat_uniform_location,
+ 1, 1, &transform_mat[0][0]);
+ } else {
+ dispatch->glUniformMatrix3fv(transform_mat_uniform_location,
+ 1, 1, &identity_mat[0][0]);
+ }
+
+ if (!_glamor_gradient_set_pixmap_destination(screen, glamor_priv, dst_picture,
+ &xscale, &yscale, x_source, y_source,
+ vertices, tex_vertices, 1))
+ goto GRADIENT_FAIL;
+
+ /* Normalize the PTs. */
+ glamor_set_normalize_pt(xscale, yscale,
+ pixman_fixed_to_double(src_picture->pSourcePict->linear.p1.x),
+ pixman_fixed_to_double(src_picture->pSourcePict->linear.p1.y),
+ glamor_priv->yInverted,
+ pt1);
+ DEBUGF("pt1:(%f, %f) ---> (%f %f)\n", pixman_fixed_to_double(src_picture->pSourcePict->linear.p1.x),
+ pixman_fixed_to_double(src_picture->pSourcePict->linear.p1.y), pt1[0], pt1[1]);
+
+ glamor_set_normalize_pt(xscale, yscale,
+ pixman_fixed_to_double(src_picture->pSourcePict->linear.p2.x),
+ pixman_fixed_to_double(src_picture->pSourcePict->linear.p2.y),
+ glamor_priv->yInverted,
+ pt2);
+ DEBUGF("pt2:(%f, %f) ---> (%f %f)\n", pixman_fixed_to_double(src_picture->pSourcePict->linear.p2.x),
+ pixman_fixed_to_double(src_picture->pSourcePict->linear.p2.y), pt2[0], pt2[1]);
+
+ /* Set all the stops and colors to shader. */
+ if (stops_count > LINEAR_SMALL_STOPS) {
+ stop_colors = malloc(4 * stops_count * sizeof(float));
+ if (stop_colors == NULL) {
+ ErrorF("Failed to allocate stop_colors memory.\n");
+ goto GRADIENT_FAIL;
+ }
+
+ n_stops = malloc(stops_count * sizeof(float));
+ if (n_stops == NULL) {
+ ErrorF("Failed to allocate n_stops memory.\n");
+ goto GRADIENT_FAIL;
+ }
+ } else {
+ stop_colors = stop_colors_st;
+ n_stops = n_stops_st;
+ }
+
+ count = _glamor_gradient_set_stops(src_picture, &src_picture->pSourcePict->gradient,
+ stop_colors, n_stops);
+
+ if (src_picture->pSourcePict->linear.nstops + 2 <= LINEAR_SMALL_STOPS) {
+ int j = 0;
+ dispatch->glUniform4f(stop_color0_uniform_location,
+ stop_colors[4*j+0], stop_colors[4*j+1],
+ stop_colors[4*j+2], stop_colors[4*j+3]);
+ j++;
+ dispatch->glUniform4f(stop_color1_uniform_location,
+ stop_colors[4*j+0], stop_colors[4*j+1],
+ stop_colors[4*j+2], stop_colors[4*j+3]);
+ j++;
+ dispatch->glUniform4f(stop_color2_uniform_location,
+ stop_colors[4*j+0], stop_colors[4*j+1],
+ stop_colors[4*j+2], stop_colors[4*j+3]);
+ j++;
+ dispatch->glUniform4f(stop_color3_uniform_location,
+ stop_colors[4*j+0], stop_colors[4*j+1],
+ stop_colors[4*j+2], stop_colors[4*j+3]);
+ j++;
+ dispatch->glUniform4f(stop_color4_uniform_location,
+ stop_colors[4*j+0], stop_colors[4*j+1],
+ stop_colors[4*j+2], stop_colors[4*j+3]);
+ j++;
+ dispatch->glUniform4f(stop_color5_uniform_location,
+ stop_colors[4*j+0], stop_colors[4*j+1],
+ stop_colors[4*j+2], stop_colors[4*j+3]);
+ j++;
+ dispatch->glUniform4f(stop_color6_uniform_location,
+ stop_colors[4*j+0], stop_colors[4*j+1],
+ stop_colors[4*j+2], stop_colors[4*j+3]);
+ j++;
+ dispatch->glUniform4f(stop_color7_uniform_location,
+ stop_colors[4*j+0], stop_colors[4*j+1],
+ stop_colors[4*j+2], stop_colors[4*j+3]);
+
+ j = 0;
+ dispatch->glUniform1f(stop0_uniform_location, n_stops[j++]);
+ dispatch->glUniform1f(stop1_uniform_location, n_stops[j++]);
+ dispatch->glUniform1f(stop2_uniform_location, n_stops[j++]);
+ dispatch->glUniform1f(stop3_uniform_location, n_stops[j++]);
+ dispatch->glUniform1f(stop4_uniform_location, n_stops[j++]);
+ dispatch->glUniform1f(stop5_uniform_location, n_stops[j++]);
+ dispatch->glUniform1f(stop6_uniform_location, n_stops[j++]);
+ dispatch->glUniform1f(stop7_uniform_location, n_stops[j++]);
+
+ dispatch->glUniform1i(n_stop_uniform_location, count);
+ } else {
+ dispatch->glUniform4fv(stop_colors_uniform_location, count, stop_colors);
+ dispatch->glUniform1fv(stops_uniform_location, count, n_stops);
+ dispatch->glUniform1i(n_stop_uniform_location, count);
+ }
+
+ if (src_picture->pSourcePict->linear.p2.y ==
+ src_picture->pSourcePict->linear.p1.y) { // The horizontal case.
+ dispatch->glUniform1i(hor_ver_uniform_location, 1);
+ DEBUGF("p1.y: %f, p2.y: %f, enter the horizontal case\n",
+ pt1[1], pt2[1]);
+
+ p1_distance = pt1[0];
+ pt_distance = (pt2[0] - p1_distance);
+ dispatch->glUniform1f(p1_distance_uniform_location, p1_distance);
+ dispatch->glUniform1f(pt_distance_uniform_location, pt_distance);
+ } else {
+ /* The slope need to compute here. In shader, the viewport set will change
+ the orginal slope and the slope which is vertical to it will not be correct.*/
+ slope = - (float)(src_picture->pSourcePict->linear.p2.x
+ - src_picture->pSourcePict->linear.p1.x) /
+ (float)(src_picture->pSourcePict->linear.p2.y
+ - src_picture->pSourcePict->linear.p1.y);
+ slope = slope * yscale / xscale;
+ dispatch->glUniform1f(pt_slope_uniform_location, slope);
+ dispatch->glUniform1i(hor_ver_uniform_location, 0);
+
+ cos_val = sqrt(1.0 / (slope * slope + 1.0));
+ dispatch->glUniform1f(cos_val_uniform_location, cos_val);
+
+ p1_distance = (pt1[1] - pt1[0] * slope) * cos_val;
+ pt_distance = (pt2[1] - pt2[0] * slope) * cos_val - p1_distance;
+ dispatch->glUniform1f(p1_distance_uniform_location, p1_distance);
+ dispatch->glUniform1f(pt_distance_uniform_location, pt_distance);
+ }
+
+ /* Now rendering. */
+ dispatch->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+ /* Do the clear logic.*/
+ if (stops_count > LINEAR_SMALL_STOPS) {
+ free(n_stops);
+ free(stop_colors);
+ }
+
+ dispatch->glBindBuffer(GL_ARRAY_BUFFER, 0);
+ dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+ dispatch->glUseProgram(0);
+
+ glamor_put_dispatch(glamor_priv);
+ return dst_picture;
+
+GRADIENT_FAIL:
+ if (dst_picture) {
+ FreePicture(dst_picture, 0);
+ }
+
+ if (stops_count > LINEAR_SMALL_STOPS) {
+ if (n_stops)
+ free(n_stops);
+ if (stop_colors)
+ free(stop_colors);
+ }
+
+ dispatch->glBindBuffer(GL_ARRAY_BUFFER, 0);
+ dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+ dispatch->glUseProgram(0);
+ glamor_put_dispatch(glamor_priv);
+ return NULL;
+}
+
+#endif /* End of GLAMOR_GRADIENT_SHADER */
+
+#endif /* End of RENDER */
diff --git a/xorg-server/glamor/glamor_largepixmap.c b/xorg-server/glamor/glamor_largepixmap.c
new file mode 100644
index 000000000..91ee8f2df
--- /dev/null
+++ b/xorg-server/glamor/glamor_largepixmap.c
@@ -0,0 +1,1324 @@
+#include <stdlib.h>
+
+#include "glamor_priv.h"
+
+/**
+ * Clip the boxes regards to each pixmap's block array.
+ *
+ * Should translate the region to relative coords to the pixmap,
+ * start at (0,0).
+ */
+#if 0
+//#define DEBUGF(str, ...) do {} while(0)
+#define DEBUGF(str, ...) ErrorF(str, ##__VA_ARGS__)
+//#define DEBUGRegionPrint(x) do {} while (0)
+#define DEBUGRegionPrint RegionPrint
+#endif
+
+static glamor_pixmap_clipped_regions *
+__glamor_compute_clipped_regions(int block_w,
+ int block_h,
+ int block_stride,
+ int x, int y,
+ int w, int h,
+ RegionPtr region,
+ int *n_region,
+ int reverse,
+ int upsidedown)
+{
+ glamor_pixmap_clipped_regions * clipped_regions;
+ BoxPtr extent;
+ int start_x, start_y, end_x, end_y;
+ int start_block_x, start_block_y;
+ int end_block_x, end_block_y;
+ int loop_start_block_x, loop_start_block_y;
+ int loop_end_block_x, loop_end_block_y;
+ int loop_block_stride;
+ int i, j, delta_i, delta_j;
+ RegionRec temp_region;
+ RegionPtr current_region;
+ int block_idx;
+ int k = 0;
+ int temp_block_idx;
+
+ extent = RegionExtents(region);
+ start_x = MAX(x, extent->x1);
+ start_y = MAX(y, extent->y1);
+ end_x = MIN(x + w, extent->x2);
+ end_y = MIN(y + h, extent->y2);
+
+ DEBUGF("start compute clipped regions:\n");
+ DEBUGF("block w %d h %d x %d y %d w %d h %d, block_stride %d \n",
+ block_w, block_h, x, y, w, h, block_stride);
+ DEBUGRegionPrint(region);
+
+ DEBUGF("start_x %d start_y %d end_x %d end_y %d \n", start_x, start_y, end_x, end_y);
+
+ if (start_x >= end_x || start_y >= end_y) {
+ *n_region = 0;
+ return NULL;
+ }
+
+ start_block_x = (start_x - x)/ block_w;
+ start_block_y = (start_y - y)/ block_h;
+ end_block_x = (end_x - x)/ block_w;
+ end_block_y = (end_y - y)/ block_h;
+
+ clipped_regions = calloc((end_block_x - start_block_x + 1)
+ * (end_block_y - start_block_y + 1),
+ sizeof(*clipped_regions));
+
+
+ DEBUGF("startx %d starty %d endx %d endy %d \n",
+ start_x, start_y, end_x, end_y);
+ DEBUGF("start_block_x %d end_block_x %d \n", start_block_x, end_block_x);
+ DEBUGF("start_block_y %d end_block_y %d \n", start_block_y, end_block_y);
+
+ if (!reverse) {
+ loop_start_block_x = start_block_x;
+ loop_end_block_x = end_block_x + 1;
+ delta_i = 1;
+ } else {
+ loop_start_block_x = end_block_x;
+ loop_end_block_x = start_block_x - 1;
+ delta_i = -1;
+ }
+
+ if (!upsidedown) {
+ loop_start_block_y = start_block_y;
+ loop_end_block_y = end_block_y + 1;
+ delta_j = 1;
+ } else {
+ loop_start_block_y = end_block_y;
+ loop_end_block_y = start_block_y - 1;
+ delta_j = -1;
+ }
+
+ loop_block_stride = delta_j * block_stride;
+ block_idx = (loop_start_block_y - delta_j) * block_stride;
+
+ for(j = loop_start_block_y; j != loop_end_block_y; j += delta_j)
+ {
+ block_idx += loop_block_stride;
+ temp_block_idx = block_idx + loop_start_block_x;
+ for(i = loop_start_block_x;
+ i != loop_end_block_x; i += delta_i, temp_block_idx += delta_i)
+ {
+ BoxRec temp_box;
+ temp_box.x1 = x + i * block_w;
+ temp_box.y1 = y + j * block_h;
+ temp_box.x2 = MIN(temp_box.x1 + block_w, end_x);
+ temp_box.y2 = MIN(temp_box.y1 + block_h, end_y);
+ RegionInitBoxes(&temp_region, &temp_box, 1);
+ DEBUGF("block idx %d \n",temp_block_idx);
+ DEBUGRegionPrint(&temp_region);
+ current_region = RegionCreate(NULL, 4);
+ RegionIntersect(current_region, &temp_region, region);
+ DEBUGF("i %d j %d region: \n",i ,j);
+ DEBUGRegionPrint(current_region);
+ if (RegionNumRects(current_region)) {
+ clipped_regions[k].region = current_region;
+ clipped_regions[k].block_idx = temp_block_idx;
+ k++;
+ } else
+ RegionDestroy(current_region);
+ RegionUninit(&temp_region);
+ }
+ }
+
+ *n_region = k;
+ return clipped_regions;
+}
+
+/**
+ * Do a two round clipping,
+ * first is to clip the region regard to current pixmap's
+ * block array. Then for each clipped region, do a inner
+ * block clipping. This is to make sure the final result
+ * will be shapped by inner_block_w and inner_block_h, and
+ * the final region also will not cross the pixmap's block
+ * boundary.
+ *
+ * This is mainly used by transformation support when do
+ * compositing.
+ */
+
+glamor_pixmap_clipped_regions *
+glamor_compute_clipped_regions_ext(glamor_pixmap_private *pixmap_priv,
+ RegionPtr region,
+ int *n_region,
+ int inner_block_w, int inner_block_h,
+ int reverse, int upsidedown)
+{
+ glamor_pixmap_clipped_regions * clipped_regions, *inner_regions, *result_regions;
+ int i, j, x, y, k, inner_n_regions;
+ int width, height;
+ glamor_pixmap_private_large_t *priv;
+ priv = &pixmap_priv->large;
+
+ DEBUGF("ext called \n");
+
+ if (pixmap_priv->type != GLAMOR_TEXTURE_LARGE) {
+ clipped_regions = calloc(1, sizeof(*clipped_regions));
+ if (clipped_regions == NULL) {
+ *n_region = 0;
+ return NULL;
+ }
+ clipped_regions[0].region = RegionCreate(NULL, 1);
+ clipped_regions[0].block_idx = 0;
+ RegionCopy(clipped_regions[0].region, region);
+ *n_region = 1;
+ priv->block_w = priv->base.pixmap->drawable.width;
+ priv->block_h = priv->base.pixmap->drawable.height;
+ priv->box_array = &priv->box;
+ priv->box.x1 = priv->box.y1 = 0;
+ priv->box.x2 = priv->block_w;
+ priv->box.y2 = priv->block_h;
+ } else {
+ clipped_regions = __glamor_compute_clipped_regions(priv->block_w,
+ priv->block_h,
+ priv->block_wcnt,
+ 0, 0,
+ priv->base.pixmap->drawable.width,
+ priv->base.pixmap->drawable.height,
+ region, n_region, reverse, upsidedown
+ );
+
+ if (clipped_regions == NULL) {
+ *n_region = 0;
+ return NULL;
+ }
+ }
+ if (inner_block_w >= priv->block_w
+ && inner_block_h >= priv->block_h)
+ return clipped_regions;
+ result_regions = calloc(*n_region
+ * ((priv->block_w + inner_block_w - 1)/inner_block_w)
+ * ((priv->block_h + inner_block_h - 1)/ inner_block_h),
+ sizeof(*result_regions));
+ k = 0;
+ for(i = 0; i < *n_region; i++)
+ {
+ x = priv->box_array[clipped_regions[i].block_idx].x1;
+ y = priv->box_array[clipped_regions[i].block_idx].y1;
+ width = priv->box_array[clipped_regions[i].block_idx].x2 - x;
+ height = priv->box_array[clipped_regions[i].block_idx].y2 - y;
+ inner_regions = __glamor_compute_clipped_regions(inner_block_w,
+ inner_block_h,
+ 0, x, y,
+ width,
+ height,
+ clipped_regions[i].region,
+ &inner_n_regions, reverse, upsidedown);
+ for(j = 0; j < inner_n_regions; j++)
+ {
+ result_regions[k].region = inner_regions[j].region;
+ result_regions[k].block_idx = clipped_regions[i].block_idx;
+ k++;
+ }
+ free(inner_regions);
+ }
+ *n_region = k;
+ free(clipped_regions);
+ return result_regions;
+}
+
+/*
+ *
+ * For the repeat pad mode, we can simply convert the region and
+ * let the out-of-box region can cover the needed edge of the source/mask
+ * Then apply a normal clip we can get what we want.
+ */
+static RegionPtr
+_glamor_convert_pad_region(RegionPtr region, int w, int h)
+{
+ RegionPtr pad_region;
+ int nrect;
+ BoxPtr box;
+ int overlap;
+
+ nrect = RegionNumRects(region);
+ box = RegionRects(region);
+ pad_region = RegionCreate(NULL, 4);
+ if (pad_region == NULL)
+ return NULL;
+ while(nrect--) {
+ BoxRec pad_box;
+ RegionRec temp_region;
+ pad_box = *box;
+ if (pad_box.x1 < 0 && pad_box.x2 <= 0)
+ pad_box.x2 = 1;
+ else if (pad_box.x1 >= w && pad_box.x2 > w)
+ pad_box.x1 = w - 1;
+ if (pad_box.y1 < 0 && pad_box.y2 <=0)
+ pad_box.y2 = 1;
+ else if (pad_box.y1 >= h && pad_box.y2 > h)
+ pad_box.y1 = h - 1;
+ RegionInitBoxes(&temp_region, &pad_box, 1);
+ RegionAppend(pad_region, &temp_region);
+ RegionUninit(&temp_region);
+ box++;
+ }
+ RegionValidate(pad_region, &overlap);
+ return pad_region;
+}
+
+/*
+ * For one type of large pixmap, its one direction is not exceed the
+ * size limitation, and in another word, on one direction it has only
+ * one block.
+ *
+ * This case of reflect repeating, we can optimize it and avoid repeat
+ * clip on that direction. We can just enlarge the repeat box and can
+ * cover all the dest region on that direction. But latter, we need to
+ * fixup the clipped result to get a correct coords for the subsequent
+ * processing. This function is to do the coords correction.
+ *
+ * */
+static void
+_glamor_largepixmap_reflect_fixup(short *xy1, short *xy2, int wh)
+{
+ int odd1, odd2;
+ int c1, c2;
+
+ if (*xy2 - *xy1 > wh) {
+ *xy1 = 0;
+ *xy2 = wh;
+ return;
+ }
+ modulus(*xy1, wh, c1);
+ odd1 = ((*xy1 - c1) / wh) & 0x1;
+ modulus(*xy2, wh, c2);
+ odd2 = ((*xy2 - c2) / wh) & 0x1;
+
+ if (odd1 && odd2) {
+ *xy1 = wh - c2;
+ *xy2 = wh - c1;
+ } else if (odd1 && !odd2) {
+ *xy1 = 0;
+ *xy2 = MAX(c2, wh - c1);
+ } else if (!odd1 && odd2) {
+ *xy2 = wh;
+ *xy1 = MIN(c1, wh - c2);
+ } else {
+ *xy1 = c1;
+ *xy2 = c2;
+ }
+}
+
+/**
+ * Clip the boxes regards to each pixmap's block array.
+ *
+ * Should translate the region to relative coords to the pixmap,
+ * start at (0,0).
+ *
+ * @is_transform: if it is set, it has a transform matrix.
+ *
+ */
+static glamor_pixmap_clipped_regions *
+_glamor_compute_clipped_regions(glamor_pixmap_private *pixmap_priv,
+ RegionPtr region, int *n_region,
+ int repeat_type, int is_transform,
+ int reverse, int upsidedown)
+{
+ glamor_pixmap_clipped_regions * clipped_regions;
+ BoxPtr extent;
+ int i, j;
+ RegionPtr current_region;
+ int pixmap_width, pixmap_height;
+ int m;
+ BoxRec repeat_box;
+ RegionRec repeat_region;
+ int right_shift = 0;
+ int down_shift = 0;
+ int x_center_shift = 0, y_center_shift = 0;
+ glamor_pixmap_private_large_t *priv;
+ priv = &pixmap_priv->large;
+
+ DEBUGRegionPrint(region);
+ if (pixmap_priv->type != GLAMOR_TEXTURE_LARGE) {
+ clipped_regions = calloc(1, sizeof(*clipped_regions));
+ clipped_regions[0].region = RegionCreate(NULL, 1);
+ clipped_regions[0].block_idx = 0;
+ RegionCopy(clipped_regions[0].region, region);
+ *n_region = 1;
+ return clipped_regions;
+ }
+
+ pixmap_width = priv->base.pixmap->drawable.width;
+ pixmap_height = priv->base.pixmap->drawable.height;
+ if (repeat_type == 0 || repeat_type == RepeatPad) {
+ RegionPtr saved_region = NULL;
+ if (repeat_type == RepeatPad) {
+ saved_region = region;
+ region = _glamor_convert_pad_region(saved_region, pixmap_width, pixmap_height);
+ if (region == NULL) {
+ *n_region = 0;
+ return NULL;
+ }
+ }
+ clipped_regions = __glamor_compute_clipped_regions(priv->block_w,
+ priv->block_h,
+ priv->block_wcnt,
+ 0, 0,
+ priv->base.pixmap->drawable.width,
+ priv->base.pixmap->drawable.height,
+ region, n_region, reverse, upsidedown
+ );
+ if (saved_region)
+ RegionDestroy(region);
+ return clipped_regions;
+ }
+ extent = RegionExtents(region);
+
+ x_center_shift = extent->x1 / pixmap_width;
+ if (x_center_shift < 0)
+ x_center_shift--;
+ if (abs(x_center_shift) & 1)
+ x_center_shift++;
+ y_center_shift = extent->y1 / pixmap_height;
+ if (y_center_shift < 0)
+ y_center_shift--;
+ if (abs(y_center_shift) & 1)
+ y_center_shift++;
+
+ if (extent->x1 < 0)
+ right_shift = ((-extent->x1 + pixmap_width - 1) / pixmap_width );
+ if (extent->y1 < 0)
+ down_shift = ((-extent->y1 + pixmap_height - 1) / pixmap_height );
+
+ if (right_shift != 0 || down_shift != 0) {
+ if (repeat_type == RepeatReflect) {
+ right_shift = (right_shift + 1)&~1;
+ down_shift = (down_shift + 1)&~1;
+ }
+ RegionTranslate(region, right_shift * pixmap_width, down_shift * pixmap_height);
+ }
+
+ extent = RegionExtents(region);
+ /* Tile a large pixmap to another large pixmap.
+ * We can't use the target large pixmap as the
+ * loop variable, instead we need to loop for all
+ * the blocks in the tile pixmap.
+ *
+ * simulate repeat each single block to cover the
+ * target's blocks. Two special case:
+ * a block_wcnt == 1 or block_hcnt ==1, then we
+ * only need to loop one direction as the other
+ * direction is fully included in the first block.
+ *
+ * For the other cases, just need to start
+ * from a proper shiftx/shifty, and then increase
+ * y by tile_height each time to walk trhough the
+ * target block and then walk trhough the target
+ * at x direction by increate tile_width each time.
+ *
+ * This way, we can consolidate all the sub blocks
+ * of the target boxes into one tile source's block.
+ *
+ * */
+ m = 0;
+ clipped_regions = calloc(priv->block_wcnt * priv->block_hcnt,
+ sizeof(*clipped_regions));
+ if (clipped_regions == NULL) {
+ *n_region = 0;
+ return NULL;
+ }
+ if (right_shift != 0 || down_shift != 0) {
+ DEBUGF("region to be repeated shifted \n");
+ DEBUGRegionPrint(region);
+ }
+ DEBUGF("repeat pixmap width %d height %d \n", pixmap_width, pixmap_height);
+ DEBUGF("extent x1 %d y1 %d x2 %d y2 %d \n", extent->x1, extent->y1, extent->x2, extent->y2);
+ for(j = 0; j < priv->block_hcnt; j++)
+ {
+ for(i = 0; i < priv->block_wcnt; i++)
+ {
+ int dx = pixmap_width;
+ int dy = pixmap_height;
+ int idx;
+ int shift_x;
+ int shift_y;
+ int saved_y1, saved_y2;
+ int x_idx = 0, y_idx = 0, saved_y_idx = 0;
+ RegionRec temp_region;
+ BoxRec reflect_repeat_box;
+ BoxPtr valid_repeat_box;
+
+ shift_x = (extent->x1 / pixmap_width) * pixmap_width;
+ shift_y = (extent->y1 / pixmap_height) * pixmap_height;
+ idx = j * priv->block_wcnt + i;
+ if (repeat_type == RepeatReflect) {
+ x_idx = (extent->x1 / pixmap_width);
+ y_idx = (extent->y1 / pixmap_height);
+ }
+
+ /* Construct a rect to clip the target region. */
+ repeat_box.x1 = shift_x + priv->box_array[idx].x1;
+ repeat_box.y1 = shift_y + priv->box_array[idx].y1;
+ if (priv->block_wcnt == 1) {
+ repeat_box.x2 = extent->x2;
+ dx = extent->x2 - repeat_box.x1;
+ } else
+ repeat_box.x2 = shift_x + priv->box_array[idx].x2;
+ if (priv->block_hcnt == 1) {
+ repeat_box.y2 = extent->y2;
+ dy = extent->y2 - repeat_box.y1;
+ } else
+ repeat_box.y2 = shift_y + priv->box_array[idx].y2;
+
+ current_region = RegionCreate(NULL, 4);
+ RegionInit(&temp_region, NULL, 4);
+ DEBUGF("init repeat box %d %d %d %d \n",
+ repeat_box.x1, repeat_box.y1, repeat_box.x2, repeat_box.y2);
+
+ if (repeat_type == RepeatNormal) {
+ saved_y1 = repeat_box.y1;
+ saved_y2 = repeat_box.y2;
+ for(; repeat_box.x1 < extent->x2;
+ repeat_box.x1 += dx, repeat_box.x2 += dx)
+ {
+ repeat_box.y1 = saved_y1;
+ repeat_box.y2 = saved_y2;
+ for( repeat_box.y1 = saved_y1, repeat_box.y2 = saved_y2;
+ repeat_box.y1 < extent->y2;
+ repeat_box.y1 += dy, repeat_box.y2 += dy)
+ {
+
+ RegionInitBoxes(&repeat_region, &repeat_box, 1);
+ DEBUGF("Start to clip repeat region: \n");
+ DEBUGRegionPrint(&repeat_region);
+ RegionIntersect(&temp_region, &repeat_region, region);
+ DEBUGF("clip result:\n");
+ DEBUGRegionPrint(&temp_region);
+ RegionAppend(current_region, &temp_region);
+ RegionUninit(&repeat_region);
+ }
+ }
+ } else if (repeat_type == RepeatReflect) {
+ saved_y1 = repeat_box.y1;
+ saved_y2 = repeat_box.y2;
+ saved_y_idx = y_idx;
+ for(; ; repeat_box.x1 += dx, repeat_box.x2 += dx)
+ {
+ repeat_box.y1 = saved_y1;
+ repeat_box.y2 = saved_y2;
+ y_idx = saved_y_idx;
+ reflect_repeat_box.x1 = (x_idx & 1) ?
+ ((2 * x_idx + 1) * dx - repeat_box.x2) : repeat_box.x1;
+ reflect_repeat_box.x2 = (x_idx & 1) ?
+ ((2 * x_idx + 1) * dx - repeat_box.x1) : repeat_box.x2;
+ valid_repeat_box = &reflect_repeat_box;
+
+ if (valid_repeat_box->x1 >= extent->x2)
+ break;
+ for( repeat_box.y1 = saved_y1, repeat_box.y2 = saved_y2;
+ ;
+ repeat_box.y1 += dy, repeat_box.y2 += dy)
+ {
+
+ DEBUGF("x_idx %d y_idx %d dx %d dy %d\n", x_idx, y_idx, dx, dy);
+ DEBUGF("repeat box %d %d %d %d \n",
+ repeat_box.x1, repeat_box.y1, repeat_box.x2, repeat_box.y2);
+
+ if (priv->block_hcnt > 1) {
+ reflect_repeat_box.y1 = (y_idx & 1) ?
+ ((2 * y_idx + 1) * dy - repeat_box.y2) : repeat_box.y1;
+ reflect_repeat_box.y2 = (y_idx & 1) ?
+ ((2 * y_idx + 1) * dy - repeat_box.y1) : repeat_box.y2;
+ } else {
+ reflect_repeat_box.y1 = repeat_box.y1;
+ reflect_repeat_box.y2 = repeat_box.y2;
+ }
+
+ DEBUGF("valid_repeat_box x1 %d y1 %d \n",
+ valid_repeat_box->x1, valid_repeat_box->y1);
+ if (valid_repeat_box->y1 >= extent->y2)
+ break;
+ RegionInitBoxes(&repeat_region, valid_repeat_box, 1);
+ DEBUGF("start to clip repeat[reflect] region: \n");
+ DEBUGRegionPrint(&repeat_region);
+ RegionIntersect(&temp_region, &repeat_region, region);
+ DEBUGF("result:\n");
+ DEBUGRegionPrint(&temp_region);
+ if (is_transform && RegionNumRects(&temp_region)) {
+ BoxRec temp_box;
+ BoxPtr temp_extent;
+ temp_extent = RegionExtents(&temp_region);
+ if (priv->block_wcnt > 1) {
+ if (x_idx & 1) {
+ temp_box.x1 = ((2 * x_idx + 1)*dx - temp_extent->x2);
+ temp_box.x2 = ((2 * x_idx + 1)*dx - temp_extent->x1);
+ } else {
+ temp_box.x1 = temp_extent->x1;
+ temp_box.x2 = temp_extent->x2;
+ }
+ modulus(temp_box.x1, pixmap_width, temp_box.x1);
+ modulus(temp_box.x2, pixmap_width, temp_box.x2);
+ if (temp_box.x2 == 0) temp_box.x2 = pixmap_width;
+ } else {
+ temp_box.x1 = temp_extent->x1;
+ temp_box.x2 = temp_extent->x2;
+ _glamor_largepixmap_reflect_fixup(&temp_box.x1, &temp_box.x2, pixmap_width);
+ }
+
+ if (priv->block_hcnt > 1) {
+ if (y_idx & 1) {
+ temp_box.y1 = ((2 * y_idx + 1)*dy - temp_extent->y2);
+ temp_box.y2 = ((2 * y_idx + 1)*dy - temp_extent->y1);
+ } else {
+ temp_box.y1 = temp_extent->y1;
+ temp_box.y2 = temp_extent->y2;
+ }
+
+ modulus(temp_box.y1, pixmap_height, temp_box.y1);
+ modulus(temp_box.y2, pixmap_height, temp_box.y2);
+ if (temp_box.y2 == 0) temp_box.y2 = pixmap_height;
+ } else {
+ temp_box.y1 = temp_extent->y1;
+ temp_box.y2 = temp_extent->y2;
+ _glamor_largepixmap_reflect_fixup(&temp_box.y1, &temp_box.y2, pixmap_height);
+ }
+
+ RegionInitBoxes(&temp_region, &temp_box, 1);
+ RegionTranslate(&temp_region, x_center_shift * pixmap_width, y_center_shift * pixmap_height);
+ DEBUGF("for transform result:\n");
+ DEBUGRegionPrint(&temp_region);
+ }
+ RegionAppend(current_region, &temp_region);
+ RegionUninit(&repeat_region);
+ y_idx++;
+ }
+ x_idx++;
+ }
+ }
+ DEBUGF("dx %d dy %d \n", dx, dy);
+
+ if (RegionNumRects(current_region)) {
+
+ if ((right_shift != 0 || down_shift != 0) && !(is_transform && repeat_type == RepeatReflect))
+ RegionTranslate(current_region,
+ -right_shift * pixmap_width,
+ -down_shift * pixmap_height);
+ clipped_regions[m].region = current_region;
+ clipped_regions[m].block_idx = idx;
+ m++;
+ } else
+ RegionDestroy(current_region);
+ RegionUninit(&temp_region);
+ }
+ }
+
+ if (right_shift != 0 || down_shift != 0)
+ RegionTranslate(region, -right_shift * pixmap_width, -down_shift * pixmap_height);
+ *n_region = m;
+
+ return clipped_regions;
+}
+
+glamor_pixmap_clipped_regions *
+glamor_compute_clipped_regions(glamor_pixmap_private *priv, RegionPtr region,
+ int *n_region, int repeat_type,
+ int reverse, int upsidedown)
+{
+ return _glamor_compute_clipped_regions(priv, region, n_region, repeat_type, 0, reverse, upsidedown);
+}
+
+/* XXX overflow still exist. maybe we need to change to use region32.
+ * by default. Or just use region32 for repeat cases?
+ **/
+glamor_pixmap_clipped_regions *
+glamor_compute_transform_clipped_regions(glamor_pixmap_private *priv, struct pixman_transform *transform,
+ RegionPtr region, int *n_region, int dx, int dy, int repeat_type,
+ int reverse, int upsidedown)
+{
+ BoxPtr temp_extent;
+ struct pixman_box32 temp_box;
+ struct pixman_box16 short_box;
+ RegionPtr temp_region;
+ glamor_pixmap_clipped_regions *ret;
+
+ temp_region = RegionCreate(NULL, 4);
+ temp_extent = RegionExtents(region);
+ DEBUGF("dest region \n");
+ DEBUGRegionPrint(region);
+ /* dx/dy may exceed MAX SHORT. we have to use
+ * a box32 to represent it.*/
+ temp_box.x1 = temp_extent->x1 + dx;
+ temp_box.x2 = temp_extent->x2 + dx;
+ temp_box.y1 = temp_extent->y1 + dy;
+ temp_box.y2 = temp_extent->y2 + dy;
+
+ DEBUGF("source box %d %d %d %d \n", temp_box.x1, temp_box.y1, temp_box.x2, temp_box.y2);
+ if (transform)
+ glamor_get_transform_extent_from_box(&temp_box, transform);
+ if (repeat_type == RepeatNone) {
+ if (temp_box.x1 < 0) temp_box.x1 = 0;
+ if (temp_box.y1 < 0) temp_box.y1 = 0;
+ temp_box.x2 = MIN(temp_box.x2, priv->base.pixmap->drawable.width);
+ temp_box.y2 = MIN(temp_box.y2, priv->base.pixmap->drawable.height);
+ }
+ /* Now copy back the box32 to a box16 box. */
+ short_box.x1 = temp_box.x1;
+ short_box.y1 = temp_box.y1;
+ short_box.x2 = temp_box.x2;
+ short_box.y2 = temp_box.y2;
+ RegionInitBoxes(temp_region, &short_box, 1);
+ DEBUGF("copy to temp source region \n");
+ DEBUGRegionPrint(temp_region);
+ ret = _glamor_compute_clipped_regions(priv,
+ temp_region,
+ n_region,
+ repeat_type,
+ 1, reverse,
+ upsidedown);
+ DEBUGF("n_regions = %d \n", *n_region);
+ RegionDestroy(temp_region);
+
+ return ret;
+}
+/*
+ * As transform and repeatpad mode.
+ * We may get a clipped result which in multipe regions.
+ * It's not easy to do a 2nd round clipping just as we do
+ * without transform/repeatPad. As it's not easy to reverse
+ * the 2nd round clipping result with a transform/repeatPad mode,
+ * or even impossible for some transformation.
+ *
+ * So we have to merge the fragmental region into one region
+ * if the clipped result cross the region boundary.
+ */
+static void
+glamor_merge_clipped_regions(glamor_pixmap_private *pixmap_priv, int repeat_type,
+ glamor_pixmap_clipped_regions *clipped_regions,
+ int *n_regions, int *need_clean_fbo)
+{
+ BoxPtr temp_extent;
+ BoxRec temp_box, copy_box;
+ RegionPtr temp_region;
+ glamor_pixmap_private *temp_priv;
+ PixmapPtr temp_pixmap;
+ int overlap;
+ int i;
+ int pixmap_width, pixmap_height;
+ glamor_pixmap_private_large_t *priv;
+
+ priv = &pixmap_priv->large;
+ pixmap_width = priv->base.pixmap->drawable.width;
+ pixmap_height = priv->base.pixmap->drawable.height;
+
+ temp_region = RegionCreate(NULL, 4);
+ for(i = 0; i < *n_regions; i++)
+ {
+ DEBUGF("Region %d:\n", i);
+ DEBUGRegionPrint(clipped_regions[i].region);
+ RegionAppend(temp_region, clipped_regions[i].region);
+ }
+
+ RegionValidate(temp_region, &overlap);
+ DEBUGF("temp region: \n");
+ DEBUGRegionPrint(temp_region);
+ temp_extent = RegionExtents(temp_region);
+
+ temp_box = *temp_extent;
+
+ DEBUGF("need copy region: \n");
+ DEBUGF("%d %d %d %d \n", temp_box.x1, temp_box.y1, temp_box.x2, temp_box.y2);
+ temp_pixmap = glamor_create_pixmap(priv->base.pixmap->drawable.pScreen,
+ temp_box.x2 - temp_box.x1,
+ temp_box.y2 - temp_box.y1,
+ priv->base.pixmap->drawable.depth,
+ GLAMOR_CREATE_PIXMAP_FIXUP);
+ if (temp_pixmap == NULL) {
+ assert(0);
+ return;
+ }
+
+ temp_priv = glamor_get_pixmap_private(temp_pixmap);
+ assert(temp_priv->type != GLAMOR_TEXTURE_LARGE);
+
+ priv->box = temp_box;
+ if (temp_extent->x1 >= 0 && temp_extent->x2 <= pixmap_width
+ && temp_extent->y1 >= 0 && temp_extent->y2 <= pixmap_height) {
+ int dx, dy;
+ copy_box.x1 = 0;
+ copy_box.y1 = 0;
+ copy_box.x2 = temp_extent->x2 - temp_extent->x1;
+ copy_box.y2 = temp_extent->y2 - temp_extent->y1;
+ dx = temp_extent->x1;
+ dy = temp_extent->y1;
+ glamor_copy_n_to_n(&priv->base.pixmap->drawable,
+ &temp_pixmap->drawable,
+ NULL, &copy_box, 1, dx,
+ dy, 0, 0, 0, NULL);
+// glamor_solid(temp_pixmap, 0, 0, temp_pixmap->drawable.width,
+// temp_pixmap->drawable.height, GXcopy, 0xffffffff, 0xff00);
+ } else {
+ for (i = 0; i < *n_regions; i++)
+ {
+ BoxPtr box;
+ int nbox;
+ box = REGION_RECTS(clipped_regions[i].region);
+ nbox = REGION_NUM_RECTS(clipped_regions[i].region);
+ while(nbox--) {
+ int dx, dy, c, d;
+ DEBUGF("box x1 %d y1 %d x2 %d y2 %d \n",
+ box->x1, box->y1, box->x2, box->y2);
+ modulus(box->x1, pixmap_width, c);
+ dx = c - (box->x1 - temp_box.x1);
+ copy_box.x1 = box->x1 - temp_box.x1;
+ copy_box.x2 = box->x2 - temp_box.x1;
+
+ modulus(box->y1, pixmap_height, d);
+ dy = d - (box->y1 - temp_box.y1);
+ copy_box.y1 = box->y1 - temp_box.y1;
+ copy_box.y2 = box->y2 - temp_box.y1;
+
+ DEBUGF("copying box %d %d %d %d, dx %d dy %d\n",
+ copy_box.x1, copy_box.y1, copy_box.x2,
+ copy_box.y2, dx, dy);
+
+ glamor_copy_n_to_n(&priv->base.pixmap->drawable,
+ &temp_pixmap->drawable,
+ NULL, &copy_box, 1, dx,
+ dy, 0, 0, 0, NULL);
+ box++;
+ }
+ }
+ //glamor_solid(temp_pixmap, 0, 0, temp_pixmap->drawable.width,
+ // temp_pixmap->drawable.height, GXcopy, 0xffffffff, 0xff);
+ }
+ /* The first region will be released at caller side. */
+ for(i = 1; i < *n_regions; i++)
+ RegionDestroy(clipped_regions[i].region);
+ RegionDestroy(temp_region);
+ priv->box = temp_box;
+ priv->base.fbo = glamor_pixmap_detach_fbo(temp_priv);
+ DEBUGF("priv box x1 %d y1 %d x2 %d y2 %d \n",
+ priv->box.x1, priv->box.y1, priv->box.x2, priv->box.y2);
+ glamor_destroy_pixmap(temp_pixmap);
+ *need_clean_fbo = 1;
+ *n_regions = 1;
+}
+
+
+
+/**
+ * Given an expected transformed block width and block height,
+ *
+ * This function calculate a new block width and height which
+ * guarantee the transform result will not exceed the given
+ * block width and height.
+ *
+ * For large block width and height (> 2048), we choose a
+ * smaller new width and height and to reduce the cross region
+ * boundary and can avoid some overhead.
+ *
+ **/
+Bool
+glamor_get_transform_block_size(struct pixman_transform *transform,
+ int block_w, int block_h,
+ int *transformed_block_w,
+ int *transformed_block_h)
+{
+ double a,b,c,d,e,f,g,h;
+ double scale;
+ int width, height;
+ a = pixman_fixed_to_double(transform->matrix[0][0]);
+ b = pixman_fixed_to_double(transform->matrix[0][1]);
+ c = pixman_fixed_to_double(transform->matrix[1][0]);
+ d = pixman_fixed_to_double(transform->matrix[1][1]);
+ scale = pixman_fixed_to_double(transform->matrix[2][2]);
+ if (block_w > 2048) {
+ /* For large block size, we shrink it to smaller box,
+ * thus latter we may get less cross boundary regions and
+ * thus can avoid some extra copy.
+ *
+ **/
+ width = block_w / 4;
+ height = block_h / 4;
+ } else {
+ width = block_w - 2;
+ height = block_h - 2;
+ }
+ e = a + b;
+ f = c + d;
+
+ g = a - b;
+ h = c - d;
+
+ e = MIN(block_w, floor(width * scale) / MAX(fabs(e), fabs(g)));
+ f = MIN(block_h, floor(height * scale) / MAX(fabs(f), fabs(h)));
+ *transformed_block_w = MIN(e, f) - 1;
+ *transformed_block_h = *transformed_block_w;
+ if (*transformed_block_w <= 0 || *transformed_block_h <= 0)
+ return FALSE;
+ DEBUGF("original block_w/h %d %d, fixed %d %d \n", block_w, block_h,
+ *transformed_block_w, *transformed_block_h);
+ return TRUE;
+}
+
+#define VECTOR_FROM_POINT(p, x, y) \
+ p.v[0] = x; \
+ p.v[1] = y; \
+ p.v[2] = 1.0;
+void
+glamor_get_transform_extent_from_box(struct pixman_box32 *box,
+ struct pixman_transform *transform)
+{
+ struct pixman_f_vector p0, p1, p2, p3;
+ float min_x, min_y, max_x, max_y;
+
+ struct pixman_f_transform ftransform;
+
+ VECTOR_FROM_POINT(p0, box->x1, box->y1)
+ VECTOR_FROM_POINT(p1, box->x2, box->y1)
+ VECTOR_FROM_POINT(p2, box->x2, box->y2)
+ VECTOR_FROM_POINT(p3, box->x1, box->y2)
+
+ pixman_f_transform_from_pixman_transform(&ftransform, transform);
+ pixman_f_transform_point(&ftransform, &p0);
+ pixman_f_transform_point(&ftransform, &p1);
+ pixman_f_transform_point(&ftransform, &p2);
+ pixman_f_transform_point(&ftransform, &p3);
+
+ min_x = MIN(p0.v[0], p1.v[0]);
+ min_x = MIN(min_x, p2.v[0]);
+ min_x = MIN(min_x, p3.v[0]);
+
+ min_y = MIN(p0.v[1], p1.v[1]);
+ min_y = MIN(min_y, p2.v[1]);
+ min_y = MIN(min_y, p3.v[1]);
+
+ max_x = MAX(p0.v[0], p1.v[0]);
+ max_x = MAX(max_x, p2.v[0]);
+ max_x = MAX(max_x, p3.v[0]);
+
+ max_y = MAX(p0.v[1], p1.v[1]);
+ max_y = MAX(max_y, p2.v[1]);
+ max_y = MAX(max_y, p3.v[1]);
+ box->x1 = floor(min_x) - 1;
+ box->y1 = floor(min_y) - 1;
+ box->x2 = ceil(max_x) + 1;
+ box->y2 = ceil(max_y) + 1;
+}
+
+static void
+_glamor_process_transformed_clipped_region(glamor_pixmap_private *priv,
+ int repeat_type,
+ glamor_pixmap_clipped_regions *clipped_regions,
+ int *n_regions, int *need_clean_fbo)
+{
+ int shift_x, shift_y;
+ if (*n_regions != 1) {
+ /* Merge all source regions into one region. */
+ glamor_merge_clipped_regions(priv, repeat_type,
+ clipped_regions, n_regions,
+ need_clean_fbo);
+ } else {
+ SET_PIXMAP_FBO_CURRENT(priv,
+ clipped_regions[0].block_idx);
+ if (repeat_type == RepeatReflect || repeat_type == RepeatNormal) {
+ /* The required source areas are in one region,
+ * we need to shift the corresponding box's coords to proper position,
+ * thus we can calculate the relative coords correctly.*/
+ BoxPtr temp_box;
+ int rem;
+ temp_box = RegionExtents(clipped_regions[0].region);
+ modulus(temp_box->x1, priv->base.pixmap->drawable.width, rem);
+ shift_x = (temp_box->x1 - rem) / priv->base.pixmap->drawable.width;
+ modulus(temp_box->y1, priv->base.pixmap->drawable.height, rem);
+ shift_y = (temp_box->y1 - rem) / priv->base.pixmap->drawable.height;
+
+ if (shift_x != 0) {
+ priv->large.box.x1 += shift_x * priv->base.pixmap->drawable.width;
+ priv->large.box.x2 += shift_x * priv->base.pixmap->drawable.width;
+ }
+ if (shift_y != 0) {
+ priv->large.box.y1 += shift_y * priv->base.pixmap->drawable.height;
+ priv->large.box.y2 += shift_y * priv->base.pixmap->drawable.height;
+ }
+ }
+ }
+}
+
+
+Bool
+glamor_composite_largepixmap_region(CARD8 op,
+ PicturePtr source,
+ PicturePtr mask,
+ PicturePtr dest,
+ glamor_pixmap_private * source_pixmap_priv,
+ glamor_pixmap_private * mask_pixmap_priv,
+ glamor_pixmap_private * dest_pixmap_priv,
+ RegionPtr region, Bool force_clip,
+ INT16 x_source,
+ INT16 y_source,
+ INT16 x_mask,
+ INT16 y_mask,
+ INT16 x_dest, INT16 y_dest,
+ CARD16 width, CARD16 height)
+{
+ glamor_screen_private *glamor_priv;
+ glamor_pixmap_clipped_regions *clipped_dest_regions;
+ glamor_pixmap_clipped_regions *clipped_source_regions;
+ glamor_pixmap_clipped_regions *clipped_mask_regions;
+ int n_dest_regions;
+ int n_mask_regions;
+ int n_source_regions;
+ int i,j,k;
+ int need_clean_source_fbo = 0;
+ int need_clean_mask_fbo = 0;
+ int is_normal_source_fbo = 0;
+ int is_normal_mask_fbo = 0;
+ int fixed_block_width, fixed_block_height;
+ int null_source, null_mask;
+ glamor_pixmap_private * need_free_source_pixmap_priv = NULL;
+ glamor_pixmap_private * need_free_mask_pixmap_priv = NULL;
+ int source_repeat_type = 0, mask_repeat_type = 0;
+ int ok = TRUE;
+
+ if (source->repeat)
+ source_repeat_type = source->repeatType;
+ else
+ source_repeat_type = RepeatNone;
+
+ if (mask && mask->repeat)
+ mask_repeat_type = mask->repeatType;
+ else
+ mask_repeat_type = RepeatNone;
+
+ glamor_priv = dest_pixmap_priv->base.glamor_priv;
+ fixed_block_width = glamor_priv->max_fbo_size;
+ fixed_block_height = glamor_priv->max_fbo_size;
+ /* If we got an totally out-of-box region for a source or mask
+ * region without repeat, we need to set it as null_source and
+ * give it a solid color (0,0,0,0). */
+ null_source = 0;
+ null_mask = 0;
+ RegionTranslate(region, -dest->pDrawable->x,
+ -dest->pDrawable->y);
+
+ /* need to transform the dest region to the correct sourcei/mask region.
+ * it's a little complex, as one single edge of the
+ * target region may be transformed to cross a block boundary of the
+ * source or mask. Then it's impossible to handle it as usual way.
+ * We may have to split the original dest region to smaller region, and
+ * make sure each region's transformed region can fit into one texture,
+ * and then continue this loop again, and each time when a transformed region
+ * cross the bound, we need to copy it to a single pixmap and do the composition
+ * with the new pixmap. If the transformed region doesn't cross a source/mask's
+ * boundary then we don't need to copy.
+ *
+ */
+ if (source_pixmap_priv
+ && source->transform
+ && source_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
+ int source_transformed_block_width, source_transformed_block_height;
+ if (!glamor_get_transform_block_size(source->transform,
+ source_pixmap_priv->large.block_w,
+ source_pixmap_priv->large.block_h,
+ &source_transformed_block_width,
+ &source_transformed_block_height)) {
+ DEBUGF("source block size less than 1, fallback.\n");
+ RegionTranslate(region, dest->pDrawable->x,
+ dest->pDrawable->y);
+ return FALSE;
+ }
+ fixed_block_width = min(fixed_block_width , source_transformed_block_width);
+ fixed_block_height = min(fixed_block_height , source_transformed_block_height);
+ DEBUGF("new source block size %d x %d \n", fixed_block_width, fixed_block_height);
+ }
+
+ if (mask_pixmap_priv
+ && mask->transform
+ && mask_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
+ int mask_transformed_block_width, mask_transformed_block_height;
+ if (!glamor_get_transform_block_size(mask->transform,
+ mask_pixmap_priv->large.block_w,
+ mask_pixmap_priv->large.block_h,
+ &mask_transformed_block_width,
+ &mask_transformed_block_height)) {
+ DEBUGF("mask block size less than 1, fallback.\n");
+ RegionTranslate(region, dest->pDrawable->x,
+ dest->pDrawable->y);
+ return FALSE;
+ }
+ fixed_block_width = min(fixed_block_width , mask_transformed_block_width);
+ fixed_block_height = min(fixed_block_height , mask_transformed_block_height);
+ DEBUGF("new mask block size %d x %d \n", fixed_block_width, fixed_block_height);
+ }
+
+ /*compute the correct block width and height whose transformed source/mask
+ *region can fit into one texture.*/
+ if (force_clip || fixed_block_width < glamor_priv->max_fbo_size
+ || fixed_block_height < glamor_priv->max_fbo_size)
+ clipped_dest_regions = glamor_compute_clipped_regions_ext(dest_pixmap_priv,
+ region,
+ &n_dest_regions,
+ fixed_block_width,
+ fixed_block_height,
+ 0, 0);
+ else
+ clipped_dest_regions = glamor_compute_clipped_regions(dest_pixmap_priv,
+ region,
+ &n_dest_regions,
+ 0, 0, 0);
+ DEBUGF("dest clipped result %d region: \n", n_dest_regions);
+ if (source_pixmap_priv
+ && (source_pixmap_priv == dest_pixmap_priv || source_pixmap_priv == mask_pixmap_priv)
+ && source_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
+ /* XXX self-copy...*/
+ need_free_source_pixmap_priv = source_pixmap_priv;
+ source_pixmap_priv = malloc(sizeof(*source_pixmap_priv));
+ *source_pixmap_priv = *need_free_source_pixmap_priv;
+ need_free_source_pixmap_priv = source_pixmap_priv;
+ }
+ assert(mask_pixmap_priv != dest_pixmap_priv);
+
+ for(i = 0; i < n_dest_regions; i++)
+ {
+ DEBUGF("dest region %d idx %d\n", i, clipped_dest_regions[i].block_idx);
+ DEBUGRegionPrint(clipped_dest_regions[i].region);
+ SET_PIXMAP_FBO_CURRENT(dest_pixmap_priv, clipped_dest_regions[i].block_idx);
+ if ( source_pixmap_priv && source_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
+ if (!source->transform && source_repeat_type != RepeatPad) {
+ RegionTranslate(clipped_dest_regions[i].region,
+ x_source - x_dest,
+ y_source - y_dest);
+ clipped_source_regions = glamor_compute_clipped_regions(source_pixmap_priv,
+ clipped_dest_regions[i].region,
+ &n_source_regions, source_repeat_type,
+ 0, 0);
+ is_normal_source_fbo = 1;
+ }
+ else {
+ clipped_source_regions = glamor_compute_transform_clipped_regions(source_pixmap_priv,
+ source->transform,
+ clipped_dest_regions[i].region,
+ &n_source_regions,
+ x_source - x_dest, y_source - y_dest,
+ source_repeat_type, 0, 0);
+ is_normal_source_fbo = 0;
+ if (n_source_regions == 0) {
+ /* Pad the out-of-box region to (0,0,0,0). */
+ null_source = 1;
+ n_source_regions = 1;
+ } else
+ _glamor_process_transformed_clipped_region(source_pixmap_priv,
+ source_repeat_type, clipped_source_regions, &n_source_regions,
+ &need_clean_source_fbo);
+ }
+ DEBUGF("source clipped result %d region: \n", n_source_regions);
+ for(j = 0; j < n_source_regions; j++)
+ {
+ if (is_normal_source_fbo)
+ SET_PIXMAP_FBO_CURRENT(source_pixmap_priv,
+ clipped_source_regions[j].block_idx);
+
+ if (mask_pixmap_priv && mask_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
+ if (is_normal_mask_fbo && is_normal_source_fbo) {
+ /* both mask and source are normal fbo box without transform or repeatpad.
+ * The region is clipped against source and then we clip it against mask here.*/
+ DEBUGF("source region %d idx %d\n", j, clipped_source_regions[j].block_idx);
+ DEBUGRegionPrint(clipped_source_regions[j].region);
+ RegionTranslate(clipped_source_regions[j].region,
+ - x_source + x_mask,
+ - y_source + y_mask);
+ clipped_mask_regions = glamor_compute_clipped_regions(mask_pixmap_priv,
+ clipped_source_regions[j].region,
+ &n_mask_regions, mask_repeat_type,
+ 0, 0);
+ is_normal_mask_fbo = 1;
+ } else if (is_normal_mask_fbo && !is_normal_source_fbo) {
+ assert(n_source_regions == 1);
+ /* The source fbo is not a normal fbo box, it has transform or repeatpad.
+ * the valid clip region should be the clip dest region rather than the
+ * clip source region.*/
+ RegionTranslate(clipped_dest_regions[i].region,
+ - x_dest + x_mask,
+ - y_dest + y_mask);
+ clipped_mask_regions = glamor_compute_clipped_regions(mask_pixmap_priv,
+ clipped_dest_regions[i].region,
+ &n_mask_regions, mask_repeat_type,
+ 0, 0);
+ is_normal_mask_fbo = 1;
+ } else {
+ /* This mask region has transform or repeatpad, we need clip it agains the previous
+ * valid region rather than the mask region. */
+ if (!is_normal_source_fbo)
+ clipped_mask_regions = glamor_compute_transform_clipped_regions(mask_pixmap_priv,
+ mask->transform,
+ clipped_dest_regions[i].region,
+ &n_mask_regions,
+ x_mask - x_dest,
+ y_mask - y_dest,
+ mask_repeat_type, 0, 0);
+ else
+ clipped_mask_regions = glamor_compute_transform_clipped_regions(mask_pixmap_priv,
+ mask->transform,
+ clipped_source_regions[j].region,
+ &n_mask_regions,
+ x_mask - x_source, y_mask - y_source,
+ mask_repeat_type, 0, 0);
+ is_normal_mask_fbo = 0;
+ if (n_mask_regions == 0) {
+ /* Pad the out-of-box region to (0,0,0,0). */
+ null_mask = 1;
+ n_mask_regions = 1;
+ } else
+ _glamor_process_transformed_clipped_region(mask_pixmap_priv,
+ mask_repeat_type, clipped_mask_regions, &n_mask_regions,
+ &need_clean_mask_fbo);
+ }
+ DEBUGF("mask clipped result %d region: \n", n_mask_regions);
+
+#define COMPOSITE_REGION(region) do { \
+ if (!glamor_composite_clipped_region(op, \
+ null_source ? NULL : source, \
+ null_mask ? NULL : mask, dest, \
+ null_source ? NULL : source_pixmap_priv, \
+ null_mask ? NULL : mask_pixmap_priv, \
+ dest_pixmap_priv, region, \
+ x_source, y_source, x_mask, y_mask, \
+ x_dest, y_dest)) { \
+ assert(0); \
+ } \
+ } while(0)
+
+ for(k = 0; k < n_mask_regions; k++)
+ {
+ DEBUGF("mask region %d idx %d\n", k, clipped_mask_regions[k].block_idx);
+ DEBUGRegionPrint(clipped_mask_regions[k].region);
+ if (is_normal_mask_fbo) {
+ SET_PIXMAP_FBO_CURRENT(mask_pixmap_priv,
+ clipped_mask_regions[k].block_idx);
+ DEBUGF("mask fbo off %d %d \n",
+ mask_pixmap_priv->large.box.x1,
+ mask_pixmap_priv->large.box.y1);
+ DEBUGF("start composite mask hasn't transform.\n");
+ RegionTranslate(clipped_mask_regions[k].region,
+ x_dest - x_mask + dest->pDrawable->x,
+ y_dest - y_mask + dest->pDrawable->y);
+ COMPOSITE_REGION(clipped_mask_regions[k].region);
+ } else if (!is_normal_mask_fbo && !is_normal_source_fbo) {
+ DEBUGF("start composite both mask and source have transform.\n");
+ RegionTranslate(clipped_dest_regions[i].region,
+ dest->pDrawable->x,
+ dest->pDrawable->y);
+ COMPOSITE_REGION(clipped_dest_regions[i].region);
+ } else {
+ DEBUGF("start composite only mask has transform.\n");
+ RegionTranslate(clipped_source_regions[j].region,
+ x_dest - x_source + dest->pDrawable->x,
+ y_dest - y_source + dest->pDrawable->y);
+ COMPOSITE_REGION(clipped_source_regions[j].region);
+ }
+ RegionDestroy(clipped_mask_regions[k].region);
+ }
+ free(clipped_mask_regions);
+ if (null_mask) null_mask = 0;
+ if (need_clean_mask_fbo) {
+ assert(is_normal_mask_fbo == 0);
+ glamor_destroy_fbo(mask_pixmap_priv->base.fbo);
+ mask_pixmap_priv->base.fbo = NULL;
+ need_clean_mask_fbo = 0;
+ }
+ } else {
+ if (is_normal_source_fbo) {
+ RegionTranslate(clipped_source_regions[j].region,
+ -x_source + x_dest + dest->pDrawable->x,
+ -y_source + y_dest + dest->pDrawable->y);
+ COMPOSITE_REGION(clipped_source_regions[j].region);
+ } else {
+ /* Source has transform or repeatPad. dest regions is the right
+ * region to do the composite. */
+ RegionTranslate(clipped_dest_regions[i].region,
+ dest->pDrawable->x,
+ dest->pDrawable->y);
+ COMPOSITE_REGION(clipped_dest_regions[i].region);
+ }
+ }
+ if (clipped_source_regions && clipped_source_regions[j].region)
+ RegionDestroy(clipped_source_regions[j].region);
+ }
+ free(clipped_source_regions);
+ if (null_source) null_source = 0;
+ if (need_clean_source_fbo) {
+ assert(is_normal_source_fbo == 0);
+ glamor_destroy_fbo(source_pixmap_priv->base.fbo);
+ source_pixmap_priv->base.fbo = NULL;
+ need_clean_source_fbo = 0;
+ }
+ }
+ else {
+ if (mask_pixmap_priv && mask_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
+ if (!mask->transform && mask_repeat_type != RepeatPad) {
+ RegionTranslate(clipped_dest_regions[i].region,
+ x_mask - x_dest,
+ y_mask - y_dest);
+ clipped_mask_regions = glamor_compute_clipped_regions(mask_pixmap_priv,
+ clipped_dest_regions[i].region,
+ &n_mask_regions, mask_repeat_type, 0, 0);
+ is_normal_mask_fbo = 1;
+ }
+ else {
+ clipped_mask_regions = glamor_compute_transform_clipped_regions(mask_pixmap_priv,
+ mask->transform,
+ clipped_dest_regions[i].region,
+ &n_mask_regions,
+ x_mask - x_dest, y_mask - y_dest,
+ mask_repeat_type, 0, 0);
+ is_normal_mask_fbo = 0;
+ if (n_mask_regions == 0) {
+ /* Pad the out-of-box region to (0,0,0,0). */
+ null_mask = 1;
+ n_mask_regions = 1;
+ } else
+ _glamor_process_transformed_clipped_region(mask_pixmap_priv,
+ mask_repeat_type, clipped_mask_regions, &n_mask_regions,
+ &need_clean_mask_fbo);
+ }
+
+ for(k = 0; k < n_mask_regions; k++)
+ {
+ DEBUGF("mask region %d idx %d\n", k, clipped_mask_regions[k].block_idx);
+ DEBUGRegionPrint(clipped_mask_regions[k].region);
+ if (is_normal_mask_fbo) {
+ SET_PIXMAP_FBO_CURRENT(mask_pixmap_priv,
+ clipped_mask_regions[k].block_idx);
+ RegionTranslate(clipped_mask_regions[k].region,
+ x_dest - x_mask + dest->pDrawable->x,
+ y_dest - y_mask + dest->pDrawable->y);
+ COMPOSITE_REGION(clipped_mask_regions[k].region);
+ } else {
+ RegionTranslate(clipped_dest_regions[i].region,
+ dest->pDrawable->x,
+ dest->pDrawable->y);
+ COMPOSITE_REGION(clipped_dest_regions[i].region);
+ }
+ RegionDestroy(clipped_mask_regions[k].region);
+ }
+ free(clipped_mask_regions);
+ if (null_mask) null_mask = 0;
+ if (need_clean_mask_fbo) {
+ glamor_destroy_fbo(mask_pixmap_priv->base.fbo);
+ mask_pixmap_priv->base.fbo = NULL;
+ need_clean_mask_fbo = 0;
+ }
+ }
+ else {
+ RegionTranslate(clipped_dest_regions[i].region,
+ dest->pDrawable->x,
+ dest->pDrawable->y);
+ COMPOSITE_REGION(clipped_dest_regions[i].region);
+ }
+ }
+ RegionDestroy(clipped_dest_regions[i].region);
+ }
+ free(clipped_dest_regions);
+ free(need_free_source_pixmap_priv);
+ free(need_free_mask_pixmap_priv);
+ ok = TRUE;
+ return ok;
+}
diff --git a/xorg-server/glamor/glamor_picture.c b/xorg-server/glamor/glamor_picture.c
new file mode 100644
index 000000000..7d5ffbb76
--- /dev/null
+++ b/xorg-server/glamor/glamor_picture.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ * Copyright © 1998 Keith Packard
+ *
+ * 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.
+ *
+ * Authors:
+ * Zhigang Gong <zhigang.gong@gmail.com>
+ *
+ */
+
+#include <stdlib.h>
+
+#include "glamor_priv.h"
+#include "mipict.h"
+
+/* Upload picture to texture. We may need to flip the y axis or
+ * wire alpha to 1. So we may conditional create fbo for the picture.
+ * */
+enum glamor_pixmap_status
+glamor_upload_picture_to_texture(PicturePtr picture)
+{
+ PixmapPtr pixmap;
+ assert(picture->pDrawable);
+ pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
+
+ return glamor_upload_pixmap_to_texture(pixmap);
+}
+
+
+Bool
+glamor_prepare_access_picture(PicturePtr picture, glamor_access_t access)
+{
+ if (!picture || !picture->pDrawable)
+ return TRUE;
+
+ return glamor_prepare_access(picture->pDrawable, access);
+}
+
+void
+glamor_finish_access_picture(PicturePtr picture, glamor_access_t access)
+{
+ if (!picture || !picture->pDrawable)
+ return;
+
+ glamor_finish_access(picture->pDrawable, access);
+}
+
+/*
+ * We should already have drawable attached to it, if it has one.
+ * Then set the attached pixmap to is_picture format, and set
+ * the pict format.
+ * */
+int
+glamor_create_picture(PicturePtr picture)
+{
+ PixmapPtr pixmap;
+ glamor_pixmap_private *pixmap_priv;
+
+ if (!picture || !picture->pDrawable)
+ return 0;
+
+ pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ if (!pixmap_priv) {
+ /* We must create a pixmap priv to track the picture format even
+ * if the pixmap is a pure in memory pixmap. The reason is that
+ * we may need to upload this pixmap to a texture on the fly. During
+ * the uploading, we need to know the picture format. */
+ glamor_set_pixmap_type(pixmap, GLAMOR_MEMORY);
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ } else {
+ if (GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
+ /* If the picture format is not compatible with glamor fbo format,
+ * we have to mark this pixmap as a separated texture, and don't
+ * fallback to DDX layer. */
+ if (pixmap_priv->type == GLAMOR_TEXTURE_DRM
+ && !glamor_pict_format_is_compatible(picture->format,
+ pixmap->drawable.depth))
+ glamor_set_pixmap_type(pixmap, GLAMOR_SEPARATE_TEXTURE);
+ }
+ }
+
+ pixmap_priv->base.is_picture = 1;
+ pixmap_priv->base.picture = picture;
+
+ return miCreatePicture(picture);
+}
+
+void
+glamor_destroy_picture(PicturePtr picture)
+{
+ PixmapPtr pixmap;
+ glamor_pixmap_private *pixmap_priv;
+
+ if (!picture || !picture->pDrawable)
+ return;
+
+ pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+
+ if (pixmap_priv) {
+ pixmap_priv->base.is_picture = 0;
+ pixmap_priv->base.picture = NULL;
+ }
+ miDestroyPicture(picture);
+}
+
+void
+glamor_picture_format_fixup(PicturePtr picture,
+ glamor_pixmap_private * pixmap_priv)
+{
+ pixmap_priv->base.picture = picture;
+}
diff --git a/xorg-server/glamor/glamor_pixmap.c b/xorg-server/glamor/glamor_pixmap.c
new file mode 100644
index 000000000..84694ec3c
--- /dev/null
+++ b/xorg-server/glamor/glamor_pixmap.c
@@ -0,0 +1,1433 @@
+/*
+ * Copyright © 2001 Keith Packard
+ * Copyright © 2008 Intel Corporation
+ *
+ * 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.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ * Zhigang Gong <zhigang.gong@linux.intel.com>
+ *
+ */
+
+#include <stdlib.h>
+
+#include "glamor_priv.h"
+/**
+ * Sets the offsets to add to coordinates to make them address the same bits in
+ * the backing drawable. These coordinates are nonzero only for redirected
+ * windows.
+ */
+void
+glamor_get_drawable_deltas(DrawablePtr drawable, PixmapPtr pixmap,
+ int *x, int *y)
+{
+#ifdef COMPOSITE
+ if (drawable->type == DRAWABLE_WINDOW) {
+ *x = -pixmap->screen_x;
+ *y = -pixmap->screen_y;
+ return;
+ }
+#endif
+
+ *x = 0;
+ *y = 0;
+}
+
+
+void
+glamor_pixmap_init(ScreenPtr screen)
+{
+
+}
+
+void
+glamor_pixmap_fini(ScreenPtr screen)
+{
+}
+
+void
+glamor_set_destination_pixmap_fbo(glamor_pixmap_fbo * fbo, int x0, int y0, int width, int height)
+{
+ glamor_gl_dispatch *dispatch = glamor_get_dispatch(fbo->glamor_priv);
+ dispatch->glBindFramebuffer(GL_FRAMEBUFFER, fbo->fb);
+#ifndef GLAMOR_GLES2
+ dispatch->glMatrixMode(GL_PROJECTION);
+ dispatch->glLoadIdentity();
+ dispatch->glMatrixMode(GL_MODELVIEW);
+ dispatch->glLoadIdentity();
+#endif
+ dispatch->glViewport(x0, y0,
+ width, height);
+
+ glamor_put_dispatch(fbo->glamor_priv);
+}
+
+void
+glamor_set_destination_pixmap_priv_nc(glamor_pixmap_private * pixmap_priv)
+{
+ int w,h;
+
+ PIXMAP_PRIV_GET_ACTUAL_SIZE(pixmap_priv, w, h);
+ glamor_set_destination_pixmap_fbo(pixmap_priv->base.fbo, 0, 0,
+ w, h);
+}
+
+int
+glamor_set_destination_pixmap_priv(glamor_pixmap_private * pixmap_priv)
+{
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+ return -1;
+
+ glamor_set_destination_pixmap_priv_nc(pixmap_priv);
+ return 0;
+}
+
+int
+glamor_set_destination_pixmap(PixmapPtr pixmap)
+{
+ int err;
+ glamor_pixmap_private *pixmap_priv =
+ glamor_get_pixmap_private(pixmap);
+
+ err = glamor_set_destination_pixmap_priv(pixmap_priv);
+ return err;
+}
+
+Bool
+glamor_set_planemask(PixmapPtr pixmap, unsigned long planemask)
+{
+ if (glamor_pm_is_solid(&pixmap->drawable, planemask)) {
+ return GL_TRUE;
+ }
+
+ glamor_fallback("unsupported planemask %lx\n", planemask);
+ return GL_FALSE;
+}
+
+Bool
+glamor_set_alu(struct glamor_gl_dispatch *dispatch, unsigned char alu)
+{
+#ifndef GLAMOR_GLES2
+ if (alu == GXcopy) {
+ dispatch->glDisable(GL_COLOR_LOGIC_OP);
+ return TRUE;
+ }
+ dispatch->glEnable(GL_COLOR_LOGIC_OP);
+ switch (alu) {
+ case GXclear:
+ dispatch->glLogicOp(GL_CLEAR);
+ break;
+ case GXand:
+ dispatch->glLogicOp(GL_AND);
+ break;
+ case GXandReverse:
+ dispatch->glLogicOp(GL_AND_REVERSE);
+ break;
+ case GXandInverted:
+ dispatch->glLogicOp(GL_AND_INVERTED);
+ break;
+ case GXnoop:
+ dispatch->glLogicOp(GL_NOOP);
+ break;
+ case GXxor:
+ dispatch->glLogicOp(GL_XOR);
+ break;
+ case GXor:
+ dispatch->glLogicOp(GL_OR);
+ break;
+ case GXnor:
+ dispatch->glLogicOp(GL_NOR);
+ break;
+ case GXequiv:
+ dispatch->glLogicOp(GL_EQUIV);
+ break;
+ case GXinvert:
+ dispatch->glLogicOp(GL_INVERT);
+ break;
+ case GXorReverse:
+ dispatch->glLogicOp(GL_OR_REVERSE);
+ break;
+ case GXcopyInverted:
+ dispatch->glLogicOp(GL_COPY_INVERTED);
+ break;
+ case GXorInverted:
+ dispatch->glLogicOp(GL_OR_INVERTED);
+ break;
+ case GXnand:
+ dispatch->glLogicOp(GL_NAND);
+ break;
+ case GXset:
+ dispatch->glLogicOp(GL_SET);
+ break;
+ default:
+ glamor_fallback("unsupported alu %x\n", alu);
+ return FALSE;
+ }
+#else
+ if (alu != GXcopy)
+ return FALSE;
+#endif
+ return TRUE;
+}
+
+static void *
+_glamor_color_convert_a1_a8(void *src_bits, void *dst_bits, int w, int h, int stride, int revert)
+{
+ PictFormatShort dst_format, src_format;
+ pixman_image_t *dst_image;
+ pixman_image_t *src_image;
+ int src_stride;
+
+ if (revert == REVERT_UPLOADING_A1) {
+ src_format = PICT_a1;
+ dst_format = PICT_a8;
+ src_stride = PixmapBytePad(w, 1);
+ } else {
+ dst_format = PICT_a1;
+ src_format = PICT_a8;
+ src_stride = (((w * 8 + 7) / 8) + 3) & ~3;
+ }
+
+ dst_image = pixman_image_create_bits(dst_format,
+ w, h,
+ dst_bits,
+ stride);
+ if (dst_image == NULL) {
+ return NULL;
+ }
+
+ src_image = pixman_image_create_bits(src_format,
+ w, h,
+ src_bits,
+ src_stride);
+
+ if (src_image == NULL) {
+ pixman_image_unref(dst_image);
+ return NULL;
+ }
+
+ pixman_image_composite(PictOpSrc, src_image, NULL, dst_image,
+ 0, 0, 0, 0, 0, 0,
+ w,h);
+
+ pixman_image_unref(src_image);
+ pixman_image_unref(dst_image);
+ return dst_bits;
+}
+
+#define ADJUST_BITS(d, src_bits, dst_bits) (((dst_bits) == (src_bits)) ? (d) : \
+ (((dst_bits) > (src_bits)) ? \
+ (((d) << ((dst_bits) - (src_bits))) \
+ + (( 1 << ((dst_bits) - (src_bits))) >> 1)) \
+ : ((d) >> ((src_bits) - (dst_bits)))))
+
+#define GLAMOR_DO_CONVERT(src, dst, no_alpha, swap, \
+ a_shift_src, a_bits_src, \
+ b_shift_src, b_bits_src, \
+ g_shift_src, g_bits_src, \
+ r_shift_src, r_bits_src, \
+ a_shift, a_bits, \
+ b_shift, b_bits, \
+ g_shift, g_bits, \
+ r_shift, r_bits) \
+ { \
+ typeof(src) a,b,g,r; \
+ typeof(src) a_mask_src, b_mask_src, g_mask_src, r_mask_src;\
+ a_mask_src = (((1 << (a_bits_src)) - 1) << a_shift_src);\
+ b_mask_src = (((1 << (b_bits_src)) - 1) << b_shift_src);\
+ g_mask_src = (((1 << (g_bits_src)) - 1) << g_shift_src);\
+ r_mask_src = (((1 << (r_bits_src)) - 1) << r_shift_src);\
+ if (no_alpha) \
+ a = (a_mask_src) >> (a_shift_src); \
+ else \
+ a = ((src) & (a_mask_src)) >> (a_shift_src); \
+ b = ((src) & (b_mask_src)) >> (b_shift_src); \
+ g = ((src) & (g_mask_src)) >> (g_shift_src); \
+ r = ((src) & (r_mask_src)) >> (r_shift_src); \
+ a = ADJUST_BITS(a, a_bits_src, a_bits); \
+ b = ADJUST_BITS(b, b_bits_src, b_bits); \
+ g = ADJUST_BITS(g, g_bits_src, g_bits); \
+ r = ADJUST_BITS(r, r_bits_src, r_bits); \
+ if (swap == 0) \
+ (*dst) = ((a) << (a_shift)) | ((b) << (b_shift)) | ((g) << (g_shift)) | ((r) << (r_shift)); \
+ else \
+ (*dst) = ((a) << (a_shift)) | ((r) << (b_shift)) | ((g) << (g_shift)) | ((b) << (r_shift)); \
+ }
+
+static void *
+_glamor_color_revert_x2b10g10r10(void *src_bits, void *dst_bits, int w, int h, int stride, int no_alpha, int revert, int swap_rb)
+{
+ int x,y;
+ unsigned int *words, *saved_words, *source_words;
+ int swap = !(swap_rb == SWAP_NONE_DOWNLOADING || swap_rb == SWAP_NONE_UPLOADING);
+
+ source_words = src_bits;
+ words = dst_bits;
+ saved_words = words;
+
+ for (y = 0; y < h; y++)
+ {
+ DEBUGF("Line %d : ", y);
+ for (x = 0; x < w; x++)
+ {
+ unsigned int pixel = source_words[x];
+
+ if (revert == REVERT_DOWNLOADING_2_10_10_10)
+ GLAMOR_DO_CONVERT(pixel, &words[x], no_alpha, swap,
+ 24, 8, 16, 8, 8, 8, 0, 8,
+ 30, 2, 20, 10, 10, 10, 0, 10)
+ else
+ GLAMOR_DO_CONVERT(pixel, &words[x], no_alpha, swap,
+ 30, 2, 20, 10, 10, 10, 0, 10,
+ 24, 8, 16, 8, 8, 8, 0, 8);
+ DEBUGF("%x:%x ", pixel, words[x]);
+ }
+ DEBUGF("\n");
+ words += stride / sizeof(*words);
+ source_words += stride / sizeof(*words);
+ }
+ DEBUGF("\n");
+ return saved_words;
+
+}
+
+static void *
+_glamor_color_revert_x1b5g5r5(void *src_bits, void *dst_bits, int w, int h, int stride, int no_alpha, int revert, int swap_rb)
+{
+ int x,y;
+ unsigned short *words, *saved_words, *source_words;
+ int swap = !(swap_rb == SWAP_NONE_DOWNLOADING || swap_rb == SWAP_NONE_UPLOADING);
+
+ words = dst_bits;
+ source_words = src_bits;
+ saved_words = words;
+
+ for (y = 0; y < h; y++)
+ {
+ DEBUGF("Line %d : ", y);
+ for (x = 0; x < w; x++)
+ {
+ unsigned short pixel = source_words[x];
+
+ if (revert == REVERT_DOWNLOADING_1_5_5_5)
+ GLAMOR_DO_CONVERT(pixel, &words[x], no_alpha, swap,
+ 0, 1, 1, 5, 6, 5, 11, 5,
+ 15, 1, 10, 5, 5, 5, 0, 5)
+ else
+ GLAMOR_DO_CONVERT(pixel, &words[x], no_alpha, swap,
+ 15, 1, 10, 5, 5, 5, 0, 5,
+ 0, 1, 1, 5, 6, 5, 11, 5);
+ DEBUGF("%04x:%04x ", pixel, words[x]);
+ }
+ DEBUGF("\n");
+ words += stride / sizeof(*words);
+ source_words += stride / sizeof(*words);
+ }
+ DEBUGF("\n");
+ return saved_words;
+}
+
+/*
+ * This function is to convert an unsupported color format to/from a
+ * supported GL format.
+ * Here are the current scenarios:
+ *
+ * @no_alpha:
+ * If it is set, then we need to wire the alpha value to 1.
+ * @revert:
+ REVERT_DOWNLOADING_A1 : convert an Alpha8 buffer to a A1 buffer.
+ REVERT_UPLOADING_A1 : convert an A1 buffer to an Alpha8 buffer
+ REVERT_DOWNLOADING_2_10_10_10 : convert r10G10b10X2 to X2B10G10R10
+ REVERT_UPLOADING_2_10_10_10 : convert X2B10G10R10 to R10G10B10X2
+ REVERT_DOWNLOADING_1_5_5_5 : convert B5G5R5X1 to X1R5G5B5
+ REVERT_UPLOADING_1_5_5_5 : convert X1R5G5B5 to B5G5R5X1
+ @swap_rb: if we have the swap_rb set, then we need to swap the R and B's position.
+ *
+ */
+
+static void *
+glamor_color_convert_to_bits(void *src_bits, void *dst_bits, int w, int h, int stride, int no_alpha, int revert, int swap_rb)
+{
+ if (revert == REVERT_DOWNLOADING_A1 || revert == REVERT_UPLOADING_A1) {
+ return _glamor_color_convert_a1_a8(src_bits, dst_bits, w, h, stride, revert);
+ } else if (revert == REVERT_DOWNLOADING_2_10_10_10 || revert == REVERT_UPLOADING_2_10_10_10) {
+ return _glamor_color_revert_x2b10g10r10(src_bits, dst_bits, w, h, stride, no_alpha, revert, swap_rb);
+ } else if (revert == REVERT_DOWNLOADING_1_5_5_5 || revert == REVERT_UPLOADING_1_5_5_5) {
+ return _glamor_color_revert_x1b5g5r5(src_bits, dst_bits, w, h, stride, no_alpha, revert, swap_rb);
+ } else
+ ErrorF("convert a non-supported mode %x.\n", revert);
+
+ return NULL;
+}
+
+/**
+ * Upload pixmap to a specified texture.
+ * This texture may not be the one attached to it.
+ **/
+int in_restore = 0;
+static void
+__glamor_upload_pixmap_to_texture(PixmapPtr pixmap, unsigned int *tex,
+ GLenum format,
+ GLenum type,
+ int x, int y, int w, int h,
+ void *bits, int pbo)
+{
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(pixmap->drawable.pScreen);
+ glamor_gl_dispatch *dispatch;
+ int non_sub = 0;
+ unsigned int iformat = 0;
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+ if (*tex == 0) {
+ dispatch->glGenTextures(1, tex);
+ if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
+ gl_iformat_for_depth(pixmap->drawable.depth, &iformat);
+ else
+ iformat = format;
+ non_sub = 1;
+ assert(x == 0 && y == 0);
+ }
+
+ dispatch->glBindTexture(GL_TEXTURE_2D, *tex);
+ dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ GL_NEAREST);
+ dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
+ GL_NEAREST);
+ dispatch->glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+
+ if (bits == NULL)
+ dispatch->glBindBuffer(GL_PIXEL_UNPACK_BUFFER,
+ pbo);
+ if (non_sub)
+ dispatch->glTexImage2D(GL_TEXTURE_2D,
+ 0, iformat, w, h, 0,
+ format, type,
+ bits);
+ else
+ dispatch->glTexSubImage2D(GL_TEXTURE_2D,
+ 0, x, y, w, h,
+ format, type,
+ bits);
+
+ if (bits == NULL)
+ dispatch->glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
+ glamor_put_dispatch(glamor_priv);
+}
+
+static Bool
+_glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format, GLenum type,
+ int no_alpha, int revert,
+ int swap_rb, int x, int y, int w, int h,
+ int stride, void* bits, int pbo)
+{
+ glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
+ glamor_gl_dispatch *dispatch;
+ static float vertices[8];
+ static float texcoords[8] = { 0, 1,
+ 1, 1,
+ 1, 0,
+ 0, 0
+ };
+ static float texcoords_inv[8] = { 0, 0,
+ 1, 0,
+ 1, 1,
+ 0, 1
+ };
+ float *ptexcoords;
+ float dst_xscale, dst_yscale;
+ GLuint tex = 0;
+ int need_flip;
+ int need_free_bits = 0;
+
+ need_flip = !glamor_priv->yInverted;
+
+ if (bits == NULL)
+ goto ready_to_upload;
+
+ if (revert > REVERT_NORMAL) {
+ /* XXX if we are restoring the pixmap, then we may not need to allocate
+ * new buffer */
+ void *converted_bits;
+
+ if (pixmap->drawable.depth == 1)
+ stride = (((w * 8 + 7) / 8) + 3) & ~3;
+
+ converted_bits = malloc(h * stride);
+
+ if (converted_bits == NULL)
+ return FALSE;
+ bits = glamor_color_convert_to_bits(bits, converted_bits, w, h,
+ stride,
+ no_alpha, revert, swap_rb);
+ if (bits == NULL) {
+ ErrorF("Failed to convert pixmap no_alpha %d,"
+ "revert mode %d, swap mode %d\n", no_alpha, revert, swap_rb);
+ return FALSE;
+ }
+ no_alpha = 0;
+ revert = REVERT_NONE;
+ swap_rb = SWAP_NONE_UPLOADING;
+ need_free_bits = TRUE;
+ }
+
+ready_to_upload:
+
+ /* Try fast path firstly, upload the pixmap to the texture attached
+ * to the fbo directly. */
+ if (no_alpha == 0
+ && revert == REVERT_NONE
+ && swap_rb == SWAP_NONE_UPLOADING
+ && !need_flip
+#ifdef WALKAROUND_LARGE_TEXTURE_MAP
+ && pixmap_priv->type != GLAMOR_TEXTURE_LARGE
+#endif
+ ) {
+ int fbo_x_off, fbo_y_off;
+ assert(pixmap_priv->base.fbo->tex);
+ pixmap_priv_get_fbo_off(pixmap_priv, &fbo_x_off, &fbo_y_off);
+
+ assert(x + fbo_x_off >= 0 && y + fbo_y_off >= 0);
+ assert(x + fbo_x_off + w <= pixmap_priv->base.fbo->width);
+ assert(y + fbo_y_off + h <= pixmap_priv->base.fbo->height);
+ __glamor_upload_pixmap_to_texture(pixmap, &pixmap_priv->base.fbo->tex,
+ format, type,
+ x + fbo_x_off, y + fbo_y_off, w, h,
+ bits, pbo);
+ return TRUE;
+ }
+
+ if (need_flip)
+ ptexcoords = texcoords;
+ else
+ ptexcoords = texcoords_inv;
+
+ pixmap_priv_get_dest_scale(pixmap_priv, &dst_xscale, &dst_yscale);
+ glamor_set_normalize_vcoords(pixmap_priv, dst_xscale,
+ dst_yscale,
+ x, y,
+ x + w, y + h,
+ glamor_priv->yInverted,
+ vertices);
+ /* Slow path, we need to flip y or wire alpha to 1. */
+ dispatch = glamor_get_dispatch(glamor_priv);
+ dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
+ GL_FALSE, 2 * sizeof(float),
+ vertices);
+ dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+ dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
+ GL_FALSE, 2 * sizeof(float),
+ ptexcoords);
+ dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+
+ glamor_set_destination_pixmap_priv_nc(pixmap_priv);
+ __glamor_upload_pixmap_to_texture(pixmap, &tex,
+ format, type,
+ 0, 0, w, h,
+ bits, pbo);
+ dispatch->glActiveTexture(GL_TEXTURE0);
+ dispatch->glBindTexture(GL_TEXTURE_2D, tex);
+
+ dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ GL_NEAREST);
+ dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
+ GL_NEAREST);
+#ifndef GLAMOR_GLES2
+ dispatch->glEnable(GL_TEXTURE_2D);
+#endif
+ dispatch->glUseProgram(glamor_priv->finish_access_prog[no_alpha]);
+ dispatch->glUniform1i(glamor_priv->
+ finish_access_revert[no_alpha],
+ revert);
+ dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[no_alpha],
+ swap_rb);
+
+ dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+
+#ifndef GLAMOR_GLES2
+ dispatch->glDisable(GL_TEXTURE_2D);
+#endif
+ dispatch->glUseProgram(0);
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+ dispatch->glDeleteTextures(1, &tex);
+ dispatch->glBindFramebuffer(GL_FRAMEBUFFER, 0);
+
+ glamor_put_dispatch(glamor_priv);
+
+ if (need_free_bits)
+ free(bits);
+ return TRUE;
+}
+
+/*
+ * Prepare to upload a pixmap to texture memory.
+ * no_alpha equals 1 means the format needs to wire alpha to 1.
+ * Two condtion need to setup a fbo for a pixmap
+ * 1. !yInverted, we need to do flip if we are not yInverted.
+ * 2. no_alpha != 0, we need to wire the alpha.
+ * */
+static int
+glamor_pixmap_upload_prepare(PixmapPtr pixmap, GLenum format, int no_alpha, int revert, int swap_rb)
+{
+ int flag = 0;
+ glamor_pixmap_private *pixmap_priv;
+ glamor_screen_private *glamor_priv;
+ glamor_pixmap_fbo *fbo;
+ GLenum iformat;
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
+
+ if (pixmap_priv->base.gl_fbo)
+ return 0;
+
+ if (pixmap_priv->base.fbo
+ && (pixmap_priv->base.fbo->width < pixmap->drawable.width
+ || pixmap_priv->base.fbo->height < pixmap->drawable.height)) {
+ fbo = glamor_pixmap_detach_fbo(pixmap_priv);
+ glamor_destroy_fbo(fbo);
+ }
+
+ if (pixmap_priv->base.fbo && pixmap_priv->base.fbo->fb)
+ return 0;
+
+ if (!(no_alpha
+ || (revert == REVERT_NORMAL)
+ || (swap_rb != SWAP_NONE_UPLOADING)
+ || !glamor_priv->yInverted)) {
+ /* We don't need a fbo, a simple texture uploading should work. */
+
+ flag = GLAMOR_CREATE_FBO_NO_FBO;
+ }
+
+ if ((flag == GLAMOR_CREATE_FBO_NO_FBO
+ && pixmap_priv->base.fbo && pixmap_priv->base.fbo->tex)
+ || (flag == 0
+ && pixmap_priv->base.fbo && pixmap_priv->base.fbo->fb))
+ return 0;
+
+ if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
+ gl_iformat_for_depth(pixmap->drawable.depth, &iformat);
+ else
+ iformat = format;
+
+ if (!glamor_pixmap_ensure_fbo(pixmap, iformat, flag))
+ return -1;
+
+ return 0;
+}
+
+/*
+ * upload sub region to a large region.
+ * */
+static void
+glamor_put_bits(char *dst_bits, int dst_stride, char *src_bits,
+ int src_stride, int bpp,
+ int x, int y, int w, int h)
+{
+ int j;
+ int byte_per_pixel;
+
+ byte_per_pixel = bpp / 8;
+ src_bits += y * src_stride + (x * byte_per_pixel);
+
+ for(j = y; j < y + h; j++)
+ {
+ memcpy(dst_bits, src_bits, w * byte_per_pixel);
+ src_bits += src_stride;
+ dst_bits += dst_stride;
+ }
+}
+/*
+ * download sub region from a large region.
+ */
+static void
+glamor_get_bits(char *dst_bits, int dst_stride, char *src_bits,
+ int src_stride, int bpp,
+ int x, int y, int w, int h)
+{
+ int j;
+ int byte_per_pixel;
+
+ byte_per_pixel = bpp / 8;
+ dst_bits += y * dst_stride + x * byte_per_pixel;
+
+ for(j = y; j < y + h; j++)
+ {
+ memcpy(dst_bits, src_bits, w * byte_per_pixel);
+ src_bits += src_stride;
+ dst_bits += dst_stride;
+ }
+}
+
+
+Bool
+glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, int h,
+ int stride, void *bits, int pbo)
+{
+ GLenum format, type;
+ int no_alpha, revert, swap_rb;
+ glamor_pixmap_private *pixmap_priv;
+ Bool force_clip;
+
+ if (glamor_get_tex_format_type_from_pixmap(pixmap,
+ &format,
+ &type,
+ &no_alpha,
+ &revert,
+ &swap_rb, 1)) {
+ glamor_fallback("Unknown pixmap depth %d.\n",
+ pixmap->drawable.depth);
+ return TRUE;
+ }
+ if (glamor_pixmap_upload_prepare(pixmap, format, no_alpha, revert, swap_rb))
+ return FALSE;
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ force_clip = pixmap_priv->base.glamor_priv->gl_flavor != GLAMOR_GL_DESKTOP
+ && !glamor_check_fbo_size(pixmap_priv->base.glamor_priv, w, h);
+
+ if (pixmap_priv->type == GLAMOR_TEXTURE_LARGE || force_clip) {
+ RegionRec region;
+ BoxRec box;
+ int n_region;
+ glamor_pixmap_clipped_regions *clipped_regions;
+ void *sub_bits;
+ int i,j;
+
+ sub_bits = malloc(h * stride);
+ if (sub_bits == NULL)
+ return FALSE;
+ box.x1 = x;
+ box.y1 = y;
+ box.x2 = x + w;
+ box.y2 = y + h;
+ RegionInitBoxes(&region, &box, 1);
+ if (!force_clip)
+ clipped_regions = glamor_compute_clipped_regions(pixmap_priv, &region, &n_region, 0, 0, 0);
+ else
+ clipped_regions = glamor_compute_clipped_regions_ext(pixmap_priv, &region, &n_region,
+ pixmap_priv->base.glamor_priv->max_fbo_size,
+ pixmap_priv->base.glamor_priv->max_fbo_size, 0, 0);
+ DEBUGF("prepare upload %dx%d to a large pixmap %p\n", w, h, pixmap);
+ for(i = 0; i < n_region; i++)
+ {
+ BoxPtr boxes;
+ int nbox;
+ int temp_stride;
+ void *temp_bits;
+
+ assert(pbo == 0);
+
+ SET_PIXMAP_FBO_CURRENT(pixmap_priv, clipped_regions[i].block_idx);
+
+ boxes = RegionRects(clipped_regions[i].region);
+ nbox = RegionNumRects(clipped_regions[i].region);
+ DEBUGF("split to %d boxes\n", nbox);
+ for(j = 0; j < nbox; j++)
+ {
+ temp_stride = PixmapBytePad(boxes[j].x2 - boxes[j].x1,
+ pixmap->drawable.depth);
+
+ if (boxes[j].x1 == x && temp_stride == stride) {
+ temp_bits = (char*)bits + (boxes[j].y1 - y) * stride;
+ } else {
+ temp_bits = sub_bits;
+ glamor_put_bits(temp_bits, temp_stride, bits, stride,
+ pixmap->drawable.bitsPerPixel,
+ boxes[j].x1 - x, boxes[j].y1 - y,
+ boxes[j].x2 - boxes[j].x1,
+ boxes[j].y2 - boxes[j].y1);
+ }
+ DEBUGF("upload x %d y %d w %d h %d temp stride %d \n",
+ boxes[j].x1 - x, boxes[j].y1 - y,
+ boxes[j].x2 - boxes[j].x1,
+ boxes[j].y2 - boxes[j].y1, temp_stride);
+ if (_glamor_upload_bits_to_pixmap_texture(pixmap, format, type, no_alpha,
+ revert, swap_rb, boxes[j].x1, boxes[j].y1,
+ boxes[j].x2 - boxes[j].x1,
+ boxes[j].y2 - boxes[j].y1,
+ temp_stride, temp_bits, pbo) == FALSE) {
+ RegionUninit(&region);
+ free(sub_bits);
+ assert(0);
+ return FALSE;
+ }
+ }
+ RegionDestroy(clipped_regions[i].region);
+ }
+ free(sub_bits);
+ free(clipped_regions);
+ RegionUninit(&region);
+ return TRUE;
+ } else
+ return _glamor_upload_bits_to_pixmap_texture(pixmap, format, type, no_alpha, revert, swap_rb,
+ x, y, w, h, stride, bits, pbo);
+}
+
+enum glamor_pixmap_status
+glamor_upload_pixmap_to_texture(PixmapPtr pixmap)
+{
+ glamor_pixmap_private *pixmap_priv;
+ void *data;
+ int pbo;
+ int ret;
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+
+ if ((pixmap_priv->base.fbo)
+ && (pixmap_priv->base.fbo->pbo_valid)) {
+ data = NULL;
+ pbo = pixmap_priv->base.fbo->pbo;
+ } else {
+ data = pixmap->devPrivate.ptr;
+ pbo = 0;
+ }
+
+ if (glamor_upload_sub_pixmap_to_texture(pixmap, 0, 0,
+ pixmap->drawable.width,
+ pixmap->drawable.height,
+ pixmap->devKind,
+ data, pbo))
+ ret = GLAMOR_UPLOAD_DONE;
+ else
+ ret = GLAMOR_UPLOAD_FAILED;
+
+ return ret;
+}
+
+void
+glamor_restore_pixmap_to_texture(PixmapPtr pixmap)
+{
+ if (glamor_upload_pixmap_to_texture(pixmap) != GLAMOR_UPLOAD_DONE)
+ LogMessage(X_WARNING, "Failed to restore pixmap to texture.\n");
+}
+
+/*
+ * as gles2 only support a very small set of color format and
+ * type when do glReadPixel,
+ * Before we use glReadPixels to get back a textured pixmap,
+ * Use shader to convert it to a supported format and thus
+ * get a new temporary pixmap returned.
+ * */
+
+glamor_pixmap_fbo *
+glamor_es2_pixmap_read_prepare(PixmapPtr source, int x, int y, int w, int h, GLenum format,
+ GLenum type, int no_alpha, int revert, int swap_rb)
+
+{
+ glamor_pixmap_private *source_priv;
+ glamor_screen_private *glamor_priv;
+ ScreenPtr screen;
+ glamor_pixmap_fbo *temp_fbo;
+ glamor_gl_dispatch *dispatch;
+ float temp_xscale, temp_yscale, source_xscale, source_yscale;
+ static float vertices[8];
+ static float texcoords[8];
+
+ screen = source->drawable.pScreen;
+
+ glamor_priv = glamor_get_screen_private(screen);
+ source_priv = glamor_get_pixmap_private(source);
+ temp_fbo = glamor_create_fbo(glamor_priv,
+ w, h,
+ format,
+ 0);
+ if (temp_fbo == NULL)
+ return NULL;
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+ temp_xscale = 1.0 / w;
+ temp_yscale = 1.0 / h;
+
+ glamor_set_normalize_vcoords((struct glamor_pixmap_private*)NULL,temp_xscale,
+ temp_yscale,
+ 0, 0,
+ w, h,
+ glamor_priv->yInverted,
+ vertices);
+
+ dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
+ GL_FALSE, 2 * sizeof(float),
+ vertices);
+ dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+
+ pixmap_priv_get_scale(source_priv, &source_xscale, &source_yscale);
+ glamor_set_normalize_tcoords(source_priv, source_xscale,
+ source_yscale,
+ x, y,
+ x + w, y + h,
+ glamor_priv->yInverted,
+ texcoords);
+
+ dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
+ GL_FALSE, 2 * sizeof(float),
+ texcoords);
+ dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+
+ dispatch->glActiveTexture(GL_TEXTURE0);
+ dispatch->glBindTexture(GL_TEXTURE_2D, source_priv->base.fbo->tex);
+ dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_MIN_FILTER,
+ GL_NEAREST);
+ dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_MAG_FILTER,
+ GL_NEAREST);
+
+ glamor_set_destination_pixmap_fbo(temp_fbo, 0, 0, w, h);
+ dispatch->glUseProgram(glamor_priv->finish_access_prog[no_alpha]);
+ dispatch->glUniform1i(glamor_priv->
+ finish_access_revert[no_alpha],
+ revert);
+ dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[no_alpha],
+ swap_rb);
+
+ dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+ dispatch->glUseProgram(0);
+ glamor_put_dispatch(glamor_priv);
+ return temp_fbo;
+}
+
+/*
+ * Download a sub region of pixmap to a specified memory region.
+ * The pixmap must have a valid FBO, otherwise return a NULL.
+ * */
+
+static void *
+_glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, GLenum format,
+ GLenum type, int no_alpha,
+ int revert, int swap_rb,
+ int x, int y, int w, int h,
+ int stride, void *bits, int pbo, glamor_access_t access)
+{
+ glamor_pixmap_private *pixmap_priv;
+ GLenum gl_access = 0, gl_usage = 0;
+ void *data, *read;
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(pixmap->drawable.pScreen);
+ glamor_gl_dispatch *dispatch;
+ glamor_pixmap_fbo *temp_fbo = NULL;
+ int need_post_conversion = 0;
+ int need_free_data = 0;
+ int fbo_x_off, fbo_y_off;
+
+ data = bits;
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+ return NULL;
+
+ switch (access) {
+ case GLAMOR_ACCESS_RO:
+ gl_access = GL_READ_ONLY;
+ gl_usage = GL_STREAM_READ;
+ break;
+ case GLAMOR_ACCESS_WO:
+ return bits;
+ case GLAMOR_ACCESS_RW:
+ gl_access = GL_READ_WRITE;
+ gl_usage = GL_DYNAMIC_DRAW;
+ break;
+ default:
+ ErrorF("Glamor: Invalid access code. %d\n", access);
+ assert(0);
+ }
+
+ glamor_set_destination_pixmap_priv_nc(pixmap_priv);
+
+ need_post_conversion = (revert > REVERT_NORMAL);
+ if (need_post_conversion) {
+ if (pixmap->drawable.depth == 1) {
+ int temp_stride;
+ temp_stride = (((w * 8 + 7) / 8) + 3) & ~3;
+ data = malloc(temp_stride * h);
+ if (data == NULL)
+ return NULL;
+ need_free_data = 1;
+ }
+ }
+
+ pixmap_priv_get_fbo_off(pixmap_priv, &fbo_x_off, &fbo_y_off);
+
+ if (glamor_priv->gl_flavor == GLAMOR_GL_ES2
+ && !need_post_conversion
+ && (swap_rb != SWAP_NONE_DOWNLOADING || revert != REVERT_NONE)) {
+ if (!(temp_fbo = glamor_es2_pixmap_read_prepare(pixmap, x, y, w, h,
+ format, type, no_alpha,
+ revert, swap_rb))) {
+ free(data);
+ return NULL;
+ }
+ x = 0;
+ y = 0;
+ fbo_x_off = 0;
+ fbo_y_off = 0;
+ }
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+ dispatch->glPixelStorei(GL_PACK_ALIGNMENT, 4);
+
+ if (glamor_priv->has_pack_invert || glamor_priv->yInverted) {
+
+ if (!glamor_priv->yInverted) {
+ assert(glamor_priv->gl_flavor ==
+ GLAMOR_GL_DESKTOP);
+ dispatch->glPixelStorei(GL_PACK_INVERT_MESA, 1);
+ }
+
+ if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP && data == NULL) {
+ assert(pbo > 0);
+ dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo);
+ dispatch->glBufferData(GL_PIXEL_PACK_BUFFER,
+ stride *
+ h,
+ NULL, gl_usage);
+ }
+
+ dispatch->glReadPixels(x + fbo_x_off, y + fbo_y_off, w, h, format, type, data);
+
+ if (!glamor_priv->yInverted) {
+ assert(glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP);
+ dispatch->glPixelStorei(GL_PACK_INVERT_MESA, 0);
+ }
+ if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP && bits == NULL) {
+ bits = dispatch->glMapBuffer(GL_PIXEL_PACK_BUFFER,
+ gl_access);
+ dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
+ }
+ } else {
+ unsigned int temp_pbo;
+ int yy;
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+ dispatch->glGenBuffers(1, &temp_pbo);
+ dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER,
+ temp_pbo);
+ dispatch->glBufferData(GL_PIXEL_PACK_BUFFER,
+ stride *
+ h,
+ NULL, GL_STREAM_READ);
+ dispatch->glReadPixels(x + fbo_x_off, y + fbo_y_off, w, h,
+ format, type, 0);
+ read = dispatch->glMapBuffer(GL_PIXEL_PACK_BUFFER,
+ GL_READ_ONLY);
+ for (yy = 0; yy < pixmap->drawable.height; yy++)
+ memcpy((char*)data + yy * stride,
+ (char*)read + (h - yy - 1) * stride, stride);
+ dispatch->glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
+ dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
+ dispatch->glDeleteBuffers(1, &temp_pbo);
+ }
+
+ dispatch->glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ glamor_put_dispatch(glamor_priv);
+
+ if (need_post_conversion) {
+ /* As OpenGL desktop version never enters here.
+ * Don't need to consider if the pbo is valid.*/
+ bits = glamor_color_convert_to_bits(data, bits,
+ w, h,
+ stride,
+ no_alpha,
+ revert, swap_rb);
+ }
+
+ if (temp_fbo != NULL)
+ glamor_destroy_fbo(temp_fbo);
+ if (need_free_data)
+ free(data);
+
+ return bits;
+}
+
+void *
+glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, int x, int y, int w, int h,
+ int stride, void *bits, int pbo, glamor_access_t access)
+{
+ GLenum format, type;
+ int no_alpha, revert, swap_rb;
+ glamor_pixmap_private *pixmap_priv;
+ Bool force_clip;
+
+ if (glamor_get_tex_format_type_from_pixmap(pixmap,
+ &format,
+ &type,
+ &no_alpha,
+ &revert,
+ &swap_rb, 0)) {
+ glamor_fallback("Unknown pixmap depth %d.\n",
+ pixmap->drawable.depth);
+ return NULL;
+ }
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+ return NULL;
+
+ force_clip = pixmap_priv->base.glamor_priv->gl_flavor != GLAMOR_GL_DESKTOP
+ && !glamor_check_fbo_size(pixmap_priv->base.glamor_priv, w, h);
+
+ if (pixmap_priv->type == GLAMOR_TEXTURE_LARGE || force_clip) {
+
+ RegionRec region;
+ BoxRec box;
+ int n_region;
+ glamor_pixmap_clipped_regions *clipped_regions;
+ void *sub_bits;
+ int i,j;
+
+ sub_bits = malloc(h * stride);
+ if (sub_bits == NULL)
+ return FALSE;
+ box.x1 = x;
+ box.y1 = y;
+ box.x2 = x + w;
+ box.y2 = y + h;
+ RegionInitBoxes(&region, &box, 1);
+
+ if (!force_clip)
+ clipped_regions = glamor_compute_clipped_regions(pixmap_priv, &region, &n_region, 0, 0, 0);
+ else
+ clipped_regions = glamor_compute_clipped_regions_ext(pixmap_priv, &region, &n_region,
+ pixmap_priv->base.glamor_priv->max_fbo_size,
+ pixmap_priv->base.glamor_priv->max_fbo_size, 0, 0);
+
+ DEBUGF("start download large pixmap %p %dx%d \n", pixmap, w, h);
+ for(i = 0; i < n_region; i++)
+ {
+ BoxPtr boxes;
+ int nbox;
+ int temp_stride;
+ void *temp_bits;
+
+ assert(pbo == 0);
+ SET_PIXMAP_FBO_CURRENT(pixmap_priv, clipped_regions[i].block_idx);
+
+ boxes = RegionRects(clipped_regions[i].region);
+ nbox = RegionNumRects(clipped_regions[i].region);
+ for(j = 0; j < nbox; j++)
+ {
+ temp_stride = PixmapBytePad(boxes[j].x2 - boxes[j].x1,
+ pixmap->drawable.depth);
+
+ if (boxes[j].x1 == x && temp_stride == stride) {
+ temp_bits = (char*)bits + (boxes[j].y1 - y) * stride;
+ } else {
+ temp_bits = sub_bits;
+ }
+ DEBUGF("download x %d y %d w %d h %d temp stride %d \n",
+ boxes[j].x1, boxes[j].y1,
+ boxes[j].x2 - boxes[j].x1,
+ boxes[j].y2 - boxes[j].y1, temp_stride);
+
+ /* For large pixmap, we don't support pbo currently.*/
+ assert(pbo == 0);
+ if (_glamor_download_sub_pixmap_to_cpu(pixmap, format, type, no_alpha,
+ revert, swap_rb, boxes[j].x1, boxes[j].y1,
+ boxes[j].x2 - boxes[j].x1,
+ boxes[j].y2 - boxes[j].y1,
+ temp_stride, temp_bits, pbo, access) == FALSE) {
+ RegionUninit(&region);
+ free(sub_bits);
+ assert(0);
+ return NULL;
+ }
+ if (boxes[j].x1 != x || temp_stride != stride)
+ glamor_get_bits(bits, stride, temp_bits, temp_stride,
+ pixmap->drawable.bitsPerPixel,
+ boxes[j].x1 - x , boxes[j].y1 - y,
+ boxes[j].x2 - boxes[j].x1,
+ boxes[j].y2 - boxes[j].y1);
+ }
+
+ RegionDestroy(clipped_regions[i].region);
+ }
+ free(sub_bits);
+ free(clipped_regions);
+ RegionUninit(&region);
+ return bits;
+ } else
+ return _glamor_download_sub_pixmap_to_cpu(pixmap, format, type, no_alpha, revert, swap_rb,
+ x, y, w, h, stride,
+ bits, pbo, access);
+}
+
+
+/**
+ * Move a pixmap to CPU memory.
+ * The input data is the pixmap's fbo.
+ * The output data is at pixmap->devPrivate.ptr. We always use pbo
+ * to read the fbo and then map it to va. If possible, we will use
+ * it directly as devPrivate.ptr.
+ * If successfully download a fbo to cpu then return TRUE.
+ * Otherwise return FALSE.
+ **/
+Bool
+glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
+{
+ glamor_pixmap_private *pixmap_priv =
+ glamor_get_pixmap_private(pixmap);
+ unsigned int stride;
+ void *data = NULL, *dst;
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(pixmap->drawable.pScreen);
+ glamor_gl_dispatch *dispatch;
+ int pbo = 0;
+
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+ return TRUE;
+
+ glamor_debug_output(GLAMOR_DEBUG_TEXTURE_DOWNLOAD,
+ "Downloading pixmap %p %dx%d depth%d\n",
+ pixmap,
+ pixmap->drawable.width,
+ pixmap->drawable.height,
+ pixmap->drawable.depth);
+
+ stride = pixmap->devKind;
+
+ if (access == GLAMOR_ACCESS_WO
+ || glamor_priv->gl_flavor == GLAMOR_GL_ES2
+ || (!glamor_priv->has_pack_invert && !glamor_priv->yInverted)
+ || pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
+ data = malloc(stride * pixmap->drawable.height);
+ } else {
+ dispatch = glamor_get_dispatch(glamor_priv);
+ if (pixmap_priv->base.fbo->pbo == 0)
+ dispatch->glGenBuffers(1,
+ &pixmap_priv->base.fbo->pbo);
+ glamor_put_dispatch(glamor_priv);
+ pbo = pixmap_priv->base.fbo->pbo;
+ }
+
+ if (pixmap_priv->type == GLAMOR_TEXTURE_DRM) {
+ stride = PixmapBytePad(pixmap->drawable.width, pixmap->drawable.depth);
+ pixmap_priv->base.drm_stride = pixmap->devKind;
+ pixmap->devKind = stride;
+ }
+
+ dst = glamor_download_sub_pixmap_to_cpu(pixmap, 0, 0,
+ pixmap->drawable.width,
+ pixmap->drawable.height,
+ pixmap->devKind,
+ data, pbo, access);
+
+ if (!dst) {
+ if (data)
+ free(data);
+ return FALSE;
+ }
+
+ if (pbo != 0)
+ pixmap_priv->base.fbo->pbo_valid = 1;
+
+ pixmap_priv->base.gl_fbo = GLAMOR_FBO_DOWNLOADED;
+
+ pixmap->devPrivate.ptr = dst;
+
+ return TRUE;
+}
+
+/* fixup a fbo to the exact size as the pixmap. */
+/* XXX LARGE pixmap? */
+Bool
+glamor_fixup_pixmap_priv(ScreenPtr screen, glamor_pixmap_private *pixmap_priv)
+{
+ glamor_pixmap_fbo *old_fbo;
+ glamor_pixmap_fbo *new_fbo = NULL;
+ PixmapPtr scratch = NULL;
+ glamor_pixmap_private *scratch_priv;
+ DrawablePtr drawable;
+ GCPtr gc = NULL;
+ int ret = FALSE;
+
+ drawable = &pixmap_priv->base.pixmap->drawable;
+
+ if (!GLAMOR_PIXMAP_FBO_NOT_EAXCT_SIZE(pixmap_priv))
+ return TRUE;
+
+ old_fbo = pixmap_priv->base.fbo;
+
+ if (!old_fbo)
+ return FALSE;
+
+ gc = GetScratchGC(drawable->depth, screen);
+ if (!gc)
+ goto fail;
+
+ scratch = glamor_create_pixmap(screen, drawable->width, drawable->height,
+ drawable->depth,
+ GLAMOR_CREATE_PIXMAP_FIXUP);
+
+ scratch_priv = glamor_get_pixmap_private(scratch);
+
+ if (!scratch_priv->base.fbo)
+ goto fail;
+
+ ValidateGC(&scratch->drawable, gc);
+ glamor_copy_area(drawable,
+ &scratch->drawable,
+ gc, 0, 0,
+ drawable->width, drawable->height,
+ 0, 0);
+ old_fbo = glamor_pixmap_detach_fbo(pixmap_priv);
+ new_fbo = glamor_pixmap_detach_fbo(scratch_priv);
+ glamor_pixmap_attach_fbo(pixmap_priv->base.pixmap, new_fbo);
+ glamor_pixmap_attach_fbo(scratch, old_fbo);
+
+ DEBUGF("old %dx%d type %d\n",
+ drawable->width, drawable->height, pixmap_priv->type);
+ DEBUGF("copy tex %d %dx%d to tex %d %dx%d \n",
+ old_fbo->tex, old_fbo->width, old_fbo->height, new_fbo->tex, new_fbo->width, new_fbo->height);
+ ret = TRUE;
+fail:
+ if (gc)
+ FreeScratchGC(gc);
+ if (scratch)
+ glamor_destroy_pixmap(scratch);
+
+ return ret;
+}
+
+/*
+ * We may use this function to reduce a large pixmap to a small sub
+ * pixmap. Two scenarios currently:
+ * 1. When fallback a large textured pixmap to CPU but we do need to
+ * do rendering within a small sub region, then we can just get a
+ * sub region.
+ *
+ * 2. When uploading a large pixmap to texture but we only need to
+ * use part of the source/mask picture. As glTexImage2D will be more
+ * efficient to upload a contingent region rather than a sub block
+ * in a large buffer. We use this function to gather the sub region
+ * to a contingent sub pixmap.
+ *
+ * The sub-pixmap must have the same format as the source pixmap.
+ *
+ * */
+PixmapPtr
+glamor_get_sub_pixmap(PixmapPtr pixmap, int x, int y, int w, int h, glamor_access_t access)
+{
+ glamor_screen_private *glamor_priv;
+ PixmapPtr sub_pixmap;
+ glamor_pixmap_private *sub_pixmap_priv, *pixmap_priv;
+ void *data;
+ int pbo;
+ int flag;
+ if (x < 0 || y < 0)
+ return NULL;
+ w = (x + w) > pixmap->drawable.width ? (pixmap->drawable.width - x) : w;
+ h = (y + h) > pixmap->drawable.height ? (pixmap->drawable.height - y) : h;
+ if (access == GLAMOR_ACCESS_WO) {
+ sub_pixmap = glamor_create_pixmap(pixmap->drawable.pScreen, w, h,
+ pixmap->drawable.depth, GLAMOR_CREATE_PIXMAP_CPU);
+ return sub_pixmap;
+ }
+
+ glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
+ return NULL;
+ if (glamor_priv->gl_flavor == GLAMOR_GL_ES2 || pixmap_priv->type == GLAMOR_TEXTURE_LARGE)
+ flag = GLAMOR_CREATE_PIXMAP_CPU;
+ else
+ flag = GLAMOR_CREATE_PIXMAP_MAP;
+
+ sub_pixmap = glamor_create_pixmap(pixmap->drawable.pScreen, w, h,
+ pixmap->drawable.depth, flag);
+
+ if (sub_pixmap == NULL)
+ return NULL;
+
+ sub_pixmap_priv = glamor_get_pixmap_private(sub_pixmap);
+ pbo = sub_pixmap_priv ? (sub_pixmap_priv->base.fbo ? sub_pixmap_priv->base.fbo->pbo : 0): 0;
+
+ if (pixmap_priv->base.is_picture) {
+ sub_pixmap_priv->base.picture = pixmap_priv->base.picture;
+ sub_pixmap_priv->base.is_picture = pixmap_priv->base.is_picture;
+ }
+
+ if (pbo)
+ data = NULL;
+ else
+ data = sub_pixmap->devPrivate.ptr;
+
+ data = glamor_download_sub_pixmap_to_cpu(pixmap, x, y, w, h, sub_pixmap->devKind,
+ data, pbo, access);
+ if(data == NULL) {
+ fbDestroyPixmap(sub_pixmap);
+ return NULL;
+ }
+ if (pbo) {
+ assert(sub_pixmap->devPrivate.ptr == NULL);
+ sub_pixmap->devPrivate.ptr = data;
+ sub_pixmap_priv->base.fbo->pbo_valid = 1;
+ }
+#if 0
+ struct pixman_box16 box;
+ PixmapPtr new_sub_pixmap;
+ int dx, dy;
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = w;
+ box.y2 = h;
+
+ dx = x;
+ dy = y;
+
+ new_sub_pixmap = glamor_create_pixmap(pixmap->drawable.pScreen, w, h,
+ pixmap->drawable.depth, GLAMOR_CREATE_PIXMAP_CPU);
+ glamor_copy_n_to_n(&pixmap->drawable, &new_sub_pixmap->drawable, NULL, &box, 1, dx, dy, 0, 0, 0, NULL);
+ glamor_compare_pixmaps(new_sub_pixmap, sub_pixmap, 0, 0, w, h, 1, 1);
+#endif
+
+ return sub_pixmap;
+}
+
+void
+glamor_put_sub_pixmap(PixmapPtr sub_pixmap, PixmapPtr pixmap, int x, int y, int w, int h, glamor_access_t access)
+{
+ void *bits;
+ int pbo;
+ glamor_pixmap_private *sub_pixmap_priv;
+ if (access != GLAMOR_ACCESS_RO) {
+ sub_pixmap_priv = glamor_get_pixmap_private(sub_pixmap);
+ if (sub_pixmap_priv->base.fbo
+ && sub_pixmap_priv->base.fbo->pbo_valid) {
+ bits = NULL;
+ pbo = sub_pixmap_priv->base.fbo->pbo;
+ } else {
+ bits = sub_pixmap->devPrivate.ptr;
+ pbo = 0;
+ }
+
+ assert(x >= 0 && y >= 0);
+ w = (w > sub_pixmap->drawable.width) ? sub_pixmap->drawable.width : w;
+ h = (h > sub_pixmap->drawable.height) ? sub_pixmap->drawable.height : h;
+ glamor_upload_sub_pixmap_to_texture(pixmap, x, y, w, h, sub_pixmap->devKind, bits, pbo);
+ }
+ glamor_destroy_pixmap(sub_pixmap);
+}
diff --git a/xorg-server/glamor/glamor_polyfillrect.c b/xorg-server/glamor/glamor_polyfillrect.c
new file mode 100644
index 000000000..4e1f7b3a9
--- /dev/null
+++ b/xorg-server/glamor/glamor_polyfillrect.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ * Copyright © 1998 Keith Packard
+ *
+ * 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.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+
+#include "glamor_priv.h"
+
+/** @file glamor_fillspans.c
+ *
+ * GC PolyFillRect implementation, taken straight from fb_fill.c
+ */
+
+static Bool
+_glamor_poly_fill_rect(DrawablePtr drawable,
+ GCPtr gc, int nrect, xRectangle * prect, Bool fallback)
+{
+ int fullX1, fullX2, fullY1, fullY2;
+ int xorg, yorg;
+ int n;
+ register BoxPtr pbox;
+ RegionPtr pClip = fbGetCompositeClip(gc);
+ Bool ret = FALSE;
+
+ xorg = drawable->x;
+ yorg = drawable->y;
+
+ while (nrect--) {
+ fullX1 = prect->x + xorg;
+ fullY1 = prect->y + yorg;
+ fullX2 = fullX1 + (int) prect->width;
+ fullY2 = fullY1 + (int) prect->height;
+
+ n = REGION_NUM_RECTS(pClip);
+ pbox = REGION_RECTS(pClip);
+ /*
+ * clip the rectangle to each box in the clip region
+ * this is logically equivalent to calling Intersect(),
+ * but rectangles may overlap each other here.
+ */
+ while (n--) {
+ int x1 = fullX1;
+ int x2 = fullX2;
+ int y1 = fullY1;
+ int y2 = fullY2;
+
+ if (pbox->x1 > x1)
+ x1 = pbox->x1;
+ if (pbox->x2 < x2)
+ x2 = pbox->x2;
+ if (pbox->y1 > y1)
+ y1 = pbox->y1;
+ if (pbox->y2 < y2)
+ y2 = pbox->y2;
+
+ pbox++;
+ if (x1 >= x2 || y1 >= y2)
+ continue;
+ if (!glamor_fill(drawable, gc, x1, y1, x2 - x1,
+ y2 - y1, fallback)) {
+ nrect++;
+ goto fail;
+ }
+ }
+ prect++;
+ }
+ ret = TRUE;
+ goto done;
+
+fail:
+
+ if (!fallback
+ && glamor_ddx_fallback_check_pixmap(drawable)
+ && glamor_ddx_fallback_check_gc(gc))
+ goto done;
+
+ glamor_fallback(" to %p (%c)\n",
+ drawable, glamor_get_drawable_location(drawable));
+ if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
+ if (glamor_prepare_access_gc(gc)) {
+ fbPolyFillRect(drawable, gc, nrect, prect);
+ glamor_finish_access_gc(gc);
+ }
+ glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
+ }
+ ret = TRUE;
+
+done:
+ return ret;
+}
+
+
+void
+glamor_poly_fill_rect(DrawablePtr drawable,
+ GCPtr gc, int nrect, xRectangle * prect)
+{
+ _glamor_poly_fill_rect(drawable, gc, nrect, prect, TRUE);
+}
+
+Bool
+glamor_poly_fill_rect_nf(DrawablePtr drawable,
+ GCPtr gc, int nrect, xRectangle * prect)
+{
+ return _glamor_poly_fill_rect(drawable, gc, nrect, prect, FALSE);
+}
diff --git a/xorg-server/glamor/glamor_polylines.c b/xorg-server/glamor/glamor_polylines.c
new file mode 100644
index 000000000..e723e9500
--- /dev/null
+++ b/xorg-server/glamor/glamor_polylines.c
@@ -0,0 +1,135 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ * Copyright © 1998 Keith Packard
+ *
+ * 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.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+
+#include "glamor_priv.h"
+
+/** @file glamor_polylines.c
+ *
+ * GC PolyFillRect implementation, taken straight from fb_fill.c
+ */
+
+/**
+ * glamor_poly_lines() checks if it can accelerate the lines as a group of
+ * horizontal or vertical lines (rectangles), and uses existing rectangle fill
+ * acceleration if so.
+ */
+static Bool
+_glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
+ DDXPointPtr points, Bool fallback)
+{
+ xRectangle *rects;
+ int x1, x2, y1, y2;
+ int i;
+
+ /* Don't try to do wide lines or non-solid fill style. */
+ if (gc->lineWidth != 0) {
+ /* This ends up in miSetSpans, which is accelerated as well as we
+ * can hope X wide lines will be.
+ */
+ goto wide_line;
+ }
+ if (gc->lineStyle != LineSolid) {
+ glamor_fallback
+ ("non-solid fill line style %d\n",
+ gc->lineStyle);
+ goto fail;
+ }
+ rects = malloc(sizeof(xRectangle) * (n - 1));
+ x1 = points[0].x;
+ y1 = points[0].y;
+ /* If we have any non-horizontal/vertical, fall back. */
+ for (i = 0; i < n - 1; i++) {
+ if (mode == CoordModePrevious) {
+ x2 = x1 + points[i + 1].x;
+ y2 = y1 + points[i + 1].y;
+ } else {
+ x2 = points[i + 1].x;
+ y2 = points[i + 1].y;
+ }
+ if (x1 != x2 && y1 != y2) {
+ free(rects);
+ glamor_fallback("stub diagonal poly_line\n");
+ goto fail;
+ }
+ if (x1 < x2) {
+ rects[i].x = x1;
+ rects[i].width = x2 - x1 + 1;
+ } else {
+ rects[i].x = x2;
+ rects[i].width = x1 - x2 + 1;
+ }
+ if (y1 < y2) {
+ rects[i].y = y1;
+ rects[i].height = y2 - y1 + 1;
+ } else {
+ rects[i].y = y2;
+ rects[i].height = y1 - y2 + 1;
+ }
+
+ x1 = x2;
+ y1 = y2;
+ }
+ gc->ops->PolyFillRect(drawable, gc, n - 1, rects);
+ free(rects);
+ return TRUE;
+
+ fail:
+ if (!fallback
+ && glamor_ddx_fallback_check_pixmap(drawable)
+ && glamor_ddx_fallback_check_gc(gc))
+ return FALSE;
+
+ if (gc->lineWidth == 0) {
+ if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
+ if (glamor_prepare_access_gc(gc)) {
+ fbPolyLine(drawable, gc, mode, n, points);
+ glamor_finish_access_gc(gc);
+ }
+ glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
+ }
+ } else {
+wide_line:
+ /* fb calls mi functions in the lineWidth != 0 case. */
+ fbPolyLine(drawable, gc, mode, n, points);
+ }
+ return TRUE;
+}
+
+void
+glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
+ DDXPointPtr points)
+{
+ _glamor_poly_lines(drawable, gc, mode, n, points, TRUE);
+}
+
+Bool
+glamor_poly_lines_nf(DrawablePtr drawable, GCPtr gc, int mode, int n,
+ DDXPointPtr points)
+{
+ return _glamor_poly_lines(drawable, gc, mode, n, points, FALSE);
+}
diff --git a/xorg-server/glamor/glamor_polyops.c b/xorg-server/glamor/glamor_polyops.c
new file mode 100644
index 000000000..59301784d
--- /dev/null
+++ b/xorg-server/glamor/glamor_polyops.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ * Copyright © 1998 Keith Packard
+ *
+ * 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.
+ *
+ * Authors:
+ * Zhigang Gong <zhigang.gong@linux.intel.com>
+ *
+ */
+
+#include "glamor_priv.h"
+
+static Bool
+_glamor_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
+ DDXPointPtr ppt, Bool fallback)
+{
+ if (!fallback
+ && glamor_ddx_fallback_check_gc(pGC)
+ && glamor_ddx_fallback_check_pixmap(pDrawable))
+ return FALSE;
+
+ miPolyPoint(pDrawable, pGC, mode, npt, ppt);
+
+ return TRUE;
+}
+
+void
+glamor_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
+ DDXPointPtr ppt)
+{
+ _glamor_poly_point(pDrawable, pGC, mode, npt, ppt, TRUE);
+}
+
+Bool
+glamor_poly_point_nf(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
+ DDXPointPtr ppt)
+{
+ return _glamor_poly_point(pDrawable, pGC, mode, npt, ppt, FALSE);
+}
+
+static Bool
+_glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
+ xSegment *pSeg, Bool fallback)
+{
+ if (!fallback
+ && glamor_ddx_fallback_check_gc(pGC)
+ && glamor_ddx_fallback_check_pixmap(pDrawable))
+ return FALSE;
+
+ miPolySegment(pDrawable, pGC, nseg, pSeg);
+
+ return TRUE;
+}
+
+void
+glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
+ xSegment *pSeg)
+{
+ _glamor_poly_segment(pDrawable, pGC, nseg, pSeg, TRUE);
+}
+
+Bool
+glamor_poly_segment_nf(DrawablePtr pDrawable, GCPtr pGC, int nseg,
+ xSegment *pSeg)
+{
+ return _glamor_poly_segment(pDrawable, pGC, nseg, pSeg, FALSE);
+}
diff --git a/xorg-server/glamor/glamor_priv.h b/xorg-server/glamor/glamor_priv.h
new file mode 100644
index 000000000..7b8f762c9
--- /dev/null
+++ b/xorg-server/glamor/glamor_priv.h
@@ -0,0 +1,1047 @@
+/*
+ * Copyright © 2008 Intel Corporation
+ *
+ * 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.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+#ifndef GLAMOR_PRIV_H
+#define GLAMOR_PRIV_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "compiler.h"
+
+#include <xorg-server.h>
+#ifndef DEBUG
+#define NDEBUG
+#endif
+#include "glamor.h"
+#include "compat-api.h"
+
+#define GL_GLEXT_PROTOTYPES
+
+#ifdef GLAMOR_GLES2
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+
+#define GLAMOR_DEFAULT_PRECISION "precision mediump float;\n"
+#include "glamor_glext.h"
+#else
+#include <GL/gl.h>
+#include <GL/glext.h>
+#define GLAMOR_DEFAULT_PRECISION
+#endif
+
+#ifdef RENDER
+#include "glyphstr.h"
+#endif
+
+#include "glamor_debug.h"
+
+#include <list.h>
+/* The list.h rename all the function to add xorg_ prefix.
+ We add hack here to avoid the compile error when using
+ old version xserver header file.
+ These will be removed in future. */
+#ifndef xorg_list_entry
+#define xorg_list list
+#define xorg_list_for_each_entry list_for_each_entry
+#define xorg_list_for_each_entry_safe list_for_each_entry_safe
+#define xorg_list_del list_del
+#define xorg_list_add list_add
+#define xorg_list_append list_append
+#define xorg_list_init list_init
+#endif
+
+struct glamor_pixmap_private;
+
+typedef struct glamor_composite_shader {
+ GLuint prog;
+ GLint dest_to_dest_uniform_location;
+ GLint dest_to_source_uniform_location;
+ GLint dest_to_mask_uniform_location;
+ GLint source_uniform_location;
+ GLint mask_uniform_location;
+ GLint source_wh;
+ GLint mask_wh;
+ GLint source_repeat_mode;
+ GLint mask_repeat_mode;
+ union {
+ float source_solid_color[4];
+ struct {
+ struct glamor_pixmap_private *source_priv;
+ PicturePtr source;
+ };
+ };
+
+ union {
+ float mask_solid_color[4];
+ struct {
+ struct glamor_pixmap_private *mask_priv;
+ PicturePtr mask;
+ };
+ };
+} glamor_composite_shader;
+
+enum shader_source {
+ SHADER_SOURCE_SOLID,
+ SHADER_SOURCE_TEXTURE,
+ SHADER_SOURCE_TEXTURE_ALPHA,
+ SHADER_SOURCE_COUNT,
+};
+
+enum shader_mask {
+ SHADER_MASK_NONE,
+ SHADER_MASK_SOLID,
+ SHADER_MASK_TEXTURE,
+ SHADER_MASK_TEXTURE_ALPHA,
+ SHADER_MASK_COUNT,
+};
+
+enum shader_in {
+ SHADER_IN_SOURCE_ONLY,
+ SHADER_IN_NORMAL,
+ SHADER_IN_CA_SOURCE,
+ SHADER_IN_CA_ALPHA,
+ SHADER_IN_COUNT,
+};
+
+struct shader_key {
+ enum shader_source source;
+ enum shader_mask mask;
+ enum shader_in in;
+};
+
+struct blendinfo {
+ Bool dest_alpha;
+ Bool source_alpha;
+ GLenum source_blend;
+ GLenum dest_blend;
+};
+
+typedef struct {
+ INT16 x_src;
+ INT16 y_src;
+ INT16 x_mask;
+ INT16 y_mask;
+ INT16 x_dst;
+ INT16 y_dst;
+ INT16 width;
+ INT16 height;
+} glamor_composite_rect_t;
+
+
+enum glamor_vertex_type {
+ GLAMOR_VERTEX_POS,
+ GLAMOR_VERTEX_SOURCE,
+ GLAMOR_VERTEX_MASK
+};
+
+
+enum gradient_shader {
+ SHADER_GRADIENT_LINEAR,
+ SHADER_GRADIENT_RADIAL,
+ SHADER_GRADIENT_CONICAL,
+ SHADER_GRADIENT_COUNT,
+};
+
+enum gradient_shader_prog {
+ SHADER_GRADIENT_VS_PROG,
+ SHADER_GRADIENT_FS_MAIN_PROG,
+ SHADER_GRADIENT_FS_GETCOLOR_PROG,
+ SHADER_GRADIENT_PROG_COUNT,
+};
+
+struct glamor_screen_private;
+struct glamor_pixmap_private;
+
+enum glamor_gl_flavor {
+ GLAMOR_GL_DESKTOP, // OPENGL API
+ GLAMOR_GL_ES2 // OPENGL ES2.0 API
+};
+
+#define GLAMOR_CREATE_PIXMAP_CPU 0x100
+#define GLAMOR_CREATE_PIXMAP_FIXUP 0x101
+#define GLAMOR_CREATE_FBO_NO_FBO 0x103
+#define GLAMOR_CREATE_PIXMAP_MAP 0x104
+
+#define GLAMOR_CREATE_TEXTURE_EXACT_SIZE 0x104
+
+#define GLAMOR_NUM_GLYPH_CACHE_FORMATS 2
+
+#define GLAMOR_COMPOSITE_VBO_VERT_CNT (64*1024)
+
+typedef struct {
+ PicturePtr picture; /* Where the glyphs of the cache are stored */
+ GlyphPtr *glyphs;
+ uint16_t count;
+ uint16_t evict;
+} glamor_glyph_cache_t;
+
+#include "glamor_gl_dispatch.h"
+
+struct glamor_saved_procs {
+ CloseScreenProcPtr close_screen;
+ CreateGCProcPtr create_gc;
+ CreatePixmapProcPtr create_pixmap;
+ DestroyPixmapProcPtr destroy_pixmap;
+ GetSpansProcPtr get_spans;
+ GetImageProcPtr get_image;
+ CompositeProcPtr composite;
+ CompositeRectsProcPtr composite_rects;
+ TrapezoidsProcPtr trapezoids;
+ GlyphsProcPtr glyphs;
+ ChangeWindowAttributesProcPtr change_window_attributes;
+ CopyWindowProcPtr copy_window;
+ BitmapToRegionProcPtr bitmap_to_region;
+ TrianglesProcPtr triangles;
+ AddTrapsProcPtr addtraps;
+ CreatePictureProcPtr create_picture;
+ DestroyPictureProcPtr destroy_picture;
+ UnrealizeGlyphProcPtr unrealize_glyph;
+ SetWindowPixmapProcPtr set_window_pixmap;
+};
+
+#ifdef GLAMOR_GLES2
+#define CACHE_FORMAT_COUNT 3
+#else
+#define CACHE_FORMAT_COUNT 2
+#endif
+
+#define CACHE_BUCKET_WCOUNT 4
+#define CACHE_BUCKET_HCOUNT 4
+
+#define GLAMOR_TICK_AFTER(t0, t1) \
+ (((int)(t1) - (int)(t0)) < 0)
+
+#define IDLE_STATE 0
+#define RENDER_STATE 1
+#define BLIT_STATE 2
+#define RENDER_IDEL_MAX 32
+
+typedef struct glamor_screen_private {
+ struct glamor_gl_dispatch _dispatch;
+ int yInverted;
+ unsigned int tick;
+ enum glamor_gl_flavor gl_flavor;
+ int has_pack_invert;
+ int has_fbo_blit;
+ int max_fbo_size;
+
+ struct xorg_list fbo_cache[CACHE_FORMAT_COUNT][CACHE_BUCKET_WCOUNT][CACHE_BUCKET_HCOUNT];
+ unsigned long fbo_cache_watermark;
+
+ /* glamor_solid */
+ GLint solid_prog;
+ GLint solid_color_uniform_location;
+
+ /* vertext/elment_index buffer object for render */
+ GLuint vbo, ebo;
+ int vbo_offset;
+ int vbo_size;
+ char *vb;
+ int vb_stride;
+ Bool has_source_coords, has_mask_coords;
+ int render_nr_verts;
+ glamor_composite_shader composite_shader[SHADER_SOURCE_COUNT]
+ [SHADER_MASK_COUNT]
+ [SHADER_IN_COUNT];
+ glamor_glyph_cache_t glyphCaches[GLAMOR_NUM_GLYPH_CACHE_FORMATS];
+ Bool glyph_cache_initialized;
+
+ /* shaders to restore a texture to another texture.*/
+ GLint finish_access_prog[2];
+ GLint finish_access_revert[2];
+ GLint finish_access_swap_rb[2];
+
+ /* glamor_tile */
+ GLint tile_prog;
+ GLint tile_wh;
+
+ /* glamor gradient, 0 for small nstops, 1 for
+ large nstops and 2 for dynamic generate. */
+ GLint gradient_prog[SHADER_GRADIENT_COUNT][3];
+ GLint linear_gradient_shaders[SHADER_GRADIENT_PROG_COUNT][3];
+ int linear_max_nstops;
+ GLint radial_gradient_shaders[SHADER_GRADIENT_PROG_COUNT][3];
+ int radial_max_nstops;
+
+ /* glamor trapezoid shader. */
+ GLint trapezoid_prog;
+
+ /* glamor_putimage */
+ GLint put_image_xybitmap_prog;
+ GLint put_image_xybitmap_fg_uniform_location;
+ GLint put_image_xybitmap_bg_uniform_location;
+
+ PixmapPtr *back_pixmap;
+ int screen_fbo;
+ struct glamor_saved_procs saved_procs;
+ char delayed_fallback_string[GLAMOR_DELAYED_STRING_MAX + 1];
+ int delayed_fallback_pending;
+ int flags;
+ int state;
+ unsigned int render_idle_cnt;
+ ScreenPtr screen;
+ int dri3_enabled;
+
+ /* xv */
+ GLint xv_prog;
+} glamor_screen_private;
+
+typedef enum glamor_access {
+ GLAMOR_ACCESS_RO,
+ GLAMOR_ACCESS_RW,
+ GLAMOR_ACCESS_WO,
+} glamor_access_t;
+
+#define GLAMOR_FBO_NORMAL 1
+#define GLAMOR_FBO_DOWNLOADED 2
+/* glamor_pixmap_fbo:
+ * @list: to be used to link to the cache pool list.
+ * @expire: when push to cache pool list, set a expire count.
+ * will be freed when glamor_priv->tick is equal or
+ * larger than this expire count in block handler.
+ * @pbo_valid: The pbo has a valid copy of the pixmap's data.
+ * @tex: attached texture.
+ * @fb: attached fbo.
+ * @pbo: attached pbo.
+ * @width: width of this fbo.
+ * @height: height of this fbo.
+ * @format: internal format of this fbo's texture.
+ * @type: internal type of this fbo's texture.
+ * @glamor_priv: point to glamor private data.
+ */
+typedef struct glamor_pixmap_fbo {
+ struct xorg_list list;
+ unsigned int expire;
+ unsigned char pbo_valid;
+ GLuint tex;
+ GLuint fb;
+ GLuint pbo;
+ int width;
+ int height;
+ GLenum format;
+ GLenum type;
+ glamor_screen_private *glamor_priv;
+} glamor_pixmap_fbo;
+
+/*
+ * glamor_pixmap_private - glamor pixmap's private structure.
+ * @gl_fbo:
+ * 0 - The pixmap doesn't has a fbo attached to it.
+ * GLAMOR_FBO_NORMAL - The pixmap has a fbo and can be accessed normally.
+ * GLAMOR_FBO_DOWNLOADED - The pixmap has a fbo and already downloaded to
+ * CPU, so it can only be treated as a in-memory pixmap
+ * if this bit is set.
+ * @gl_tex: The pixmap is in a gl texture originally.
+ * @is_picture: The drawable is attached to a picture.
+ * @pict_format: the corresponding picture's format.
+ * @pixmap: The corresponding pixmap's pointer.
+ *
+ * For GLAMOR_TEXTURE_LARGE, nbox should larger than 1.
+ * And the box and fbo will both have nbox elements.
+ * and box[i] store the relatively coords in this pixmap
+ * of the fbo[i]. The reason why use boxes not region to
+ * represent this structure is we may need to use overlapped
+ * boxes for one pixmap for some special reason.
+ *
+ * pixmap
+ * ******************
+ * * fbo0 * fbo1 *
+ * * * *
+ * ******************
+ * * fbo2 * fbo3 *
+ * * * *
+ * ******************
+ *
+ * Let's assume the texture has size of 1024x1024
+ * box[0] = {0,0,1024,1024}
+ * box[1] = {1024,0,2048,2048}
+ * ...
+ *
+ * For GLAMOR_TEXTURE_ATLAS nbox should be 1. And box
+ * and fbo both has one elements, and the box store
+ * the relatively coords in the fbo of this pixmap:
+ *
+ * fbo
+ * ******************
+ * * pixmap *
+ * * ********* *
+ * * * * *
+ * * ********* *
+ * * *
+ * ******************
+ *
+ * Assume the pixmap is at the (100,100) relatively to
+ * the fbo's origin.
+ * box[0]={100, 100, 1124, 1124};
+ *
+ * Considering large pixmap is not a normal case, to keep
+ * it simple, I designe it as the following way.
+ * When deal with a large pixmap, it split the working
+ * rectangle into serval boxes, and each box fit into a
+ * corresponding fbo. And then the rendering function will
+ * loop from the left-top box to the right-bottom box,
+ * each time, we will set current box and current fbo
+ * to the box and fbo elements. Thus the inner routines
+ * can handle it as normal, only the coords calculation need
+ * to aware of it's large pixmap.
+ *
+ * Currently, we haven't implemented the atlas pixmap.
+ *
+ **/
+
+typedef struct glamor_pixmap_clipped_regions{
+ int block_idx;
+ RegionPtr region;
+} glamor_pixmap_clipped_regions;
+
+#define SET_PIXMAP_FBO_CURRENT(priv, idx) \
+ do { \
+ if (priv->type == GLAMOR_TEXTURE_LARGE) { \
+ (priv)->large.base.fbo = priv->large.fbo_array[idx]; \
+ (priv)->large.box = priv->large.box_array[idx]; \
+ } \
+ } while(0)
+
+typedef struct glamor_pixmap_private_base {
+ glamor_pixmap_type_t type;
+ unsigned char gl_fbo:2;
+ unsigned char is_picture:1;
+ unsigned char gl_tex:1;
+ glamor_pixmap_fbo *fbo;
+ PixmapPtr pixmap;
+ int drm_stride;
+ glamor_screen_private *glamor_priv;
+ PicturePtr picture;
+}glamor_pixmap_private_base_t;
+
+/*
+ * @base.fbo: current fbo.
+ * @box: current fbo's coords in the whole pixmap.
+ * @block_w: block width of this large pixmap.
+ * @block_h: block height of this large pixmap.
+ * @block_wcnt: block count in one block row.
+ * @block_hcnt: block count in one block column.
+ * @nbox: total block count.
+ * @box_array: contains each block's corresponding box.
+ * @fbo_array: contains each block's fbo pointer.
+ *
+ **/
+typedef struct glamor_pixmap_private_large {
+ union {
+ glamor_pixmap_type_t type;
+ glamor_pixmap_private_base_t base;
+ };
+ BoxRec box;
+ int block_w;
+ int block_h;
+ int block_wcnt;
+ int block_hcnt;
+ int nbox;
+ BoxPtr box_array;
+ glamor_pixmap_fbo **fbo_array;
+}glamor_pixmap_private_large_t;
+
+/*
+ * @box: the relative coords in the corresponding fbo.
+ */
+typedef struct glamor_pixmap_private_atlas {
+ union {
+ glamor_pixmap_type_t type;
+ glamor_pixmap_private_base_t base;
+ };
+ BoxRec box;
+}glamor_pixmap_private_atlas_t;
+
+typedef struct glamor_pixmap_private {
+ union {
+ glamor_pixmap_type_t type;
+ glamor_pixmap_private_base_t base;
+ glamor_pixmap_private_large_t large;
+ glamor_pixmap_private_atlas_t atlas;
+ };
+}glamor_pixmap_private;
+
+/*
+ * Pixmap dynamic status, used by dynamic upload feature.
+ *
+ * GLAMOR_NONE: initial status, don't need to do anything.
+ * GLAMOR_UPLOAD_PENDING: marked as need to be uploaded to gl texture.
+ * GLAMOR_UPLOAD_DONE: the pixmap has been uploaded successfully.
+ * GLAMOR_UPLOAD_FAILED: fail to upload the pixmap.
+ *
+ * */
+typedef enum glamor_pixmap_status {
+ GLAMOR_NONE,
+ GLAMOR_UPLOAD_PENDING,
+ GLAMOR_UPLOAD_DONE,
+ GLAMOR_UPLOAD_FAILED
+} glamor_pixmap_status_t;
+
+extern DevPrivateKey glamor_screen_private_key;
+extern DevPrivateKey glamor_pixmap_private_key;
+static inline glamor_screen_private *
+glamor_get_screen_private(ScreenPtr screen)
+{
+ return (glamor_screen_private *)
+ dixLookupPrivate(&screen->devPrivates,
+ glamor_screen_private_key);
+}
+
+static inline void
+glamor_set_screen_private(ScreenPtr screen, glamor_screen_private *priv)
+{
+ dixSetPrivate(&screen->devPrivates,
+ glamor_screen_private_key,
+ priv);
+}
+
+
+
+static inline glamor_pixmap_private *
+glamor_get_pixmap_private(PixmapPtr pixmap)
+{
+ glamor_pixmap_private *priv;
+ priv = dixLookupPrivate(&pixmap->devPrivates,
+ glamor_pixmap_private_key);
+ if (!priv) {
+ glamor_set_pixmap_type(pixmap, GLAMOR_MEMORY);
+ priv = dixLookupPrivate(&pixmap->devPrivates,
+ glamor_pixmap_private_key);
+ }
+ return priv;
+}
+
+void glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv);
+
+/**
+ * Returns TRUE if the given planemask covers all the significant bits in the
+ * pixel values for pDrawable.
+ */
+static inline Bool
+glamor_pm_is_solid(DrawablePtr drawable, unsigned long planemask)
+{
+ return (planemask & FbFullMask(drawable->depth)) ==
+ FbFullMask(drawable->depth);
+}
+
+extern int glamor_debug_level;
+
+/* glamor.c */
+PixmapPtr glamor_get_drawable_pixmap(DrawablePtr drawable);
+
+Bool glamor_destroy_pixmap(PixmapPtr pixmap);
+
+glamor_pixmap_fbo* glamor_pixmap_detach_fbo(glamor_pixmap_private *pixmap_priv);
+void glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo *fbo);
+glamor_pixmap_fbo * glamor_create_fbo_from_tex(glamor_screen_private *glamor_priv,
+ int w, int h, GLenum format, GLint tex, int flag);
+glamor_pixmap_fbo * glamor_create_fbo(glamor_screen_private *glamor_priv,
+ int w, int h, GLenum format, int flag);
+void glamor_destroy_fbo(glamor_pixmap_fbo *fbo);
+void glamor_pixmap_destroy_fbo(glamor_pixmap_private *priv);
+void glamor_purge_fbo(glamor_pixmap_fbo *fbo);
+
+void glamor_init_pixmap_fbo(ScreenPtr screen);
+void glamor_fini_pixmap_fbo(ScreenPtr screen);
+Bool glamor_pixmap_fbo_fixup(ScreenPtr screen, PixmapPtr pixmap);
+void glamor_fbo_expire(glamor_screen_private *glamor_priv);
+
+glamor_pixmap_fbo *
+glamor_create_fbo_array(glamor_screen_private *glamor_priv,
+ int w, int h, GLenum format, int flag,
+ int block_w, int block_h, glamor_pixmap_private *);
+
+/* glamor_copyarea.c */
+RegionPtr
+glamor_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc,
+ int srcx, int srcy, int width, int height, int dstx,
+ int dsty);
+void glamor_copy_n_to_n(DrawablePtr src, DrawablePtr dst, GCPtr gc,
+ BoxPtr box, int nbox, int dx, int dy, Bool reverse,
+ Bool upsidedown, Pixel bitplane, void *closure);
+
+/* glamor_copywindow.c */
+void glamor_copy_window(WindowPtr win, DDXPointRec old_origin,
+ RegionPtr src_region);
+
+/* glamor_core.c */
+Bool glamor_prepare_access(DrawablePtr drawable, glamor_access_t access);
+void glamor_finish_access(DrawablePtr drawable, glamor_access_t access);
+Bool glamor_prepare_access_window(WindowPtr window);
+void glamor_finish_access_window(WindowPtr window);
+Bool glamor_prepare_access_gc(GCPtr gc);
+void glamor_finish_access_gc(GCPtr gc);
+void glamor_init_finish_access_shaders(ScreenPtr screen);
+void glamor_fini_finish_access_shaders(ScreenPtr screen);
+const Bool glamor_get_drawable_location(const DrawablePtr drawable);
+void glamor_get_drawable_deltas(DrawablePtr drawable, PixmapPtr pixmap,
+ int *x, int *y);
+Bool glamor_stipple(PixmapPtr pixmap, PixmapPtr stipple,
+ int x, int y, int width, int height,
+ unsigned char alu, unsigned long planemask,
+ unsigned long fg_pixel, unsigned long bg_pixel,
+ int stipple_x, int stipple_y);
+GLint glamor_compile_glsl_prog(glamor_gl_dispatch * dispatch, GLenum type,
+ const char *source);
+void glamor_link_glsl_prog(glamor_gl_dispatch * dispatch, GLint prog);
+void glamor_get_color_4f_from_pixel(PixmapPtr pixmap,
+ unsigned long fg_pixel,
+ GLfloat * color);
+
+int glamor_set_destination_pixmap(PixmapPtr pixmap);
+int glamor_set_destination_pixmap_priv(glamor_pixmap_private *
+ pixmap_priv);
+void glamor_set_destination_pixmap_fbo(glamor_pixmap_fbo *, int, int, int, int);
+
+/* nc means no check. caller must ensure this pixmap has valid fbo.
+ * usually use the GLAMOR_PIXMAP_PRIV_HAS_FBO firstly.
+ * */
+void glamor_set_destination_pixmap_priv_nc(glamor_pixmap_private *
+ pixmap_priv);
+
+glamor_pixmap_fbo *
+glamor_es2_pixmap_read_prepare(PixmapPtr source, int x, int y, int w, int h, GLenum format,
+ GLenum type, int no_alpha, int revert, int swap_rb);
+
+Bool glamor_set_alu(struct glamor_gl_dispatch *dispatch,
+ unsigned char alu);
+Bool glamor_set_planemask(PixmapPtr pixmap, unsigned long planemask);
+Bool glamor_change_window_attributes(WindowPtr pWin, unsigned long mask);
+RegionPtr glamor_bitmap_to_region(PixmapPtr pixmap);
+Bool glamor_gl_has_extension(const char *extension);
+int glamor_gl_get_version(void);
+
+#define GLAMOR_GL_VERSION_ENCODE(major, minor) ( \
+ ((major) * 256) \
+ + ((minor) * 1))
+
+
+
+
+/* glamor_fill.c */
+Bool glamor_fill(DrawablePtr drawable,
+ GCPtr gc, int x, int y, int width, int height, Bool fallback);
+Bool glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
+ unsigned char alu, unsigned long planemask,
+ unsigned long fg_pixel);
+Bool
+glamor_solid_boxes(PixmapPtr pixmap,
+ BoxPtr box, int nbox,
+ unsigned long fg_pixel);
+
+/* glamor_fillspans.c */
+void glamor_fill_spans(DrawablePtr drawable,
+ GCPtr gc,
+ int n, DDXPointPtr points, int *widths, int sorted);
+
+void glamor_init_solid_shader(ScreenPtr screen);
+void glamor_fini_solid_shader(ScreenPtr screen);
+
+/* glamor_getspans.c */
+void
+
+glamor_get_spans(DrawablePtr drawable,
+ int wmax,
+ DDXPointPtr points,
+ int *widths, int nspans, char *dst_start);
+
+/* glamor_glyphs.c */
+void glamor_glyphs_fini(ScreenPtr screen);
+void glamor_glyphs(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc,
+ INT16 ySrc, int nlist, GlyphListPtr list,
+ GlyphPtr * glyphs);
+
+/* glamor_setspans.c */
+void glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
+ DDXPointPtr points, int *widths, int n, int sorted);
+
+/* glamor_polyfillrect.c */
+void
+glamor_poly_fill_rect(DrawablePtr drawable,
+ GCPtr gc, int nrect, xRectangle * prect);
+
+/* glamor_polylines.c */
+void
+
+glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
+ DDXPointPtr points);
+
+/* glamor_putimage.c */
+void
+
+glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
+ int w, int h, int leftPad, int format, char *bits);
+void glamor_init_putimage_shaders(ScreenPtr screen);
+void glamor_fini_putimage_shaders(ScreenPtr screen);
+
+/* glamor_render.c */
+Bool
+glamor_composite_clipped_region(CARD8 op,
+ PicturePtr source,
+ PicturePtr mask,
+ PicturePtr dest,
+ glamor_pixmap_private *soruce_pixmap_priv,
+ glamor_pixmap_private *mask_pixmap_priv,
+ glamor_pixmap_private *dest_pixmap_priv,
+ RegionPtr region,
+ int x_source,
+ int y_source,
+ int x_mask,
+ int y_mask,
+ int x_dest,
+ int y_dest);
+
+void glamor_composite(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst, INT16 yDst, CARD16 width, CARD16 height);
+
+void glamor_init_composite_shaders(ScreenPtr screen);
+void glamor_fini_composite_shaders(ScreenPtr screen);
+void glamor_composite_glyph_rects(CARD8 op,
+ PicturePtr src, PicturePtr mask,
+ PicturePtr dst, int nrect,
+ glamor_composite_rect_t * rects);
+void glamor_composite_rects (CARD8 op,
+ PicturePtr pDst,
+ xRenderColor *color,
+ int nRect,
+ xRectangle *rects);
+void glamor_init_trapezoid_shader(ScreenPtr screen);
+void glamor_fini_trapezoid_shader(ScreenPtr screen);
+PicturePtr glamor_convert_gradient_picture(ScreenPtr screen,
+ PicturePtr source,
+ int x_source,
+ int y_source, int width, int height);
+
+Bool glamor_composite_choose_shader(CARD8 op,
+ PicturePtr source,
+ PicturePtr mask,
+ PicturePtr dest,
+ glamor_pixmap_private *source_pixmap_priv,
+ glamor_pixmap_private *mask_pixmap_priv,
+ glamor_pixmap_private *dest_pixmap_priv,
+ struct shader_key *s_key,
+ glamor_composite_shader **shader,
+ struct blendinfo *op_info,
+ PictFormatShort *psaved_source_format);
+
+void
+glamor_composite_set_shader_blend(glamor_pixmap_private *dest_priv,
+ struct shader_key *key,
+ glamor_composite_shader *shader,
+ struct blendinfo *op_info);
+
+void glamor_setup_composite_vbo(ScreenPtr screen, int n_verts);
+void glamor_emit_composite_vert(ScreenPtr screen,
+ const float *src_coords,
+ const float *mask_coords,
+ const float *dst_coords, int i);
+
+/* glamor_trapezoid.c */
+void glamor_trapezoids(CARD8 op,
+ PicturePtr src, PicturePtr dst,
+ PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
+ int ntrap, xTrapezoid * traps);
+
+/* glamor_tile.c */
+Bool glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
+ int x, int y, int width, int height,
+ unsigned char alu, unsigned long planemask,
+ int tile_x, int tile_y);
+void glamor_init_tile_shader(ScreenPtr screen);
+void glamor_fini_tile_shader(ScreenPtr screen);
+
+/* glamor_gradient.c */
+void glamor_init_gradient_shader(ScreenPtr screen);
+void glamor_fini_gradient_shader(ScreenPtr screen);
+PicturePtr glamor_generate_linear_gradient_picture(ScreenPtr screen,
+ PicturePtr src_picture,
+ int x_source, int y_source,
+ int width, int height,
+ PictFormatShort format);
+PicturePtr glamor_generate_radial_gradient_picture(ScreenPtr screen,
+ PicturePtr src_picture,
+ int x_source, int y_source,
+ int width, int height,
+ PictFormatShort format);
+
+/* glamor_triangles.c */
+void
+
+glamor_triangles(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris);
+
+/* glamor_pixmap.c */
+
+void glamor_pixmap_init(ScreenPtr screen);
+void glamor_pixmap_fini(ScreenPtr screen);
+/**
+ * Download a pixmap's texture to cpu memory. If success,
+ * One copy of current pixmap's texture will be put into
+ * the pixmap->devPrivate.ptr. Will use pbo to map to
+ * the pointer if possible.
+ * The pixmap must be a gl texture pixmap. gl_fbo and
+ * gl_tex must be 1. Used by glamor_prepare_access.
+ *
+ */
+Bool glamor_download_pixmap_to_cpu(PixmapPtr pixmap,
+ glamor_access_t access);
+
+void *
+glamor_download_sub_pixmap_to_cpu(PixmapPtr pixmap, int x, int y, int w, int h,
+ int stride, void *bits, int pbo, glamor_access_t access);
+
+
+/**
+ * Restore a pixmap's data which is downloaded by
+ * glamor_download_pixmap_to_cpu to its original
+ * gl texture. Used by glamor_finish_access.
+ *
+ * The pixmap must be
+ * in texture originally. In other word, the gl_fbo
+ * must be 1.
+ **/
+void glamor_restore_pixmap_to_texture(PixmapPtr pixmap);
+
+/**
+ * According to the flag,
+ * if the flag is GLAMOR_CREATE_FBO_NO_FBO then just ensure
+ * the fbo has a valid texture. Otherwise, it will ensure
+ * the fbo has valid texture and attach to a valid fb.
+ * If the fbo already has a valid glfbo then do nothing.
+ */
+Bool
+glamor_pixmap_ensure_fbo(PixmapPtr pixmap, GLenum format, int flag);
+
+/**
+ * Upload a pixmap to gl texture. Used by dynamic pixmap
+ * uploading feature. The pixmap must be a software pixmap.
+ * This function will change current FBO and current shaders.
+ */
+enum glamor_pixmap_status glamor_upload_pixmap_to_texture(PixmapPtr
+ pixmap);
+
+Bool
+glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w, int h,
+ int stride, void *bits, int pbo);
+
+PixmapPtr
+glamor_get_sub_pixmap(PixmapPtr pixmap, int x, int y,
+ int w, int h, glamor_access_t access);
+void
+glamor_put_sub_pixmap(PixmapPtr sub_pixmap, PixmapPtr pixmap, int x, int y,
+ int w, int h, glamor_access_t access);
+
+glamor_pixmap_clipped_regions *
+glamor_compute_clipped_regions(glamor_pixmap_private *priv, RegionPtr region,
+ int *clipped_nbox, int repeat_type,
+ int reverse, int upsidedown);
+
+glamor_pixmap_clipped_regions *
+glamor_compute_clipped_regions_ext(glamor_pixmap_private *pixmap_priv,
+ RegionPtr region,
+ int *n_region,
+ int inner_block_w, int inner_block_h,
+ int reverse, int upsidedown);
+
+glamor_pixmap_clipped_regions *
+glamor_compute_transform_clipped_regions(glamor_pixmap_private *priv, struct pixman_transform *transform,
+ RegionPtr region, int *n_region, int dx, int dy, int repeat_type,
+ int reverse, int upsidedown);
+
+Bool
+glamor_composite_largepixmap_region(CARD8 op,
+ PicturePtr source,
+ PicturePtr mask,
+ PicturePtr dest,
+ glamor_pixmap_private * source_pixmap_priv,
+ glamor_pixmap_private * mask_pixmap_priv,
+ glamor_pixmap_private * dest_pixmap_priv,
+ RegionPtr region, Bool force_clip,
+ INT16 x_source,
+ INT16 y_source,
+ INT16 x_mask,
+ INT16 y_mask,
+ INT16 x_dest, INT16 y_dest,
+ CARD16 width, CARD16 height);
+
+Bool
+glamor_get_transform_block_size(struct pixman_transform *transform,
+ int block_w, int block_h,
+ int *transformed_block_w,
+ int *transformed_block_h);
+
+void
+glamor_get_transform_extent_from_box(struct pixman_box32 *temp_box,
+ struct pixman_transform *transform);
+
+/**
+ * Upload a picture to gl texture. Similar to the
+ * glamor_upload_pixmap_to_texture. Used in rendering.
+ **/
+enum glamor_pixmap_status
+ glamor_upload_picture_to_texture(PicturePtr picture);
+
+/**
+ * Upload bits to a pixmap's texture. This function will
+ * convert the bits to the specified format/type format
+ * if the conversion is unavoidable.
+ **/
+Bool glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format, GLenum type,
+ int no_alpha, int revert, int swap_rb, void *bits);
+
+/**
+ * Destroy all the resources allocated on the uploading
+ * phase, includs the tex and fbo.
+ **/
+void glamor_destroy_upload_pixmap(PixmapPtr pixmap);
+
+int glamor_create_picture(PicturePtr picture);
+
+void glamor_set_window_pixmap(WindowPtr pWindow, PixmapPtr pPixmap);
+
+Bool
+glamor_prepare_access_picture(PicturePtr picture, glamor_access_t access);
+
+void glamor_finish_access_picture(PicturePtr picture, glamor_access_t access);
+
+void glamor_destroy_picture(PicturePtr picture);
+
+/* fixup a fbo to the exact size as the pixmap. */
+Bool
+glamor_fixup_pixmap_priv(ScreenPtr screen, glamor_pixmap_private *pixmap_priv);
+
+void
+glamor_picture_format_fixup(PicturePtr picture,
+ glamor_pixmap_private * pixmap_priv);
+
+void
+glamor_get_image(DrawablePtr pDrawable, int x, int y, int w, int h,
+ unsigned int format, unsigned long planeMask, char *d);
+
+void
+glamor_add_traps(PicturePtr pPicture,
+ INT16 x_off,
+ INT16 y_off, int ntrap, xTrap * traps);
+
+RegionPtr
+glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int w, int h, int dstx, int dsty,
+ unsigned long bitPlane);
+
+void
+glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase);
+
+void
+glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr * ppci, pointer pglyphBase);
+
+void
+glamor_push_pixels(GCPtr pGC, PixmapPtr pBitmap,
+ DrawablePtr pDrawable, int w, int h, int x, int y);
+
+void
+glamor_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
+ DDXPointPtr ppt);
+
+void
+glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
+ xSegment *pSeg);
+
+void
+glamor_poly_line(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
+ DDXPointPtr ppt);
+
+void
+glamor_composite_rectangles(CARD8 op,
+ PicturePtr dst,
+ xRenderColor *color,
+ int num_rects,
+ xRectangle *rects);
+
+/* glamor_xv */
+typedef struct {
+ uint32_t transform_index;
+ uint32_t gamma; /* gamma value x 1000 */
+ int brightness;
+ int saturation;
+ int hue;
+ int contrast;
+
+ DrawablePtr pDraw;
+ PixmapPtr pPixmap;
+ uint32_t src_pitch;
+ uint8_t *src_addr;
+ int src_w, src_h, dst_w, dst_h;
+ int src_x, src_y, drw_x, drw_y;
+ int w, h;
+ RegionRec clip;
+ PixmapPtr src_pix[3]; /* y, u, v for planar */
+ int src_pix_w, src_pix_h;
+} glamor_port_private;
+
+void glamor_init_xv_shader(ScreenPtr screen);
+void glamor_fini_xv_shader(ScreenPtr screen);
+
+#include"glamor_utils.h"
+
+/* Dynamic pixmap upload to texture if needed.
+ * Sometimes, the target is a gl texture pixmap/picture,
+ * but the source or mask is in cpu memory. In that case,
+ * upload the source/mask to gl texture and then avoid
+ * fallback the whole process to cpu. Most of the time,
+ * this will increase performance obviously. */
+
+#define GLAMOR_PIXMAP_DYNAMIC_UPLOAD
+#define GLAMOR_GRADIENT_SHADER
+#define GLAMOR_TRAPEZOID_SHADER
+#define GLAMOR_TEXTURED_LARGE_PIXMAP 1
+#define WALKAROUND_LARGE_TEXTURE_MAP
+#if 0
+#define MAX_FBO_SIZE 32 /* For test purpose only. */
+#endif
+//#define GLYPHS_NO_EDEGEMAP_OVERLAP_CHECK
+#define GLYPHS_EDEGE_OVERLAP_LOOSE_CHECK
+
+#endif /* GLAMOR_PRIV_H */
diff --git a/xorg-server/glamor/glamor_putimage.c b/xorg-server/glamor/glamor_putimage.c
new file mode 100644
index 000000000..99f7ac6f5
--- /dev/null
+++ b/xorg-server/glamor/glamor_putimage.c
@@ -0,0 +1,363 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ *
+ * 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.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ * Zhigang Gong <zhigang.gong@linux.intel.com>
+ *
+ */
+
+
+/** @file glamor_putaimge.c
+ *
+ * XPutImage implementation
+ */
+#include "glamor_priv.h"
+
+void
+glamor_init_putimage_shaders(ScreenPtr screen)
+{
+#if 0
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(screen);
+ const char *xybitmap_vs =
+ "uniform float x_bias;\n" "uniform float x_scale;\n"
+ "uniform float y_bias;\n" "uniform float y_scale;\n"
+ "varying vec2 bitmap_coords;\n" "void main()\n" "{\n"
+ " gl_Position = vec4((gl_Vertex.x + x_bias) * x_scale,\n"
+ " (gl_Vertex.y + y_bias) * y_scale,\n"
+ " 0,\n"
+ " 1);\n"
+ " bitmap_coords = gl_MultiTexCoord0.xy;\n" "}\n";
+ const char *xybitmap_fs =
+ "uniform vec4 fg, bg;\n" "varying vec2 bitmap_coords;\n"
+ "uniform sampler2D bitmap_sampler;\n" "void main()\n" "{\n"
+ " float bitmap_value = texture2D(bitmap_sampler,\n"
+ " bitmap_coords).x;\n"
+ " gl_FragColor = mix(bg, fg, bitmap_value);\n" "}\n";
+ GLint fs_prog, vs_prog, prog;
+ GLint sampler_uniform_location;
+
+ if (!GLEW_ARB_fragment_shader)
+ return;
+
+ prog = dispatch->glCreateProgram();
+ vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, xybitmap_vs);
+ fs_prog =
+ glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, xybitmap_fs);
+ dispatch->glAttachShader(prog, vs_prog);
+ dispatch->glAttachShader(prog, fs_prog);
+ glamor_link_glsl_prog(prog);
+
+ dispatch->glUseProgram(prog);
+ sampler_uniform_location =
+ dispatch->glGetUniformLocation(prog, "bitmap_sampler");
+ dispatch->glUniform1i(sampler_uniform_location, 0);
+
+ glamor_priv->put_image_xybitmap_fg_uniform_location =
+ dispatch->glGetUniformLocation(prog, "fg");
+ glamor_priv->put_image_xybitmap_bg_uniform_location =
+ dispatch->glGetUniformLocation(prog, "bg");
+ glamor_get_transform_uniform_locations(prog,
+ &glamor_priv->put_image_xybitmap_transform);
+ glamor_priv->put_image_xybitmap_prog = prog;
+ dispatch->glUseProgram(0);
+#endif
+}
+
+
+/* Do an XYBitmap putimage. The bits are byte-aligned rows of bitmap
+ * data (where each row starts at a bit index of left_pad), and the
+ * destination gets filled with the gc's fg color where the bitmap is set
+ * and the bg color where the bitmap is unset.
+ *
+ * Implement this by passing the bitmap right through to GL, and sampling
+ * it to choose between fg and bg in the fragment shader. The driver may
+ * be exploding the bitmap up to be an 8-bit alpha texture, in which
+ * case we might be better off just doing the fg/bg choosing in the CPU
+ * and just draw the resulting texture to the destination.
+ */
+#if 0
+
+static int
+y_flip(PixmapPtr pixmap, int y)
+{
+ ScreenPtr screen = pixmap->drawable.pScreen;
+ PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
+
+ if (pixmap == screen_pixmap)
+ return (pixmap->drawable.height - 1) - y;
+ else
+ return y;
+}
+
+
+static void
+glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
+ int x, int y, int w, int h, int left_pad,
+ int image_format, char *bits)
+{
+ ScreenPtr screen = drawable->pScreen;
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(screen);
+ float fg[4], bg[4];
+ GLuint tex;
+ unsigned int stride = PixmapBytePad(1, w + left_pad);
+ RegionPtr clip;
+ BoxPtr box;
+ int nbox;
+ float dest_coords[8];
+ const float bitmap_coords[8] = {
+ 0.0, 0.0,
+ 1.0, 0.0,
+ 1.0, 1.0,
+ 0.0, 1.0,
+ };
+ GLfloat xscale, yscale;
+ glamor_pixmap_private *pixmap_priv;
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+
+ pixmap_priv_get_scale(pixmap_priv, &xscale, &yscale);
+
+ glamor_set_normalize_vcoords(xscale, yscale,
+ x, y,
+ x + w, y + h,
+ glamor_priv->yInverted, dest_coords);
+
+ glamor_fallback("glamor_put_image_xybitmap: disabled\n");
+ goto fail;
+
+ if (glamor_priv->put_image_xybitmap_prog == 0) {
+ ErrorF("no program for xybitmap putimage\n");
+ goto fail;
+ }
+
+ glamor_set_alu(gc->alu);
+ if (!glamor_set_planemask(pixmap, gc->planemask))
+ goto fail;
+
+ dispatch->glUseProgram(glamor_priv->put_image_xybitmap_prog);
+
+ glamor_get_color_4f_from_pixel(pixmap, gc->fgPixel, fg);
+ dispatch->glUniform4fv
+ (glamor_priv->put_image_xybitmap_fg_uniform_location, 1, fg);
+ glamor_get_color_4f_from_pixel(pixmap, gc->bgPixel, bg);
+ dispatch->glUniform4fv
+ (glamor_priv->put_image_xybitmap_bg_uniform_location, 1, bg);
+
+ dispatch->glGenTextures(1, &tex);
+ dispatch->glActiveTexture(GL_TEXTURE0);
+ dispatch->glEnable(GL_TEXTURE_2D);
+ dispatch->glBindTexture(GL_TEXTURE_2D, tex);
+ dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ GL_NEAREST);
+ dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
+ GL_NEAREST);
+ dispatch->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ dispatch->glPixelStorei(GL_UNPACK_ROW_LENGTH, stride * 8);
+ dispatch->glPixelStorei(GL_UNPACK_SKIP_PIXELS, left_pad);
+ dispatch->glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA,
+ w, h, 0, GL_COLOR_INDEX, GL_BITMAP, bits);
+ dispatch->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ dispatch->glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
+
+ /* Now that we've set up our bitmap texture and the shader, shove
+ * the destination rectangle through the cliprects and run the
+ * shader on the resulting fragments.
+ */
+ dispatch->glVertexPointer(2, GL_FLOAT, 0, dest_coords);
+ dispatch->glEnableClientState(GL_VERTEX_ARRAY);
+ dispatch->glClientActiveTexture(GL_TEXTURE0);
+ dispatch->glTexCoordPointer(2, GL_FLOAT, 0, bitmap_coords);
+ dispatch->glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+
+ dispatch->glEnable(GL_SCISSOR_TEST);
+ clip = fbGetCompositeClip(gc);
+ for (nbox = REGION_NUM_RECTS(clip),
+ box = REGION_RECTS(clip); nbox--; box++) {
+ int x1 = x;
+ int y1 = y;
+ int x2 = x + w;
+ int y2 = y + h;
+
+ if (x1 < box->x1)
+ x1 = box->x1;
+ if (y1 < box->y1)
+ y1 = box->y1;
+ if (x2 > box->x2)
+ x2 = box->x2;
+ if (y2 > box->y2)
+ y2 = box->y2;
+ if (x1 >= x2 || y1 >= y2)
+ continue;
+
+ dispatch->glScissor(box->x1,
+ y_flip(pixmap, box->y1),
+ box->x2 - box->x1, box->y2 - box->y1);
+ dispatch->glDrawArrays(GL_QUADS, 0, 4);
+ }
+
+ dispatch->glDisable(GL_SCISSOR_TEST);
+ glamor_set_alu(GXcopy);
+ glamor_set_planemask(pixmap, ~0);
+ dispatch->glDeleteTextures(1, &tex);
+ dispatch->glDisable(GL_TEXTURE_2D);
+ dispatch->glDisableClientState(GL_VERTEX_ARRAY);
+ dispatch->glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ return;
+ glamor_set_alu(GXcopy);
+ glamor_set_planemask(pixmap, ~0);
+ glamor_fallback(": to %p (%c)\n",
+ drawable, glamor_get_drawable_location(drawable));
+fail:
+ if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
+ fbPutImage(drawable, gc, 1, x, y, w, h, left_pad, XYBitmap,
+ bits);
+ glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
+ }
+}
+#endif
+
+void
+glamor_fini_putimage_shaders(ScreenPtr screen)
+{
+}
+
+
+static Bool
+_glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
+ int w, int h, int left_pad, int image_format, char *bits, Bool fallback)
+{
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_pixmap_private *pixmap_priv =
+ glamor_get_pixmap_private(pixmap);
+ RegionPtr clip;
+ int x_off, y_off;
+ Bool ret = FALSE;
+ PixmapPtr temp_pixmap, sub_pixmap;
+ glamor_pixmap_private *temp_pixmap_priv;
+ BoxRec box;
+
+ glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
+ clip = fbGetCompositeClip(gc);
+ if (image_format == XYBitmap) {
+ assert(depth == 1);
+ goto fail;
+ }
+
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
+ glamor_fallback("has no fbo.\n");
+ goto fail;
+ }
+
+ if (image_format != ZPixmap) {
+ glamor_fallback("non-ZPixmap\n");
+ goto fail;
+ }
+
+ if (!glamor_set_planemask(pixmap, gc->planemask)) {
+ goto fail;
+ }
+ /* create a temporary pixmap and upload the bits to that
+ * pixmap, then apply clip copy it to the destination pixmap.*/
+ box.x1 = x + drawable->x;
+ box.y1 = y + drawable->y;
+ box.x2 = x + w + drawable->x;
+ box.y2 = y + h + drawable->y;
+
+ if ((clip != NULL && RegionContainsRect(clip, &box) != rgnIN)
+ || gc->alu != GXcopy) {
+ temp_pixmap = glamor_create_pixmap(drawable->pScreen, w, h, depth, 0);
+ if (temp_pixmap == NULL)
+ goto fail;
+
+ temp_pixmap_priv = glamor_get_pixmap_private(temp_pixmap);
+
+ if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv)) {
+ temp_pixmap_priv->base.picture = pixmap_priv->base.picture;
+ temp_pixmap_priv->base.is_picture = pixmap_priv->base.is_picture;
+ }
+
+ glamor_upload_sub_pixmap_to_texture(temp_pixmap, 0, 0, w, h,
+ pixmap->devKind, bits, 0);
+
+ glamor_copy_area(&temp_pixmap->drawable, drawable, gc, 0, 0, w, h, x, y);
+ glamor_destroy_pixmap(temp_pixmap);
+ } else
+ glamor_upload_sub_pixmap_to_texture(pixmap, x + drawable->x + x_off, y + drawable->y + y_off,
+ w, h, PixmapBytePad(w, depth), bits, 0);
+ ret = TRUE;
+ goto done;
+
+fail:
+ glamor_set_planemask(pixmap, ~0);
+
+ if (!fallback
+ && glamor_ddx_fallback_check_pixmap(&pixmap->drawable))
+ goto done;
+
+ glamor_fallback("to %p (%c)\n",
+ drawable, glamor_get_drawable_location(drawable));
+
+ sub_pixmap = glamor_get_sub_pixmap(pixmap, x + x_off + drawable->x,
+ y + y_off + drawable->y, w, h,
+ GLAMOR_ACCESS_RW);
+ if (sub_pixmap) {
+ if (clip != NULL)
+ pixman_region_translate (clip, -x - drawable->x, -y - drawable->y);
+
+ fbPutImage(&sub_pixmap->drawable, gc, depth, 0, 0, w, h,
+ left_pad, image_format, bits);
+
+ glamor_put_sub_pixmap(sub_pixmap, pixmap,
+ x + x_off + drawable->x,
+ y + y_off + drawable->y,
+ w, h, GLAMOR_ACCESS_RW);
+ if (clip != NULL)
+ pixman_region_translate (clip, x + drawable->x, y + drawable->y);
+ } else
+ fbPutImage(drawable, gc, depth, x, y, w, h,
+ left_pad, image_format, bits);
+ ret = TRUE;
+
+done:
+ return ret;
+}
+
+void
+glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
+ int w, int h, int left_pad, int image_format, char *bits)
+{
+ _glamor_put_image(drawable, gc, depth, x, y, w, h,
+ left_pad, image_format, bits, TRUE);
+}
+
+Bool
+glamor_put_image_nf(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
+ int w, int h, int left_pad, int image_format, char *bits)
+{
+ return _glamor_put_image(drawable, gc, depth, x, y, w, h,
+ left_pad, image_format, bits, FALSE);
+}
+
diff --git a/xorg-server/glamor/glamor_render.c b/xorg-server/glamor/glamor_render.c
new file mode 100644
index 000000000..76a571f8b
--- /dev/null
+++ b/xorg-server/glamor/glamor_render.c
@@ -0,0 +1,2135 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ *
+ * 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.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ * Zhigang Gong <zhigang.gong@linux.intel.com>
+ * Junyan He <junyan.he@linux.intel.com>
+ *
+ */
+
+/** @file glamor_render.c
+ *
+ * Render acceleration implementation
+ */
+
+#include "glamor_priv.h"
+
+#ifdef RENDER
+#include "mipict.h"
+#include "fbpict.h"
+#if 0
+//#define DEBUGF(str, ...) do {} while(0)
+#define DEBUGF(str, ...) ErrorF(str, ##__VA_ARGS__)
+//#define DEBUGRegionPrint(x) do {} while (0)
+#define DEBUGRegionPrint RegionPrint
+#endif
+
+static struct blendinfo composite_op_info[] = {
+ [PictOpClear] = {0, 0, GL_ZERO, GL_ZERO},
+ [PictOpSrc] = {0, 0, GL_ONE, GL_ZERO},
+ [PictOpDst] = {0, 0, GL_ZERO, GL_ONE},
+ [PictOpOver] = {0, 1, GL_ONE, GL_ONE_MINUS_SRC_ALPHA},
+ [PictOpOverReverse] = {1, 0, GL_ONE_MINUS_DST_ALPHA, GL_ONE},
+ [PictOpIn] = {1, 0, GL_DST_ALPHA, GL_ZERO},
+ [PictOpInReverse] = {0, 1, GL_ZERO, GL_SRC_ALPHA},
+ [PictOpOut] = {1, 0, GL_ONE_MINUS_DST_ALPHA, GL_ZERO},
+ [PictOpOutReverse] = {0, 1, GL_ZERO, GL_ONE_MINUS_SRC_ALPHA},
+ [PictOpAtop] = {1, 1, GL_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA},
+ [PictOpAtopReverse] = {1, 1, GL_ONE_MINUS_DST_ALPHA, GL_SRC_ALPHA},
+ [PictOpXor] =
+ {1, 1, GL_ONE_MINUS_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA},
+ [PictOpAdd] = {0, 0, GL_ONE, GL_ONE},
+};
+#define RepeatFix 10
+static GLuint
+glamor_create_composite_fs(glamor_gl_dispatch * dispatch,
+ struct shader_key *key)
+{
+ const char *repeat_define =
+ "#define RepeatNone 0\n"
+ "#define RepeatNormal 1\n"
+ "#define RepeatPad 2\n"
+ "#define RepeatReflect 3\n"
+ "#define RepeatFix 10\n"
+ "uniform int source_repeat_mode;\n"
+ "uniform int mask_repeat_mode;\n";
+ const char *relocate_texture =
+ GLAMOR_DEFAULT_PRECISION
+ "vec2 rel_tex_coord(vec2 texture, vec4 wh, int repeat) \n"
+ "{\n"
+ " vec2 rel_tex; \n"
+ " rel_tex = texture * wh.xy; \n"
+ " if (repeat == RepeatNone)\n"
+ " return rel_tex; \n"
+ " else if (repeat == RepeatNormal) \n"
+ " rel_tex = floor(rel_tex) + (fract(rel_tex) / wh.xy); \n"
+ " else if(repeat == RepeatPad) { \n"
+ " if (rel_tex.x >= 1.0) rel_tex.x = 1.0 - wh.z * wh.x / 2.; \n"
+ " else if(rel_tex.x < 0.0) rel_tex.x = 0.0; \n"
+ " if (rel_tex.y >= 1.0) rel_tex.y = 1.0 - wh.w * wh.y / 2.; \n"
+ " else if(rel_tex.y < 0.0) rel_tex.y = 0.0; \n"
+ " rel_tex = rel_tex / wh.xy; \n"
+ " } \n"
+ " else if(repeat == RepeatReflect) {\n"
+ " if ((1.0 - mod(abs(floor(rel_tex.x)), 2.0)) < 0.001)\n"
+ " rel_tex.x = 2.0 - (1.0 - fract(rel_tex.x))/wh.x;\n"
+ " else \n"
+ " rel_tex.x = fract(rel_tex.x)/wh.x;\n"
+ " if ((1.0 - mod(abs(floor(rel_tex.y)), 2.0)) < 0.001)\n"
+ " rel_tex.y = 2.0 - (1.0 - fract(rel_tex.y))/wh.y;\n"
+ " else \n"
+ " rel_tex.y = fract(rel_tex.y)/wh.y;\n"
+ " } \n"
+ " return rel_tex; \n"
+ "}\n";
+ /* The texture and the pixmap size is not match eaxctly, so can't sample it directly.
+ * rel_sampler will recalculate the texture coords.*/
+ const char *rel_sampler =
+ " vec4 rel_sampler(sampler2D tex_image, vec2 tex, vec4 wh, int repeat, int set_alpha)\n"
+ "{\n"
+ " tex = rel_tex_coord(tex, wh, repeat - RepeatFix);\n"
+ " if (repeat == RepeatFix) {\n"
+ " if (!(tex.x >= 0.0 && tex.x < 1.0 \n"
+ " && tex.y >= 0.0 && tex.y < 1.0))\n"
+ " return vec4(0.0, 0.0, 0.0, set_alpha);\n"
+ " tex = (fract(tex) / wh.xy);\n"
+ " }\n"
+ " if (set_alpha != 1)\n"
+ " return texture2D(tex_image, tex);\n"
+ " else\n"
+ " return vec4(texture2D(tex_image, tex).rgb, 1.0);\n"
+ "}\n";
+
+ const char *source_solid_fetch =
+ GLAMOR_DEFAULT_PRECISION
+ "uniform vec4 source;\n"
+ "vec4 get_source()\n" "{\n" " return source;\n" "}\n";
+ const char *source_alpha_pixmap_fetch =
+ GLAMOR_DEFAULT_PRECISION
+ "varying vec2 source_texture;\n"
+ "uniform sampler2D source_sampler;\n"
+ "uniform vec4 source_wh;"
+ "vec4 get_source()\n"
+ "{\n"
+ " if (source_repeat_mode < RepeatFix)\n"
+ " return texture2D(source_sampler, source_texture);\n"
+ " else \n"
+ " return rel_sampler(source_sampler, source_texture,\n"
+ " source_wh, source_repeat_mode, 0);\n"
+ "}\n";
+ const char *source_pixmap_fetch =
+ GLAMOR_DEFAULT_PRECISION "varying vec2 source_texture;\n"
+ "uniform sampler2D source_sampler;\n"
+ "uniform vec4 source_wh;\n"
+ "vec4 get_source()\n"
+ "{\n"
+ " if (source_repeat_mode < RepeatFix) \n"
+ " return vec4(texture2D(source_sampler, source_texture).rgb, 1);\n"
+ " else \n"
+ " return rel_sampler(source_sampler, source_texture,\n"
+ " source_wh, source_repeat_mode, 1);\n"
+ "}\n";
+ const char *mask_solid_fetch =
+ GLAMOR_DEFAULT_PRECISION "uniform vec4 mask;\n"
+ "vec4 get_mask()\n" "{\n" " return mask;\n" "}\n";
+ const char *mask_alpha_pixmap_fetch =
+ GLAMOR_DEFAULT_PRECISION "varying vec2 mask_texture;\n"
+ "uniform sampler2D mask_sampler;\n"
+ "uniform vec4 mask_wh;\n"
+ "vec4 get_mask()\n"
+ "{\n"
+ " if (mask_repeat_mode < RepeatFix) \n"
+ " return texture2D(mask_sampler, mask_texture);\n"
+ " else \n"
+ " return rel_sampler(mask_sampler, mask_texture,\n"
+ " mask_wh, mask_repeat_mode, 0);\n"
+ "}\n";
+ const char *mask_pixmap_fetch =
+ GLAMOR_DEFAULT_PRECISION "varying vec2 mask_texture;\n"
+ "uniform sampler2D mask_sampler;\n"
+ "uniform vec4 mask_wh;\n"
+ "vec4 get_mask()\n"
+ "{\n"
+ " if (mask_repeat_mode < RepeatFix) \n"
+ " return vec4(texture2D(mask_sampler, mask_texture).rgb, 1);\n"
+ " else \n"
+ " return rel_sampler(mask_sampler, mask_texture,\n"
+ " mask_wh, mask_repeat_mode, 1);\n"
+ "}\n";
+ const char *in_source_only =
+ GLAMOR_DEFAULT_PRECISION "void main()\n" "{\n"
+ " gl_FragColor = get_source();\n" "}\n";
+ const char *in_normal =
+ GLAMOR_DEFAULT_PRECISION "void main()\n" "{\n"
+ " gl_FragColor = get_source() * get_mask().a;\n" "}\n";
+ const char *in_ca_source =
+ GLAMOR_DEFAULT_PRECISION "void main()\n" "{\n"
+ " gl_FragColor = get_source() * get_mask();\n" "}\n";
+ const char *in_ca_alpha =
+ GLAMOR_DEFAULT_PRECISION "void main()\n" "{\n"
+ " gl_FragColor = get_source().a * get_mask();\n" "}\n";
+ char *source;
+ const char *source_fetch;
+ const char *mask_fetch = "";
+ const char *in;
+ GLuint prog;
+
+ switch (key->source) {
+ case SHADER_SOURCE_SOLID:
+ source_fetch = source_solid_fetch;
+ break;
+ case SHADER_SOURCE_TEXTURE_ALPHA:
+ source_fetch = source_alpha_pixmap_fetch;
+ break;
+ case SHADER_SOURCE_TEXTURE:
+ source_fetch = source_pixmap_fetch;
+ break;
+ default:
+ FatalError("Bad composite shader source");
+ }
+
+ switch (key->mask) {
+ case SHADER_MASK_NONE:
+ break;
+ case SHADER_MASK_SOLID:
+ mask_fetch = mask_solid_fetch;
+ break;
+ case SHADER_MASK_TEXTURE_ALPHA:
+ mask_fetch = mask_alpha_pixmap_fetch;
+ break;
+ case SHADER_MASK_TEXTURE:
+ mask_fetch = mask_pixmap_fetch;
+ break;
+ default:
+ FatalError("Bad composite shader mask");
+ }
+
+ switch (key->in) {
+ case SHADER_IN_SOURCE_ONLY:
+ in = in_source_only;
+ break;
+ case SHADER_IN_NORMAL:
+ in = in_normal;
+ break;
+ case SHADER_IN_CA_SOURCE:
+ in = in_ca_source;
+ break;
+ case SHADER_IN_CA_ALPHA:
+ in = in_ca_alpha;
+ break;
+ default:
+ FatalError("Bad composite IN type");
+ }
+
+ XNFasprintf(&source, "%s%s%s%s%s%s", repeat_define, relocate_texture, rel_sampler,source_fetch, mask_fetch, in);
+
+
+ prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
+ source);
+ free(source);
+
+ return prog;
+}
+
+static GLuint
+glamor_create_composite_vs(glamor_gl_dispatch * dispatch,
+ struct shader_key *key)
+{
+ const char *main_opening =
+ "attribute vec4 v_position;\n"
+ "attribute vec4 v_texcoord0;\n"
+ "attribute vec4 v_texcoord1;\n"
+ "varying vec2 source_texture;\n"
+ "varying vec2 mask_texture;\n"
+ "void main()\n" "{\n" " gl_Position = v_position;\n";
+ const char *source_coords =
+ " source_texture = v_texcoord0.xy;\n";
+ const char *mask_coords = " mask_texture = v_texcoord1.xy;\n";
+ const char *main_closing = "}\n";
+ const char *source_coords_setup = "";
+ const char *mask_coords_setup = "";
+ char *source;
+ GLuint prog;
+
+ if (key->source != SHADER_SOURCE_SOLID)
+ source_coords_setup = source_coords;
+
+ if (key->mask != SHADER_MASK_NONE
+ && key->mask != SHADER_MASK_SOLID)
+ mask_coords_setup = mask_coords;
+
+ XNFasprintf(&source,
+ "%s%s%s%s",
+ main_opening,
+ source_coords_setup, mask_coords_setup, main_closing);
+
+ prog =
+ glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, source);
+ free(source);
+
+ return prog;
+}
+
+static void
+glamor_create_composite_shader(ScreenPtr screen, struct shader_key *key,
+ glamor_composite_shader * shader)
+{
+ GLuint vs, fs, prog;
+ GLint source_sampler_uniform_location,
+ mask_sampler_uniform_location;
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ glamor_gl_dispatch *dispatch;
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+ vs = glamor_create_composite_vs(dispatch, key);
+ if (vs == 0)
+ goto out;
+ fs = glamor_create_composite_fs(dispatch, key);
+ if (fs == 0)
+ goto out;
+
+ prog = dispatch->glCreateProgram();
+ dispatch->glAttachShader(prog, vs);
+ dispatch->glAttachShader(prog, fs);
+
+ dispatch->glBindAttribLocation(prog, GLAMOR_VERTEX_POS,
+ "v_position");
+ dispatch->glBindAttribLocation(prog, GLAMOR_VERTEX_SOURCE,
+ "v_texcoord0");
+ dispatch->glBindAttribLocation(prog, GLAMOR_VERTEX_MASK,
+ "v_texcoord1");
+
+ glamor_link_glsl_prog(dispatch, prog);
+
+ shader->prog = prog;
+
+ dispatch->glUseProgram(prog);
+
+ if (key->source == SHADER_SOURCE_SOLID) {
+ shader->source_uniform_location =
+ dispatch->glGetUniformLocation(prog, "source");
+ } else {
+ source_sampler_uniform_location =
+ dispatch->glGetUniformLocation(prog, "source_sampler");
+ dispatch->glUniform1i(source_sampler_uniform_location, 0);
+ shader->source_wh = dispatch->glGetUniformLocation(prog, "source_wh");
+ shader->source_repeat_mode = dispatch->glGetUniformLocation(prog, "source_repeat_mode");
+ }
+
+ if (key->mask != SHADER_MASK_NONE) {
+ if (key->mask == SHADER_MASK_SOLID) {
+ shader->mask_uniform_location =
+ dispatch->glGetUniformLocation(prog, "mask");
+ } else {
+ mask_sampler_uniform_location =
+ dispatch->glGetUniformLocation(prog,
+ "mask_sampler");
+ dispatch->glUniform1i
+ (mask_sampler_uniform_location, 1);
+ shader->mask_wh = dispatch->glGetUniformLocation(prog, "mask_wh");
+ shader->mask_repeat_mode = dispatch->glGetUniformLocation(prog, "mask_repeat_mode");
+ }
+ }
+
+out:
+ glamor_put_dispatch(glamor_priv);
+}
+
+static glamor_composite_shader *
+glamor_lookup_composite_shader(ScreenPtr screen, struct
+ shader_key
+ *key)
+{
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(screen);
+ glamor_composite_shader *shader;
+
+ shader =
+ &glamor_priv->composite_shader[key->source][key->
+ mask][key->in];
+ if (shader->prog == 0)
+ glamor_create_composite_shader(screen, key, shader);
+
+ return shader;
+}
+
+static void
+glamor_init_eb(unsigned short *eb, int vert_cnt)
+{
+ int i, j;
+ for(i = 0, j = 0; j < vert_cnt; i += 6, j += 4)
+ {
+ eb[i] = j;
+ eb[i + 1] = j + 1;
+ eb[i + 2] = j + 2;
+ eb[i + 3] = j;
+ eb[i + 4] = j + 2;
+ eb[i + 5] = j + 3;
+ }
+}
+
+void
+glamor_init_composite_shaders(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv;
+ glamor_gl_dispatch *dispatch;
+ unsigned short *eb;
+ float *vb = NULL;
+ int eb_size;
+
+ glamor_priv = glamor_get_screen_private(screen);
+ dispatch = glamor_get_dispatch(glamor_priv);
+ dispatch->glGenBuffers(1, &glamor_priv->vbo);
+ dispatch->glGenBuffers(1, &glamor_priv->ebo);
+ dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);
+
+ eb_size = GLAMOR_COMPOSITE_VBO_VERT_CNT * sizeof(short) * 2;
+
+ if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
+ dispatch->glBufferData(GL_ELEMENT_ARRAY_BUFFER,
+ eb_size,
+ NULL, GL_STATIC_DRAW);
+ eb = dispatch->glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY);
+ }
+ else {
+ vb = malloc(GLAMOR_COMPOSITE_VBO_VERT_CNT * sizeof(float) * 2);
+ if (vb == NULL)
+ FatalError("Failed to allocate vb memory.\n");
+ eb = malloc(eb_size);
+ }
+
+ if (eb == NULL)
+ FatalError("fatal error, fail to get element buffer. GL context may be not created correctly.\n");
+ glamor_init_eb(eb, GLAMOR_COMPOSITE_VBO_VERT_CNT);
+
+ if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
+ dispatch->glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
+ dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+ } else {
+ dispatch->glBufferData(GL_ELEMENT_ARRAY_BUFFER,
+ eb_size,
+ eb, GL_STATIC_DRAW);
+ dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+
+ dispatch->glBindBuffer(GL_ARRAY_BUFFER, glamor_priv->vbo);
+ dispatch->glBufferData(GL_ARRAY_BUFFER,
+ GLAMOR_COMPOSITE_VBO_VERT_CNT * sizeof(float) * 2,
+ NULL, GL_DYNAMIC_DRAW);
+ dispatch->glBindBuffer(GL_ARRAY_BUFFER, 0);
+
+ free(eb);
+ glamor_priv->vb = (char*)vb;
+ }
+
+ glamor_put_dispatch(glamor_priv);
+}
+
+void
+glamor_fini_composite_shaders(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv;
+ glamor_gl_dispatch *dispatch;
+ glamor_composite_shader *shader;
+ int i,j,k;
+
+ glamor_priv = glamor_get_screen_private(screen);
+ dispatch = glamor_get_dispatch(glamor_priv);
+ dispatch->glDeleteBuffers(1, &glamor_priv->vbo);
+ dispatch->glDeleteBuffers(1, &glamor_priv->ebo);
+
+ for(i = 0; i < SHADER_SOURCE_COUNT; i++)
+ for(j = 0; j < SHADER_MASK_COUNT; j++)
+ for(k = 0; k < SHADER_IN_COUNT; k++)
+ {
+ shader = &glamor_priv->composite_shader[i][j][k];
+ if (shader->prog)
+ dispatch->glDeleteProgram(shader->prog);
+ }
+ if (glamor_priv->gl_flavor != GLAMOR_GL_DESKTOP
+ && glamor_priv->vb)
+ free(glamor_priv->vb);
+
+ glamor_put_dispatch(glamor_priv);
+}
+
+static Bool
+glamor_set_composite_op(ScreenPtr screen,
+ CARD8 op, struct blendinfo *op_info_result,
+ PicturePtr dest, PicturePtr mask)
+{
+ GLenum source_blend, dest_blend;
+ struct blendinfo *op_info;
+
+ if (op >= ARRAY_SIZE(composite_op_info)) {
+ glamor_fallback("unsupported render op %d \n", op);
+ return GL_FALSE;
+ }
+ op_info = &composite_op_info[op];
+
+ source_blend = op_info->source_blend;
+ dest_blend = op_info->dest_blend;
+
+ /* If there's no dst alpha channel, adjust the blend op so that we'll treat
+ * it as always 1.
+ */
+ if (PICT_FORMAT_A(dest->format) == 0 && op_info->dest_alpha) {
+ if (source_blend == GL_DST_ALPHA)
+ source_blend = GL_ONE;
+ else if (source_blend == GL_ONE_MINUS_DST_ALPHA)
+ source_blend = GL_ZERO;
+ }
+
+ /* Set up the source alpha value for blending in component alpha mode. */
+ if (mask && mask->componentAlpha
+ && PICT_FORMAT_RGB(mask->format) != 0 && op_info->source_alpha)
+ {
+ if (dest_blend == GL_SRC_ALPHA)
+ dest_blend = GL_SRC_COLOR;
+ else if (dest_blend == GL_ONE_MINUS_SRC_ALPHA)
+ dest_blend = GL_ONE_MINUS_SRC_COLOR;
+ }
+
+ op_info_result->source_blend = source_blend;
+ op_info_result->dest_blend = dest_blend;
+ op_info_result->source_alpha = op_info->source_alpha;
+ op_info_result->dest_alpha = op_info->dest_alpha;
+
+ return TRUE;
+}
+
+static void
+glamor_set_composite_texture(glamor_screen_private *glamor_priv, int unit,
+ PicturePtr picture,
+ glamor_pixmap_private * pixmap_priv,
+ GLuint wh_location, GLuint repeat_location)
+{
+ glamor_gl_dispatch *dispatch;
+ float wh[4];
+ int repeat_type;
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+ dispatch->glActiveTexture(GL_TEXTURE0 + unit);
+ dispatch->glBindTexture(GL_TEXTURE_2D, pixmap_priv->base.fbo->tex);
+ repeat_type = picture->repeatType;
+ switch (picture->repeatType) {
+ case RepeatNone:
+#ifndef GLAMOR_GLES2
+ /* XXX GLES2 doesn't support GL_CLAMP_TO_BORDER. */
+ dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
+ GL_CLAMP_TO_BORDER);
+ dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
+ GL_CLAMP_TO_BORDER);
+#else
+ dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
+ GL_CLAMP_TO_EDGE);
+ dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
+ GL_CLAMP_TO_EDGE);
+#endif
+ break;
+ case RepeatNormal:
+ dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
+ GL_REPEAT);
+ dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
+ GL_REPEAT);
+ break;
+ case RepeatPad:
+ dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
+ GL_CLAMP_TO_EDGE);
+ dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
+ GL_CLAMP_TO_EDGE);
+ break;
+ case RepeatReflect:
+ dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
+ GL_MIRRORED_REPEAT);
+ dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
+ GL_MIRRORED_REPEAT);
+ break;
+ }
+
+ switch (picture->filter) {
+ default:
+ case PictFilterFast:
+ case PictFilterNearest:
+ dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_MIN_FILTER,
+ GL_NEAREST);
+ dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_MAG_FILTER,
+ GL_NEAREST);
+ break;
+ case PictFilterGood:
+ case PictFilterBest:
+ case PictFilterBilinear:
+ dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_MIN_FILTER,
+ GL_LINEAR);
+ dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_MAG_FILTER,
+ GL_LINEAR);
+ break;
+ }
+#ifndef GLAMOR_GLES2
+ dispatch->glEnable(GL_TEXTURE_2D);
+#endif
+
+ /*
+ * GLES2 doesn't support RepeatNone. We need to fix it anyway.
+ *
+ **/
+ if (repeat_type != RepeatNone)
+ repeat_type += RepeatFix;
+ else if (glamor_priv->gl_flavor == GLAMOR_GL_ES2
+ || pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
+ if (picture->transform
+ || (GLAMOR_PIXMAP_FBO_NOT_EAXCT_SIZE(pixmap_priv)))
+ repeat_type += RepeatFix;
+ }
+ if (repeat_type >= RepeatFix) {
+ glamor_pixmap_fbo_fix_wh_ratio(wh, pixmap_priv);
+ if ((wh[0] != 1.0 || wh[1] != 1.0 )
+ || (glamor_priv->gl_flavor == GLAMOR_GL_ES2
+ && repeat_type == RepeatFix))
+ dispatch->glUniform4fv(wh_location, 1, wh);
+ else
+ repeat_type -= RepeatFix;
+ }
+ dispatch->glUniform1i(repeat_location, repeat_type);
+ glamor_put_dispatch(glamor_priv);
+}
+
+static void
+glamor_set_composite_solid(glamor_gl_dispatch * dispatch, float *color,
+ GLint uniform_location)
+{
+ dispatch->glUniform4fv(uniform_location, 1, color);
+}
+
+static int
+compatible_formats(CARD8 op, PicturePtr dst, PicturePtr src)
+{
+ if (op == PictOpSrc) {
+ if (src->format == dst->format)
+ return 1;
+
+ if (src->format == PICT_a8r8g8b8
+ && dst->format == PICT_x8r8g8b8)
+ return 1;
+
+ if (src->format == PICT_a8b8g8r8
+ && dst->format == PICT_x8b8g8r8)
+ return 1;
+ } else if (op == PictOpOver) {
+ if (src->alphaMap || dst->alphaMap)
+ return 0;
+
+ if (src->format != dst->format)
+ return 0;
+
+ if (src->format == PICT_x8r8g8b8
+ || src->format == PICT_x8b8g8r8)
+ return 1;
+ }
+
+ return 0;
+}
+
+static char
+glamor_get_picture_location(PicturePtr picture)
+{
+ if (picture == NULL)
+ return ' ';
+
+ if (picture->pDrawable == NULL) {
+ switch (picture->pSourcePict->type) {
+ case SourcePictTypeSolidFill:
+ return 'c';
+ case SourcePictTypeLinear:
+ return 'l';
+ case SourcePictTypeRadial:
+ return 'r';
+ default:
+ return '?';
+ }
+ }
+ return glamor_get_drawable_location(picture->pDrawable);
+}
+
+static Bool
+glamor_composite_with_copy(CARD8 op,
+ PicturePtr source,
+ PicturePtr dest,
+ INT16 x_source,
+ INT16 y_source,
+ INT16 x_dest,
+ INT16 y_dest,
+ RegionPtr region)
+{
+ int ret = FALSE;
+ if (!source->pDrawable)
+ return FALSE;
+
+ if (!compatible_formats(op, dest, source))
+ return FALSE;
+
+ if (source->repeat || source->transform) {
+ return FALSE;
+ }
+
+ x_dest += dest->pDrawable->x;
+ y_dest += dest->pDrawable->y;
+ x_source += source->pDrawable->x;
+ y_source += source->pDrawable->y;
+ if (PICT_FORMAT_A(source->format) == 0) {
+ /* Fallback if we sample outside the source so that we
+ * swizzle the correct clear color for out-of-bounds texels.
+ */
+ if (region->extents.x1 + x_source - x_dest < 0)
+ goto cleanup_region;
+ if (region->extents.x2 + x_source - x_dest > source->pDrawable->width)
+ goto cleanup_region;
+
+ if (region->extents.y1 + y_source - y_dest < 0)
+ goto cleanup_region;
+ if (region->extents.y2 + y_source - y_dest > source->pDrawable->height)
+ goto cleanup_region;
+ }
+ ret = glamor_copy_n_to_n_nf(source->pDrawable,
+ dest->pDrawable, NULL,
+ RegionRects(region), RegionNumRects(region),
+ x_source - x_dest, y_source - y_dest,
+ FALSE, FALSE, 0, NULL);
+cleanup_region:
+ return ret;
+}
+
+void
+glamor_setup_composite_vbo(ScreenPtr screen, int n_verts)
+{
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(screen);
+ glamor_gl_dispatch *dispatch;
+ int vert_size;
+
+ glamor_priv->render_nr_verts = 0;
+ glamor_priv->vb_stride = 2 * sizeof(float);
+ if (glamor_priv->has_source_coords)
+ glamor_priv->vb_stride += 2 * sizeof(float);
+ if (glamor_priv->has_mask_coords)
+ glamor_priv->vb_stride += 2 * sizeof(float);
+
+ vert_size = n_verts * glamor_priv->vb_stride;
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+ dispatch->glBindBuffer(GL_ARRAY_BUFFER, glamor_priv->vbo);
+ if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
+ if (glamor_priv->vbo_size < (glamor_priv->vbo_offset + vert_size)) {
+ glamor_priv->vbo_size = GLAMOR_COMPOSITE_VBO_VERT_CNT *
+ glamor_priv->vb_stride;
+ glamor_priv->vbo_offset = 0;
+ dispatch->glBufferData(GL_ARRAY_BUFFER,
+ glamor_priv->vbo_size,
+ NULL, GL_STREAM_DRAW);
+ }
+
+ glamor_priv->vb = dispatch->glMapBufferRange(GL_ARRAY_BUFFER,
+ glamor_priv->vbo_offset,
+ vert_size,
+ GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
+ assert(glamor_priv->vb != NULL);
+ glamor_priv->vb -= glamor_priv->vbo_offset;
+ } else
+ glamor_priv->vbo_offset = 0;
+
+ dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);
+
+ dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
+ GL_FALSE, glamor_priv->vb_stride,
+ (void *) ((long)
+ glamor_priv->vbo_offset));
+ dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+
+ if (glamor_priv->has_source_coords) {
+ dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
+ GL_FLOAT, GL_FALSE,
+ glamor_priv->vb_stride,
+ (void *) ((long)
+ glamor_priv->vbo_offset
+ +
+ 2 *
+ sizeof(float)));
+ dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+ }
+
+ if (glamor_priv->has_mask_coords) {
+ dispatch->glVertexAttribPointer(GLAMOR_VERTEX_MASK, 2,
+ GL_FLOAT, GL_FALSE,
+ glamor_priv->vb_stride,
+ (void *) ((long)
+ glamor_priv->vbo_offset
+ +
+ (glamor_priv->has_source_coords
+ ? 4 : 2) *
+ sizeof(float)));
+ dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_MASK);
+ }
+ glamor_put_dispatch(glamor_priv);
+}
+
+void
+glamor_emit_composite_vert(ScreenPtr screen,
+ const float *src_coords,
+ const float *mask_coords,
+ const float *dst_coords, int i)
+{
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(screen);
+ float *vb = (float *) (glamor_priv->vb + glamor_priv->vbo_offset);
+ int j = 0;
+
+ vb[j++] = dst_coords[i * 2 + 0];
+ vb[j++] = dst_coords[i * 2 + 1];
+ if (glamor_priv->has_source_coords) {
+ vb[j++] = src_coords[i * 2 + 0];
+ vb[j++] = src_coords[i * 2 + 1];
+ }
+ if (glamor_priv->has_mask_coords) {
+ vb[j++] = mask_coords[i * 2 + 0];
+ vb[j++] = mask_coords[i * 2 + 1];
+ }
+
+ glamor_priv->render_nr_verts++;
+ glamor_priv->vbo_offset += glamor_priv->vb_stride;
+}
+
+
+
+static void
+glamor_flush_composite_rects(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(screen);
+ glamor_gl_dispatch *dispatch;
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+ if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
+ dispatch->glUnmapBuffer(GL_ARRAY_BUFFER);
+ else {
+
+ dispatch->glBindBuffer(GL_ARRAY_BUFFER, glamor_priv->vbo);
+ dispatch->glBufferData(GL_ARRAY_BUFFER,
+ glamor_priv->vbo_offset,
+ glamor_priv->vb, GL_DYNAMIC_DRAW);
+ }
+
+ if (!glamor_priv->render_nr_verts)
+ return;
+
+#ifndef GLAMOR_GLES2
+ dispatch->glDrawRangeElements(GL_TRIANGLES, 0, glamor_priv->render_nr_verts,
+ (glamor_priv->render_nr_verts * 3) / 2,
+ GL_UNSIGNED_SHORT, NULL);
+#else
+ dispatch->glDrawElements(GL_TRIANGLES, (glamor_priv->render_nr_verts * 3) / 2,
+ GL_UNSIGNED_SHORT, NULL);
+#endif
+ glamor_put_dispatch(glamor_priv);
+}
+
+int pict_format_combine_tab[][3] = {
+ {PICT_TYPE_ARGB, PICT_TYPE_A, PICT_TYPE_ARGB},
+ {PICT_TYPE_ABGR, PICT_TYPE_A, PICT_TYPE_ABGR},
+};
+
+static Bool
+combine_pict_format(PictFormatShort * des, const PictFormatShort src,
+ const PictFormatShort mask, enum shader_in in_ca)
+{
+ PictFormatShort new_vis;
+ int src_type, mask_type, src_bpp, mask_bpp;
+ int i;
+ if (src == mask) {
+ *des = src;
+ return TRUE;
+ }
+ src_bpp = PICT_FORMAT_BPP(src);
+ mask_bpp = PICT_FORMAT_BPP(mask);
+
+ assert(src_bpp == mask_bpp);
+
+ new_vis = PICT_FORMAT_VIS(src) | PICT_FORMAT_VIS(mask);
+
+ switch (in_ca) {
+ case SHADER_IN_SOURCE_ONLY:
+ return TRUE;
+ case SHADER_IN_NORMAL:
+ src_type = PICT_FORMAT_TYPE(src);
+ mask_type = PICT_TYPE_A;
+ break;
+ case SHADER_IN_CA_SOURCE:
+ src_type = PICT_FORMAT_TYPE(src);
+ mask_type = PICT_FORMAT_TYPE(mask);
+ break;
+ case SHADER_IN_CA_ALPHA:
+ src_type = PICT_TYPE_A;
+ mask_type = PICT_FORMAT_TYPE(mask);
+ break;
+ default:
+ return FALSE;
+ }
+
+ if (src_type == mask_type) {
+ *des = PICT_VISFORMAT(src_bpp, src_type, new_vis);
+ return TRUE;
+ }
+
+ for (i = 0;
+ i <
+ sizeof(pict_format_combine_tab) /
+ sizeof(pict_format_combine_tab[0]); i++) {
+ if ((src_type == pict_format_combine_tab[i][0]
+ && mask_type == pict_format_combine_tab[i][1])
+ || (src_type == pict_format_combine_tab[i][1]
+ && mask_type == pict_format_combine_tab[i][0])) {
+ *des = PICT_VISFORMAT(src_bpp,
+ pict_format_combine_tab[i]
+ [2], new_vis);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+static void
+glamor_set_normalize_tcoords_generic(glamor_pixmap_private *priv,
+ int repeat_type,
+ float *matrix,
+ float xscale, float yscale,
+ int x1, int y1, int x2, int y2,
+ int yInverted, float *texcoords,
+ int stride)
+{
+ if (!matrix && repeat_type == RepeatNone)
+ glamor_set_normalize_tcoords_ext(priv, xscale, yscale,
+ x1, y1,
+ x2, y2,
+ yInverted,
+ texcoords, stride);
+ else if (matrix && repeat_type == RepeatNone)
+ glamor_set_transformed_normalize_tcoords_ext(priv, matrix, xscale,
+ yscale, x1, y1,
+ x2, y2,
+ yInverted,
+ texcoords, stride);
+ else if (!matrix && repeat_type != RepeatNone)
+ glamor_set_repeat_normalize_tcoords_ext(priv, repeat_type,
+ xscale, yscale,
+ x1, y1,
+ x2, y2,
+ yInverted,
+ texcoords, stride);
+ else if (matrix && repeat_type != RepeatNone)
+ glamor_set_repeat_transformed_normalize_tcoords_ext(priv, repeat_type,
+ matrix, xscale, yscale,
+ x1, y1,
+ x2, y2,
+ yInverted,
+ texcoords, stride);
+}
+
+Bool glamor_composite_choose_shader(CARD8 op,
+ PicturePtr source,
+ PicturePtr mask,
+ PicturePtr dest,
+ glamor_pixmap_private *source_pixmap_priv,
+ glamor_pixmap_private *mask_pixmap_priv,
+ glamor_pixmap_private *dest_pixmap_priv,
+ struct shader_key *s_key,
+ glamor_composite_shader **shader,
+ struct blendinfo *op_info,
+ PictFormatShort *psaved_source_format)
+{
+ ScreenPtr screen = dest->pDrawable->pScreen;
+ PixmapPtr dest_pixmap = dest_pixmap_priv->base.pixmap;
+ PixmapPtr source_pixmap = NULL;
+ PixmapPtr mask_pixmap = NULL;
+ enum glamor_pixmap_status source_status = GLAMOR_NONE;
+ enum glamor_pixmap_status mask_status = GLAMOR_NONE;
+ PictFormatShort saved_source_format = 0;
+ struct shader_key key;
+ GLfloat source_solid_color[4];
+ GLfloat mask_solid_color[4];
+ Bool ret = FALSE;
+
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dest_pixmap_priv)) {
+ glamor_fallback("dest has no fbo.\n");
+ goto fail;
+ }
+
+ memset(&key, 0, sizeof(key));
+ if (!source) {
+ key.source = SHADER_SOURCE_SOLID;
+ source_solid_color[0] = 0.0;
+ source_solid_color[1] = 0.0;
+ source_solid_color[2] = 0.0;
+ source_solid_color[3] = 0.0;
+ } else if (!source->pDrawable) {
+ if (source->pSourcePict->type == SourcePictTypeSolidFill) {
+ key.source = SHADER_SOURCE_SOLID;
+ glamor_get_rgba_from_pixel(source->
+ pSourcePict->solidFill.
+ color,
+ &source_solid_color[0],
+ &source_solid_color[1],
+ &source_solid_color[2],
+ &source_solid_color[3],
+ PICT_a8r8g8b8);
+ } else
+ goto fail;
+ } else {
+ key.source = SHADER_SOURCE_TEXTURE_ALPHA;
+ }
+
+ if (mask) {
+ if (!mask->pDrawable) {
+ if (mask->pSourcePict->type ==
+ SourcePictTypeSolidFill) {
+ key.mask = SHADER_MASK_SOLID;
+ glamor_get_rgba_from_pixel
+ (mask->pSourcePict->solidFill.color,
+ &mask_solid_color[0],
+ &mask_solid_color[1],
+ &mask_solid_color[2],
+ &mask_solid_color[3], PICT_a8r8g8b8);
+ } else
+ goto fail;
+ } else {
+ key.mask = SHADER_MASK_TEXTURE_ALPHA;
+ }
+
+ if (!mask->componentAlpha) {
+ key.in = SHADER_IN_NORMAL;
+ } else {
+ if (op == PictOpClear)
+ key.mask = SHADER_MASK_NONE;
+ else if (op == PictOpSrc || op == PictOpAdd
+ || op == PictOpIn || op == PictOpOut
+ || op == PictOpOverReverse)
+ key.in = SHADER_IN_CA_SOURCE;
+ else if (op == PictOpOutReverse || op == PictOpInReverse) {
+ key.in = SHADER_IN_CA_ALPHA;
+ } else {
+ glamor_fallback("Unsupported component alpha op: %d\n", op);
+ goto fail;
+ }
+ }
+ } else {
+ key.mask = SHADER_MASK_NONE;
+ key.in = SHADER_IN_SOURCE_ONLY;
+ }
+
+ if (source && source->alphaMap) {
+ glamor_fallback("source alphaMap\n");
+ goto fail;
+ }
+ if (mask && mask->alphaMap) {
+ glamor_fallback("mask alphaMap\n");
+ goto fail;
+ }
+
+ if (key.source == SHADER_SOURCE_TEXTURE ||
+ key.source == SHADER_SOURCE_TEXTURE_ALPHA) {
+ source_pixmap = source_pixmap_priv->base.pixmap;
+ if (source_pixmap == dest_pixmap) {
+ /* XXX source and the dest share the same texture.
+ * Does it need special handle? */
+ glamor_fallback("source == dest\n");
+ }
+ if (source_pixmap_priv->base.gl_fbo == 0) {
+ /* XXX in Xephyr, we may have gl_fbo equal to 1 but gl_tex
+ * equal to zero when the pixmap is screen pixmap. Then we may
+ * refer the tex zero directly latter in the composition.
+ * It seems that it works fine, but it may have potential problem*/
+#ifdef GLAMOR_PIXMAP_DYNAMIC_UPLOAD
+ source_status = GLAMOR_UPLOAD_PENDING;
+#else
+ glamor_fallback("no texture in source\n");
+ goto fail;
+#endif
+ }
+ }
+
+ if (key.mask == SHADER_MASK_TEXTURE ||
+ key.mask == SHADER_MASK_TEXTURE_ALPHA) {
+ mask_pixmap = mask_pixmap_priv->base.pixmap;
+ if (mask_pixmap == dest_pixmap) {
+ glamor_fallback("mask == dest\n");
+ goto fail;
+ }
+ if (mask_pixmap_priv->base.gl_fbo == 0) {
+#ifdef GLAMOR_PIXMAP_DYNAMIC_UPLOAD
+ mask_status = GLAMOR_UPLOAD_PENDING;
+#else
+ glamor_fallback("no texture in mask\n");
+ goto fail;
+#endif
+ }
+ }
+
+#ifdef GLAMOR_PIXMAP_DYNAMIC_UPLOAD
+ if (source_status == GLAMOR_UPLOAD_PENDING
+ && mask_status == GLAMOR_UPLOAD_PENDING
+ && source_pixmap == mask_pixmap) {
+
+ if (source->format != mask->format) {
+ saved_source_format = source->format;
+
+ if (!combine_pict_format(&source->format, source->format,
+ mask->format, key.in)) {
+ glamor_fallback("combine source %x mask %x failed.\n",
+ source->format, mask->format);
+ goto fail;
+ }
+
+ if (source->format != saved_source_format) {
+ glamor_picture_format_fixup(source,
+ source_pixmap_priv);
+ }
+ /* XXX
+ * By default, glamor_upload_picture_to_texture will wire alpha to 1
+ * if one picture doesn't have alpha. So we don't do that again in
+ * rendering function. But here is a special case, as source and
+ * mask share the same texture but may have different formats. For
+ * example, source doesn't have alpha, but mask has alpha. Then the
+ * texture will have the alpha value for the mask. And will not wire
+ * to 1 for the source. In this case, we have to use different shader
+ * to wire the source's alpha to 1.
+ *
+ * But this may cause a potential problem if the source's repeat mode
+ * is REPEAT_NONE, and if the source is smaller than the dest, then
+ * for the region not covered by the source may be painted incorrectly.
+ * because we wire the alpha to 1.
+ *
+ **/
+ if (!PICT_FORMAT_A(saved_source_format)
+ && PICT_FORMAT_A(mask->format))
+ key.source = SHADER_SOURCE_TEXTURE;
+
+ if (!PICT_FORMAT_A(mask->format)
+ && PICT_FORMAT_A(saved_source_format))
+ key.mask = SHADER_MASK_TEXTURE;
+
+ mask_status = GLAMOR_NONE;
+ }
+
+ source_status = glamor_upload_picture_to_texture(source);
+ if (source_status != GLAMOR_UPLOAD_DONE) {
+ glamor_fallback("Failed to upload source texture.\n");
+ goto fail;
+ }
+ } else {
+ if (source_status == GLAMOR_UPLOAD_PENDING) {
+ source_status = glamor_upload_picture_to_texture(source);
+ if (source_status != GLAMOR_UPLOAD_DONE) {
+ glamor_fallback("Failed to upload source texture.\n");
+ goto fail;
+ }
+ }
+
+ if (mask_status == GLAMOR_UPLOAD_PENDING) {
+ mask_status = glamor_upload_picture_to_texture(mask);
+ if (mask_status != GLAMOR_UPLOAD_DONE) {
+ glamor_fallback("Failed to upload mask texture.\n");
+ goto fail;
+ }
+ }
+ }
+#endif
+
+ /*Before enter the rendering stage, we need to fixup
+ * transformed source and mask, if the transform is not int translate. */
+ if (key.source != SHADER_SOURCE_SOLID
+ && source->transform
+ && !pixman_transform_is_int_translate(source->transform)
+ && source_pixmap_priv->type != GLAMOR_TEXTURE_LARGE) {
+ if (!glamor_fixup_pixmap_priv(screen, source_pixmap_priv))
+ goto fail;
+ }
+ if (key.mask != SHADER_MASK_NONE && key.mask != SHADER_MASK_SOLID
+ && mask->transform
+ && !pixman_transform_is_int_translate(mask->transform)
+ && mask_pixmap_priv->type != GLAMOR_TEXTURE_LARGE) {
+ if (!glamor_fixup_pixmap_priv(screen, mask_pixmap_priv))
+ goto fail;
+ }
+
+
+ if (!glamor_set_composite_op(screen, op, op_info, dest, mask))
+ goto fail;
+
+ *shader = glamor_lookup_composite_shader(screen, &key);
+ if ((*shader)->prog == 0) {
+ glamor_fallback("no shader program for this"
+ "render acccel mode\n");
+ goto fail;
+ }
+
+ if (key.source == SHADER_SOURCE_SOLID)
+ memcpy(&(*shader)->source_solid_color[0],
+ source_solid_color, 4*sizeof(float));
+ else {
+ (*shader)->source_priv = source_pixmap_priv;
+ (*shader)->source = source;
+ }
+
+ if (key.mask == SHADER_MASK_SOLID)
+ memcpy(&(*shader)->mask_solid_color[0],
+ mask_solid_color, 4*sizeof(float));
+ else {
+ (*shader)->mask_priv = mask_pixmap_priv;
+ (*shader)->mask = mask;
+ }
+
+ ret = TRUE;
+ memcpy(s_key, &key, sizeof(key));
+ *psaved_source_format = saved_source_format;
+ goto done;
+
+fail:
+ if (saved_source_format)
+ source->format = saved_source_format;
+done:
+ return ret;
+}
+
+void
+glamor_composite_set_shader_blend(glamor_pixmap_private *dest_priv,
+ struct shader_key *key,
+ glamor_composite_shader *shader,
+ struct blendinfo *op_info)
+{
+ glamor_gl_dispatch *dispatch;
+ glamor_screen_private *glamor_priv;
+
+ glamor_priv = dest_priv->base.glamor_priv;
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+ dispatch->glUseProgram(shader->prog);
+
+ if (key->source == SHADER_SOURCE_SOLID) {
+ glamor_set_composite_solid(dispatch,
+ shader->source_solid_color,
+ shader->source_uniform_location);
+ } else {
+ glamor_set_composite_texture(glamor_priv, 0,
+ shader->source,
+ shader->source_priv, shader->source_wh,
+ shader->source_repeat_mode);
+ }
+
+ if (key->mask != SHADER_MASK_NONE) {
+ if (key->mask == SHADER_MASK_SOLID) {
+ glamor_set_composite_solid(dispatch,
+ shader->mask_solid_color,
+ shader->mask_uniform_location);
+ } else {
+ glamor_set_composite_texture(glamor_priv, 1,
+ shader->mask,
+ shader->mask_priv, shader->mask_wh,
+ shader->mask_repeat_mode);
+ }
+ }
+
+ if (op_info->source_blend == GL_ONE
+ && op_info->dest_blend == GL_ZERO) {
+ dispatch->glDisable(GL_BLEND);
+ } else {
+ dispatch->glEnable(GL_BLEND);
+ dispatch->glBlendFunc(op_info->source_blend,
+ op_info->dest_blend);
+ }
+
+ glamor_put_dispatch(glamor_priv);
+}
+
+static Bool
+glamor_composite_with_shader(CARD8 op,
+ PicturePtr source,
+ PicturePtr mask,
+ PicturePtr dest,
+ glamor_pixmap_private *source_pixmap_priv,
+ glamor_pixmap_private *mask_pixmap_priv,
+ glamor_pixmap_private *dest_pixmap_priv,
+ int nrect, glamor_composite_rect_t * rects,
+ Bool two_pass_ca)
+{
+ ScreenPtr screen = dest->pDrawable->pScreen;
+ glamor_screen_private *glamor_priv = dest_pixmap_priv->base.glamor_priv;
+ PixmapPtr dest_pixmap = dest_pixmap_priv->base.pixmap;
+ PixmapPtr source_pixmap = NULL;
+ PixmapPtr mask_pixmap = NULL;
+ glamor_gl_dispatch *dispatch = NULL;
+ GLfloat dst_xscale, dst_yscale;
+ GLfloat mask_xscale = 1, mask_yscale = 1,
+ src_xscale = 1, src_yscale = 1;
+ struct shader_key key, key_ca;
+ float *vertices;
+ int dest_x_off, dest_y_off;
+ int source_x_off, source_y_off;
+ int mask_x_off, mask_y_off;
+ PictFormatShort saved_source_format = 0;
+ float src_matrix[9], mask_matrix[9];
+ float *psrc_matrix = NULL, *pmask_matrix = NULL;
+ int vert_stride = 4;
+ int nrect_max;
+ Bool ret = FALSE;
+ glamor_composite_shader *shader = NULL, *shader_ca = NULL;
+ struct blendinfo op_info, op_info_ca;
+
+ if(!glamor_composite_choose_shader(op, source, mask, dest,
+ source_pixmap_priv, mask_pixmap_priv,
+ dest_pixmap_priv,
+ &key, &shader, &op_info,
+ &saved_source_format)) {
+ glamor_fallback("glamor_composite_choose_shader failed\n");
+ return ret;
+ }
+ if (two_pass_ca) {
+ if(!glamor_composite_choose_shader(PictOpAdd, source, mask, dest,
+ source_pixmap_priv, mask_pixmap_priv,
+ dest_pixmap_priv,
+ &key_ca, &shader_ca, &op_info_ca,
+ &saved_source_format)) {
+ glamor_fallback("glamor_composite_choose_shader failed\n");
+ return ret;
+ }
+ }
+
+ glamor_set_destination_pixmap_priv_nc(dest_pixmap_priv);
+ glamor_composite_set_shader_blend(dest_pixmap_priv, &key, shader, &op_info);
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+
+ glamor_priv->has_source_coords = key.source != SHADER_SOURCE_SOLID;
+ glamor_priv->has_mask_coords = (key.mask != SHADER_MASK_NONE &&
+ key.mask != SHADER_MASK_SOLID);
+
+ dest_pixmap = glamor_get_drawable_pixmap(dest->pDrawable);
+ dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap);
+ glamor_get_drawable_deltas(dest->pDrawable, dest_pixmap,
+ &dest_x_off, &dest_y_off);
+ pixmap_priv_get_dest_scale(dest_pixmap_priv, &dst_xscale, &dst_yscale);
+
+ if (glamor_priv->has_source_coords) {
+ source_pixmap = source_pixmap_priv->base.pixmap;
+ glamor_get_drawable_deltas(source->pDrawable,
+ source_pixmap, &source_x_off,
+ &source_y_off);
+ pixmap_priv_get_scale(source_pixmap_priv, &src_xscale,
+ &src_yscale);
+ if (source->transform) {
+ psrc_matrix = src_matrix;
+ glamor_picture_get_matrixf(source, psrc_matrix);
+ }
+ vert_stride += 4;
+ }
+
+ if (glamor_priv->has_mask_coords) {
+ mask_pixmap = mask_pixmap_priv->base.pixmap;
+ glamor_get_drawable_deltas(mask->pDrawable, mask_pixmap,
+ &mask_x_off, &mask_y_off);
+ pixmap_priv_get_scale(mask_pixmap_priv, &mask_xscale,
+ &mask_yscale);
+ if (mask->transform) {
+ pmask_matrix = mask_matrix;
+ glamor_picture_get_matrixf(mask, pmask_matrix);
+ }
+ vert_stride += 4;
+ }
+
+ nrect_max = (vert_stride * nrect) > GLAMOR_COMPOSITE_VBO_VERT_CNT ?
+ (GLAMOR_COMPOSITE_VBO_VERT_CNT / vert_stride) : nrect;
+
+ while(nrect) {
+ int mrect, rect_processed;
+ int vb_stride;
+
+ mrect = nrect > nrect_max ? nrect_max : nrect ;
+ glamor_setup_composite_vbo(screen, mrect * vert_stride);
+ rect_processed = mrect;
+ vb_stride = glamor_priv->vb_stride/sizeof(float);
+ while (mrect--) {
+ INT16 x_source;
+ INT16 y_source;
+ INT16 x_mask;
+ INT16 y_mask;
+ INT16 x_dest;
+ INT16 y_dest;
+ CARD16 width;
+ CARD16 height;
+
+ x_dest = rects->x_dst + dest_x_off;
+ y_dest = rects->y_dst + dest_y_off;
+ x_source = rects->x_src + source_x_off;
+ y_source = rects->y_src + source_y_off;
+ x_mask = rects->x_mask + mask_x_off;
+ y_mask = rects->y_mask + mask_y_off;
+ width = rects->width;
+ height = rects->height;
+
+ DEBUGF("dest(%d,%d) source(%d %d) mask (%d %d), width %d height %d \n",
+ x_dest, y_dest, x_source, y_source,x_mask,y_mask,width,height);
+ vertices = (float*)(glamor_priv->vb + glamor_priv->vbo_offset);
+ assert(glamor_priv->vbo_offset < glamor_priv->vbo_size - glamor_priv->vb_stride);
+ glamor_set_normalize_vcoords_ext(dest_pixmap_priv, dst_xscale,
+ dst_yscale,
+ x_dest, y_dest,
+ x_dest + width, y_dest + height,
+ glamor_priv->yInverted,
+ vertices, vb_stride);
+ vertices += 2;
+ if (key.source != SHADER_SOURCE_SOLID) {
+ glamor_set_normalize_tcoords_generic(
+ source_pixmap_priv, source->repeatType, psrc_matrix,
+ src_xscale, src_yscale, x_source, y_source,
+ x_source + width, y_source + height,
+ glamor_priv->yInverted, vertices, vb_stride);
+ vertices += 2;
+ }
+
+ if (key.mask != SHADER_MASK_NONE
+ && key.mask != SHADER_MASK_SOLID) {
+ glamor_set_normalize_tcoords_generic(
+ mask_pixmap_priv, mask->repeatType, pmask_matrix,
+ mask_xscale, mask_yscale, x_mask, y_mask,
+ x_mask + width, y_mask + height,
+ glamor_priv->yInverted, vertices, vb_stride);
+ }
+ glamor_priv->render_nr_verts += 4;
+ glamor_priv->vbo_offset += glamor_priv->vb_stride * 4;
+ rects++;
+ }
+ glamor_flush_composite_rects(screen);
+ nrect -= rect_processed;
+ if (two_pass_ca) {
+ glamor_composite_set_shader_blend(dest_pixmap_priv,
+ &key_ca, shader_ca,
+ &op_info_ca);
+ glamor_flush_composite_rects(screen);
+ if (nrect)
+ glamor_composite_set_shader_blend(dest_pixmap_priv,
+ &key, shader,
+ &op_info);
+ }
+ }
+
+ dispatch->glBindBuffer(GL_ARRAY_BUFFER, 0);
+ dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_MASK);
+ dispatch->glDisable(GL_BLEND);
+#ifndef GLAMOR_GLES2
+ dispatch->glActiveTexture(GL_TEXTURE0);
+ dispatch->glDisable(GL_TEXTURE_2D);
+ dispatch->glActiveTexture(GL_TEXTURE1);
+ dispatch->glDisable(GL_TEXTURE_2D);
+#endif
+ DEBUGF("finish rendering.\n");
+ dispatch->glUseProgram(0);
+ glamor_priv->state = RENDER_STATE;
+ glamor_priv->render_idle_cnt = 0;
+ if (saved_source_format)
+ source->format = saved_source_format;
+ glamor_put_dispatch(glamor_priv);
+
+ ret = TRUE;
+ return ret;
+}
+
+PicturePtr
+glamor_convert_gradient_picture(ScreenPtr screen,
+ PicturePtr source,
+ int x_source,
+ int y_source, int width, int height)
+{
+ PixmapPtr pixmap;
+ PicturePtr dst = NULL;
+ int error;
+ PictFormatShort format;
+ if (!source->pDrawable)
+ format = PICT_a8r8g8b8;
+ else
+ format = source->format;
+#ifdef GLAMOR_GRADIENT_SHADER
+ if (!source->pDrawable) {
+ if (source->pSourcePict->type == SourcePictTypeLinear) {
+ dst = glamor_generate_linear_gradient_picture(screen,
+ source, x_source, y_source, width, height, format);
+ } else if (source->pSourcePict->type == SourcePictTypeRadial) {
+ dst = glamor_generate_radial_gradient_picture(screen,
+ source, x_source, y_source, width, height, format);
+ }
+
+ if (dst) {
+#if 0 /* Debug to compare it to pixman, Enable it if needed. */
+ glamor_compare_pictures(screen, source,
+ dst, x_source, y_source, width, height,
+ 0, 3);
+#endif
+ return dst;
+ }
+ }
+#endif
+ pixmap = glamor_create_pixmap(screen,
+ width,
+ height,
+ PIXMAN_FORMAT_DEPTH(format),
+ GLAMOR_CREATE_PIXMAP_CPU);
+
+ if (!pixmap)
+ return NULL;
+
+ dst = CreatePicture(0,
+ &pixmap->drawable,
+ PictureMatchFormat(screen,
+ PIXMAN_FORMAT_DEPTH(format),
+ format),
+ 0, 0, serverClient, &error);
+ glamor_destroy_pixmap(pixmap);
+ if (!dst)
+ return NULL;
+
+ ValidatePicture(dst);
+
+ fbComposite(PictOpSrc, source, NULL, dst, x_source, y_source,
+ 0, 0, 0, 0, width, height);
+ return dst;
+}
+
+Bool
+glamor_composite_clipped_region(CARD8 op,
+ PicturePtr source,
+ PicturePtr mask,
+ PicturePtr dest,
+ glamor_pixmap_private *source_pixmap_priv,
+ glamor_pixmap_private *mask_pixmap_priv,
+ glamor_pixmap_private *dest_pixmap_priv,
+ RegionPtr region,
+ int x_source,
+ int y_source,
+ int x_mask,
+ int y_mask,
+ int x_dest,
+ int y_dest)
+{
+ ScreenPtr screen = dest->pDrawable->pScreen;
+ PixmapPtr source_pixmap = NULL, mask_pixmap = NULL;
+ PicturePtr temp_src = source, temp_mask = mask;
+ glamor_pixmap_private *temp_src_priv = source_pixmap_priv;
+ glamor_pixmap_private *temp_mask_priv = mask_pixmap_priv;
+ int x_temp_src, y_temp_src, x_temp_mask, y_temp_mask;
+ BoxPtr extent;
+ glamor_composite_rect_t rect[10];
+ glamor_composite_rect_t *prect = rect;
+ int prect_size = ARRAY_SIZE(rect);
+ int ok = FALSE;
+ int i;
+ int width;
+ int height;
+ BoxPtr box;
+ int nbox;
+ Bool two_pass_ca = FALSE;
+
+ extent = RegionExtents(region);
+ box = RegionRects(region);
+ nbox = RegionNumRects(region);
+ width = extent->x2 - extent->x1;
+ height = extent->y2 - extent->y1;
+
+ x_temp_src = x_source;
+ y_temp_src = y_source;
+ x_temp_mask = x_mask;
+ y_temp_mask = y_mask;
+
+ DEBUGF("clipped (%d %d) (%d %d) (%d %d) width %d height %d \n",
+ x_source, y_source, x_mask, y_mask, x_dest, y_dest, width, height);
+
+ if (source_pixmap_priv)
+ source_pixmap = source_pixmap_priv->base.pixmap;
+
+ if (mask_pixmap_priv)
+ mask_pixmap = mask_pixmap_priv->base.pixmap;
+
+ /* XXX is it possible source mask have non-zero drawable.x/y? */
+ if (source
+ && ((!source->pDrawable
+ && (source->pSourcePict->type != SourcePictTypeSolidFill))
+ || (source->pDrawable
+ && !GLAMOR_PIXMAP_PRIV_HAS_FBO(source_pixmap_priv)
+ && (source_pixmap->drawable.width != width
+ || source_pixmap->drawable.height != height)))) {
+ temp_src =
+ glamor_convert_gradient_picture(screen, source,
+ extent->x1 + x_source - x_dest,
+ extent->y1 + y_source - y_dest,
+ width, height);
+ if (!temp_src) {
+ temp_src = source;
+ goto out;
+ }
+ temp_src_priv = glamor_get_pixmap_private((PixmapPtr)(temp_src->pDrawable));
+ x_temp_src = - extent->x1 + x_dest;
+ y_temp_src = - extent->y1 + y_dest;
+ }
+
+ if (mask
+ &&
+ ((!mask->pDrawable
+ && (mask->pSourcePict->type != SourcePictTypeSolidFill))
+ || (mask->pDrawable
+ && !GLAMOR_PIXMAP_PRIV_HAS_FBO(mask_pixmap_priv)
+ && (mask_pixmap->drawable.width != width
+ || mask_pixmap->drawable.height != height)))) {
+ /* XXX if mask->pDrawable is the same as source->pDrawable, we have an opportunity
+ * to do reduce one convertion. */
+ temp_mask =
+ glamor_convert_gradient_picture(screen, mask,
+ extent->x1 + x_mask - x_dest,
+ extent->y1 + y_mask - y_dest,
+ width, height);
+ if (!temp_mask) {
+ temp_mask = mask;
+ goto out;
+ }
+ temp_mask_priv = glamor_get_pixmap_private((PixmapPtr)(temp_mask->pDrawable));
+ x_temp_mask = - extent->x1 + x_dest;
+ y_temp_mask = - extent->y1 + y_dest;
+ }
+ /* Do two-pass PictOpOver componentAlpha, until we enable
+ * dual source color blending.
+ */
+
+ if (mask && mask->componentAlpha) {
+ if (op == PictOpOver) {
+ two_pass_ca = TRUE;
+ op = PictOpOutReverse;
+ }
+ }
+
+ if (!mask && temp_src) {
+ if (glamor_composite_with_copy(op, temp_src, dest,
+ x_temp_src, y_temp_src,
+ x_dest, y_dest, region)) {
+ ok = TRUE;
+ goto out;
+ }
+ }
+
+ /*XXXXX, self copy?*/
+
+ x_dest += dest->pDrawable->x;
+ y_dest += dest->pDrawable->y;
+ if (temp_src && temp_src->pDrawable) {
+ x_temp_src += temp_src->pDrawable->x;
+ y_temp_src += temp_src->pDrawable->y;
+ }
+ if (temp_mask && temp_mask->pDrawable) {
+ x_temp_mask += temp_mask->pDrawable->x;
+ y_temp_mask += temp_mask->pDrawable->y;
+ }
+
+ if (nbox > ARRAY_SIZE(rect)) {
+ prect = calloc(nbox, sizeof(*prect));
+ if (prect)
+ prect_size = nbox;
+ else {
+ prect = rect;
+ prect_size = ARRAY_SIZE(rect);
+ }
+ }
+ while(nbox) {
+ int box_cnt;
+ box_cnt = nbox > prect_size ? prect_size : nbox;
+ for (i = 0; i < box_cnt; i++) {
+ prect[i].x_src = box[i].x1 + x_temp_src - x_dest;
+ prect[i].y_src = box[i].y1 + y_temp_src - y_dest;
+ prect[i].x_mask = box[i].x1 + x_temp_mask - x_dest;
+ prect[i].y_mask = box[i].y1 + y_temp_mask - y_dest;
+ prect[i].x_dst = box[i].x1;
+ prect[i].y_dst = box[i].y1;
+ prect[i].width = box[i].x2 - box[i].x1;
+ prect[i].height = box[i].y2 - box[i].y1;
+ DEBUGF("dest %d %d \n", prect[i].x_dst, prect[i].y_dst);
+ }
+ ok = glamor_composite_with_shader(op, temp_src, temp_mask, dest,
+ temp_src_priv, temp_mask_priv,
+ dest_pixmap_priv,
+ box_cnt, prect, two_pass_ca);
+ if (!ok)
+ break;
+ nbox -= box_cnt;
+ box += box_cnt;
+ }
+
+ if (prect != rect)
+ free(prect);
+out:
+ if (temp_src != source)
+ FreePicture(temp_src, 0);
+ if (temp_mask != mask)
+ FreePicture(temp_mask, 0);
+
+ return ok;
+}
+
+static Bool
+_glamor_composite(CARD8 op,
+ PicturePtr source,
+ PicturePtr mask,
+ PicturePtr dest,
+ INT16 x_source,
+ INT16 y_source,
+ INT16 x_mask,
+ INT16 y_mask,
+ INT16 x_dest, INT16 y_dest,
+ CARD16 width, CARD16 height, Bool fallback)
+{
+ ScreenPtr screen = dest->pDrawable->pScreen;
+ glamor_pixmap_private *dest_pixmap_priv;
+ glamor_pixmap_private *source_pixmap_priv =
+ NULL, *mask_pixmap_priv = NULL;
+ PixmapPtr dest_pixmap =
+ glamor_get_drawable_pixmap(dest->pDrawable);
+ PixmapPtr source_pixmap = NULL, mask_pixmap = NULL;
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(screen);
+ Bool ret = TRUE;
+ RegionRec region;
+ BoxPtr extent;
+ int nbox, ok = FALSE;
+ PixmapPtr sub_dest_pixmap = NULL;
+ PixmapPtr sub_source_pixmap = NULL;
+ PixmapPtr sub_mask_pixmap = NULL;
+ int dest_x_off, dest_y_off, saved_dest_x, saved_dest_y;
+ int source_x_off, source_y_off, saved_source_x, saved_source_y;
+ int mask_x_off, mask_y_off, saved_mask_x, saved_mask_y;
+ DrawablePtr saved_dest_drawable;
+ DrawablePtr saved_source_drawable;
+ DrawablePtr saved_mask_drawable;
+ int force_clip = 0;
+ dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap);
+
+ if (source->pDrawable) {
+ source_pixmap = glamor_get_drawable_pixmap(source->pDrawable);
+ source_pixmap_priv = glamor_get_pixmap_private(source_pixmap);
+ if (source_pixmap_priv && source_pixmap_priv->type == GLAMOR_DRM_ONLY)
+ goto fail;
+ }
+
+ if (mask && mask->pDrawable) {
+ mask_pixmap = glamor_get_drawable_pixmap(mask->pDrawable);
+ mask_pixmap_priv = glamor_get_pixmap_private(mask_pixmap);
+ if (mask_pixmap_priv && mask_pixmap_priv->type == GLAMOR_DRM_ONLY)
+ goto fail;
+ }
+
+ DEBUGF("source pixmap %p (%d %d) mask(%d %d) dest(%d %d) width %d height %d \n",
+ source_pixmap, x_source, y_source, x_mask, y_mask, x_dest, y_dest, width, height);
+
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dest_pixmap_priv)) {
+ goto fail;
+ }
+
+ if (op >= ARRAY_SIZE(composite_op_info))
+ goto fail;
+
+ if (mask && mask->componentAlpha) {
+ if (op == PictOpAtop
+ || op == PictOpAtopReverse
+ || op == PictOpXor
+ || op >= PictOpSaturate) {
+ glamor_fallback
+ ("glamor_composite(): component alpha op %x\n", op);
+ goto fail;
+ }
+ }
+
+ if ((source && source->filter >= PictFilterConvolution)
+ || (mask && mask->filter >= PictFilterConvolution)) {
+ glamor_fallback("glamor_composite(): unsupported filter\n");
+ goto fail;
+ }
+
+ if (!miComputeCompositeRegion(&region,
+ source, mask, dest,
+ x_source + (source_pixmap ? source->pDrawable->x : 0),
+ y_source + (source_pixmap ? source->pDrawable->y : 0),
+ x_mask + (mask_pixmap ? mask->pDrawable->x : 0),
+ y_mask + (mask_pixmap ? mask->pDrawable->y : 0),
+ x_dest + dest->pDrawable->x,
+ y_dest + dest->pDrawable->y,
+ width,
+ height)) {
+ ret = TRUE;
+ goto done;
+ }
+
+ nbox = REGION_NUM_RECTS(&region);
+ DEBUGF("first clipped when compositing.\n");
+ DEBUGRegionPrint(&region);
+ extent = RegionExtents(&region);
+ if (nbox == 0) {
+ ret = TRUE;
+ goto done;
+ }
+ /* If destination is not a large pixmap, but the region is larger
+ * than texture size limitation, and source or mask is memory pixmap,
+ * then there may be need to load a large memory pixmap to a
+ * texture, and this is not permitted. Then we force to clip the
+ * destination and make sure latter will not upload a large memory
+ * pixmap. */
+ if (!glamor_check_fbo_size(glamor_priv,
+ extent->x2 - extent->x1, extent->y2 - extent->y1)
+ && (dest_pixmap_priv->type != GLAMOR_TEXTURE_LARGE)
+ && ((source_pixmap_priv
+ && (source_pixmap_priv->type == GLAMOR_MEMORY || source->repeatType == RepeatPad))
+ || (mask_pixmap_priv
+ && (mask_pixmap_priv->type == GLAMOR_MEMORY || mask->repeatType == RepeatPad))
+ || (!source_pixmap_priv
+ && (source->pSourcePict->type != SourcePictTypeSolidFill))
+ || (!mask_pixmap_priv && mask
+ && mask->pSourcePict->type != SourcePictTypeSolidFill)))
+ force_clip = 1;
+
+ if (force_clip || dest_pixmap_priv->type == GLAMOR_TEXTURE_LARGE
+ || (source_pixmap_priv
+ && source_pixmap_priv->type == GLAMOR_TEXTURE_LARGE)
+ || (mask_pixmap_priv
+ && mask_pixmap_priv->type == GLAMOR_TEXTURE_LARGE))
+ ok = glamor_composite_largepixmap_region(op,
+ source, mask, dest,
+ source_pixmap_priv,
+ mask_pixmap_priv,
+ dest_pixmap_priv,
+ &region, force_clip,
+ x_source, y_source,
+ x_mask, y_mask,
+ x_dest, y_dest,
+ width, height);
+ else
+ ok = glamor_composite_clipped_region(op, source,
+ mask, dest,
+ source_pixmap_priv,
+ mask_pixmap_priv,
+ dest_pixmap_priv,
+ &region,
+ x_source, y_source,
+ x_mask, y_mask,
+ x_dest, y_dest);
+
+ REGION_UNINIT(dest->pDrawable->pScreen, &region);
+
+ if (ok)
+ goto done;
+fail:
+
+ if (!fallback
+ && glamor_ddx_fallback_check_pixmap(&dest_pixmap->drawable)
+ && (!source_pixmap
+ || glamor_ddx_fallback_check_pixmap(&source_pixmap->drawable))
+ && (!mask_pixmap
+ || glamor_ddx_fallback_check_pixmap(&mask_pixmap->drawable))) {
+ ret = FALSE;
+ goto done;
+ }
+
+ glamor_fallback
+ ("from picts %p:%p %dx%d / %p:%p %d x %d (%c,%c) to pict %p:%p %dx%d (%c)\n",
+ source, source->pDrawable,
+ source->pDrawable ? source->pDrawable->width : 0,
+ source->pDrawable ? source->pDrawable->height : 0, mask,
+ (!mask) ? NULL : mask->pDrawable, (!mask
+ || !mask->pDrawable) ? 0 :
+ mask->pDrawable->width, (!mask
+ || !mask->
+ pDrawable) ? 0 : mask->pDrawable->
+ height, glamor_get_picture_location(source),
+ glamor_get_picture_location(mask), dest, dest->pDrawable,
+ dest->pDrawable->width, dest->pDrawable->height,
+ glamor_get_picture_location(dest));
+
+#define GET_SUB_PICTURE(p, access) do { \
+ glamor_get_drawable_deltas(p->pDrawable, p ##_pixmap, \
+ & p ##_x_off, & p ##_y_off); \
+ sub_ ##p ##_pixmap = glamor_get_sub_pixmap(p ##_pixmap, \
+ x_ ##p + p ##_x_off + p->pDrawable->x, \
+ y_ ##p + p ##_y_off + p->pDrawable->y, \
+ width, height, access); \
+ if (sub_ ##p ##_pixmap != NULL) { \
+ saved_ ##p ##_drawable = p->pDrawable; \
+ saved_ ##p ##_x = x_ ##p; \
+ saved_ ##p ##_y = y_ ##p; \
+ if (p->pCompositeClip) \
+ pixman_region_translate (p->pCompositeClip, \
+ -p->pDrawable->x - x_ ##p, \
+ -p->pDrawable->y - y_ ##p); \
+ p->pDrawable = &sub_ ##p ##_pixmap->drawable; \
+ x_ ##p = 0; \
+ y_ ##p = 0; \
+ } } while(0)
+ GET_SUB_PICTURE(dest, GLAMOR_ACCESS_RW);
+ if (source->pDrawable && !source->transform)
+ GET_SUB_PICTURE(source, GLAMOR_ACCESS_RO);
+ if (mask && mask->pDrawable && !mask->transform)
+ GET_SUB_PICTURE(mask, GLAMOR_ACCESS_RO);
+
+ if (glamor_prepare_access_picture(dest, GLAMOR_ACCESS_RW)) {
+ if (source_pixmap == dest_pixmap || glamor_prepare_access_picture
+ (source, GLAMOR_ACCESS_RO)) {
+ if (!mask
+ || glamor_prepare_access_picture(mask,
+ GLAMOR_ACCESS_RO))
+ {
+ fbComposite(op,
+ source, mask, dest,
+ x_source, y_source,
+ x_mask, y_mask, x_dest,
+ y_dest, width, height);
+ if (mask)
+ glamor_finish_access_picture(mask, GLAMOR_ACCESS_RO);
+ }
+ if (source_pixmap != dest_pixmap)
+ glamor_finish_access_picture(source, GLAMOR_ACCESS_RO);
+ }
+ glamor_finish_access_picture(dest, GLAMOR_ACCESS_RW);
+ }
+
+#define PUT_SUB_PICTURE(p, access) do { \
+ if (sub_ ##p ##_pixmap != NULL) { \
+ x_ ##p = saved_ ##p ##_x; \
+ y_ ##p = saved_ ##p ##_y; \
+ p->pDrawable = saved_ ##p ##_drawable; \
+ if (p->pCompositeClip) \
+ pixman_region_translate (p->pCompositeClip, \
+ p->pDrawable->x + x_ ##p, \
+ p->pDrawable->y + y_ ##p); \
+ glamor_put_sub_pixmap(sub_ ##p ##_pixmap, p ##_pixmap, \
+ x_ ##p + p ##_x_off + p->pDrawable->x, \
+ y_ ##p + p ##_y_off + p->pDrawable->y, \
+ width, height, access); \
+ }} while(0)
+ if (mask && mask->pDrawable)
+ PUT_SUB_PICTURE(mask, GLAMOR_ACCESS_RO);
+ if (source->pDrawable)
+ PUT_SUB_PICTURE(source, GLAMOR_ACCESS_RO);
+ PUT_SUB_PICTURE(dest, GLAMOR_ACCESS_RW);
+ done:
+ return ret;
+}
+
+void
+glamor_composite(CARD8 op,
+ PicturePtr source,
+ PicturePtr mask,
+ PicturePtr dest,
+ INT16 x_source,
+ INT16 y_source,
+ INT16 x_mask,
+ INT16 y_mask,
+ INT16 x_dest, INT16 y_dest,
+ CARD16 width, CARD16 height)
+{
+ _glamor_composite(op, source, mask, dest, x_source, y_source,
+ x_mask, y_mask, x_dest, y_dest, width, height,
+ TRUE);
+}
+
+Bool
+glamor_composite_nf(CARD8 op,
+ PicturePtr source,
+ PicturePtr mask,
+ PicturePtr dest,
+ INT16 x_source,
+ INT16 y_source,
+ INT16 x_mask,
+ INT16 y_mask,
+ INT16 x_dest, INT16 y_dest,
+ CARD16 width, CARD16 height)
+{
+ return _glamor_composite(op, source, mask, dest, x_source, y_source,
+ x_mask, y_mask, x_dest, y_dest, width, height,
+ FALSE);
+}
+
+static void
+glamor_get_src_rect_extent(int nrect,
+ glamor_composite_rect_t *rects,
+ BoxPtr extent)
+{
+ extent->x1 = MAXSHORT;
+ extent->y1 = MAXSHORT;
+ extent->x2 = MINSHORT;
+ extent->y2 = MINSHORT;
+
+ while(nrect--) {
+ if (extent->x1 > rects->x_src)
+ extent->x1 = rects->x_src;
+ if (extent->y1 > rects->y_src)
+ extent->y1 = rects->y_src;
+ if (extent->x2 < rects->x_src + rects->width)
+ extent->x2 = rects->x_src + rects->width;
+ if (extent->y2 < rects->y_src + rects->height)
+ extent->y2 = rects->y_src + rects->height;
+ rects++;
+ }
+}
+
+static void
+glamor_composite_src_rect_translate(int nrect,
+ glamor_composite_rect_t *rects,
+ int x, int y)
+{
+ while(nrect--) {
+ rects->x_src += x;
+ rects->y_src += y;
+ rects++;
+ }
+}
+
+void
+glamor_composite_glyph_rects(CARD8 op,
+ PicturePtr src, PicturePtr mask, PicturePtr dst,
+ int nrect, glamor_composite_rect_t * rects)
+{
+ int n;
+ PicturePtr temp_src = NULL;
+ glamor_composite_rect_t *r;
+
+ ValidatePicture(src);
+ ValidatePicture(dst);
+ if (!(glamor_is_large_picture(src)
+ || (mask && glamor_is_large_picture(mask))
+ || glamor_is_large_picture(dst))) {
+ glamor_pixmap_private *src_pixmap_priv = NULL;
+ glamor_pixmap_private *mask_pixmap_priv = NULL;
+ glamor_pixmap_private *dst_pixmap_priv;
+ glamor_pixmap_private *temp_src_priv = NULL;
+ BoxRec src_extent;
+
+ dst_pixmap_priv = glamor_get_pixmap_private
+ (glamor_get_drawable_pixmap(dst->pDrawable));
+
+ if (mask && mask->pDrawable)
+ mask_pixmap_priv = glamor_get_pixmap_private
+ (glamor_get_drawable_pixmap(mask->pDrawable));
+ if (src->pDrawable)
+ src_pixmap_priv = glamor_get_pixmap_private
+ (glamor_get_drawable_pixmap(src->pDrawable));
+
+ if (!src->pDrawable
+ && (src->pSourcePict->type != SourcePictTypeSolidFill)) {
+ glamor_get_src_rect_extent(nrect, rects, &src_extent);
+ temp_src = glamor_convert_gradient_picture(dst->pDrawable->pScreen,
+ src,
+ src_extent.x1, src_extent.y1,
+ src_extent.x2 - src_extent.x1,
+ src_extent.y2 - src_extent.y1);
+ if (!temp_src)
+ goto fallback;
+
+ temp_src_priv = glamor_get_pixmap_private
+ ((PixmapPtr)(temp_src->pDrawable));
+ glamor_composite_src_rect_translate(nrect, rects,
+ -src_extent.x1, -src_extent.y1);
+ } else {
+ temp_src = src;
+ temp_src_priv = src_pixmap_priv;
+ }
+
+ if (mask && mask->componentAlpha) {
+ if (op == PictOpOver) {
+ if (glamor_composite_with_shader(PictOpOutReverse,
+ temp_src, mask, dst, temp_src_priv,
+ mask_pixmap_priv, dst_pixmap_priv, nrect, rects,
+ TRUE))
+ goto done;
+ }
+ } else {
+ if (glamor_composite_with_shader(op, temp_src, mask, dst, temp_src_priv,
+ mask_pixmap_priv, dst_pixmap_priv, nrect, rects, FALSE))
+ goto done;
+ }
+ }
+fallback:
+ n = nrect;
+ r = rects;
+
+ while (n--) {
+ CompositePicture(op,
+ temp_src ? temp_src : src,
+ mask,
+ dst,
+ r->x_src, r->y_src,
+ r->x_mask, r->y_mask,
+ r->x_dst, r->y_dst, r->width, r->height);
+ r++;
+ }
+
+done:
+ if (temp_src && temp_src != src)
+ FreePicture(temp_src, 0);
+}
+
+static Bool
+_glamor_composite_rects (CARD8 op,
+ PicturePtr pDst,
+ xRenderColor *color,
+ int nRect,
+ xRectangle *rects,
+ Bool fallback)
+{
+ miCompositeRects(op, pDst, color, nRect, rects);
+ return TRUE;
+}
+
+void
+glamor_composite_rects (CARD8 op,
+ PicturePtr pDst,
+ xRenderColor *color,
+ int nRect,
+ xRectangle *rects)
+{
+ _glamor_composite_rects(op, pDst, color, nRect, rects, TRUE);
+}
+
+Bool
+glamor_composite_rects_nf (CARD8 op,
+ PicturePtr pDst,
+ xRenderColor *color,
+ int nRect,
+ xRectangle *rects)
+{
+ return _glamor_composite_rects(op, pDst, color, nRect, rects, FALSE);
+}
+
+#endif /* RENDER */
diff --git a/xorg-server/glamor/glamor_setspans.c b/xorg-server/glamor/glamor_setspans.c
new file mode 100644
index 000000000..3d447b606
--- /dev/null
+++ b/xorg-server/glamor/glamor_setspans.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ *
+ * 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.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ * Zhigang Gong <zhigang.gong@linux.intel.com>
+ *
+ */
+
+#include "glamor_priv.h"
+
+static Bool
+_glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
+ DDXPointPtr points, int *widths, int numPoints, int sorted,
+ Bool fallback)
+{
+ PixmapPtr dest_pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_pixmap_private *dest_pixmap_priv;
+ int i;
+ uint8_t *drawpixels_src = (uint8_t *) src;
+ RegionPtr clip = fbGetCompositeClip(gc);
+ BoxRec *pbox;
+ int x_off, y_off;
+ Bool ret = FALSE;
+
+ dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap);
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dest_pixmap_priv)) {
+ glamor_fallback("pixmap has no fbo.\n");
+ goto fail;
+ }
+
+ /* XXX Shall we set alu here? */
+ if (!glamor_set_planemask(dest_pixmap, gc->planemask))
+ goto fail;
+
+ glamor_get_drawable_deltas(drawable, dest_pixmap, &x_off, &y_off);
+ for (i = 0; i < numPoints; i++) {
+
+ int n = REGION_NUM_RECTS(clip);
+ pbox = REGION_RECTS(clip);
+ while (n--) {
+ int x1 = points[i].x;
+ int x2 = x1 + widths[i];
+ int y1 = points[i].y;
+
+ if (pbox->y1 > points[i].y || pbox->y2 < points[i].y)
+ break;
+ x1 = x1 > pbox->x1 ? x1 : pbox->x1;
+ x2 = x2 < pbox->x2 ? x2 : pbox->x2;
+ if (x1 >= x2)
+ continue;
+ glamor_upload_sub_pixmap_to_texture(dest_pixmap, x1 + x_off, y1 + y_off, x2 - x1, 1,
+ PixmapBytePad(widths[i], drawable->depth),
+ drawpixels_src, 0);
+ }
+ drawpixels_src += PixmapBytePad(widths[i], drawable->depth);
+ }
+ ret = TRUE;
+ goto done;
+
+fail:
+ if (!fallback
+ && glamor_ddx_fallback_check_pixmap(drawable))
+ goto done;
+
+ glamor_fallback("to %p (%c)\n",
+ drawable, glamor_get_drawable_location(drawable));
+ if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
+ fbSetSpans(drawable, gc, src, points, widths, numPoints, sorted);
+ glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
+ }
+ ret = TRUE;
+
+done:
+ return ret;
+}
+
+void
+glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
+ DDXPointPtr points, int *widths, int n, int sorted)
+{
+ _glamor_set_spans(drawable, gc, src, points,
+ widths, n, sorted, TRUE);
+}
+
+Bool
+glamor_set_spans_nf(DrawablePtr drawable, GCPtr gc, char *src,
+ DDXPointPtr points, int *widths, int n, int sorted)
+{
+ return _glamor_set_spans(drawable, gc, src, points,
+ widths, n, sorted, FALSE);
+}
diff --git a/xorg-server/glamor/glamor_tile.c b/xorg-server/glamor/glamor_tile.c
new file mode 100644
index 000000000..60486cfc0
--- /dev/null
+++ b/xorg-server/glamor/glamor_tile.c
@@ -0,0 +1,325 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ *
+ * 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.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ * Zhigang Gong <zhigang.gong@linux.intel.com>
+ *
+ */
+
+#include "glamor_priv.h"
+
+/** @file glamor_tile.c
+ *
+ * Implements the basic fill-with-a-tile support used by multiple GC ops.
+ */
+
+void
+glamor_init_tile_shader(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv;
+ glamor_gl_dispatch *dispatch;
+ const char *tile_vs =
+ "attribute vec4 v_position;\n"
+ "attribute vec4 v_texcoord0;\n"
+ "varying vec2 tile_texture;\n"
+ "void main()\n"
+ "{\n"
+ " gl_Position = v_position;\n"
+ " tile_texture = v_texcoord0.xy;\n" "}\n";
+ const char *tile_fs =
+ GLAMOR_DEFAULT_PRECISION
+ "varying vec2 tile_texture;\n"
+ "uniform sampler2D sampler;\n"
+ "uniform vec2 wh;"
+ "void main()\n"
+ "{\n"
+ " vec2 rel_tex;"
+ " rel_tex = tile_texture * wh; \n"
+ " rel_tex = floor(rel_tex) + (fract(rel_tex) / wh); \n"
+ " gl_FragColor = texture2D(sampler, rel_tex);\n"
+ "}\n";
+ GLint fs_prog, vs_prog;
+ GLint sampler_uniform_location;
+
+ glamor_priv = glamor_get_screen_private(screen);
+ dispatch = glamor_get_dispatch(glamor_priv);
+ glamor_priv->tile_prog = dispatch->glCreateProgram();
+ vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, tile_vs);
+ fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
+ tile_fs);
+ dispatch->glAttachShader(glamor_priv->tile_prog, vs_prog);
+ dispatch->glAttachShader(glamor_priv->tile_prog, fs_prog);
+
+ dispatch->glBindAttribLocation(glamor_priv->tile_prog,
+ GLAMOR_VERTEX_POS, "v_position");
+ dispatch->glBindAttribLocation(glamor_priv->tile_prog,
+ GLAMOR_VERTEX_SOURCE,
+ "v_texcoord0");
+ glamor_link_glsl_prog(dispatch, glamor_priv->tile_prog);
+
+ sampler_uniform_location =
+ dispatch->glGetUniformLocation(glamor_priv->tile_prog,
+ "sampler");
+ dispatch->glUseProgram(glamor_priv->tile_prog);
+ dispatch->glUniform1i(sampler_uniform_location, 0);
+
+ glamor_priv->tile_wh =
+ dispatch->glGetUniformLocation(glamor_priv->tile_prog,
+ "wh");
+ dispatch->glUseProgram(0);
+ glamor_put_dispatch(glamor_priv);
+}
+
+void
+glamor_fini_tile_shader(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv;
+ glamor_gl_dispatch *dispatch;
+
+ glamor_priv = glamor_get_screen_private(screen);
+ dispatch = glamor_get_dispatch(glamor_priv);
+ dispatch->glDeleteProgram(glamor_priv->tile_prog);
+ glamor_put_dispatch(glamor_priv);
+}
+
+static void
+_glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
+ int x, int y, int width, int height,
+ int tile_x, int tile_y)
+{
+ ScreenPtr screen = pixmap->drawable.pScreen;
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(screen);
+ glamor_gl_dispatch *dispatch;
+ int x1 = x;
+ int x2 = x + width;
+ int y1 = y;
+ int y2 = y + height;
+ int tile_x1 = tile_x;
+ int tile_x2 = tile_x + width;
+ int tile_y1 = tile_y;
+ int tile_y2 = tile_y + height;
+ float vertices[8];
+ float source_texcoords[8];
+ GLfloat dst_xscale, dst_yscale, src_xscale, src_yscale;
+ glamor_pixmap_private *src_pixmap_priv;
+ glamor_pixmap_private *dst_pixmap_priv;
+ float wh[4];
+ src_pixmap_priv = glamor_get_pixmap_private(tile);
+ dst_pixmap_priv = glamor_get_pixmap_private(pixmap);
+
+ glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv);
+ pixmap_priv_get_dest_scale(dst_pixmap_priv, &dst_xscale, &dst_yscale);
+ pixmap_priv_get_scale(src_pixmap_priv, &src_xscale,
+ &src_yscale);
+ dispatch = glamor_get_dispatch(glamor_priv);
+ dispatch->glUseProgram(glamor_priv->tile_prog);
+
+ glamor_pixmap_fbo_fix_wh_ratio(wh, src_pixmap_priv);
+ dispatch->glUniform2fv(glamor_priv->tile_wh, 1, wh);
+ dispatch->glActiveTexture(GL_TEXTURE0);
+ dispatch->glBindTexture(GL_TEXTURE_2D,
+ src_pixmap_priv->base.fbo->tex);
+ dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_MIN_FILTER,
+ GL_NEAREST);
+ dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_MAG_FILTER,
+ GL_NEAREST);
+ dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
+ GL_REPEAT);
+ dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
+ GL_REPEAT);
+#ifndef GLAMOR_GLES2
+ dispatch->glEnable(GL_TEXTURE_2D);
+#endif
+ glamor_set_repeat_normalize_tcoords
+ (src_pixmap_priv, RepeatNormal,
+ src_xscale, src_yscale,
+ tile_x1, tile_y1,
+ tile_x2, tile_y2,
+ glamor_priv->yInverted,
+ source_texcoords);
+
+ dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
+ GL_FLOAT, GL_FALSE,
+ 2 * sizeof(float),
+ source_texcoords);
+ dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+
+ glamor_set_normalize_vcoords(dst_pixmap_priv, dst_xscale, dst_yscale,
+ x1, y1,
+ x2, y2,
+ glamor_priv->yInverted, vertices);
+
+ dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
+ GL_FALSE, 2 * sizeof(float),
+ vertices);
+ dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+ dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+#ifndef GLAMOR_GLES2
+ dispatch->glDisable(GL_TEXTURE_2D);
+#endif
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+ dispatch->glUseProgram(0);
+ glamor_put_dispatch(glamor_priv);
+
+ glamor_priv->state = RENDER_STATE;
+ glamor_priv->render_idle_cnt = 0;
+}
+
+Bool
+glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
+ int x, int y, int width, int height,
+ unsigned char alu, unsigned long planemask,
+ int tile_x, int tile_y)
+{
+ ScreenPtr screen = pixmap->drawable.pScreen;
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(screen);
+ glamor_pixmap_private *dst_pixmap_priv;
+ glamor_pixmap_private *src_pixmap_priv;
+ glamor_gl_dispatch *dispatch;
+
+ dst_pixmap_priv = glamor_get_pixmap_private(pixmap);
+ src_pixmap_priv = glamor_get_pixmap_private(tile);
+
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dst_pixmap_priv))
+ return FALSE;
+
+ if (glamor_priv->tile_prog == 0) {
+ glamor_fallback("Tiling unsupported\n");
+ goto fail;
+ }
+
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(src_pixmap_priv)) {
+ /* XXX dynamic uploading candidate. */
+ glamor_fallback("Non-texture tile pixmap\n");
+ goto fail;
+ }
+
+ if (!glamor_set_planemask(pixmap, planemask)) {
+ glamor_fallback("unsupported planemask %lx\n", planemask);
+ goto fail;
+ }
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+ if (!glamor_set_alu(dispatch, alu)) {
+ glamor_fallback("unsupported alu %x\n", alu);
+ glamor_put_dispatch(glamor_priv);
+ goto fail;
+ }
+
+ if (dst_pixmap_priv->type == GLAMOR_TEXTURE_LARGE
+ || src_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
+ glamor_pixmap_clipped_regions *clipped_dst_regions;
+ int n_dst_region, i, j, k;
+ BoxRec box;
+ RegionRec region;
+
+ box.x1 = x;
+ box.y1 = y;
+ box.x2 = x + width;
+ box.y2 = y + height;
+ RegionInitBoxes(&region, &box, 1);
+ clipped_dst_regions = glamor_compute_clipped_regions(dst_pixmap_priv,
+ &region, &n_dst_region, 0, 0, 0);
+ for(i = 0; i < n_dst_region; i++)
+ {
+ int n_src_region;
+ glamor_pixmap_clipped_regions *clipped_src_regions;
+ BoxPtr current_boxes;
+ int n_current_boxes;
+
+ SET_PIXMAP_FBO_CURRENT(dst_pixmap_priv, clipped_dst_regions[i].block_idx);
+
+ if (src_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
+ RegionTranslate(clipped_dst_regions[i].region,
+ tile_x - x, tile_y - y);
+ DEBUGF("tiled a large src pixmap. %dx%d \n", tile->drawable.width, tile->drawable.height);
+ clipped_src_regions = glamor_compute_clipped_regions(src_pixmap_priv,
+ clipped_dst_regions[i].region,
+ &n_src_region, 1, 0, 0);
+ DEBUGF("got %d src regions %d \n", n_src_region);
+ for (j = 0; j < n_src_region; j++)
+ {
+
+ SET_PIXMAP_FBO_CURRENT(src_pixmap_priv, clipped_src_regions[j].block_idx);
+
+ RegionTranslate(clipped_src_regions[j].region,
+ x - tile_x,
+ y - tile_y);
+ current_boxes = RegionRects(clipped_src_regions[j].region);
+ n_current_boxes = RegionNumRects(clipped_src_regions[j].region);
+ for(k = 0; k < n_current_boxes; k++)
+ {
+ DEBUGF("Tile on %d %d %d %d dst block id %d tile block id %d tilex %d tiley %d\n",
+ current_boxes[k].x1, current_boxes[k].y1,
+ current_boxes[k].x2 - current_boxes[k].x1,
+ current_boxes[k].y2 - current_boxes[k].y1,
+ clipped_dst_regions[i].block_idx,
+ clipped_src_regions[j].block_idx,
+ (tile_x + (current_boxes[k].x1 - x)),
+ tile_y + (current_boxes[k].y1 - y));
+
+ _glamor_tile(pixmap, tile,
+ current_boxes[k].x1, current_boxes[k].y1,
+ current_boxes[k].x2 - current_boxes[k].x1,
+ current_boxes[k].y2 - current_boxes[k].y1,
+ (tile_x + (current_boxes[k].x1 - x)),
+ (tile_y + (current_boxes[k].y1 - y)));
+ }
+
+ RegionDestroy(clipped_src_regions[j].region);
+ }
+ free(clipped_src_regions);
+ } else {
+ current_boxes = RegionRects(clipped_dst_regions[i].region);
+ n_current_boxes = RegionNumRects(clipped_dst_regions[i].region);
+ for(k = 0; k < n_current_boxes; k++)
+ {
+ _glamor_tile(pixmap, tile,
+ current_boxes[k].x1, current_boxes[k].y1,
+ current_boxes[k].x2 - current_boxes[k].x1,
+ current_boxes[k].y2 - current_boxes[k].y1,
+ (tile_x + (current_boxes[k].x1 - x)),
+ (tile_y + (current_boxes[k].y1 - y)));
+ }
+ }
+ RegionDestroy(clipped_dst_regions[i].region);
+ }
+ free(clipped_dst_regions);
+ RegionUninit(&region);
+ }
+ else
+ _glamor_tile(pixmap, tile, x, y, width, height, tile_x, tile_y);
+
+ glamor_set_alu(dispatch, GXcopy);
+ glamor_put_dispatch(glamor_priv);
+ return TRUE;
+fail:
+ return FALSE;
+
+}
diff --git a/xorg-server/glamor/glamor_trapezoid.c b/xorg-server/glamor/glamor_trapezoid.c
new file mode 100644
index 000000000..76b3729cf
--- /dev/null
+++ b/xorg-server/glamor/glamor_trapezoid.c
@@ -0,0 +1,1819 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ *
+ * 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.
+ *
+ * Authors:
+ * Junyan He <junyan.he@linux.intel.com>
+ *
+ */
+
+/** @file glamor_trapezoid.c
+ *
+ * Trapezoid acceleration implementation
+ */
+
+#include "glamor_priv.h"
+
+#ifdef RENDER
+#include "mipict.h"
+#include "fbpict.h"
+
+static xFixed
+_glamor_linefixedX (xLineFixed *l, xFixed y, Bool ceil)
+{
+ xFixed dx = l->p2.x - l->p1.x;
+ xFixed_32_32 ex = (xFixed_32_32) (y - l->p1.y) * dx;
+ xFixed dy = l->p2.y - l->p1.y;
+ if (ceil)
+ ex += (dy - 1);
+ return l->p1.x + (xFixed) (ex / dy);
+}
+
+static xFixed
+_glamor_linefixedY (xLineFixed *l, xFixed x, Bool ceil)
+{
+ xFixed dy = l->p2.y - l->p1.y;
+ xFixed_32_32 ey = (xFixed_32_32) (x - l->p1.x) * dy;
+ xFixed dx = l->p2.x - l->p1.x;
+ if (ceil)
+ ey += (dx - 1);
+ return l->p1.y + (xFixed) (ey / dx);
+}
+
+#ifdef GLAMOR_TRAPEZOID_SHADER
+
+#define GLAMOR_VERTEX_TOP_BOTTOM (GLAMOR_VERTEX_SOURCE + 1)
+#define GLAMOR_VERTEX_LEFT_PARAM (GLAMOR_VERTEX_SOURCE + 2)
+#define GLAMOR_VERTEX_RIGHT_PARAM (GLAMOR_VERTEX_SOURCE + 3)
+
+#define DEBUG_CLIP_VTX 0
+
+#define POINT_INSIDE_CLIP_RECT(point, rect) \
+ (point[0] >= IntToxFixed(rect->x1) \
+ && point[0] <= IntToxFixed(rect->x2) \
+ && point[1] >= IntToxFixed(rect->y1) \
+ && point[1] <= IntToxFixed(rect->y2))
+
+static xFixed
+_glamor_lines_crossfixedY (xLineFixed *l, xLineFixed *r)
+{
+ xFixed dx1 = l->p2.x - l->p1.x;
+ xFixed dx2 = r->p2.x - r->p1.x;
+ xFixed dy1 = l->p2.y - l->p1.y;
+ xFixed dy2 = r->p2.y - r->p1.y;
+ xFixed_32_32 tmp = (xFixed_32_32) dy2 * dy1;
+ xFixed_32_32 dividend1 = (tmp >> 32) * (l->p1.x - r->p1.x);
+ xFixed_32_32 dividend2;
+ xFixed_32_32 dividend3;
+ xFixed_32_32 divisor;
+
+ tmp = (xFixed_32_32) dx1 * dy2;
+ dividend2 = (tmp >> 32) * l->p1.y;
+ tmp = (xFixed_32_32) dy1 * dx2;
+ dividend3 = (tmp >> 32) * r->p1.y;
+ divisor = ((xFixed_32_32) dx1 * (xFixed_32_32) dy2
+ - (xFixed_32_32) dy1 * (xFixed_32_32) dx2) >> 32;
+
+ if (divisor)
+ return (xFixed)((dividend2 - dividend1 - dividend3) / divisor);
+
+ return 0xFFFFFFFF;
+}
+
+static Bool
+point_inside_trapezoid(int point[2], xTrapezoid * trap, xFixed cut_y)
+{
+ int ret = TRUE;
+ int tmp;
+ if (point[1] > trap->bottom) {
+ ret = FALSE;
+ if (DEBUG_CLIP_VTX) {
+ ErrorF("Out of Trap bottom, point[1] = %d(0x%x)), "
+ "bottom = %d(0x%x)\n",
+ (unsigned int)xFixedToInt(point[1]), point[1],
+ (unsigned int)xFixedToInt(trap->bottom),
+ (unsigned int)trap->bottom);
+ }
+
+ return ret;
+ }
+
+ if (point[1] < trap->top) {
+ ret = FALSE;
+ if (DEBUG_CLIP_VTX) {
+ ErrorF("Out of Trap top, point[1] = %d(0x%x)), "
+ "top = %d(0x%x)\n",
+ (unsigned int)xFixedToInt(point[1]), point[1],
+ (unsigned int)xFixedToInt(trap->top),
+ (unsigned int)trap->top);
+ }
+
+ return ret;
+ }
+
+ tmp = _glamor_linefixedX (&trap->left, point[1], FALSE);
+ if (point[0] < tmp) {
+ ret = FALSE;
+
+ if (abs(cut_y - trap->top) < pixman_fixed_1_minus_e &&
+ abs(point[1] - trap->top) < pixman_fixed_1_minus_e &&
+ tmp - point[0] < pixman_fixed_1_minus_e) {
+ ret = TRUE;
+ } else if (abs(cut_y - trap->bottom) < pixman_fixed_1_minus_e &&
+ point[1] - trap->bottom < pixman_fixed_1_minus_e &&
+ tmp - point[0] < pixman_fixed_1_minus_e) {
+ ret = TRUE;
+ }
+
+ if (DEBUG_CLIP_VTX && !ret) {
+ ErrorF("Out of Trap left, point[0] = %d(0x%x)), "
+ "left = %d(0x%x)\n",
+ (unsigned int)xFixedToInt(point[0]), point[0],
+ (unsigned int)xFixedToInt(tmp), (unsigned int)tmp);
+ }
+
+ if (!ret)
+ return ret;
+ }
+
+ tmp = _glamor_linefixedX (&trap->right, point[1], TRUE);
+ if (point[0] > tmp) {
+ ret = FALSE;
+
+ if (abs(cut_y - trap->top) < pixman_fixed_1_minus_e &&
+ abs(point[1] - trap->top) < pixman_fixed_1_minus_e &&
+ point[0] - tmp < pixman_fixed_1_minus_e) {
+ ret = TRUE;
+ } else if (abs(cut_y - trap->bottom) < pixman_fixed_1_minus_e &&
+ abs(point[1] - trap->bottom) < pixman_fixed_1_minus_e &&
+ point[0] - tmp < pixman_fixed_1_minus_e) {
+ ret = TRUE;
+ }
+
+ if (DEBUG_CLIP_VTX && !ret) {
+ ErrorF("Out of Trap right, point[0] = %d(0x%x)), "
+ "right = %d(0x%x)\n",
+ (unsigned int)xFixedToInt(point[0]), point[0],
+ (unsigned int)xFixedToInt(tmp), (unsigned int)tmp);
+ }
+
+ if (!ret)
+ return ret;
+ }
+
+ return ret;
+}
+
+static void
+glamor_emit_composite_triangle(ScreenPtr screen,
+ const float *src_coords,
+ const float *mask_coords,
+ const float *dst_coords)
+{
+ glamor_emit_composite_vert(screen, src_coords, mask_coords,
+ dst_coords, 0);
+ glamor_emit_composite_vert(screen, src_coords, mask_coords,
+ dst_coords, 1);
+ glamor_emit_composite_vert(screen, src_coords, mask_coords,
+ dst_coords, 2);
+}
+
+static void
+glamor_flush_composite_triangles(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(screen);
+ glamor_gl_dispatch *dispatch;
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+ if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
+ dispatch->glUnmapBuffer(GL_ARRAY_BUFFER);
+ else {
+
+ dispatch->glBindBuffer(GL_ARRAY_BUFFER, glamor_priv->vbo);
+ dispatch->glBufferData(GL_ARRAY_BUFFER,
+ glamor_priv->vbo_offset,
+ glamor_priv->vb, GL_DYNAMIC_DRAW);
+ }
+
+ if (!glamor_priv->render_nr_verts)
+ return;
+
+ dispatch->glDrawArrays(GL_TRIANGLES, 0, glamor_priv->render_nr_verts);
+ glamor_put_dispatch(glamor_priv);
+}
+
+static Bool
+_glamor_clip_trapezoid_vertex(xTrapezoid * trap, BoxPtr pbox,
+ int vertex[6], int *num)
+{
+ xFixed edge_cross_y = 0xFFFFFFFF;
+ int tl[2];
+ int bl[2];
+ int tr[2];
+ int br[2];
+ int left_cut_top[2];
+ int left_cut_left[2];
+ int left_cut_right[2];
+ int left_cut_bottom[2];
+ int right_cut_top[2];
+ int right_cut_left[2];
+ int right_cut_right[2];
+ int right_cut_bottom[2];
+ int tmp[2];
+ int tmp_vtx[20*2];
+ float tmp_vtx_slope[20];
+ BoxRec trap_bound;
+ int i = 0;
+ int vertex_num = 0;
+
+ if (DEBUG_CLIP_VTX) {
+ ErrorF("The parameter of xTrapezoid is:\ntop: %d 0x%x\tbottom: %d 0x%x\n"
+ "left: p1 (%d 0x%x, %d 0x%x)\tp2 (%d 0x%x, %d 0x%x)\n"
+ "right: p1 (%d 0x%x, %d 0x%x)\tp2 (%d 0x%x, %d 0x%x)\n",
+ xFixedToInt(trap->top), (unsigned int)trap->top,
+ xFixedToInt(trap->bottom), (unsigned int)trap->bottom,
+ xFixedToInt(trap->left.p1.x), (unsigned int)trap->left.p1.x,
+ xFixedToInt(trap->left.p1.y), (unsigned int)trap->left.p1.y,
+ xFixedToInt(trap->left.p2.x), (unsigned int)trap->left.p2.x,
+ xFixedToInt(trap->left.p2.y), (unsigned int)trap->left.p2.y,
+ xFixedToInt(trap->right.p1.x), (unsigned int)trap->right.p1.x,
+ xFixedToInt(trap->right.p1.y), (unsigned int)trap->right.p1.y,
+ xFixedToInt(trap->right.p2.x), (unsigned int)trap->right.p2.x,
+ xFixedToInt(trap->right.p2.y), (unsigned int)trap->right.p2.y);
+ }
+
+ miTrapezoidBounds(1, trap, &trap_bound);
+ if (DEBUG_CLIP_VTX)
+ ErrorF("The bounds for this traps is: bounds.x1 = %d, bounds.x2 = %d, "
+ "bounds.y1 = %d, bounds.y2 = %d\n", trap_bound.x1, trap_bound.x2,
+ trap_bound.y1, trap_bound.y2);
+
+ if (trap_bound.x1 > pbox->x2 || trap_bound.x2 < pbox->x1)
+ return FALSE;
+ if (trap_bound.y1 > pbox->y2 || trap_bound.y2 < pbox->y1)
+ return FALSE;
+
+#define IS_TRAP_EDGE_VERTICAL(edge) \
+ (edge->p1.x == edge->p2.x)
+
+#define CACULATE_CUT_VERTEX(vtx, cal_x, ceil, vh_edge, edge) \
+ do { \
+ if(cal_x) { \
+ vtx[1] = (vh_edge); \
+ vtx[0] = (_glamor_linefixedX( \
+ edge, vh_edge, ceil)); \
+ if(DEBUG_CLIP_VTX) \
+ ErrorF("The intersection point of line y=%d and " \
+ "line of p1:(%d,%d) -- p2 (%d,%d) " \
+ "is (%d, %d)\n", \
+ xFixedToInt(vh_edge), \
+ xFixedToInt(edge->p1.x), \
+ xFixedToInt(edge->p1.y), \
+ xFixedToInt(edge->p2.x), \
+ xFixedToInt(edge->p2.y), \
+ xFixedToInt(vtx[0]), \
+ xFixedToInt(vtx[1])); \
+ } else { \
+ vtx[0] = (vh_edge); \
+ vtx[1] = (_glamor_linefixedY( \
+ edge, vh_edge, ceil)); \
+ if(DEBUG_CLIP_VTX) \
+ ErrorF("The intersection point of line x=%d and " \
+ "line of p1:(%d,%d) -- p2 (%d,%d) " \
+ "is (%d, %d)\n", \
+ xFixedToInt(vh_edge), \
+ xFixedToInt(edge->p1.x), \
+ xFixedToInt(edge->p1.y), \
+ xFixedToInt(edge->p2.x), \
+ xFixedToInt(edge->p2.y), \
+ xFixedToInt(vtx[0]), \
+ xFixedToInt(vtx[1])); \
+ } \
+ } while(0)
+
+#define ADD_VERTEX_IF_INSIDE(vtx) \
+ if(POINT_INSIDE_CLIP_RECT(vtx, pbox) \
+ && point_inside_trapezoid(vtx, trap, edge_cross_y)){ \
+ tmp_vtx[vertex_num] = xFixedToInt(vtx[0]); \
+ tmp_vtx[vertex_num + 1] = xFixedToInt(vtx[1]); \
+ vertex_num += 2; \
+ if(DEBUG_CLIP_VTX) \
+ ErrorF("@ Point: (%d, %d) is inside " \
+ "the Rect and Trapezoid\n", \
+ xFixedToInt(vtx[0]), \
+ xFixedToInt(vtx[1])); \
+ } else if(DEBUG_CLIP_VTX){ \
+ ErrorF("X Point: (%d, %d) is outside " \
+ "the Rect and Trapezoid\t", \
+ xFixedToInt(vtx[0]), \
+ xFixedToInt(vtx[1])); \
+ if(POINT_INSIDE_CLIP_RECT(vtx, pbox)) \
+ ErrorF("The Point is outside " \
+ "the Trapezoid\n"); \
+ else \
+ ErrorF("The Point is outside " \
+ "the Rect\n"); \
+ }
+
+ /*Trap's right edge cut right edge. */
+ if((!IS_TRAP_EDGE_VERTICAL((&trap->left))) ||
+ (!IS_TRAP_EDGE_VERTICAL((&trap->right)))) {
+ edge_cross_y = _glamor_lines_crossfixedY((&trap->left), (&trap->right));
+ if (DEBUG_CLIP_VTX) {
+ ErrorF("Trap's left edge cut right edge at %d(0x%x), "
+ "trap_top = %x, trap_bottom = %x\n",
+ xFixedToInt(edge_cross_y), edge_cross_y,
+ (unsigned int)trap->top, (unsigned int)trap->bottom);
+ }
+ }
+
+ /*Trap's TopLeft, BottomLeft, TopRight and BottomRight. */
+ CACULATE_CUT_VERTEX(tl, 1, FALSE, trap->top, (&trap->left));
+ CACULATE_CUT_VERTEX(bl, 1, FALSE, trap->bottom, (&trap->left));
+ CACULATE_CUT_VERTEX(tr, 1, TRUE, trap->top, (&trap->right));
+ CACULATE_CUT_VERTEX(br, 1, TRUE, trap->bottom, (&trap->right));
+
+ if (DEBUG_CLIP_VTX)
+ ErrorF("Trap's TopLeft, BottomLeft, TopRight and BottomRight\n");
+ if (DEBUG_CLIP_VTX)
+ ErrorF("Caculate the vertex of trapezoid:\n"
+ " (%3d, %3d)-------------------------(%3d, %3d)\n"
+ " / \\ \n"
+ " / \\ \n"
+ " / \\ \n"
+ " (%3d, %3d)---------------------------------(%3d, %3d)\n"
+ "Clip with rect:\n"
+ " (%3d, %3d)------------------------(%3d, %3d) \n"
+ " | | \n"
+ " | | \n"
+ " | | \n"
+ " (%3d, %3d)------------------------(%3d, %3d) \n",
+ xFixedToInt(tl[0]), xFixedToInt(tl[1]), xFixedToInt(tr[0]),
+ xFixedToInt(tr[1]), xFixedToInt(bl[0]), xFixedToInt(bl[1]),
+ xFixedToInt(br[0]), xFixedToInt(br[1]),
+ pbox->x1, pbox->y1, pbox->x2, pbox->y1, pbox->x1, pbox->y2,
+ pbox->x2, pbox->y2);
+
+ ADD_VERTEX_IF_INSIDE(tl);
+ ADD_VERTEX_IF_INSIDE(bl);
+ ADD_VERTEX_IF_INSIDE(tr);
+ ADD_VERTEX_IF_INSIDE(br);
+
+ /*Trap's left edge cut Rect. */
+ if (DEBUG_CLIP_VTX)
+ ErrorF("Trap's left edge cut Rect\n");
+ CACULATE_CUT_VERTEX(left_cut_top, 1, FALSE, IntToxFixed(pbox->y1), (&trap->left));
+ ADD_VERTEX_IF_INSIDE(left_cut_top);
+ if (!IS_TRAP_EDGE_VERTICAL((&trap->left))) {
+ CACULATE_CUT_VERTEX(left_cut_left, 0, FALSE, IntToxFixed(pbox->x1), (&trap->left));
+ ADD_VERTEX_IF_INSIDE(left_cut_left);
+ }
+ CACULATE_CUT_VERTEX(left_cut_bottom, 1, FALSE, IntToxFixed(pbox->y2), (&trap->left));
+ ADD_VERTEX_IF_INSIDE(left_cut_bottom);
+ if (!IS_TRAP_EDGE_VERTICAL((&trap->left))) {
+ CACULATE_CUT_VERTEX(left_cut_right, 0, FALSE, IntToxFixed(pbox->x2), (&trap->left));
+ ADD_VERTEX_IF_INSIDE(left_cut_right);
+ }
+
+ /*Trap's right edge cut Rect. */
+ if (DEBUG_CLIP_VTX)
+ ErrorF("Trap's right edge cut Rect\n");
+ CACULATE_CUT_VERTEX(right_cut_top, 1, TRUE, IntToxFixed(pbox->y1), (&trap->right));
+ ADD_VERTEX_IF_INSIDE(right_cut_top);
+ if (!IS_TRAP_EDGE_VERTICAL((&trap->right))) {
+ CACULATE_CUT_VERTEX(right_cut_left, 0, TRUE, IntToxFixed(pbox->x1), (&trap->right));
+ ADD_VERTEX_IF_INSIDE(right_cut_left);
+ }
+ CACULATE_CUT_VERTEX(right_cut_bottom, 1, TRUE, IntToxFixed(pbox->y2), (&trap->right));
+ ADD_VERTEX_IF_INSIDE(right_cut_bottom);
+ if (!IS_TRAP_EDGE_VERTICAL((&trap->right))) {
+ CACULATE_CUT_VERTEX(right_cut_right, 0, TRUE, IntToxFixed(pbox->x2), (&trap->right));
+ ADD_VERTEX_IF_INSIDE(right_cut_right);
+ }
+
+ /* Trap's top cut Left and Right of rect. */
+ if (DEBUG_CLIP_VTX)
+ ErrorF("Trap's top cut Left and Right of rect\n");
+ tmp[0] = IntToxFixed(pbox->x1);
+ tmp[1] = trap->top;
+ ADD_VERTEX_IF_INSIDE(tmp);
+ tmp[0] = IntToxFixed(pbox->x2);
+ tmp[1] = trap->top;
+ ADD_VERTEX_IF_INSIDE(tmp);
+
+ /* Trap's bottom cut Left and Right of rect. */
+ if (DEBUG_CLIP_VTX)
+ ErrorF("Trap's bottom cut Left and Right of rect\n");
+ tmp[0] = IntToxFixed(pbox->x1);
+ tmp[1] = trap->bottom;
+ ADD_VERTEX_IF_INSIDE(tmp);
+ tmp[0] = IntToxFixed(pbox->x2);
+ tmp[1] = trap->bottom;
+ ADD_VERTEX_IF_INSIDE(tmp);
+
+ /* The orginal 4 vertex of rect. */
+ if (DEBUG_CLIP_VTX)
+ ErrorF("The orginal 4 vertex of rect\n");
+ tmp[0] = IntToxFixed(pbox->x1);
+ tmp[1] = IntToxFixed(pbox->y1);
+ ADD_VERTEX_IF_INSIDE(tmp);
+ tmp[0] = IntToxFixed(pbox->x1);
+ tmp[1] = IntToxFixed(pbox->y2);
+ ADD_VERTEX_IF_INSIDE(tmp);
+ tmp[0] = IntToxFixed(pbox->x2);
+ tmp[1] = IntToxFixed(pbox->y2);
+ ADD_VERTEX_IF_INSIDE(tmp);
+ tmp[0] = IntToxFixed(pbox->x2);
+ tmp[1] = IntToxFixed(pbox->y1);
+ ADD_VERTEX_IF_INSIDE(tmp);
+
+ if (DEBUG_CLIP_VTX) {
+ ErrorF("\nThe candidate vertex number is %d\n", vertex_num / 2);
+ for (i = 0; i < vertex_num / 2; i++) {
+ ErrorF("(%d, %d) ", tmp_vtx[2*i], tmp_vtx[2*i + 1]);
+ }
+ ErrorF("\n");
+ }
+
+ /* Sort the vertex by X and then Y. */
+ for (i = 0; i < vertex_num / 2; i++) {
+ int j;
+ for (j = 0; j < vertex_num / 2 - i - 1; j++) {
+ if (tmp_vtx[2*j] > tmp_vtx[2*(j+1)]
+ || (tmp_vtx[2*j] == tmp_vtx[2*(j+1)]
+ && tmp_vtx[2*j + 1] > tmp_vtx[2*(j+1) + 1])) {
+ tmp[0] = tmp_vtx[2*j];
+ tmp[1] = tmp_vtx[2*j + 1];
+ tmp_vtx[2*j] = tmp_vtx[2*(j+1)];
+ tmp_vtx[2*j + 1] = tmp_vtx[2*(j+1) + 1];
+ tmp_vtx[2*(j+1)] = tmp[0];
+ tmp_vtx[2*(j+1) + 1] = tmp[1];
+ }
+ }
+
+ }
+
+ if (DEBUG_CLIP_VTX) {
+ ErrorF("\nAfter sort vertex number is:\n");
+ for (i = 0; i < vertex_num / 2; i++) {
+ ErrorF("(%d, %d) ", tmp_vtx[2*i], tmp_vtx[2*i + 1]);
+ }
+ ErrorF("\n");
+ }
+
+ memset(vertex, -1, 2*6);
+ *num = 0;
+
+ for (i = 0; i < vertex_num / 2; i++) {
+ if (*num > 0 && vertex[2*(*num - 1)] == tmp_vtx[2*i]
+ && vertex[2*(*num - 1) + 1] == tmp_vtx[2*i + 1]) {
+ /*same vertex.*/
+ if (DEBUG_CLIP_VTX)
+ ErrorF("X Point:(%d, %d) discard\n",
+ tmp_vtx[2*i], tmp_vtx[2*i + 1]);
+ continue;
+ }
+
+ (*num)++;
+ if (*num > 6) {
+ if (DEBUG_CLIP_VTX)
+ FatalError("Trapezoid clip with Rect can never have vtx"
+ "number bigger than 6\n");
+ else {
+ ErrorF("Trapezoid clip with Rect can never have vtx"
+ "number bigger than 6\n");
+ *num = 6;
+ break;
+ }
+ }
+
+ vertex[2*(*num - 1)] = tmp_vtx[2*i];
+ vertex[2*(*num - 1) + 1] = tmp_vtx[2*i + 1];
+ if (DEBUG_CLIP_VTX)
+ ErrorF("@ Point:(%d, %d) select, num now is %d\n",
+ tmp_vtx[2*i], tmp_vtx[2*i + 1], *num);
+ }
+
+ /* Now we need to arrange the vtx in the polygon's counter-clockwise
+ order. We first select the left and top point as the start point and
+ sort every vtx by the slope from vtx to the start vtx. */
+ for (i = 1; i < *num; i++) {
+ tmp_vtx_slope[i] = (vertex[2*i] != vertex[0] ?
+ (float)(vertex[2*i + 1] - vertex[1]) / (float)(vertex[2*i] - vertex[0])
+ : (float)INT_MAX);
+ }
+
+ if (DEBUG_CLIP_VTX) {
+ ErrorF("\nvtx number: %d, VTX and slope:\n", *num);
+ for (i = 0; i < *num; i++) {
+ ErrorF("(%d, %d):%f ",
+ vertex[2*i], vertex[2*i + 1],
+ tmp_vtx_slope[i]);
+ }
+ ErrorF("\n");
+ }
+
+ /* Sort the vertex by slope. */
+ for (i = 0; i < *num - 1; i++) {
+ int j;
+ float tmp_slope;
+ for (j = 1; j < *num - i - 1; j++) {
+ if (tmp_vtx_slope[j] < tmp_vtx_slope[j + 1]) {
+ tmp_slope = tmp_vtx_slope[j];
+ tmp_vtx_slope[j] = tmp_vtx_slope[j + 1];
+ tmp_vtx_slope[j + 1] = tmp_slope;
+ tmp[0] = vertex[2*j];
+ tmp[1] = vertex[2*j + 1];
+ vertex[2*j] = vertex[2*(j+1)];
+ vertex[2*j + 1] = vertex[2*(j+1) + 1];
+ vertex[2*(j+1)] = tmp[0];
+ vertex[2*(j+1) + 1] = tmp[1];
+ }
+ }
+ }
+
+ if (DEBUG_CLIP_VTX) {
+ ErrorF("\nBefore return, vtx number: %d, VTX and slope:\n", *num);
+ for (i = 0; i < *num; i++) {
+ ErrorF("(%d, %d):%f ",
+ vertex[2*i], vertex[2*i + 1],
+ tmp_vtx_slope[i]);
+ }
+ ErrorF("\n");
+ }
+
+ return TRUE;
+}
+
+static void
+glamor_setup_composite_vbo_for_trapezoid(ScreenPtr screen, int n_verts)
+{
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(screen);
+ glamor_gl_dispatch *dispatch;
+ int stride;
+ int vert_size;
+
+ glamor_priv->render_nr_verts = 0;
+
+ /* For GLAMOR_VERTEX_POS */
+ glamor_priv->vb_stride = 2 * sizeof(float);
+
+ /* For GLAMOR_GLAMOR_VERTEX_SOURCE */
+ glamor_priv->vb_stride += 2 * sizeof(float);
+
+ /* For GLAMOR_VERTEX_TOP_BOTTOM */
+ glamor_priv->vb_stride += 2 * sizeof(float);
+
+ /* For GLAMOR_VERTEX_LEFT_PARAM */
+ glamor_priv->vb_stride += 4 * sizeof(float);
+
+ /* For GLAMOR_VERTEX_RIGHT_PARAM */
+ glamor_priv->vb_stride += 4 * sizeof(float);
+
+ vert_size = n_verts * glamor_priv->vb_stride;
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_TOP_BOTTOM);
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_LEFT_PARAM);
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_RIGHT_PARAM);
+
+ dispatch->glBindBuffer(GL_ARRAY_BUFFER, glamor_priv->vbo);
+ if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
+ if (glamor_priv->vbo_size < (glamor_priv->vbo_offset + vert_size)) {
+ glamor_priv->vbo_size = GLAMOR_COMPOSITE_VBO_VERT_CNT *
+ glamor_priv->vb_stride;
+ glamor_priv->vbo_offset = 0;
+ dispatch->glBufferData(GL_ARRAY_BUFFER,
+ glamor_priv->vbo_size,
+ NULL, GL_STREAM_DRAW);
+ }
+
+ glamor_priv->vb = dispatch->glMapBufferRange(GL_ARRAY_BUFFER,
+ glamor_priv->vbo_offset,
+ vert_size,
+ GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
+
+ assert(glamor_priv->vb != NULL);
+ glamor_priv->vb -= glamor_priv->vbo_offset;
+ } else {
+ glamor_priv->vbo_offset = 0;
+ }
+
+ dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);
+
+ /* Set the vertex pointer. */
+ dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
+ GL_FALSE, glamor_priv->vb_stride,
+ (void *) ((long)glamor_priv->vbo_offset));
+ dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+ stride = 2;
+
+ dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
+ GL_FALSE, glamor_priv->vb_stride,
+ (void *) ((long)glamor_priv->vbo_offset + stride * sizeof(float)));
+ dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+ stride += 2;
+
+ dispatch->glVertexAttribPointer(GLAMOR_VERTEX_TOP_BOTTOM, 2, GL_FLOAT,
+ GL_FALSE, glamor_priv->vb_stride,
+ (void *) ((long)glamor_priv->vbo_offset + stride * sizeof(float)));
+ dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_TOP_BOTTOM);
+ stride += 2;
+
+ dispatch->glVertexAttribPointer(GLAMOR_VERTEX_LEFT_PARAM, 4, GL_FLOAT,
+ GL_FALSE, glamor_priv->vb_stride,
+ (void *) ((long)glamor_priv->vbo_offset + stride * sizeof(float)));
+ dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_LEFT_PARAM);
+ stride += 4;
+
+ dispatch->glVertexAttribPointer(GLAMOR_VERTEX_RIGHT_PARAM, 4, GL_FLOAT,
+ GL_FALSE, glamor_priv->vb_stride,
+ (void *) ((long)glamor_priv->vbo_offset + stride * sizeof(float)));
+ dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_RIGHT_PARAM);
+
+ glamor_put_dispatch(glamor_priv);
+}
+
+static Bool
+_glamor_trapezoids_with_shader(CARD8 op,
+ PicturePtr src, PicturePtr dst,
+ PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
+ int ntrap, xTrapezoid * traps)
+{
+ ScreenPtr screen = dst->pDrawable->pScreen;
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ struct shader_key key;
+ glamor_composite_shader *shader = NULL;
+ struct blendinfo op_info;
+ PictFormatShort saved_source_format = 0;
+ PixmapPtr source_pixmap = NULL;
+ PixmapPtr dest_pixmap = NULL;
+ glamor_pixmap_private *source_pixmap_priv = NULL;
+ glamor_pixmap_private *dest_pixmap_priv = NULL;
+ glamor_pixmap_private *temp_src_priv = NULL;
+ int x_temp_src, y_temp_src;
+ int src_width, src_height;
+ int source_x_off, source_y_off;
+ GLfloat src_xscale = 1, src_yscale = 1;
+ int x_dst, y_dst;
+ int dest_x_off, dest_y_off;
+ GLfloat dst_xscale, dst_yscale;
+ BoxRec bounds;
+ PicturePtr temp_src = src;
+ glamor_gl_dispatch *dispatch = NULL;
+ int vert_stride = 3;
+ int ntriangle_per_loop;
+ int nclip_rect;
+ int mclip_rect;
+ int clip_processed;
+ int clipped_vtx[6*2];
+ RegionRec region;
+ BoxPtr box = NULL;
+ BoxPtr pbox = NULL;
+ int traps_count = 0;
+ int traps_not_completed = 0;
+ xTrapezoid * ptrap = NULL;
+ int nbox;
+ float src_matrix[9];
+ Bool ret = FALSE;
+
+ /* If a mask format wasn't provided, we get to choose, but behavior should
+ * be as if there was no temporary mask the traps were accumulated into.
+ */
+ if (!mask_format) {
+ if (dst->polyEdge == PolyEdgeSharp)
+ mask_format = PictureMatchFormat(screen, 1, PICT_a1);
+ else
+ mask_format = PictureMatchFormat(screen, 8, PICT_a8);
+ for (; ntrap; ntrap--, traps++)
+ glamor_trapezoids(op, src, dst, mask_format, x_src,
+ y_src, 1, traps);
+ return TRUE;
+ }
+
+ miTrapezoidBounds(ntrap, traps, &bounds);
+ DEBUGF("The bounds for all traps is: bounds.x1 = %d, bounds.x2 = %d, "
+ "bounds.y1 = %d, bounds.y2 = %d\n", bounds.x1, bounds.x2,
+ bounds.y1, bounds.y2);
+
+ /* No area need to render. */
+ if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
+ return TRUE;
+
+ dest_pixmap = glamor_get_drawable_pixmap(dst->pDrawable);
+ dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap);
+
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dest_pixmap_priv)
+ || dest_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
+ /* Currently. Always fallback to cpu if destination is in CPU memory.*/
+ ret = FALSE;
+ DEBUGF("dst pixmap has no FBO.\n");
+ goto TRAPEZOID_OUT;
+ }
+
+ if (src->pDrawable) {
+ source_pixmap = glamor_get_drawable_pixmap(src->pDrawable);
+ source_pixmap_priv = glamor_get_pixmap_private(source_pixmap);
+ temp_src_priv = source_pixmap_priv;
+ if (source_pixmap_priv
+ && (source_pixmap_priv->type == GLAMOR_DRM_ONLY
+ || source_pixmap_priv->type == GLAMOR_TEXTURE_LARGE)) {
+ ret = FALSE;
+ goto TRAPEZOID_OUT;
+ }
+ }
+
+ x_dst = bounds.x1;
+ y_dst = bounds.y1;
+
+ src_width = bounds.x2 - bounds.x1;
+ src_height = bounds.y2 - bounds.y1;
+
+ x_temp_src = x_src + bounds.x1 - (traps[0].left.p1.x >> 16);
+ y_temp_src = y_src + bounds.y1 - (traps[0].left.p1.y >> 16);
+
+ if ((!src->pDrawable &&
+ (src->pSourcePict->type != SourcePictTypeSolidFill)) //1. The Gradient case.
+ /* 2. Has no fbo but can upload.*/
+ || (src->pDrawable && !GLAMOR_PIXMAP_PRIV_HAS_FBO(source_pixmap_priv)
+ && ((src_width * src_height * 4 <
+ source_pixmap->drawable.width * source_pixmap->drawable.height)
+ || !glamor_check_fbo_size(glamor_priv, source_pixmap->drawable.width,
+ source_pixmap->drawable.height)))) {
+
+ if (!glamor_check_fbo_size(glamor_priv, src_width, src_height)) {
+ ret = FALSE;
+ goto TRAPEZOID_OUT;
+ }
+ temp_src = glamor_convert_gradient_picture(screen, src,
+ x_src, y_src,
+ src_width, src_height);
+ if (!temp_src) {
+ temp_src = src;
+ ret = FALSE;
+ DEBUGF("Convert gradient picture failed\n");
+ goto TRAPEZOID_OUT;
+ }
+ temp_src_priv = glamor_get_pixmap_private((PixmapPtr)temp_src->pDrawable);
+ x_temp_src = y_temp_src = 0;
+ }
+
+ x_dst += dst->pDrawable->x;
+ y_dst += dst->pDrawable->y;
+ if (temp_src->pDrawable) {
+ x_temp_src += temp_src->pDrawable->x;
+ y_temp_src += temp_src->pDrawable->y;
+ }
+
+ if (!miComputeCompositeRegion(&region,
+ temp_src, NULL, dst,
+ x_temp_src, y_temp_src,
+ 0, 0,
+ x_dst, y_dst,
+ src_width, src_height)) {
+ DEBUGF("All the regions are clipped out, do nothing\n");
+ goto TRAPEZOID_OUT;
+ }
+
+ box = REGION_RECTS(&region);
+ nbox = REGION_NUM_RECTS(&region);
+ pbox = box;
+
+ ret = glamor_composite_choose_shader(op, temp_src, NULL, dst,
+ temp_src_priv, NULL, dest_pixmap_priv,
+ &key, &shader, &op_info, &saved_source_format);
+ if (ret == FALSE) {
+ DEBUGF("can not set the shader program for composite\n");
+ goto TRAPEZOID_RESET_GL;
+ }
+ glamor_set_destination_pixmap_priv_nc(dest_pixmap_priv);
+ glamor_composite_set_shader_blend(dest_pixmap_priv, &key, shader, &op_info);
+ glamor_priv->has_source_coords = key.source != SHADER_SOURCE_SOLID;
+ glamor_priv->has_mask_coords = (key.mask != SHADER_MASK_NONE &&
+ key.mask != SHADER_MASK_SOLID);
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+
+ glamor_get_drawable_deltas(dst->pDrawable, dest_pixmap,
+ &dest_x_off, &dest_y_off);
+
+ pixmap_priv_get_dest_scale(dest_pixmap_priv, &dst_xscale, &dst_yscale);
+
+ if (glamor_priv->has_source_coords) {
+ source_pixmap = glamor_get_drawable_pixmap(temp_src->pDrawable);
+ source_pixmap_priv = glamor_get_pixmap_private(source_pixmap);
+ glamor_get_drawable_deltas(temp_src->pDrawable,
+ source_pixmap,
+ &source_x_off, &source_y_off);
+ pixmap_priv_get_scale(source_pixmap_priv,
+ &src_xscale, &src_yscale);
+ glamor_picture_get_matrixf(temp_src, src_matrix);
+ vert_stride += 3;
+ }
+
+ if (glamor_priv->has_mask_coords) {
+ DEBUGF("Should never have mask coords here!\n");
+ ret = FALSE;
+ goto TRAPEZOID_RESET_GL;
+ }
+
+ /* A trapezoid clip with a rectangle will at most generate a hexagon,
+ which can be devided into 4 triangles to render. */
+ ntriangle_per_loop = (vert_stride * nbox * ntrap * 4) > GLAMOR_COMPOSITE_VBO_VERT_CNT ?
+ (GLAMOR_COMPOSITE_VBO_VERT_CNT / vert_stride) : nbox * ntrap * 4;
+ ntriangle_per_loop = (ntriangle_per_loop / 4) * 4;
+
+ nclip_rect = nbox;
+ while (nclip_rect) {
+ mclip_rect = (nclip_rect * ntrap * 4) > ntriangle_per_loop ?
+ (ntriangle_per_loop / (4 * ntrap)) : nclip_rect;
+
+ if (!mclip_rect) {/* Maybe too many traps. */
+ mclip_rect = 1;
+ ptrap = traps;
+ traps_count = ntriangle_per_loop / 4;
+ traps_not_completed = ntrap - traps_count;
+ } else {
+ traps_count = ntrap;
+ ptrap = traps;
+ traps_not_completed = 0;
+ }
+
+NTRAPS_LOOP_AGAIN:
+
+ glamor_setup_composite_vbo(screen, mclip_rect * traps_count * 4 * vert_stride);
+ clip_processed = mclip_rect;
+
+
+ while (mclip_rect--) {
+ while (traps_count--) {
+ int vtx_num;
+ int i;
+ float vertices[3*2], source_texcoords[3*2];
+
+ DEBUGF("In loop of render trapezoid, nclip_rect = %d, mclip_rect = %d, "
+ "clip_processed = %d, traps_count = %d, traps_not_completed = %d\n",
+ nclip_rect, mclip_rect, clip_processed, traps_count, traps_not_completed);
+
+ if (_glamor_clip_trapezoid_vertex(ptrap, pbox, clipped_vtx, &vtx_num)) {
+ for (i = 0; i < vtx_num - 2; i++) {
+ int clipped_vtx_tmp[3*2];
+
+ clipped_vtx_tmp[0] = clipped_vtx[0];
+ clipped_vtx_tmp[1] = clipped_vtx[1];
+ clipped_vtx_tmp[2] = clipped_vtx[(i+1)*2];
+ clipped_vtx_tmp[3] = clipped_vtx[(i+1)*2 + 1];
+ clipped_vtx_tmp[4] = clipped_vtx[(i+2)*2];
+ clipped_vtx_tmp[5] = clipped_vtx[(i+2)*2 + 1];
+ glamor_set_normalize_tri_vcoords(
+ dst_xscale, dst_yscale, clipped_vtx_tmp,
+ glamor_priv->yInverted, vertices);
+ DEBUGF("vertices of triangle: (%f X %f), (%f X %f), "
+ "(%f X %f)\n", vertices[0], vertices[1],
+ vertices[2], vertices[3], vertices[4], vertices[5]);
+
+
+ if (key.source != SHADER_SOURCE_SOLID) {
+ if (src->transform) {
+ glamor_set_transformed_normalize_tri_tcoords(
+ source_pixmap_priv,
+ src_matrix, src_xscale, src_yscale,
+ clipped_vtx_tmp,
+ glamor_priv->yInverted,
+ source_texcoords);
+ } else {
+ glamor_set_normalize_tri_tcoords(
+ src_xscale, src_yscale,
+ clipped_vtx_tmp,
+ glamor_priv->yInverted,
+ source_texcoords);
+ }
+
+ DEBUGF("source_texcoords of triangle: (%f X %f), "
+ "(%f X %f), (%f X %f)\n",
+ source_texcoords[0], source_texcoords[1],
+ source_texcoords[2], source_texcoords[3],
+ source_texcoords[4], source_texcoords[5]);
+ }
+
+ glamor_emit_composite_triangle(screen, source_texcoords,
+ NULL, vertices);
+ }
+ }
+
+ ptrap++;
+ }
+
+ if (traps_not_completed) { /* one loop of ntraps not completed */
+ mclip_rect = 1;
+ traps_count = traps_not_completed > (ntriangle_per_loop / 4) ?
+ (ntriangle_per_loop / 4) : traps_not_completed;
+ traps_not_completed -= traps_count;
+ glamor_flush_composite_triangles(screen);
+ goto NTRAPS_LOOP_AGAIN;
+ } else {
+ ptrap = traps;
+ traps_count = ntrap;
+ }
+
+ pbox++;
+ }
+
+ glamor_flush_composite_triangles(screen);
+
+ nclip_rect -= clip_processed;
+ }
+
+ ret = TRUE;
+
+TRAPEZOID_RESET_GL:
+ dispatch->glBindBuffer(GL_ARRAY_BUFFER, 0);
+ dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_MASK);
+ dispatch->glDisable(GL_BLEND);
+#ifndef GLAMOR_GLES2
+ dispatch->glActiveTexture(GL_TEXTURE0);
+ dispatch->glDisable(GL_TEXTURE_2D);
+ dispatch->glActiveTexture(GL_TEXTURE1);
+ dispatch->glDisable(GL_TEXTURE_2D);
+#endif
+ dispatch->glUseProgram(0);
+
+TRAPEZOID_OUT:
+ if (box) {
+ REGION_UNINIT(dst->pDrawable->pScreen, &region);
+ }
+
+ if (temp_src != src) {
+ FreePicture(temp_src, 0);
+ } else {
+ if (saved_source_format) {
+ src->format = saved_source_format;
+ }
+ }
+
+ if (dispatch) {
+ glamor_put_dispatch(glamor_priv);
+ }
+
+ return ret;
+}
+
+void
+glamor_init_trapezoid_shader(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv;
+ glamor_gl_dispatch *dispatch;
+ GLint fs_prog, vs_prog;
+
+ const char *trapezoid_vs =
+ GLAMOR_DEFAULT_PRECISION
+ "attribute vec4 v_position;\n"
+ "attribute vec2 v_texcoord;\n"
+ /* v_top_bottom, v_left_param and v_right_param contain the
+ constant value for all the vertex of one rect. Using uniform
+ is more suitable but we need to reset the uniform variables
+ for every rect rendering and can not use the vbo, which causes
+ performance loss. So we set these attributes to same value
+ for every vertex of one rect and so it is also a constant in FS */
+ "attribute vec2 v_top_bottom;\n"
+ "attribute vec4 v_left_param;\n"
+ "attribute vec4 v_right_param;\n"
+ "\n"
+ "varying vec2 source_texture;\n"
+ "varying float trap_top;\n"
+ "varying float trap_bottom;\n"
+ "varying float trap_left_x;\n"
+ "varying float trap_left_y;\n"
+ "varying float trap_left_slope;\n"
+ "varying float trap_left_vertical_f;\n"
+ "varying float trap_right_x;\n"
+ "varying float trap_right_y;\n"
+ "varying float trap_right_slope;\n"
+ "varying float trap_right_vertical_f;\n"
+ "\n"
+ "void main()\n"
+ "{\n"
+ " gl_Position = v_position;\n"
+ " source_texture = v_texcoord.xy;\n"
+ " trap_top = v_top_bottom.x;\n"
+ " trap_bottom = v_top_bottom.y;\n"
+ " \n"
+ " trap_left_x = v_left_param.x;\n"
+ " trap_left_y = v_left_param.y;\n"
+ " trap_left_slope = v_left_param.z;\n"
+ " trap_left_vertical_f = v_left_param.w;\n"
+ " \n"
+ " trap_right_x = v_right_param.x;\n"
+ " trap_right_y = v_right_param.y;\n"
+ " trap_right_slope = v_right_param.z;\n"
+ " trap_right_vertical_f = v_right_param.w;\n"
+ "}\n";
+
+ /*
+ * Because some GL fill function do not support the MultSample
+ * anti-alias, we need to do the MSAA here. This manner like
+ * pixman, will caculate the value of area in trapezoid dividing
+ * the totol area for each pixel, as follow:
+ |
+ ----+------------------------------------------------------>
+ |
+ | -------------
+ | / \
+ | / \
+ | / \
+ | / +----------------+
+ | / |.....\ |
+ | / |......\ |
+ | / |.......\ |
+ | / |........\ |
+ | /-------------------+---------\ |
+ | | |
+ | | |
+ | +----------------+
+ |
+ \|/
+
+ */
+ const char *trapezoid_fs =
+ GLAMOR_DEFAULT_PRECISION
+ "varying vec2 source_texture; \n"
+ "varying float trap_top; \n"
+ "varying float trap_bottom; \n"
+ "varying float trap_left_x; \n"
+ "varying float trap_left_y; \n"
+ "varying float trap_left_slope; \n"
+ "varying float trap_left_vertical_f; \n"
+ "varying float trap_right_x; \n"
+ "varying float trap_right_y; \n"
+ "varying float trap_right_slope; \n"
+ "varying float trap_right_vertical_f; \n"
+ "float x_per_pix = 1.0;"
+ "float y_per_pix = 1.0;"
+ "\n"
+ "float get_alpha_val() \n"
+ "{ \n"
+ " float x_up_cut_left; \n"
+ " float x_bottom_cut_left; \n"
+ " float x_up_cut_right; \n"
+ " float x_bottom_cut_right; \n"
+ " bool trap_left_vertical;\n"
+ " bool trap_right_vertical;\n"
+ " if (abs(trap_left_vertical_f - 1.0) <= 0.0001)\n"
+ " trap_left_vertical = true;\n"
+ " else\n"
+ " trap_left_vertical = false;\n"
+ " if (abs(trap_right_vertical_f - 1.0) <= 0.0001)\n"
+ " trap_right_vertical = true;\n"
+ " else\n"
+ " trap_right_vertical = false;\n"
+ " \n"
+ " if(trap_left_vertical == true) { \n"
+ " x_up_cut_left = trap_left_x; \n"
+ " x_bottom_cut_left = trap_left_x; \n"
+ " } else { \n"
+ " x_up_cut_left = trap_left_x \n"
+ " + (source_texture.y - y_per_pix/2.0 - trap_left_y) \n"
+ " / trap_left_slope; \n"
+ " x_bottom_cut_left = trap_left_x \n"
+ " + (source_texture.y + y_per_pix/2.0 - trap_left_y) \n"
+ " / trap_left_slope; \n"
+ " } \n"
+ " \n"
+ " if(trap_right_vertical == true) { \n"
+ " x_up_cut_right = trap_right_x; \n"
+ " x_bottom_cut_right = trap_right_x; \n"
+ " } else { \n"
+ " x_up_cut_right = trap_right_x \n"
+ " + (source_texture.y - y_per_pix/2.0 - trap_right_y) \n"
+ " / trap_right_slope; \n"
+ " x_bottom_cut_right = trap_right_x \n"
+ " + (source_texture.y + y_per_pix/2.0 - trap_right_y) \n"
+ " / trap_right_slope; \n"
+ " } \n"
+ " \n"
+ " if((x_up_cut_left <= source_texture.x - x_per_pix/2.0) && \n"
+ " (x_bottom_cut_left <= source_texture.x - x_per_pix/2.0) && \n"
+ " (x_up_cut_right >= source_texture.x + x_per_pix/2.0) && \n"
+ " (x_bottom_cut_right >= source_texture.x + x_per_pix/2.0) && \n"
+ " (trap_top <= source_texture.y - y_per_pix/2.0) && \n"
+ " (trap_bottom >= source_texture.y + y_per_pix/2.0)) { \n"
+ // The complete inside case.
+ " return 1.0; \n"
+ " } else if((trap_top > source_texture.y + y_per_pix/2.0) || \n"
+ " (trap_bottom < source_texture.y - y_per_pix/2.0)) { \n"
+ // The complete outside. Above the top or Below the bottom.
+ " return 0.0; \n"
+ " } else { \n"
+ " if((x_up_cut_right < source_texture.x - x_per_pix/2.0 && \n"
+ " x_bottom_cut_right < source_texture.x - x_per_pix/2.0) \n"
+ " || (x_up_cut_left > source_texture.x + x_per_pix/2.0 && \n"
+ " x_bottom_cut_left > source_texture.x + x_per_pix/2.0)) { \n"
+ // The complete outside. At Left or Right of the trapezoide.
+ " return 0.0; \n"
+ " } \n"
+ " } \n"
+ // Get here, the pix is partly inside the trapezoid.
+ " { \n"
+ " float percent = 0.0; \n"
+ " float up = (source_texture.y - y_per_pix/2.0) >= trap_top ? \n"
+ " (source_texture.y - y_per_pix/2.0) : trap_top; \n"
+ " float bottom = (source_texture.y + y_per_pix/2.0) <= trap_bottom ? \n"
+ " (source_texture.y + y_per_pix/2.0) : trap_bottom; \n"
+ " float left = source_texture.x - x_per_pix/2.0; \n"
+ " float right = source_texture.x + x_per_pix/2.0; \n"
+ " \n"
+ " percent = (bottom - up) / y_per_pix; \n"
+ " \n"
+ " if(trap_left_vertical == true) { \n"
+ " if(trap_left_x > source_texture.x - x_per_pix/2.0 && \n"
+ " trap_left_x < source_texture.x + x_per_pix/2.0) \n"
+ " left = trap_left_x; \n"
+ " } \n"
+ " if(trap_right_vertical == true) { \n"
+ " if(trap_right_x > source_texture.x - x_per_pix/2.0 && \n"
+ " trap_right_x < source_texture.x + x_per_pix/2.0) \n"
+ " right = trap_right_x; \n"
+ " } \n"
+ " if((up >= bottom) || (left >= right)) \n"
+ " return 0.0; \n"
+ " \n"
+ " percent = percent * ((right - left)/x_per_pix); \n"
+ " if(trap_left_vertical == true && trap_right_vertical == true) \n"
+ " return percent; \n"
+ " \n"
+ " if(trap_left_vertical != true) { \n"
+ " float area; \n"
+ // the slope should never be 0.0 here
+ " float up_x = trap_left_x + (up - trap_left_y)/trap_left_slope; \n"
+ " float bottom_x = trap_left_x + (bottom - trap_left_y)/trap_left_slope; \n"
+ " if(trap_left_slope < 0.0 && up_x > left) { \n"
+ /* case 1
+ |
+ ----+------------------------------------->
+ | /
+ | /
+ | +---/--------+
+ | | /.........|
+ | | /..........|
+ | |/...........|
+ | /............|
+ | /|............|
+ | +------------+
+ |
+ \|/
+ */
+ " float left_y = trap_left_y + trap_left_slope*(left - trap_left_x); \n"
+ " if((up_x > left) && (left_y > up)) { \n"
+ " area = 0.5 * (up_x - left) * (left_y - up); \n"
+ " if(up_x > right) { \n"
+ " float right_y = trap_left_y \n"
+ " + trap_left_slope*(right - trap_left_x); \n"
+ " area = area - 0.5 * (up_x - right) * (right_y - up); \n"
+ " } \n"
+ " if(left_y > bottom) { \n"
+ " area = area - 0.5 * (bottom_x - left) * (left_y - bottom); \n"
+ " } \n"
+ " } else { \n"
+ " area = 0.0; \n"
+ " } \n"
+ " percent = percent * (1.0 - (area/((right-left)*(bottom-up)))); \n"
+ " } else if(trap_left_slope > 0.0 && bottom_x > left) { \n"
+ /* case 2
+ |
+ ----+------------------------------------->
+ | \
+ | \
+ | +\-----------+
+ | | \..........|
+ | | \.........|
+ | | \........|
+ | | \.......|
+ | | \......|
+ | +------\-----+
+ | \
+ | \
+ \|/
+ */
+ " float right_y = trap_left_y + trap_left_slope*(right - trap_left_x); \n"
+ " if((up_x < right) && (right_y > up)) { \n"
+ " area = 0.5 * (right - up_x) * (right_y - up); \n"
+ " if(up_x < left) { \n"
+ " float left_y = trap_left_y \n"
+ " + trap_left_slope*(left - trap_left_x); \n"
+ " area = area - 0.5 * (left - up_x) * (left_y - up); \n"
+ " } \n"
+ " if(right_y > bottom) { \n"
+ " area = area - 0.5 * (right - bottom_x) * (right_y - bottom); \n"
+ " } \n"
+ " } else { \n"
+ " area = 0.0; \n"
+ " } \n"
+ " percent = percent * (area/((right-left)*(bottom-up))); \n"
+ " } \n"
+ " } \n"
+ " \n"
+ " if(trap_right_vertical != true) { \n"
+ " float area; \n"
+ // the slope should never be 0.0 here
+ " float up_x = trap_right_x + (up - trap_right_y)/trap_right_slope; \n"
+ " float bottom_x = trap_right_x + (bottom - trap_right_y)/trap_right_slope; \n"
+ " if(trap_right_slope < 0.0 && bottom_x < right) { \n"
+ /* case 3
+ |
+ ----+------------------------------------->
+ | /
+ | +--------/---+
+ | |......./ |
+ | |....../ |
+ | |...../ |
+ | |..../ |
+ | |.../ |
+ | +--/---------+
+ | /
+ |
+ \|/
+ */
+ " float left_y = trap_right_y + trap_right_slope*(left - trap_right_x); \n"
+ " if((up_x > left) && (left_y > up)) { \n"
+ " area = 0.5 * (up_x - left) * (left_y - up); \n"
+ " if(up_x > right) { \n"
+ " float right_y = trap_right_y \n"
+ " + trap_right_slope*(right - trap_right_x); \n"
+ " area = area - 0.5 * (up_x - right) * (right_y - up); \n"
+ " } \n"
+ " if(left_y > bottom) { \n"
+ " area = area - 0.5 * (bottom_x - left) * (left_y - bottom); \n"
+ " } \n"
+ " } else { \n"
+ " area = 0.0; \n"
+ " } \n"
+ " percent = percent * (area/((right-left)*(bottom-up))); \n"
+ " } else if(trap_right_slope > 0.0 && up_x < right) { \n"
+ /* case 4
+ |
+ ----+------------------------------------->
+ | \
+ | +--------\---+
+ | |.........\ |
+ | |..........\ |
+ | |...........\|
+ | |............\
+ | |............|\
+ | +------------+ \
+ | \
+ |
+ \|/
+ */
+ " float right_y = trap_right_y + trap_right_slope*(right - trap_right_x); \n"
+ " if((up_x < right) && (right_y > up)) { \n"
+ " area = 0.5 * (right - up_x) * (right_y - up); \n"
+ " if(up_x < left) { \n"
+ " float left_y = trap_right_y \n"
+ " + trap_right_slope*(left - trap_right_x); \n"
+ " area = area - 0.5 * (left - up_x) * (left_y - up); \n"
+ " } \n"
+ " if(right_y > bottom) { \n"
+ " area = area - 0.5 * (right - bottom_x) * (right_y - bottom); \n"
+ " } \n"
+ " } else { \n"
+ " area = 0.0; \n"
+ " } \n"
+ " percent = percent * (1.0 - (area/((right-left)*(bottom-up)))); \n"
+ " } \n"
+ " } \n"
+ " \n"
+ " return percent; \n"
+ " } \n"
+ "} \n"
+ "\n"
+ "void main() \n"
+ "{ \n"
+ " float alpha_val = get_alpha_val(); \n"
+ " gl_FragColor = vec4(0.0, 0.0, 0.0, alpha_val); \n"
+ "}\n";
+
+ glamor_priv = glamor_get_screen_private(screen);
+ dispatch = glamor_get_dispatch(glamor_priv);
+
+ glamor_priv->trapezoid_prog = dispatch->glCreateProgram();
+
+ vs_prog = glamor_compile_glsl_prog(dispatch,
+ GL_VERTEX_SHADER, trapezoid_vs);
+ fs_prog = glamor_compile_glsl_prog(dispatch,
+ GL_FRAGMENT_SHADER, trapezoid_fs);
+
+ dispatch->glAttachShader(glamor_priv->trapezoid_prog, vs_prog);
+ dispatch->glAttachShader(glamor_priv->trapezoid_prog, fs_prog);
+
+ dispatch->glBindAttribLocation(glamor_priv->trapezoid_prog,
+ GLAMOR_VERTEX_POS, "v_positionsition");
+ dispatch->glBindAttribLocation(glamor_priv->trapezoid_prog,
+ GLAMOR_VERTEX_SOURCE, "v_texcoord");
+ dispatch->glBindAttribLocation(glamor_priv->trapezoid_prog,
+ GLAMOR_VERTEX_TOP_BOTTOM, "v_top_bottom");
+ dispatch->glBindAttribLocation(glamor_priv->trapezoid_prog,
+ GLAMOR_VERTEX_LEFT_PARAM, "v_left_param");
+ dispatch->glBindAttribLocation(glamor_priv->trapezoid_prog,
+ GLAMOR_VERTEX_RIGHT_PARAM, "v_right_param");
+
+ glamor_link_glsl_prog(dispatch, glamor_priv->trapezoid_prog);
+
+ dispatch->glUseProgram(0);
+
+ glamor_put_dispatch(glamor_priv);
+}
+
+void
+glamor_fini_trapezoid_shader(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv;
+ glamor_gl_dispatch *dispatch;
+
+ glamor_priv = glamor_get_screen_private(screen);
+ dispatch = glamor_get_dispatch(glamor_priv);
+ dispatch->glDeleteProgram(glamor_priv->trapezoid_prog);
+ glamor_put_dispatch(glamor_priv);
+}
+
+static Bool
+_glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
+ xTrapezoid * traps, int ntrap, BoxRec *bounds)
+{
+ glamor_screen_private *glamor_priv;
+ glamor_gl_dispatch *dispatch;
+ glamor_pixmap_private *pixmap_priv;
+ PixmapPtr pixmap = NULL;
+ GLint trapezoid_prog;
+ GLfloat xscale, yscale;
+ float left_slope, right_slope;
+ xTrapezoid *ptrap;
+ BoxRec one_trap_bound;
+ int nrect_max;
+ int i, j;
+ float *vertices;
+ float params[4];
+
+ glamor_priv = glamor_get_screen_private(screen);
+ trapezoid_prog = glamor_priv->trapezoid_prog;
+
+ pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)
+ || pixmap_priv->type == GLAMOR_TEXTURE_LARGE) { /* should always have here. */
+ DEBUGF("GLAMOR_PIXMAP_PRIV_HAS_FBO check failed, fallback\n");
+ return FALSE;
+ }
+
+ /* First, clear all to zero */
+ if (!glamor_solid(pixmap, 0, 0, pixmap_priv->base.pixmap->drawable.width,
+ pixmap_priv->base.pixmap->drawable.height,
+ GXclear, 0xFFFFFFFF, 0)) {
+ DEBUGF("glamor_solid failed, fallback\n");
+ return FALSE;
+ }
+
+ dispatch = glamor_get_dispatch(glamor_priv);
+
+ glamor_set_destination_pixmap_priv_nc(pixmap_priv);
+
+ pixmap_priv_get_dest_scale(pixmap_priv, (&xscale), (&yscale));
+
+ dispatch->glBindBuffer(GL_ARRAY_BUFFER, 0);
+ dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+
+ /* Now draw the Trapezoid mask. */
+ dispatch->glUseProgram(trapezoid_prog);
+
+ dispatch->glEnable(GL_BLEND);
+ dispatch->glBlendFunc(GL_ONE, GL_ONE);
+
+ nrect_max = GLAMOR_COMPOSITE_VBO_VERT_CNT / (4 * GLAMOR_VERTEX_RIGHT_PARAM);
+
+ for (i = 0; i < ntrap;) {
+ int mrect;
+ int stride;
+
+ mrect = (ntrap - i) > nrect_max ? nrect_max : (ntrap - i);
+ glamor_setup_composite_vbo_for_trapezoid(screen, 4 * mrect);
+ stride = glamor_priv->vb_stride / sizeof(float);
+
+ for (j = 0; j < mrect; j++) {
+ ptrap = traps + i + j;
+
+ DEBUGF("--- The parameter of xTrapezoid is:\ntop: %d 0x%x\tbottom: %d 0x%x\n"
+ "left: p1 (%d 0x%x, %d 0x%x)\tp2 (%d 0x%x, %d 0x%x)\n"
+ "right: p1 (%d 0x%x, %d 0x%x)\tp2 (%d 0x%x, %d 0x%x)\n",
+ xFixedToInt(ptrap->top), ptrap->top,
+ xFixedToInt(ptrap->bottom), ptrap->bottom,
+ xFixedToInt(ptrap->left.p1.x), ptrap->left.p1.x,
+ xFixedToInt(ptrap->left.p1.y), ptrap->left.p1.y,
+ xFixedToInt(ptrap->left.p2.x), ptrap->left.p2.x,
+ xFixedToInt(ptrap->left.p2.y), ptrap->left.p2.y,
+ xFixedToInt(ptrap->right.p1.x), ptrap->right.p1.x,
+ xFixedToInt(ptrap->right.p1.y), ptrap->right.p1.y,
+ xFixedToInt(ptrap->right.p2.x), ptrap->right.p2.x,
+ xFixedToInt(ptrap->right.p2.y), ptrap->right.p2.y);
+
+ miTrapezoidBounds(1, ptrap, &one_trap_bound);
+
+ vertices = (float*)(glamor_priv->vb + glamor_priv->vbo_offset) + 2;
+ glamor_set_tcoords_ext((pixmap_priv->base.pixmap->drawable.width),
+ (pixmap_priv->base.pixmap->drawable.height),
+ (one_trap_bound.x1),
+ (one_trap_bound.y1),
+ (one_trap_bound.x2),
+ (one_trap_bound.y2),
+ glamor_priv->yInverted, vertices, stride);
+ DEBUGF("tex_vertices --> leftup : %f X %f, rightup: %f X %f,"
+ "rightbottom: %f X %f, leftbottom : %f X %f\n",
+ vertices[0], vertices[1],
+ vertices[1*stride], vertices[1*stride + 1],
+ vertices[2*stride], vertices[2*stride + 1],
+ vertices[3*stride], vertices[3*stride + 1]);
+
+ /* Need to rebase. */
+ one_trap_bound.x1 -= bounds->x1;
+ one_trap_bound.x2 -= bounds->x1;
+ one_trap_bound.y1 -= bounds->y1;
+ one_trap_bound.y2 -= bounds->y1;
+
+ vertices -= 2;
+
+ glamor_set_normalize_vcoords_ext(pixmap_priv, xscale, yscale,
+ one_trap_bound.x1, one_trap_bound.y1,
+ one_trap_bound.x2, one_trap_bound.y2,
+ glamor_priv->yInverted, vertices, stride);
+ DEBUGF("vertices --> leftup : %f X %f, rightup: %f X %f,"
+ "rightbottom: %f X %f, leftbottom : %f X %f\n",
+ vertices[0], vertices[1],
+ vertices[1*stride], vertices[1*stride + 1],
+ vertices[2*stride], vertices[2*stride + 1],
+ vertices[3*stride], vertices[3*stride + 1]);
+ vertices += 4;
+
+ /* Set the top and bottom. */
+ params[0] = ((float)ptrap->top) / 65536;
+ params[1] = ((float)ptrap->bottom) / 65536;
+ glamor_set_const_ext(params, 2, vertices, 4, stride);
+ vertices += 2;
+
+ /* Set the left params. */
+ params[0] = ((float)ptrap->left.p1.x) / 65536;
+ params[1] = ((float)ptrap->left.p1.y) / 65536;
+
+ if (ptrap->left.p1.x == ptrap->left.p2.x) {
+ left_slope = 0.0;
+ params[3] = 1.0;
+ } else {
+ left_slope = ((float)(ptrap->left.p1.y - ptrap->left.p2.y))
+ / ((float)(ptrap->left.p1.x - ptrap->left.p2.x));
+ params[3] = 0.0;
+ }
+ params[2] = left_slope;
+ glamor_set_const_ext(params, 4, vertices, 4, stride);
+ vertices += 4;
+
+ /* Set the left params. */
+ params[0] = ((float)ptrap->right.p1.x) / 65536;
+ params[1] = ((float)ptrap->right.p1.y) / 65536;
+
+ if (ptrap->right.p1.x == ptrap->right.p2.x) {
+ right_slope = 0.0;
+ params[3] = 1.0;
+ } else {
+ right_slope = ((float)(ptrap->right.p1.y - ptrap->right.p2.y))
+ / ((float)(ptrap->right.p1.x - ptrap->right.p2.x));
+ params[3] = 0.0;
+ }
+ params[2] = right_slope;
+ glamor_set_const_ext(params, 4, vertices, 4, stride);
+
+ DEBUGF("trap_top = %f, trap_bottom = %f, "
+ "trap_left_x = %f, trap_left_y = %f, left_slope = %f, "
+ "trap_right_x = %f, trap_right_y = %f, right_slope = %f\n",
+ ((float)ptrap->top) / 65536, ((float)ptrap->bottom) / 65536,
+ ((float)ptrap->left.p1.x) / 65536, ((float)ptrap->left.p1.y) / 65536,
+ left_slope,
+ ((float)ptrap->right.p1.x) / 65536, ((float)ptrap->right.p1.y) / 65536,
+ right_slope);
+
+ glamor_priv->render_nr_verts += 4;
+ glamor_priv->vbo_offset += glamor_priv->vb_stride * 4;
+ }
+
+ i += mrect;
+
+ /* Now rendering. */
+ if (!glamor_priv->render_nr_verts)
+ continue;
+
+ if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP)
+ dispatch->glUnmapBuffer(GL_ARRAY_BUFFER);
+ else {
+ dispatch->glBindBuffer(GL_ARRAY_BUFFER, glamor_priv->vbo);
+ dispatch->glBufferData(GL_ARRAY_BUFFER,
+ glamor_priv->vbo_offset,
+ glamor_priv->vb, GL_DYNAMIC_DRAW);
+ }
+
+#ifndef GLAMOR_GLES2
+ dispatch->glDrawRangeElements(GL_TRIANGLES, 0, glamor_priv->render_nr_verts,
+ (glamor_priv->render_nr_verts * 3) / 2,
+ GL_UNSIGNED_SHORT, NULL);
+#else
+ dispatch->glDrawElements(GL_TRIANGLES, (glamor_priv->render_nr_verts * 3) / 2,
+ GL_UNSIGNED_SHORT, NULL);
+#endif
+ }
+
+ dispatch->glBindBuffer(GL_ARRAY_BUFFER, 0);
+ dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+ dispatch->glBlendFunc(GL_ONE, GL_ZERO);
+ dispatch->glDisable(GL_BLEND);
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_TOP_BOTTOM);
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_LEFT_PARAM);
+ dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_RIGHT_PARAM);
+ dispatch->glUseProgram(0);
+ glamor_put_dispatch(glamor_priv);
+ return TRUE;
+}
+
+#endif /*GLAMOR_TRAPEZOID_SHADER */
+
+/**
+ * Creates an appropriate picture for temp mask use.
+ */
+static PicturePtr
+glamor_create_mask_picture(ScreenPtr screen,
+ PicturePtr dst,
+ PictFormatPtr pict_format,
+ CARD16 width, CARD16 height, int gpu)
+{
+ PixmapPtr pixmap;
+ PicturePtr picture;
+ int error;
+
+ if (!pict_format) {
+ if (dst->polyEdge == PolyEdgeSharp)
+ pict_format =
+ PictureMatchFormat(screen, 1, PICT_a1);
+ else
+ pict_format =
+ PictureMatchFormat(screen, 8, PICT_a8);
+ if (!pict_format)
+ return 0;
+ }
+
+ if (gpu) {
+ pixmap = glamor_create_pixmap(screen, width, height,
+ pict_format->depth, 0);
+ } else {
+ pixmap = glamor_create_pixmap(screen, 0, 0,
+ pict_format->depth,
+ GLAMOR_CREATE_PIXMAP_CPU);
+ }
+
+ if (!pixmap)
+ return 0;
+ picture = CreatePicture(0, &pixmap->drawable, pict_format,
+ 0, 0, serverClient, &error);
+ glamor_destroy_pixmap(pixmap);
+ return picture;
+}
+
+static int
+_glamor_trapezoid_bounds (int ntrap, xTrapezoid *traps, BoxPtr box)
+{
+ int has_large_trapezoid = 0;
+ box->y1 = MAXSHORT;
+ box->y2 = MINSHORT;
+ box->x1 = MAXSHORT;
+ box->x2 = MINSHORT;
+
+ for (; ntrap; ntrap--, traps++) {
+ INT16 x1, y1, x2, y2;
+
+ if (!xTrapezoidValid(traps))
+ continue;
+ y1 = xFixedToInt (traps->top);
+ if (y1 < box->y1)
+ box->y1 = y1;
+
+ y2 = xFixedToInt (xFixedCeil (traps->bottom));
+ if (y2 > box->y2)
+ box->y2 = y2;
+
+ x1 = xFixedToInt (min (_glamor_linefixedX (&traps->left, traps->top, FALSE),
+ _glamor_linefixedX (&traps->left, traps->bottom, FALSE)));
+ if (x1 < box->x1)
+ box->x1 = x1;
+
+ x2 = xFixedToInt (xFixedCeil (max (_glamor_linefixedX (&traps->right, traps->top, TRUE),
+ _glamor_linefixedX (&traps->right, traps->bottom, TRUE))));
+ if (x2 > box->x2)
+ box->x2 = x2;
+
+ if (!has_large_trapezoid && (x2 - x1) > 256 && (y2 - y1) > 32)
+ has_large_trapezoid = 1;
+ }
+
+ return has_large_trapezoid;
+}
+
+/**
+ * glamor_trapezoids will first try to create a trapezoid mask using shader,
+ * if failed, miTrapezoids will generate trapezoid mask accumulating in
+ * system memory.
+ */
+static Bool
+_glamor_trapezoids(CARD8 op,
+ PicturePtr src, PicturePtr dst,
+ PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
+ int ntrap, xTrapezoid * traps, Bool fallback)
+{
+ ScreenPtr screen = dst->pDrawable->pScreen;
+ BoxRec bounds;
+ PicturePtr picture;
+ INT16 x_dst, y_dst;
+ INT16 x_rel, y_rel;
+ int width, height, stride;
+ PixmapPtr pixmap;
+ pixman_image_t *image = NULL;
+ int ret = 0;
+ int has_large_trapezoid;
+
+ /* If a mask format wasn't provided, we get to choose, but behavior should
+ * be as if there was no temporary mask the traps were accumulated into.
+ */
+ if (!mask_format) {
+ if (dst->polyEdge == PolyEdgeSharp)
+ mask_format =
+ PictureMatchFormat(screen, 1, PICT_a1);
+ else
+ mask_format =
+ PictureMatchFormat(screen, 8, PICT_a8);
+ for (; ntrap; ntrap--, traps++)
+ glamor_trapezoids(op, src, dst, mask_format, x_src,
+ y_src, 1, traps);
+ return TRUE;
+ }
+
+ has_large_trapezoid = _glamor_trapezoid_bounds(ntrap, traps, &bounds);
+ DEBUGF("The bounds for all traps is: bounds.x1 = %d, bounds.x2 = %d, "
+ "bounds.y1 = %d, bounds.y2 = %d, ---- ntrap = %d\n", bounds.x1,
+ bounds.x2, bounds.y1, bounds.y2, ntrap);
+
+ if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
+ return TRUE;
+
+ x_dst = traps[0].left.p1.x >> 16;
+ y_dst = traps[0].left.p1.y >> 16;
+
+ width = bounds.x2 - bounds.x1;
+ height = bounds.y2 - bounds.y1;
+ stride = PixmapBytePad(width, mask_format->depth);
+
+#ifdef GLAMOR_TRAPEZOID_SHADER
+ /* We seperate the render to two paths.
+ Some GL implemetation do not implement the Anti-Alias for triangles
+ and polygen's filling. So when the edge is not vertical or horizontal,
+ sawtooth will be obvious. The trapezoid is widely used to render wide
+ lines and circles. In these case, the line or circle will be divided
+ into a large number of small trapezoids to approximate it, so the sawtooth
+ at the edge will cause the result not be acceptable.
+ When the depth of the mask is 1, there is no Anti-Alias needed, so we
+ use the clip logic to generate the result directly(fast path).
+ When the depth is not 1, AA is needed and we use a shader to generate
+ a temp mask pixmap.
+ */
+ if (mask_format->depth == 1) {
+ ret = _glamor_trapezoids_with_shader(op, src, dst, mask_format,
+ x_src, y_src, ntrap, traps);
+ if(ret)
+ return TRUE;
+ } else {
+ if (has_large_trapezoid || ntrap > 256) {
+ /* The shader speed is relative slower than pixman when generating big chunk
+ trapezoid mask. We fallback to pixman to improve the performance. */
+ ;
+ } else if (dst->polyMode == PolyModeImprecise) {
+ /* The precise mode is that we sample the trapezoid on the centre points of
+ an (2*n+1)x(2*n-1) subpixel grid. It is computationally expensive in shader
+ and we use inside area ratio to replace it if the polymode == Imprecise. */
+ picture = glamor_create_mask_picture(screen, dst, mask_format,
+ width, height, 1);
+ if (!picture)
+ return TRUE;
+
+ ret = _glamor_generate_trapezoid_with_shader(screen, picture, traps, ntrap, &bounds);
+
+ if (!ret)
+ FreePicture(picture, 0);
+ }
+ }
+#endif
+
+ if (!ret) {
+ DEBUGF("Fallback to sw rasterize of trapezoid\n");
+
+ picture = glamor_create_mask_picture(screen, dst, mask_format,
+ width, height, 0);
+ if (!picture)
+ return TRUE;
+
+ image = pixman_image_create_bits(picture->format,
+ width, height, NULL, stride);
+ if (!image) {
+ FreePicture(picture, 0);
+ return TRUE;
+ }
+
+ for (; ntrap; ntrap--, traps++)
+ pixman_rasterize_trapezoid(image,
+ (pixman_trapezoid_t *) traps,
+ -bounds.x1, -bounds.y1);
+
+ pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
+
+ screen->ModifyPixmapHeader(pixmap, width, height,
+ mask_format->depth,
+ BitsPerPixel(mask_format->depth),
+ PixmapBytePad(width,
+ mask_format->depth),
+ pixman_image_get_data(image));
+ }
+
+ x_rel = bounds.x1 + x_src - x_dst;
+ y_rel = bounds.y1 + y_src - y_dst;
+ DEBUGF("x_src = %d, y_src = %d, x_dst = %d, y_dst = %d, "
+ "x_rel = %d, y_rel = %d\n", x_src, y_src, x_dst,
+ y_dst, x_rel, y_rel);
+
+ CompositePicture(op, src, picture, dst,
+ x_rel, y_rel,
+ 0, 0,
+ bounds.x1, bounds.y1,
+ bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
+
+ if (image)
+ pixman_image_unref(image);
+
+ FreePicture(picture, 0);
+ return TRUE;
+}
+
+void
+glamor_trapezoids(CARD8 op,
+ PicturePtr src, PicturePtr dst,
+ PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
+ int ntrap, xTrapezoid * traps)
+{
+ DEBUGF("x_src = %d, y_src = %d, ntrap = %d\n", x_src, y_src, ntrap);
+
+ _glamor_trapezoids(op, src, dst, mask_format, x_src,
+ y_src, ntrap, traps, TRUE);
+}
+
+Bool
+glamor_trapezoids_nf(CARD8 op,
+ PicturePtr src, PicturePtr dst,
+ PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
+ int ntrap, xTrapezoid * traps)
+{
+ DEBUGF("x_src = %d, y_src = %d, ntrap = %d\n", x_src, y_src, ntrap);
+
+ return _glamor_trapezoids(op, src, dst, mask_format, x_src,
+ y_src, ntrap, traps, FALSE);
+}
+
+#endif /* RENDER */
+
diff --git a/xorg-server/glamor/glamor_triangles.c b/xorg-server/glamor/glamor_triangles.c
new file mode 100644
index 000000000..e0f4a9708
--- /dev/null
+++ b/xorg-server/glamor/glamor_triangles.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ * Copyright © 1998 Keith Packard
+ *
+ * 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.
+ *
+ * Authors:
+ * Zhigang Gong <zhigang.gong@gmail.com>
+ *
+ */
+
+#include "glamor_priv.h"
+
+static Bool
+_glamor_triangles(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris, Bool fallback)
+{
+ if (!fallback
+ && glamor_ddx_fallback_check_pixmap(pDst->pDrawable)
+ && (!pSrc->pDrawable
+ || glamor_ddx_fallback_check_pixmap(pSrc->pDrawable)))
+ return FALSE;
+
+ if (glamor_prepare_access_picture(pDst, GLAMOR_ACCESS_RW)) {
+ if (glamor_prepare_access_picture(pSrc,
+ GLAMOR_ACCESS_RO)) {
+
+ fbTriangles(op, pSrc, pDst, maskFormat, xSrc,
+ ySrc, ntris, tris);
+
+ glamor_finish_access_picture(pSrc, GLAMOR_ACCESS_RO);
+ }
+
+ glamor_finish_access_picture(pDst, GLAMOR_ACCESS_RW);
+ }
+ return TRUE;
+}
+
+void
+glamor_triangles(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris)
+{
+ _glamor_triangles(op, pSrc, pDst, maskFormat,
+ xSrc, ySrc, ntris, tris, TRUE);
+}
+
+Bool
+glamor_triangles_nf(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ PictFormatPtr maskFormat,
+ INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris)
+{
+ return _glamor_triangles(op, pSrc, pDst, maskFormat,
+ xSrc, ySrc, ntris, tris, FALSE);
+}
+
diff --git a/xorg-server/glamor/glamor_utils.h b/xorg-server/glamor/glamor_utils.h
new file mode 100644
index 000000000..d30783826
--- /dev/null
+++ b/xorg-server/glamor/glamor_utils.h
@@ -0,0 +1,1835 @@
+/*
+ * Copyright © 2009 Intel Corporation
+ *
+ * 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.
+ *
+ * Authors:
+ * Zhigang Gong <zhigang.gong@linux.intel.com>
+ *
+ */
+
+#ifndef GLAMOR_PRIV_H
+#error This file can only be included by glamor_priv.h
+#endif
+
+#ifndef __GLAMOR_UTILS_H__
+#define __GLAMOR_UTILS_H__
+
+#define v_from_x_coord_x(_xscale_, _x_) ( 2 * (_x_) * (_xscale_) - 1.0)
+#define v_from_x_coord_y(_yscale_, _y_) (-2 * (_y_) * (_yscale_) + 1.0)
+#define v_from_x_coord_y_inverted(_yscale_, _y_) (2 * (_y_) * (_yscale_) - 1.0)
+#define t_from_x_coord_x(_xscale_, _x_) ((_x_) * (_xscale_))
+#define t_from_x_coord_y(_yscale_, _y_) (1.0 - (_y_) * (_yscale_))
+#define t_from_x_coord_y_inverted(_yscale_, _y_) ((_y_) * (_yscale_))
+
+#define pixmap_priv_get_dest_scale(_pixmap_priv_, _pxscale_, _pyscale_) \
+ do { \
+ int _w_,_h_; \
+ PIXMAP_PRIV_GET_ACTUAL_SIZE(_pixmap_priv_, _w_, _h_); \
+ *(_pxscale_) = 1.0 / _w_; \
+ *(_pyscale_) = 1.0 / _h_; \
+ } while(0)
+
+#define pixmap_priv_get_scale(_pixmap_priv_, _pxscale_, _pyscale_) \
+ do { \
+ *(_pxscale_) = 1.0 / (_pixmap_priv_)->base.fbo->width; \
+ *(_pyscale_) = 1.0 / (_pixmap_priv_)->base.fbo->height; \
+ } while(0)
+
+#define GLAMOR_PIXMAP_FBO_NOT_EAXCT_SIZE(priv) \
+ (priv->base.fbo->width != priv->base.pixmap->drawable.width \
+ || priv->base.fbo->height != priv->base.pixmap->drawable.height) \
+
+#define PIXMAP_PRIV_GET_ACTUAL_SIZE(priv, w, h) \
+ do { \
+ if (unlikely(priv->type == GLAMOR_TEXTURE_LARGE)) { \
+ w = priv->large.box.x2 - priv->large.box.x1; \
+ h = priv->large.box.y2 - priv->large.box.y1; \
+ } else { \
+ w = priv->base.pixmap->drawable.width; \
+ h = priv->base.pixmap->drawable.height; \
+ } \
+ } while(0)
+
+#define glamor_pixmap_fbo_fix_wh_ratio(wh, priv) \
+ do { \
+ int actual_w, actual_h; \
+ PIXMAP_PRIV_GET_ACTUAL_SIZE(priv, actual_w, actual_h); \
+ wh[0] = (float)priv->base.fbo->width / actual_w; \
+ wh[1] = (float)priv->base.fbo->height / actual_h; \
+ wh[2] = 1.0 / priv->base.fbo->width; \
+ wh[3] = 1.0 / priv->base.fbo->height; \
+ } while(0)
+
+#define pixmap_priv_get_fbo_off(_priv_, _xoff_, _yoff_) \
+ do { \
+ if (unlikely(_priv_ && (_priv_)->type == GLAMOR_TEXTURE_LARGE)) { \
+ *(_xoff_) = - (_priv_)->large.box.x1; \
+ *(_yoff_) = - (_priv_)->large.box.y1; \
+ } else { \
+ *(_xoff_) = 0; \
+ *(_yoff_) = 0; \
+ } \
+ } while(0)
+
+#define xFixedToFloat(_val_) ((float)xFixedToInt(_val_) \
+ + ((float)xFixedFrac(_val_) / 65536.0))
+
+#define glamor_picture_get_matrixf(_picture_, _matrix_) \
+ do { \
+ int _i_; \
+ if ((_picture_)->transform) \
+ { \
+ for(_i_ = 0; _i_ < 3; _i_++) \
+ { \
+ (_matrix_)[_i_ * 3 + 0] = \
+ xFixedToFloat((_picture_)->transform->matrix[_i_][0]); \
+ (_matrix_)[_i_ * 3 + 1] = \
+ xFixedToFloat((_picture_)->transform->matrix[_i_][1]); \
+ (_matrix_)[_i_ * 3 + 2] = \
+ xFixedToFloat((_picture_)->transform->matrix[_i_][2]); \
+ } \
+ } \
+ } while(0)
+
+#define fmod(x, w) (x - w * floor((float)x/w))
+
+#define fmodulus(x, w, c) do {c = fmod(x, w); \
+ c = c >= 0 ? c : c + w;} \
+ while(0)
+/* @x: is current coord
+ * @x2: is the right/bottom edge
+ * @w: is current width or height
+ * @odd: is output value, 0 means we are in an even region, 1 means we are in a
+ * odd region.
+ * @c: is output value, equal to x mod w. */
+#define fodd_repeat_mod(x, x2, w, odd, c) \
+ do { \
+ float shift; \
+ fmodulus((x), w, c); \
+ shift = fabs((x) - (c)); \
+ shift = floor(fabs(round(shift)) / w); \
+ odd = (int)shift & 1; \
+ if (odd && (((x2 % w) == 0) && \
+ round(fabs(x)) == x2)) \
+ odd = 0; \
+ } while(0)
+
+/* @txy: output value, is the corrected coords.
+ * @xy: input coords to be fixed up.
+ * @cd: xy mod wh, is a input value.
+ * @wh: current width or height.
+ * @bxy1,bxy2: current box edge's x1/x2 or y1/y2
+ *
+ * case 1:
+ * ----------
+ * | * |
+ * | |
+ * ----------
+ * tx = (c - x1) mod w
+ *
+ * case 2:
+ * ---------
+ * * | |
+ * | |
+ * ---------
+ * tx = - (c - (x1 mod w))
+ *
+ * case 3:
+ *
+ * ----------
+ * | | *
+ * | |
+ * ----------
+ * tx = ((x2 mod x) - c) + (x2 - x1)
+ **/
+#define __glamor_repeat_reflect_fixup(txy, xy, \
+ cd, wh, bxy1, bxy2) \
+ do { \
+ cd = wh - cd; \
+ if ( xy >= bxy1 && xy < bxy2) { \
+ cd = cd - bxy1; \
+ fmodulus(cd, wh, txy); \
+ } else if (xy < bxy1) { \
+ float bxy1_mod; \
+ fmodulus(bxy1, wh, bxy1_mod); \
+ txy = -(cd - bxy1_mod); \
+ } \
+ else if (xy >= bxy2) { \
+ float bxy2_mod; \
+ fmodulus(bxy2, wh, bxy2_mod); \
+ if (bxy2_mod == 0) \
+ bxy2_mod = wh; \
+ txy = (bxy2_mod - cd) + bxy2 - bxy1; \
+ } else {assert(0); txy = 0;} \
+ } while(0)
+
+#define _glamor_repeat_reflect_fixup(txy, xy, cd, odd, \
+ wh, bxy1, bxy2) \
+ do { \
+ if (odd) { \
+ __glamor_repeat_reflect_fixup(txy, xy, \
+ cd, wh, bxy1, bxy2); \
+ } else \
+ txy = xy - bxy1; \
+ } while(0)
+
+#define _glamor_get_reflect_transform_coords(priv, repeat_type, \
+ tx1, ty1, \
+ _x1_, _y1_) \
+ do { \
+ int odd_x, odd_y; \
+ float c, d; \
+ fodd_repeat_mod(_x1_,priv->box.x2, \
+ priv->base.pixmap->drawable.width, \
+ odd_x, c); \
+ fodd_repeat_mod(_y1_, priv->box.y2, \
+ priv->base.pixmap->drawable.height, \
+ odd_y, d); \
+ DEBUGF("c %f d %f oddx %d oddy %d \n", \
+ c, d, odd_x, odd_y); \
+ DEBUGF("x2 %d x1 %d fbo->width %d \n", priv->box.x2, \
+ priv->box.x1, priv->base.fbo->width); \
+ DEBUGF("y2 %d y1 %d fbo->height %d \n", priv->box.y2, \
+ priv->box.y1, priv->base.fbo->height); \
+ _glamor_repeat_reflect_fixup(tx1, _x1_, c, odd_x, \
+ priv->base.pixmap->drawable.width, \
+ priv->box.x1, priv->box.x2); \
+ _glamor_repeat_reflect_fixup(ty1, _y1_, d, odd_y, \
+ priv->base.pixmap->drawable.height, \
+ priv->box.y1, priv->box.y2); \
+ } while(0)
+
+#define _glamor_get_repeat_coords(priv, repeat_type, tx1, \
+ ty1, tx2, ty2, \
+ _x1_, _y1_, _x2_, \
+ _y2_, c, d, odd_x, odd_y) \
+ do { \
+ if (repeat_type == RepeatReflect) { \
+ DEBUGF("x1 y1 %d %d\n", \
+ _x1_, _y1_ ); \
+ DEBUGF("width %d box.x1 %d \n", \
+ (priv)->base.pixmap->drawable.width, \
+ priv->box.x1); \
+ if (odd_x) { \
+ c = (priv)->base.pixmap->drawable.width \
+ - c; \
+ tx1 = c - priv->box.x1; \
+ tx2 = tx1 - ((_x2_) - (_x1_)); \
+ } else { \
+ tx1 = c - priv->box.x1; \
+ tx2 = tx1 + ((_x2_) - (_x1_)); \
+ } \
+ if (odd_y){ \
+ d = (priv)->base.pixmap->drawable.height\
+ - d; \
+ ty1 = d - priv->box.y1; \
+ ty2 = ty1 - ((_y2_) - (_y1_)); \
+ } else { \
+ ty1 = d - priv->box.y1; \
+ ty2 = ty1 + ((_y2_) - (_y1_)); \
+ } \
+ } else { /* RepeatNormal*/ \
+ tx1 = (c - priv->box.x1); \
+ ty1 = (d - priv->box.y1); \
+ tx2 = tx1 + ((_x2_) - (_x1_)); \
+ ty2 = ty1 + ((_y2_) - (_y1_)); \
+ } \
+ } while(0)
+
+
+/* _x1_ ... _y2_ may has fractional. */
+#define glamor_get_repeat_transform_coords(priv, repeat_type, tx1, \
+ ty1, _x1_, _y1_) \
+ do { \
+ DEBUGF("width %d box.x1 %d x2 %d y1 %d y2 %d\n", \
+ (priv)->base.pixmap->drawable.width, \
+ priv->box.x1, priv->box.x2, priv->box.y1, \
+ priv->box.y2); \
+ DEBUGF("x1 %f y1 %f \n", _x1_, _y1_); \
+ if (repeat_type != RepeatReflect) { \
+ tx1 = _x1_ - priv->box.x1; \
+ ty1 = _y1_ - priv->box.y1; \
+ } else \
+ _glamor_get_reflect_transform_coords(priv, repeat_type, \
+ tx1, ty1, \
+ _x1_, _y1_); \
+ DEBUGF("tx1 %f ty1 %f \n", tx1, ty1); \
+ } while(0)
+
+/* _x1_ ... _y2_ must be integer. */
+#define glamor_get_repeat_coords(priv, repeat_type, tx1, \
+ ty1, tx2, ty2, _x1_, _y1_, _x2_, \
+ _y2_) \
+ do { \
+ int c, d; \
+ int odd_x = 0, odd_y = 0; \
+ DEBUGF("width %d box.x1 %d x2 %d y1 %d y2 %d\n", \
+ (priv)->base.pixmap->drawable.width, \
+ priv->box.x1, priv->box.x2, \
+ priv->box.y1, priv->box.y2); \
+ modulus((_x1_), (priv)->base.pixmap->drawable.width, c); \
+ modulus((_y1_), (priv)->base.pixmap->drawable.height, d); \
+ DEBUGF("c %d d %d \n", c, d); \
+ if (repeat_type == RepeatReflect) { \
+ odd_x = abs((_x1_ - c) \
+ / (priv->base.pixmap->drawable.width)) & 1; \
+ odd_y = abs((_y1_ - d) \
+ / (priv->base.pixmap->drawable.height)) & 1; \
+ } \
+ _glamor_get_repeat_coords(priv, repeat_type, tx1, ty1, tx2, ty2,\
+ _x1_, _y1_, _x2_, _y2_, c, d, \
+ odd_x, odd_y); \
+ } while(0)
+
+#define glamor_transform_point(matrix, tx, ty, x, y) \
+ do { \
+ int _i_; \
+ float _result_[4]; \
+ for (_i_ = 0; _i_ < 3; _i_++) { \
+ _result_[_i_] = (matrix)[_i_ * 3] * (x) + (matrix)[_i_ * 3 + 1] * (y) \
+ + (matrix)[_i_ * 3 + 2]; \
+ } \
+ tx = _result_[0] / _result_[2]; \
+ ty = _result_[1] / _result_[2]; \
+ } while(0)
+
+#define _glamor_set_normalize_tpoint(xscale, yscale, _tx_, _ty_, \
+ texcoord, yInverted) \
+ do { \
+ (texcoord)[0] = t_from_x_coord_x(xscale, _tx_); \
+ if (likely(yInverted)) \
+ (texcoord)[1] = t_from_x_coord_y_inverted(yscale, _ty_);\
+ else \
+ (texcoord)[1] = t_from_x_coord_y(yscale, _ty_); \
+ DEBUGF("normalized point tx %f ty %f \n", (texcoord)[0], \
+ (texcoord)[1]); \
+ } while(0)
+
+#define glamor_set_transformed_point(priv, matrix, xscale, \
+ yscale, texcoord, \
+ x, y, \
+ yInverted) \
+ do { \
+ float tx, ty; \
+ int fbo_x_off, fbo_y_off; \
+ pixmap_priv_get_fbo_off(priv, &fbo_x_off, &fbo_y_off); \
+ glamor_transform_point(matrix, tx, ty, x, y); \
+ DEBUGF("tx %f ty %f fbooff %d %d \n", \
+ tx, ty, fbo_x_off, fbo_y_off); \
+ \
+ tx += fbo_x_off; \
+ ty += fbo_y_off; \
+ (texcoord)[0] = t_from_x_coord_x(xscale, tx); \
+ if (likely(yInverted)) \
+ (texcoord)[1] = t_from_x_coord_y_inverted(yscale, ty); \
+ else \
+ (texcoord)[1] = t_from_x_coord_y(yscale, ty); \
+ DEBUGF("normalized tx %f ty %f \n", (texcoord)[0], (texcoord)[1]); \
+ } while(0)
+
+#define glamor_set_transformed_normalize_tri_tcoords(priv, \
+ matrix, \
+ xscale, \
+ yscale, \
+ vtx, \
+ yInverted, \
+ texcoords) \
+ do { \
+ glamor_set_transformed_point(priv, matrix, xscale, yscale, \
+ texcoords, (vtx)[0], (vtx)[1], \
+ yInverted); \
+ glamor_set_transformed_point(priv, matrix, xscale, yscale, \
+ texcoords+2, (vtx)[2], (vtx)[3], \
+ yInverted); \
+ glamor_set_transformed_point(priv, matrix, xscale, yscale, \
+ texcoords+4, (vtx)[4], (vtx)[5], \
+ yInverted); \
+ } while (0)
+
+#define glamor_set_transformed_normalize_tcoords_ext( priv, \
+ matrix, \
+ xscale, \
+ yscale, \
+ tx1, ty1, tx2, ty2, \
+ yInverted, texcoords, \
+ stride) \
+ do { \
+ glamor_set_transformed_point(priv, matrix, xscale, yscale, \
+ texcoords, tx1, ty1, \
+ yInverted); \
+ glamor_set_transformed_point(priv, matrix, xscale, yscale, \
+ texcoords + 1 * stride, tx2, ty1, \
+ yInverted); \
+ glamor_set_transformed_point(priv, matrix, xscale, yscale, \
+ texcoords + 2 * stride, tx2, ty2, \
+ yInverted); \
+ glamor_set_transformed_point(priv, matrix, xscale, yscale, \
+ texcoords + 3 * stride, tx1, ty2, \
+ yInverted); \
+ } while (0)
+
+#define glamor_set_transformed_normalize_tcoords( priv, \
+ matrix, \
+ xscale, \
+ yscale, \
+ tx1, ty1, tx2, ty2, \
+ yInverted, texcoords) \
+ do { \
+ glamor_set_transformed_normalize_tcoords_ext( priv, \
+ matrix, \
+ xscale, \
+ yscale, \
+ tx1, ty1, tx2, ty2, \
+ yInverted, texcoords, \
+ 2); \
+ } while (0)
+
+
+
+#define glamor_set_normalize_tri_tcoords(xscale, \
+ yscale, \
+ vtx, \
+ yInverted, \
+ texcoords) \
+ do { \
+ _glamor_set_normalize_tpoint(xscale, yscale, \
+ (vtx)[0], (vtx)[1], \
+ texcoords, \
+ yInverted); \
+ _glamor_set_normalize_tpoint(xscale, yscale, \
+ (vtx)[2], (vtx)[3], \
+ texcoords+2, \
+ yInverted); \
+ _glamor_set_normalize_tpoint(xscale, yscale, \
+ (vtx)[4], (vtx)[5], \
+ texcoords+4, \
+ yInverted); \
+ } while (0)
+
+#define glamor_set_repeat_transformed_normalize_tcoords_ext( priv, \
+ repeat_type, \
+ matrix, \
+ xscale, \
+ yscale, \
+ _x1_, _y1_, \
+ _x2_, _y2_, \
+ yInverted, \
+ texcoords, \
+ stride) \
+ do { \
+ if (likely(priv->type != GLAMOR_TEXTURE_LARGE)) { \
+ glamor_set_transformed_normalize_tcoords_ext(priv, matrix, xscale, \
+ yscale, _x1_, _y1_, \
+ _x2_, _y2_, yInverted, \
+ texcoords, stride); \
+ } else { \
+ float tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4; \
+ float ttx1, tty1, ttx2, tty2, ttx3, tty3, ttx4, tty4; \
+ DEBUGF("original coords %d %d %d %d\n", _x1_, _y1_, _x2_, _y2_); \
+ glamor_transform_point(matrix, tx1, ty1, _x1_, _y1_); \
+ glamor_transform_point(matrix, tx2, ty2, _x2_, _y1_); \
+ glamor_transform_point(matrix, tx3, ty3, _x2_, _y2_); \
+ glamor_transform_point(matrix, tx4, ty4, _x1_, _y2_); \
+ DEBUGF("transformed %f %f %f %f %f %f %f %f\n", \
+ tx1, ty1, tx2, ty2, tx3, ty3, tx4, ty4); \
+ glamor_get_repeat_transform_coords((&priv->large), repeat_type, \
+ ttx1, tty1, \
+ tx1, ty1); \
+ glamor_get_repeat_transform_coords((&priv->large), repeat_type, \
+ ttx2, tty2, \
+ tx2, ty2); \
+ glamor_get_repeat_transform_coords((&priv->large), repeat_type, \
+ ttx3, tty3, \
+ tx3, ty3); \
+ glamor_get_repeat_transform_coords((&priv->large), repeat_type, \
+ ttx4, tty4, \
+ tx4, ty4); \
+ DEBUGF("repeat transformed %f %f %f %f %f %f %f %f\n", ttx1, tty1, \
+ ttx2, tty2, ttx3, tty3, ttx4, tty4); \
+ _glamor_set_normalize_tpoint(xscale, yscale, ttx1, tty1, \
+ texcoords, yInverted); \
+ _glamor_set_normalize_tpoint(xscale, yscale, ttx2, tty2, \
+ texcoords + 1 * stride, yInverted); \
+ _glamor_set_normalize_tpoint(xscale, yscale, ttx3, tty3, \
+ texcoords + 2 * stride, yInverted); \
+ _glamor_set_normalize_tpoint(xscale, yscale, ttx4, tty4, \
+ texcoords + 3 * stride, yInverted); \
+ } \
+ } while (0)
+
+
+#define glamor_set_repeat_transformed_normalize_tcoords( priv, \
+ repeat_type, \
+ matrix, \
+ xscale, \
+ yscale, \
+ _x1_, _y1_, \
+ _x2_, _y2_, \
+ yInverted, \
+ texcoords) \
+ do { \
+ glamor_set_repeat_transformed_normalize_tcoords_ext( priv, \
+ repeat_type, \
+ matrix, \
+ xscale, \
+ yscale, \
+ _x1_, _y1_, \
+ _x2_, _y2_, \
+ yInverted, \
+ texcoords, \
+ 2); \
+ } while (0)
+
+#define _glamor_set_normalize_tcoords(xscale, yscale, tx1, \
+ ty1, tx2, ty2, \
+ yInverted, vertices, stride) \
+ do { \
+ /* vertices may be write-only, so we use following \
+ * temporary variable. */ \
+ float _t0_, _t1_, _t2_, _t5_; \
+ (vertices)[0] = _t0_ = t_from_x_coord_x(xscale, tx1); \
+ (vertices)[1 * stride] = _t2_ = t_from_x_coord_x(xscale, tx2); \
+ (vertices)[2 * stride] = _t2_; \
+ (vertices)[3 * stride] = _t0_; \
+ if (likely(yInverted)) { \
+ (vertices)[1] = _t1_ = t_from_x_coord_y_inverted(yscale, ty1); \
+ (vertices)[2 * stride + 1] = _t5_ = t_from_x_coord_y_inverted(yscale, ty2);\
+ } \
+ else { \
+ (vertices)[1] = _t1_ = t_from_x_coord_y(yscale, ty1); \
+ (vertices)[2 * stride + 1] = _t5_ = t_from_x_coord_y(yscale, ty2);\
+ } \
+ (vertices)[1 * stride + 1] = _t1_; \
+ (vertices)[3 * stride + 1] = _t5_; \
+ } while(0)
+
+#define glamor_set_normalize_tcoords_ext(priv, xscale, yscale, \
+ x1, y1, x2, y2, \
+ yInverted, vertices, stride) \
+ do { \
+ if (unlikely(priv->type == GLAMOR_TEXTURE_LARGE)) { \
+ float tx1, tx2, ty1, ty2; \
+ int fbo_x_off, fbo_y_off; \
+ pixmap_priv_get_fbo_off(priv, &fbo_x_off, &fbo_y_off); \
+ tx1 = x1 + fbo_x_off; \
+ tx2 = x2 + fbo_x_off; \
+ ty1 = y1 + fbo_y_off; \
+ ty2 = y2 + fbo_y_off; \
+ _glamor_set_normalize_tcoords(xscale, yscale, tx1, ty1, \
+ tx2, ty2, yInverted, vertices, \
+ stride); \
+ } else \
+ _glamor_set_normalize_tcoords(xscale, yscale, x1, y1, \
+ x2, y2, yInverted, vertices, stride);\
+ } while(0)
+
+
+#define glamor_set_normalize_tcoords(priv, xscale, yscale, \
+ x1, y1, x2, y2, \
+ yInverted, vertices) \
+ do { \
+ glamor_set_normalize_tcoords_ext(priv, xscale, yscale, \
+ x1, y1, x2, y2, \
+ yInverted, vertices, 2); \
+ } while(0)
+
+#define glamor_set_repeat_normalize_tcoords_ext(priv, repeat_type, \
+ xscale, yscale, \
+ _x1_, _y1_, _x2_, _y2_, \
+ yInverted, vertices, stride)\
+ do { \
+ if (unlikely(priv->type == GLAMOR_TEXTURE_LARGE)) { \
+ float tx1, tx2, ty1, ty2; \
+ if (repeat_type == RepeatPad) { \
+ tx1 = _x1_ - priv->large.box.x1; \
+ ty1 = _y1_ - priv->large.box.y1; \
+ tx2 = tx1 + ((_x2_) - (_x1_)); \
+ ty2 = ty1 + ((_y2_) - (_y1_)); \
+ } else { \
+ glamor_get_repeat_coords((&priv->large), repeat_type, \
+ tx1, ty1, tx2, ty2, \
+ _x1_, _y1_, _x2_, _y2_); \
+ } \
+ _glamor_set_normalize_tcoords(xscale, yscale, tx1, ty1, \
+ tx2, ty2, yInverted, vertices, \
+ stride); \
+ } else \
+ _glamor_set_normalize_tcoords(xscale, yscale, _x1_, _y1_, \
+ _x2_, _y2_, yInverted, vertices, \
+ stride); \
+ } while(0)
+
+
+#define glamor_set_repeat_normalize_tcoords(priv, repeat_type, \
+ xscale, yscale, \
+ _x1_, _y1_, _x2_, _y2_, \
+ yInverted, vertices) \
+ do { \
+ glamor_set_repeat_normalize_tcoords_ext(priv, repeat_type, \
+ xscale, yscale, \
+ _x1_, _y1_, _x2_, _y2_, \
+ yInverted, vertices, 2); \
+ } while(0)
+
+#define glamor_set_normalize_tcoords_tri_stripe(xscale, yscale, \
+ x1, y1, x2, y2, \
+ yInverted, vertices) \
+ do { \
+ (vertices)[0] = t_from_x_coord_x(xscale, x1); \
+ (vertices)[2] = t_from_x_coord_x(xscale, x2); \
+ (vertices)[6] = (vertices)[2]; \
+ (vertices)[4] = (vertices)[0]; \
+ if (likely(yInverted)) { \
+ (vertices)[1] = t_from_x_coord_y_inverted(yscale, y1); \
+ (vertices)[7] = t_from_x_coord_y_inverted(yscale, y2); \
+ } \
+ else { \
+ (vertices)[1] = t_from_x_coord_y(yscale, y1); \
+ (vertices)[7] = t_from_x_coord_y(yscale, y2); \
+ } \
+ (vertices)[3] = (vertices)[1]; \
+ (vertices)[5] = (vertices)[7]; \
+ } while(0)
+
+#define glamor_set_tcoords(width, height, x1, y1, x2, y2, \
+ yInverted, vertices) \
+ do { \
+ (vertices)[0] = (x1); \
+ (vertices)[2] = (x2); \
+ (vertices)[4] = (vertices)[2]; \
+ (vertices)[6] = (vertices)[0]; \
+ if (likely(yInverted)) { \
+ (vertices)[1] = (y1); \
+ (vertices)[5] = (y2); \
+ } \
+ else { \
+ (vertices)[1] = height - (y2); \
+ (vertices)[5] = height - (y1); \
+ } \
+ (vertices)[3] = (vertices)[1]; \
+ (vertices)[7] = (vertices)[5]; \
+ } while(0)
+
+#define glamor_set_tcoords_ext(width, height, x1, y1, x2, y2, \
+ yInverted, vertices, stride) \
+ do { \
+ (vertices)[0] = (x1); \
+ (vertices)[1*stride] = (x2); \
+ (vertices)[2*stride] = (vertices)[1*stride]; \
+ (vertices)[3*stride] = (vertices)[0]; \
+ if (likely(yInverted)) { \
+ (vertices)[1] = (y1); \
+ (vertices)[2*stride + 1] = (y2); \
+ } \
+ else { \
+ (vertices)[1] = height - (y2); \
+ (vertices)[2*stride + 1] = height - (y1); \
+ } \
+ (vertices)[1*stride + 1] = (vertices)[1]; \
+ (vertices)[3*stride + 1] = (vertices)[2*stride + 1]; \
+ } while(0)
+
+#define glamor_set_normalize_one_vcoord(xscale, yscale, x, y, \
+ yInverted, vertices) \
+ do { \
+ (vertices)[0] = v_from_x_coord_x(xscale, x); \
+ if (likely(yInverted)) { \
+ (vertices)[1] = v_from_x_coord_y_inverted(yscale, y); \
+ } else { \
+ (vertices)[1] = v_from_x_coord_y(yscale, y); \
+ } \
+ } while(0)
+
+#define glamor_set_normalize_tri_vcoords(xscale, yscale, vtx, \
+ yInverted, vertices) \
+ do { \
+ glamor_set_normalize_one_vcoord(xscale, yscale, \
+ (vtx)[0], (vtx)[1], \
+ yInverted, vertices); \
+ glamor_set_normalize_one_vcoord(xscale, yscale, \
+ (vtx)[2], (vtx)[3], \
+ yInverted, vertices+2); \
+ glamor_set_normalize_one_vcoord(xscale, yscale, \
+ (vtx)[4], (vtx)[5], \
+ yInverted, vertices+4); \
+ } while(0)
+
+#define glamor_set_tcoords_tri_strip(width, height, x1, y1, x2, y2, \
+ yInverted, vertices) \
+ do { \
+ (vertices)[0] = (x1); \
+ (vertices)[2] = (x2); \
+ (vertices)[6] = (vertices)[2]; \
+ (vertices)[4] = (vertices)[0]; \
+ if (likely(yInverted)) { \
+ (vertices)[1] = (y1); \
+ (vertices)[7] = (y2); \
+ } \
+ else { \
+ (vertices)[1] = height - (y2); \
+ (vertices)[7] = height - (y1); \
+ } \
+ (vertices)[3] = (vertices)[1]; \
+ (vertices)[5] = (vertices)[7]; \
+ } while(0)
+
+#define glamor_set_normalize_vcoords_ext(priv, xscale, yscale, \
+ x1, y1, x2, y2, \
+ yInverted, vertices, stride) \
+ do { \
+ int fbo_x_off, fbo_y_off; \
+ /* vertices may be write-only, so we use following \
+ * temporary variable. */ \
+ float _t0_, _t1_, _t2_, _t5_; \
+ pixmap_priv_get_fbo_off(priv, &fbo_x_off, &fbo_y_off); \
+ (vertices)[0] = _t0_ = v_from_x_coord_x(xscale, x1 + fbo_x_off); \
+ (vertices)[1 * stride] = _t2_ = v_from_x_coord_x(xscale, \
+ x2 + fbo_x_off); \
+ (vertices)[2 * stride] = _t2_; \
+ (vertices)[3 * stride] = _t0_; \
+ if (likely(yInverted)) { \
+ (vertices)[1] = _t1_ = v_from_x_coord_y_inverted(yscale, \
+ y1 + fbo_y_off); \
+ (vertices)[2 * stride + 1] = _t5_ = \
+ v_from_x_coord_y_inverted(yscale, \
+ y2 + fbo_y_off); \
+ } \
+ else { \
+ (vertices)[1] = _t1_ = v_from_x_coord_y(yscale, y1 + fbo_y_off); \
+ (vertices)[2 * stride + 1] = _t5_ = v_from_x_coord_y(yscale, \
+ y2 + fbo_y_off); \
+ } \
+ (vertices)[1 * stride + 1] = _t1_; \
+ (vertices)[3 * stride + 1] = _t5_; \
+ } while(0)
+
+
+#define glamor_set_normalize_vcoords(priv, xscale, yscale, \
+ x1, y1, x2, y2, \
+ yInverted, vertices) \
+ do { \
+ glamor_set_normalize_vcoords_ext(priv, xscale, yscale, \
+ x1, y1, x2, y2, \
+ yInverted, vertices, 2); \
+ } while(0)
+
+#define glamor_set_const_ext(params, nparam, vertices, nverts, stride) \
+ do { \
+ int _i_ = 0, _j_ = 0; \
+ for(; _i_ < nverts; _i_++) { \
+ for(_j_ = 0; _j_ < nparam; _j_++) { \
+ vertices[stride*_i_ + _j_] = params[_j_]; \
+ } \
+ } \
+ } while(0)
+
+#define glamor_set_normalize_vcoords_tri_strip(xscale, yscale, \
+ x1, y1, x2, y2, \
+ yInverted, vertices) \
+ do { \
+ (vertices)[0] = v_from_x_coord_x(xscale, x1); \
+ (vertices)[2] = v_from_x_coord_x(xscale, x2); \
+ (vertices)[6] = (vertices)[2]; \
+ (vertices)[4] = (vertices)[0]; \
+ if (likely(yInverted)) { \
+ (vertices)[1] = v_from_x_coord_y_inverted(yscale, y1); \
+ (vertices)[7] = v_from_x_coord_y_inverted(yscale, y2); \
+ } \
+ else { \
+ (vertices)[1] = v_from_x_coord_y(yscale, y1); \
+ (vertices)[7] = v_from_x_coord_y(yscale, y2); \
+ } \
+ (vertices)[3] = (vertices)[1]; \
+ (vertices)[5] = (vertices)[7]; \
+ } while(0)
+
+#define glamor_set_normalize_pt(xscale, yscale, x, y, \
+ yInverted, pt) \
+ do { \
+ (pt)[0] = t_from_x_coord_x(xscale, x); \
+ if (likely(yInverted)) { \
+ (pt)[1] = t_from_x_coord_y_inverted(yscale, y); \
+ } else { \
+ (pt)[1] = t_from_x_coord_y(yscale, y); \
+ } \
+ } while(0)
+
+#define glamor_set_circle_centre(width, height, x, y, \
+ yInverted, c) \
+ do { \
+ (c)[0] = (float)x; \
+ if (likely(yInverted)) { \
+ (c)[1] = (float)y; \
+ } else { \
+ (c)[1] = (float)height - (float)y; \
+ } \
+ } while(0)
+
+inline static void
+glamor_calculate_boxes_bound(BoxPtr bound, BoxPtr boxes, int nbox)
+{
+ int x_min, y_min;
+ int x_max, y_max;
+ int i;
+ x_min = y_min = MAXSHORT;
+ x_max = y_max = MINSHORT;
+ for (i = 0; i < nbox; i++) {
+ if (x_min > boxes[i].x1)
+ x_min = boxes[i].x1;
+ if (y_min > boxes[i].y1)
+ y_min = boxes[i].y1;
+
+ if (x_max < boxes[i].x2)
+ x_max = boxes[i].x2;
+ if (y_max < boxes[i].y2)
+ y_max = boxes[i].y2;
+ }
+ bound->x1 = x_min;
+ bound->y1 = y_min;
+ bound->x2 = x_max;
+ bound->y2 = y_max;
+}
+
+inline static void
+glamor_translate_boxes(BoxPtr boxes, int nbox, int dx, int dy)
+{
+ int i;
+ for (i = 0; i < nbox; i++) {
+ boxes[i].x1 += dx;
+ boxes[i].y1 += dy;
+ boxes[i].x2 += dx;
+ boxes[i].y2 += dy;
+ }
+}
+
+static inline Bool
+region_is_empty(pixman_region16_t *region)
+{
+ return region->data && region->data->numRects == 0;
+}
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+#endif
+
+#define ALIGN(i,m) (((i) + (m) - 1) & ~((m) - 1))
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+
+#define glamor_check_fbo_size(_glamor_,_w_, _h_) ((_w_) > 0 && (_h_) > 0 \
+ && (_w_) <= _glamor_->max_fbo_size \
+ && (_h_) <= _glamor_->max_fbo_size)
+
+/* For 1bpp pixmap, we don't store it as texture. */
+#define glamor_check_pixmap_fbo_depth(_depth_) ( \
+ _depth_ == 8 \
+ || _depth_ == 15 \
+ || _depth_ == 16 \
+ || _depth_ == 24 \
+ || _depth_ == 30 \
+ || _depth_ == 32)
+
+#define GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv) (pixmap_priv && pixmap_priv->base.is_picture == 1)
+#define GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv) (pixmap_priv && pixmap_priv->base.gl_fbo == GLAMOR_FBO_NORMAL)
+#define GLAMOR_PIXMAP_PRIV_HAS_FBO_DOWNLOADED(pixmap_priv) (pixmap_priv && (pixmap_priv->base.gl_fbo == GLAMOR_FBO_DOWNLOADED))
+
+/**
+ * Borrow from uxa.
+ */
+static inline CARD32
+format_for_depth(int depth)
+{
+ switch (depth) {
+ case 1:
+ return PICT_a1;
+ case 4:
+ return PICT_a4;
+ case 8:
+ return PICT_a8;
+ case 15:
+ return PICT_x1r5g5b5;
+ case 16:
+ return PICT_r5g6b5;
+ default:
+ case 24:
+ return PICT_x8r8g8b8;
+#if XORG_VERSION_CURRENT >= 10699900
+ case 30:
+ return PICT_x2r10g10b10;
+#endif
+ case 32:
+ return PICT_a8r8g8b8;
+ }
+}
+
+static inline void
+gl_iformat_for_depth(int depth, GLenum * format)
+{
+ switch (depth) {
+#ifndef GLAMOR_GLES2
+ case 1:
+ case 8:
+ *format = GL_ALPHA;
+ break;
+#endif
+ default:
+ *format = GL_RGBA;
+ break;
+ }
+}
+
+static inline CARD32
+format_for_pixmap(PixmapPtr pixmap)
+{
+ glamor_pixmap_private *pixmap_priv;
+ PictFormatShort pict_format;
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv))
+ pict_format = pixmap_priv->base.picture->format;
+ else
+ pict_format = format_for_depth(pixmap->drawable.depth);
+
+ return pict_format;
+}
+
+#define REVERT_NONE 0
+#define REVERT_NORMAL 1
+#define REVERT_DOWNLOADING_A1 2
+#define REVERT_UPLOADING_A1 3
+#define REVERT_DOWNLOADING_2_10_10_10 4
+#define REVERT_UPLOADING_2_10_10_10 5
+#define REVERT_DOWNLOADING_1_5_5_5 7
+#define REVERT_UPLOADING_1_5_5_5 8
+#define REVERT_DOWNLOADING_10_10_10_2 9
+#define REVERT_UPLOADING_10_10_10_2 10
+
+#define SWAP_NONE_DOWNLOADING 0
+#define SWAP_DOWNLOADING 1
+#define SWAP_UPLOADING 2
+#define SWAP_NONE_UPLOADING 3
+
+/*
+ * Map picture's format to the correct gl texture format and type.
+ * no_alpha is used to indicate whehter we need to wire alpha to 1.
+ *
+ * Although opengl support A1/GL_BITMAP, we still don't use it
+ * here, it seems that mesa has bugs when uploading a A1 bitmap.
+ *
+ * Return 0 if find a matched texture type. Otherwise return -1.
+ **/
+#ifndef GLAMOR_GLES2
+static inline int
+glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
+ GLenum * tex_format,
+ GLenum * tex_type,
+ int *no_alpha,
+ int *revert,
+ int *swap_rb,
+ int is_upload)
+
+{
+ *no_alpha = 0;
+ *revert = REVERT_NONE;
+ *swap_rb = is_upload ? SWAP_NONE_UPLOADING : SWAP_NONE_DOWNLOADING;
+ switch (format) {
+ case PICT_a1:
+ *tex_format = GL_ALPHA;
+ *tex_type = GL_UNSIGNED_BYTE;
+ *revert = is_upload ? REVERT_UPLOADING_A1 : REVERT_DOWNLOADING_A1;
+ break;
+ case PICT_b8g8r8x8:
+ *no_alpha = 1;
+ case PICT_b8g8r8a8:
+ *tex_format = GL_BGRA;
+ *tex_type = GL_UNSIGNED_INT_8_8_8_8;
+ break;
+
+ case PICT_x8r8g8b8:
+ *no_alpha = 1;
+ case PICT_a8r8g8b8:
+ *tex_format = GL_BGRA;
+ *tex_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+ break;
+ case PICT_x8b8g8r8:
+ *no_alpha = 1;
+ case PICT_a8b8g8r8:
+ *tex_format = GL_RGBA;
+ *tex_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+ break;
+ case PICT_x2r10g10b10:
+ *no_alpha = 1;
+ case PICT_a2r10g10b10:
+ *tex_format = GL_BGRA;
+ *tex_type = GL_UNSIGNED_INT_2_10_10_10_REV;
+ break;
+ case PICT_x2b10g10r10:
+ *no_alpha = 1;
+ case PICT_a2b10g10r10:
+ *tex_format = GL_RGBA;
+ *tex_type = GL_UNSIGNED_INT_2_10_10_10_REV;
+ break;
+
+ case PICT_r5g6b5:
+ *tex_format = GL_RGB;
+ *tex_type = GL_UNSIGNED_SHORT_5_6_5;
+ break;
+ case PICT_b5g6r5:
+ *tex_format = GL_RGB;
+ *tex_type = GL_UNSIGNED_SHORT_5_6_5_REV;
+ break;
+ case PICT_x1b5g5r5:
+ *no_alpha = 1;
+ case PICT_a1b5g5r5:
+ *tex_format = GL_RGBA;
+ *tex_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
+ break;
+
+ case PICT_x1r5g5b5:
+ *no_alpha = 1;
+ case PICT_a1r5g5b5:
+ *tex_format = GL_BGRA;
+ *tex_type = GL_UNSIGNED_SHORT_1_5_5_5_REV;
+ break;
+ case PICT_a8:
+ *tex_format = GL_ALPHA;
+ *tex_type = GL_UNSIGNED_BYTE;
+ break;
+ case PICT_x4r4g4b4:
+ *no_alpha = 1;
+ case PICT_a4r4g4b4:
+ *tex_format = GL_BGRA;
+ *tex_type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
+ break;
+
+ case PICT_x4b4g4r4:
+ *no_alpha = 1;
+ case PICT_a4b4g4r4:
+ *tex_format = GL_RGBA;
+ *tex_type = GL_UNSIGNED_SHORT_4_4_4_4_REV;
+ break;
+
+ default:
+ LogMessageVerb(X_INFO, 0,
+ "fail to get matched format for %x \n",
+ format);
+ return -1;
+ }
+ return 0;
+}
+
+/* Currently, we use RGBA to represent all formats. */
+inline static int cache_format(GLenum format)
+{
+ switch (format) {
+ case GL_ALPHA:
+ return 1;
+ case GL_RGBA:
+ return 0;
+ default:
+ return -1;
+ }
+}
+
+#else
+#define IS_LITTLE_ENDIAN (IMAGE_BYTE_ORDER == LSBFirst)
+
+static inline int
+glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
+ GLenum * tex_format,
+ GLenum * tex_type,
+ int *no_alpha,
+ int *revert,
+ int *swap_rb,
+ int is_upload)
+{
+ int need_swap_rb = 0;
+
+ *no_alpha = 0;
+ *revert = IS_LITTLE_ENDIAN ? REVERT_NONE : REVERT_NORMAL;
+
+ switch (format) {
+ case PICT_b8g8r8x8:
+ *no_alpha = 1;
+ case PICT_b8g8r8a8:
+ *tex_format = GL_RGBA;
+ *tex_type = GL_UNSIGNED_BYTE;
+ need_swap_rb = 1;
+ *revert = IS_LITTLE_ENDIAN ? REVERT_NORMAL : REVERT_NONE;
+ break;
+
+ case PICT_x8r8g8b8:
+ *no_alpha = 1;
+ case PICT_a8r8g8b8:
+ *tex_format = GL_RGBA;
+ *tex_type = GL_UNSIGNED_BYTE;
+ need_swap_rb = 1;
+ break;
+
+ case PICT_x8b8g8r8:
+ *no_alpha = 1;
+ case PICT_a8b8g8r8:
+ *tex_format = GL_RGBA;
+ *tex_type = GL_UNSIGNED_BYTE;
+ break;
+
+ case PICT_x2r10g10b10:
+ *no_alpha = 1;
+ case PICT_a2r10g10b10:
+ *tex_format = GL_RGBA;
+ /* glReadPixmap doesn't support GL_UNSIGNED_INT_10_10_10_2.
+ * we have to use GL_UNSIGNED_BYTE and do the conversion in
+ * shader latter.*/
+ *tex_type = GL_UNSIGNED_BYTE;
+ if (is_upload == 1) {
+ if (!IS_LITTLE_ENDIAN)
+ *revert = REVERT_UPLOADING_10_10_10_2;
+ else
+ *revert = REVERT_UPLOADING_2_10_10_10;
+ }
+ else {
+ if (!IS_LITTLE_ENDIAN) {
+ *revert = REVERT_DOWNLOADING_10_10_10_2;
+ }
+ else {
+ *revert = REVERT_DOWNLOADING_2_10_10_10;
+ }
+ }
+ need_swap_rb = 1;
+
+ break;
+
+ case PICT_x2b10g10r10:
+ *no_alpha = 1;
+ case PICT_a2b10g10r10:
+ *tex_format = GL_RGBA;
+ *tex_type = GL_UNSIGNED_BYTE;
+ if (is_upload == 1) {
+ if (!IS_LITTLE_ENDIAN)
+ *revert = REVERT_UPLOADING_10_10_10_2;
+ else
+ *revert = REVERT_UPLOADING_2_10_10_10;
+ }
+ else {
+ if (!IS_LITTLE_ENDIAN) {
+ *revert = REVERT_DOWNLOADING_10_10_10_2;
+ }
+ else {
+ *revert = REVERT_DOWNLOADING_2_10_10_10;
+ }
+ }
+ break;
+
+ case PICT_r5g6b5:
+ *tex_format = GL_RGB;
+ *tex_type = GL_UNSIGNED_SHORT_5_6_5;
+ *revert = IS_LITTLE_ENDIAN ? REVERT_NONE : REVERT_NORMAL;
+
+ break;
+
+ case PICT_b5g6r5:
+ *tex_format = GL_RGB;
+ *tex_type = GL_UNSIGNED_SHORT_5_6_5;
+ need_swap_rb = IS_LITTLE_ENDIAN ? 1 : 0;;
+ break;
+
+ case PICT_x1b5g5r5:
+ *no_alpha = 1;
+ case PICT_a1b5g5r5:
+ *tex_format = GL_RGBA;
+ *tex_type = GL_UNSIGNED_SHORT_5_5_5_1;
+ if (IS_LITTLE_ENDIAN) {
+ *revert = is_upload ? REVERT_UPLOADING_1_5_5_5 : REVERT_DOWNLOADING_1_5_5_5;
+ } else
+ *revert = REVERT_NONE;
+ break;
+
+ case PICT_x1r5g5b5:
+ *no_alpha = 1;
+ case PICT_a1r5g5b5:
+ *tex_format = GL_RGBA;
+ *tex_type = GL_UNSIGNED_SHORT_5_5_5_1;
+ if (IS_LITTLE_ENDIAN) {
+ *revert = is_upload ? REVERT_UPLOADING_1_5_5_5 : REVERT_DOWNLOADING_1_5_5_5;
+ } else
+ *revert = REVERT_NONE;
+ need_swap_rb = 1;
+ break;
+
+ case PICT_a1:
+ *tex_format = GL_ALPHA;
+ *tex_type = GL_UNSIGNED_BYTE;
+ *revert = is_upload ? REVERT_UPLOADING_A1 : REVERT_DOWNLOADING_A1;
+ break;
+
+ case PICT_a8:
+ *tex_format = GL_ALPHA;
+ *tex_type = GL_UNSIGNED_BYTE;
+ *revert = REVERT_NONE;
+ break;
+
+ case PICT_x4r4g4b4:
+ *no_alpha = 1;
+ case PICT_a4r4g4b4:
+ *tex_format = GL_RGBA;
+ *tex_type = GL_UNSIGNED_SHORT_4_4_4_4;
+ *revert = IS_LITTLE_ENDIAN ? REVERT_NORMAL : REVERT_NONE;
+ need_swap_rb = 1;
+ break;
+
+ case PICT_x4b4g4r4:
+ *no_alpha = 1;
+ case PICT_a4b4g4r4:
+ *tex_format = GL_RGBA;
+ *tex_type = GL_UNSIGNED_SHORT_4_4_4_4;
+ *revert = IS_LITTLE_ENDIAN ? REVERT_NORMAL : REVERT_NONE;
+ break;
+
+ default:
+ LogMessageVerb(X_INFO, 0,
+ "fail to get matched format for %x \n",
+ format);
+ return -1;
+ }
+
+ if (need_swap_rb)
+ *swap_rb = is_upload ? SWAP_UPLOADING : SWAP_DOWNLOADING;
+ else
+ *swap_rb = is_upload ? SWAP_NONE_UPLOADING : SWAP_NONE_DOWNLOADING;
+ return 0;
+}
+
+inline static int cache_format(GLenum format)
+{
+ switch (format) {
+ case GL_ALPHA:
+ return 2;
+ case GL_RGB:
+ return 1;
+ case GL_RGBA:
+ return 0;
+ default:
+ return -1;
+ }
+}
+
+#endif
+
+
+static inline int
+glamor_get_tex_format_type_from_pixmap(PixmapPtr pixmap,
+ GLenum * format,
+ GLenum * type,
+ int *no_alpha,
+ int *revert,
+ int *swap_rb,
+ int is_upload)
+{
+ glamor_pixmap_private *pixmap_priv;
+ PictFormatShort pict_format;
+
+ pixmap_priv = glamor_get_pixmap_private(pixmap);
+ if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv))
+ pict_format = pixmap_priv->base.picture->format;
+ else
+ pict_format = format_for_depth(pixmap->drawable.depth);
+
+ return glamor_get_tex_format_type_from_pictformat(pict_format,
+ format, type,
+ no_alpha,
+ revert,
+ swap_rb,
+ is_upload);
+}
+
+
+/* borrowed from uxa */
+static inline Bool
+glamor_get_rgba_from_pixel(CARD32 pixel,
+ float *red,
+ float *green,
+ float *blue, float *alpha, CARD32 format)
+{
+ int rbits, bbits, gbits, abits;
+ int rshift, bshift, gshift, ashift;
+
+ rbits = PICT_FORMAT_R(format);
+ gbits = PICT_FORMAT_G(format);
+ bbits = PICT_FORMAT_B(format);
+ abits = PICT_FORMAT_A(format);
+
+ if (PICT_FORMAT_TYPE(format) == PICT_TYPE_A) {
+ rshift = gshift = bshift = ashift = 0;
+ } else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ARGB) {
+ bshift = 0;
+ gshift = bbits;
+ rshift = gshift + gbits;
+ ashift = rshift + rbits;
+ } else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ABGR) {
+ rshift = 0;
+ gshift = rbits;
+ bshift = gshift + gbits;
+ ashift = bshift + bbits;
+#if XORG_VERSION_CURRENT >= 10699900
+ } else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_BGRA) {
+ ashift = 0;
+ rshift = abits;
+ if (abits == 0)
+ rshift = PICT_FORMAT_BPP(format) - (rbits + gbits +
+ bbits);
+ gshift = rshift + rbits;
+ bshift = gshift + gbits;
+#endif
+ } else {
+ return FALSE;
+ }
+#define COLOR_INT_TO_FLOAT(_fc_, _p_, _s_, _bits_) \
+ *_fc_ = (((_p_) >> (_s_)) & (( 1 << (_bits_)) - 1)) \
+ / (float)((1<<(_bits_)) - 1)
+
+ if (rbits)
+ COLOR_INT_TO_FLOAT(red, pixel, rshift, rbits);
+ else
+ *red = 0;
+
+ if (gbits)
+ COLOR_INT_TO_FLOAT(green, pixel, gshift, gbits);
+ else
+ *green = 0;
+
+ if (bbits)
+ COLOR_INT_TO_FLOAT(blue, pixel, bshift, bbits);
+ else
+ *blue = 0;
+
+ if (abits)
+ COLOR_INT_TO_FLOAT(alpha, pixel, ashift, abits);
+ else
+ *alpha = 1;
+
+ return TRUE;
+}
+
+inline static Bool glamor_pict_format_is_compatible(PictFormatShort pict_format, int depth)
+{
+ GLenum iformat;
+
+ gl_iformat_for_depth(depth, &iformat);
+ switch (iformat) {
+ case GL_RGBA:
+ return (pict_format == PICT_a8r8g8b8 || pict_format == PICT_x8r8g8b8);
+ case GL_ALPHA:
+ return (pict_format == PICT_a8);
+ default:
+ return FALSE;
+ }
+}
+
+/* return TRUE if we can access this pixmap at DDX driver. */
+inline static Bool glamor_ddx_fallback_check_pixmap(DrawablePtr drawable)
+{
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
+ return (!pixmap_priv
+ || (pixmap_priv->type == GLAMOR_TEXTURE_DRM
+ || pixmap_priv->type == GLAMOR_MEMORY
+ || pixmap_priv->type == GLAMOR_DRM_ONLY));
+}
+
+inline static Bool glamor_ddx_fallback_check_gc(GCPtr gc)
+{
+ PixmapPtr pixmap;
+ if (!gc)
+ return TRUE;
+ switch (gc->fillStyle) {
+ case FillStippled:
+ case FillOpaqueStippled:
+ pixmap = gc->stipple;
+ break;
+ case FillTiled:
+ pixmap = gc->tile.pixmap;
+ break;
+ default:
+ pixmap = NULL;
+ }
+ return (!pixmap || glamor_ddx_fallback_check_pixmap(&pixmap->drawable));
+}
+inline static Bool glamor_is_large_pixmap(PixmapPtr pixmap)
+{
+ glamor_pixmap_private *priv;
+
+ priv = glamor_get_pixmap_private(pixmap);
+ return (priv->type == GLAMOR_TEXTURE_LARGE);
+}
+
+inline static Bool glamor_is_large_picture(PicturePtr picture)
+{
+ PixmapPtr pixmap;
+
+ if (picture->pDrawable) {
+ pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
+ return glamor_is_large_pixmap(pixmap);
+ }
+ return FALSE;
+}
+
+inline static Bool glamor_tex_format_is_readable(GLenum format)
+{
+ return ((format == GL_RGBA || format == GL_RGB || format == GL_ALPHA));
+
+}
+
+static inline void _glamor_dump_pixmap_bits(PixmapPtr pixmap, int x, int y, int w, int h)
+{
+ int i,j;
+ unsigned char * p = pixmap->devPrivate.ptr;
+ int stride = pixmap->devKind;
+
+ p = p + y * stride + x;
+
+ for (i = 0; i < h; i++)
+ {
+ ErrorF("line %3d: ", i);
+ for(j = 0; j < w; j++)
+ ErrorF("%2d ", (p[j/8] & (1 << (j%8)))>>(j%8));
+ p += stride;
+ ErrorF("\n");
+ }
+}
+
+static inline void _glamor_dump_pixmap_byte(PixmapPtr pixmap, int x, int y, int w, int h)
+{
+ int i,j;
+ unsigned char * p = pixmap->devPrivate.ptr;
+ int stride = pixmap->devKind;
+
+ p = p + y * stride + x;
+
+ for (i = 0; i < h; i++)
+ {
+ ErrorF("line %3d: ", i);
+ for(j = 0; j < w; j++)
+ ErrorF("%2x ", p[j]);
+ p += stride;
+ ErrorF("\n");
+ }
+}
+
+static inline void _glamor_dump_pixmap_sword(PixmapPtr pixmap, int x, int y, int w, int h)
+{
+ int i,j;
+ unsigned short * p = pixmap->devPrivate.ptr;
+ int stride = pixmap->devKind / 2;
+
+ p = p + y * stride + x;
+
+ for (i = 0; i < h; i++)
+ {
+ ErrorF("line %3d: ", i);
+ for(j = 0; j < w; j++)
+ ErrorF("%2x ", p[j]);
+ p += stride;
+ ErrorF("\n");
+ }
+}
+
+static inline void _glamor_dump_pixmap_word(PixmapPtr pixmap, int x, int y, int w, int h)
+{
+ int i,j;
+ unsigned int * p = pixmap->devPrivate.ptr;
+ int stride = pixmap->devKind / 4;
+
+ p = p + y * stride + x;
+
+ for (i = 0; i < h; i++)
+ {
+ ErrorF("line %3d: ", i);
+ for(j = 0; j < w; j++)
+ ErrorF("%2x ", p[j]);
+ p += stride;
+ ErrorF("\n");
+ }
+}
+
+static inline void glamor_dump_pixmap(PixmapPtr pixmap, int x, int y, int w, int h)
+{
+ w = ((x + w) > pixmap->drawable.width) ? (pixmap->drawable.width - x) : w;
+ h = ((y + h) > pixmap->drawable.height) ? (pixmap->drawable.height - y) : h;
+
+ glamor_prepare_access(&pixmap->drawable, GLAMOR_ACCESS_RO);
+ switch (pixmap->drawable.depth) {
+ case 8:
+ _glamor_dump_pixmap_byte(pixmap, x, y, w, h);
+ break;
+ case 15:
+ case 16:
+ _glamor_dump_pixmap_sword(pixmap, x, y, w, h);
+ break;
+
+ case 24:
+ case 32:
+ _glamor_dump_pixmap_word(pixmap, x, y, w, h);
+ break;
+ case 1:
+ _glamor_dump_pixmap_bits(pixmap, x, y, w, h);
+ break;
+ default:
+ ErrorF("dump depth %d, not implemented.\n", pixmap->drawable.depth);
+ }
+ glamor_finish_access(&pixmap->drawable, GLAMOR_ACCESS_RO);
+}
+
+static inline void _glamor_compare_pixmaps(PixmapPtr pixmap1, PixmapPtr pixmap2,
+ int x, int y, int w, int h,
+ PictFormatShort short_format,
+ int all, int diffs)
+{
+ int i, j;
+ unsigned char * p1 = pixmap1->devPrivate.ptr;
+ unsigned char * p2 = pixmap2->devPrivate.ptr;
+ int line_need_printed = 0;
+ int test_code = 0xAABBCCDD;
+ int little_endian = 0;
+ unsigned char *p_test;
+ int bpp = pixmap1->drawable.depth == 8 ? 1 : 4;
+ int stride = pixmap1->devKind;
+
+ assert(pixmap1->devKind == pixmap2->devKind);
+
+ ErrorF("stride:%d, width:%d, height:%d\n", stride, w, h);
+
+ p1 = p1 + y * stride + x;
+ p2 = p2 + y * stride + x;
+
+ if (all) {
+ for (i = 0; i < h; i++) {
+ ErrorF("line %3d: ", i);
+
+ for (j = 0; j < stride; j++) {
+ if (j % bpp == 0)
+ ErrorF("[%d]%2x:%2x ", j / bpp, p1[j], p2[j]);
+ else
+ ErrorF("%2x:%2x ", p1[j], p2[j]);
+ }
+
+ p1 += stride;
+ p2 += stride;
+ ErrorF("\n");
+ }
+ } else {
+ if (short_format == PICT_a8r8g8b8) {
+ p_test = (unsigned char *) & test_code;
+ little_endian = (*p_test == 0xDD);
+ bpp = 4;
+
+ for (i = 0; i < h; i++) {
+ line_need_printed = 0;
+
+ for (j = 0; j < stride; j++) {
+ if (p1[j] != p2[j] && (p1[j] - p2[j] > diffs || p2[j] - p1[j] > diffs)) {
+ if (line_need_printed) {
+ if (little_endian) {
+ switch (j % 4) {
+ case 2:
+ ErrorF("[%d]RED:%2x:%2x ", j / bpp, p1[j], p2[j]);
+ break;
+ case 1:
+ ErrorF("[%d]GREEN:%2x:%2x ", j / bpp, p1[j], p2[j]);
+ break;
+ case 0:
+ ErrorF("[%d]BLUE:%2x:%2x ", j / bpp, p1[j], p2[j]);
+ break;
+ case 3:
+ ErrorF("[%d]Alpha:%2x:%2x ", j / bpp, p1[j], p2[j]);
+ break;
+ }
+ } else {
+ switch (j % 4) {
+ case 1:
+ ErrorF("[%d]RED:%2x:%2x ", j / bpp, p1[j], p2[j]);
+ break;
+ case 2:
+ ErrorF("[%d]GREEN:%2x:%2x ", j / bpp, p1[j], p2[j]);
+ break;
+ case 3:
+ ErrorF("[%d]BLUE:%2x:%2x ", j / bpp, p1[j], p2[j]);
+ break;
+ case 0:
+ ErrorF("[%d]Alpha:%2x:%2x ", j / bpp, p1[j], p2[j]);
+ break;
+ }
+ }
+ } else {
+ line_need_printed = 1;
+ j = -1;
+ ErrorF("line %3d: ", i);
+ continue;
+ }
+ }
+ }
+
+ p1 += stride;
+ p2 += stride;
+ ErrorF("\n");
+ }
+ } //more format can be added here.
+ else { // the default format, just print.
+ for (i = 0; i < h; i++) {
+ line_need_printed = 0;
+
+ for (j = 0; j < stride; j++) {
+ if (p1[j] != p2[j]) {
+ if (line_need_printed) {
+ ErrorF("[%d]%2x:%2x ", j / bpp, p1[j], p2[j]);
+ } else {
+ line_need_printed = 1;
+ j = -1;
+ ErrorF("line %3d: ", i);
+ continue;
+ }
+ }
+ }
+
+ p1 += stride;
+ p2 += stride;
+ ErrorF("\n");
+ }
+ }
+ }
+}
+
+static inline void glamor_compare_pixmaps(PixmapPtr pixmap1, PixmapPtr pixmap2,
+ int x, int y, int w, int h, int all, int diffs)
+{
+ assert(pixmap1->drawable.depth == pixmap2->drawable.depth);
+
+ glamor_prepare_access(&pixmap1->drawable, GLAMOR_ACCESS_RO);
+ glamor_prepare_access(&pixmap2->drawable, GLAMOR_ACCESS_RO);
+
+ _glamor_compare_pixmaps(pixmap1, pixmap2, x, y, w, h, -1, all, diffs);
+
+ glamor_finish_access(&pixmap1->drawable, GLAMOR_ACCESS_RO);
+ glamor_finish_access(&pixmap2->drawable, GLAMOR_ACCESS_RO);
+}
+
+/* This function is used to compare two pictures.
+ If the picture has no drawable, we use fb functions to generate it. */
+static inline void glamor_compare_pictures( ScreenPtr screen,
+ PicturePtr fst_picture,
+ PicturePtr snd_picture,
+ int x_source, int y_source,
+ int width, int height,
+ int all, int diffs)
+{
+ PixmapPtr fst_pixmap;
+ PixmapPtr snd_pixmap;
+ int fst_generated, snd_generated;
+ int error;
+ int fst_type = -1;
+ int snd_type = -1; // -1 represent has drawable.
+
+ if (fst_picture->format != snd_picture->format) {
+ ErrorF("Different picture format can not compare!\n");
+ return;
+ }
+
+ if (!fst_picture->pDrawable) {
+ fst_type = fst_picture->pSourcePict->type;
+ }
+
+ if (!snd_picture->pDrawable) {
+ snd_type = snd_picture->pSourcePict->type;
+ }
+
+ if ((fst_type != -1) && (snd_type != -1) && (fst_type != snd_type)) {
+ ErrorF("Different picture type will never be same!\n");
+ return;
+ }
+
+ fst_generated = snd_generated = 0;
+
+ if (!fst_picture->pDrawable) {
+ PicturePtr pixman_pic;
+ PixmapPtr pixmap = NULL;
+ PictFormatShort format;
+
+ format = fst_picture->format;
+
+ pixmap = glamor_create_pixmap(screen,
+ width, height,
+ PIXMAN_FORMAT_DEPTH(format),
+ GLAMOR_CREATE_PIXMAP_CPU);
+
+ pixman_pic = CreatePicture(0,
+ &pixmap->drawable,
+ PictureMatchFormat(screen,
+ PIXMAN_FORMAT_DEPTH(format), format),
+ 0, 0, serverClient, &error);
+
+ fbComposite(PictOpSrc, fst_picture, NULL, pixman_pic,
+ x_source, y_source,
+ 0, 0,
+ 0, 0,
+ width, height);
+
+ glamor_destroy_pixmap(pixmap);
+
+ fst_picture = pixman_pic;
+ fst_generated = 1;
+ }
+
+ if (!snd_picture->pDrawable) {
+ PicturePtr pixman_pic;
+ PixmapPtr pixmap = NULL;
+ PictFormatShort format;
+
+ format = snd_picture->format;
+
+ pixmap = glamor_create_pixmap(screen,
+ width, height,
+ PIXMAN_FORMAT_DEPTH(format),
+ GLAMOR_CREATE_PIXMAP_CPU);
+
+ pixman_pic = CreatePicture(0,
+ &pixmap->drawable,
+ PictureMatchFormat(screen,
+ PIXMAN_FORMAT_DEPTH(format), format),
+ 0, 0, serverClient, &error);
+
+ fbComposite(PictOpSrc, snd_picture, NULL, pixman_pic,
+ x_source, y_source,
+ 0, 0,
+ 0, 0,
+ width, height);
+
+ glamor_destroy_pixmap(pixmap);
+
+ snd_picture = pixman_pic;
+ snd_generated = 1;
+ }
+
+ fst_pixmap = glamor_get_drawable_pixmap(fst_picture->pDrawable);
+ snd_pixmap = glamor_get_drawable_pixmap(snd_picture->pDrawable);
+
+ if (fst_pixmap->drawable.depth != snd_pixmap->drawable.depth) {
+ if (fst_generated)
+ glamor_destroy_picture(fst_picture);
+ if (snd_generated)
+ glamor_destroy_picture(snd_picture);
+
+ ErrorF("Different pixmap depth can not compare!\n");
+ return;
+ }
+
+ glamor_prepare_access(&fst_pixmap->drawable, GLAMOR_ACCESS_RO);
+ glamor_prepare_access(&snd_pixmap->drawable, GLAMOR_ACCESS_RO);
+
+ if ((fst_type == SourcePictTypeLinear) ||
+ (fst_type == SourcePictTypeRadial) ||
+ (fst_type == SourcePictTypeConical) ||
+ (snd_type == SourcePictTypeLinear) ||
+ (snd_type == SourcePictTypeRadial) ||
+ (snd_type == SourcePictTypeConical)) {
+ x_source = y_source = 0;
+ }
+
+ _glamor_compare_pixmaps(fst_pixmap, snd_pixmap,
+ x_source, y_source,
+ width, height,
+ fst_picture->format, all, diffs);
+
+ glamor_finish_access(&fst_pixmap->drawable, GLAMOR_ACCESS_RO);
+ glamor_finish_access(&snd_pixmap->drawable, GLAMOR_ACCESS_RO);
+
+ if (fst_generated)
+ glamor_destroy_picture(fst_picture);
+ if (snd_generated)
+ glamor_destroy_picture(snd_picture);
+
+ return;
+}
+
+#ifdef __i386__
+static inline unsigned long __fls(unsigned long x)
+{
+ asm("bsr %1,%0"
+ : "=r" (x)
+ : "rm" (x));
+ return x;
+}
+#else
+static inline unsigned long __fls(unsigned long x)
+{
+ int n;
+
+ if (x == 0) return(0);
+ n = 0;
+ if (x <= 0x0000FFFF) {n = n +16; x = x <<16;}
+ if (x <= 0x00FFFFFF) {n = n + 8; x = x << 8;}
+ if (x <= 0x0FFFFFFF) {n = n + 4; x = x << 4;}
+ if (x <= 0x3FFFFFFF) {n = n + 2; x = x << 2;}
+ if (x <= 0x7FFFFFFF) {n = n + 1;}
+ return 31 - n;
+}
+#endif
+
+static inline void glamor_make_current(ScreenPtr screen)
+{
+ glamor_egl_make_current(screen);
+}
+
+static inline void glamor_restore_current(ScreenPtr screen)
+{
+ glamor_egl_restore_context(screen);
+}
+
+#ifdef GLX_USE_SHARED_DISPATCH
+static inline glamor_gl_dispatch *
+glamor_get_dispatch(glamor_screen_private *glamor_priv)
+{
+ if (glamor_priv->flags & GLAMOR_USE_EGL_SCREEN)
+ glamor_make_current(glamor_priv->screen);
+
+ return &glamor_priv->_dispatch;
+}
+
+static inline void
+glamor_put_dispatch(glamor_screen_private *glamor_priv)
+{
+ if (glamor_priv->flags & GLAMOR_USE_EGL_SCREEN)
+ glamor_restore_current(glamor_priv->screen);
+}
+#else
+#warning "Indirect GLX may be broken, need to implement context switch."
+static inline glamor_gl_dispatch *
+glamor_get_dispatch(glamor_screen_private *glamor_priv)
+{
+ return &glamor_priv->_dispatch;
+}
+
+static inline void
+glamor_put_dispatch(glamor_screen_private *glamor_priv)
+{
+}
+
+#endif
+
+#endif
diff --git a/xorg-server/glamor/glamor_window.c b/xorg-server/glamor/glamor_window.c
new file mode 100644
index 000000000..b67c72880
--- /dev/null
+++ b/xorg-server/glamor/glamor_window.c
@@ -0,0 +1,103 @@
+/*
+ * Copyright © 2008 Intel Corporation
+ * Copyright © 1998 Keith Packard
+ *
+ * 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 Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#include "glamor_priv.h"
+
+/** @file glamor_window.c
+ *
+ * Screen Change Window Attribute implementation.
+ */
+
+
+static void
+glamor_fixup_window_pixmap(DrawablePtr pDrawable, PixmapPtr * ppPixmap)
+{
+ PixmapPtr pPixmap = *ppPixmap;
+ glamor_pixmap_private *pixmap_priv;
+
+ if (pPixmap->drawable.bitsPerPixel != pDrawable->bitsPerPixel) {
+ pixmap_priv = glamor_get_pixmap_private(pPixmap);
+ if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
+ glamor_fallback("pixmap %p has no fbo\n", pPixmap);
+ goto fail;
+ }
+ glamor_debug_output(GLAMOR_DEBUG_UNIMPL,
+ "To be implemented.\n");
+ }
+ return;
+
+ fail:
+ GLAMOR_PANIC
+ (" We can't fall back to fbFixupWindowPixmap, as the fb24_32ReformatTile"
+ " is broken for glamor. \n");
+}
+
+Bool
+glamor_change_window_attributes(WindowPtr pWin, unsigned long mask)
+{
+ if (mask & CWBackPixmap) {
+ if (pWin->backgroundState == BackgroundPixmap)
+ glamor_fixup_window_pixmap(&pWin->drawable,
+ &pWin->
+ background.pixmap);
+ }
+
+ if (mask & CWBorderPixmap) {
+ if (pWin->borderIsPixel == FALSE)
+ glamor_fixup_window_pixmap(&pWin->drawable,
+ &pWin->border.pixmap);
+ }
+ return TRUE;
+}
+
+void
+glamor_set_window_pixmap(WindowPtr win, PixmapPtr pPixmap)
+{
+ ScreenPtr screen = win->drawable.pScreen;
+ glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(screen);
+ PixmapPtr old = screen->GetWindowPixmap(win);
+
+ if (pPixmap != old) {
+ glamor_pixmap_private *pixmap_priv;
+ PicturePtr pic = NULL;
+
+ pixmap_priv = glamor_get_pixmap_private(old);
+ if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv) && pixmap_priv->base.picture->pDrawable == (DrawablePtr)win) {
+ pic = pixmap_priv->base.picture;
+ pixmap_priv->base.is_picture = 0;
+ pixmap_priv->base.picture = NULL;
+ }
+
+ pixmap_priv = glamor_get_pixmap_private(pPixmap);
+ if (pixmap_priv) {
+ pixmap_priv->base.is_picture = !!pic;
+ pixmap_priv->base.picture = pic;
+ }
+ }
+
+ screen->SetWindowPixmap = glamor_priv->saved_procs.set_window_pixmap;
+ (screen->SetWindowPixmap)(win, pPixmap);
+ glamor_priv->saved_procs.set_window_pixmap = screen->SetWindowPixmap;
+ screen->SetWindowPixmap = glamor_set_window_pixmap;
+}
diff --git a/xorg-server/glamor/glamor_xv.c b/xorg-server/glamor/glamor_xv.c
new file mode 100644
index 000000000..a89b4cd3f
--- /dev/null
+++ b/xorg-server/glamor/glamor_xv.c
@@ -0,0 +1,645 @@
+/*
+ * Copyright © 2013 Red Hat
+ *
+ * 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.
+ *
+ * Authors:
+ * Dave Airlie <airlied@redhat.com>
+ *
+ * some code is derived from the xf86-video-ati radeon driver, mainly
+ * the calculations.
+ */
+
+/** @file glamor_xv.c
+ *
+ * Xv acceleration implementation
+ */
+
+#include "glamor_priv.h"
+
+#ifdef GLAMOR_XV
+#include "xf86xv.h"
+#include <X11/extensions/Xv.h>
+#include "fourcc.h"
+/* Reference color space transform data */
+typedef struct tagREF_TRANSFORM
+{
+ float RefLuma;
+ float RefRCb;
+ float RefRCr;
+ float RefGCb;
+ float RefGCr;
+ float RefBCb;
+ float RefBCr;
+} REF_TRANSFORM;
+
+#define RTFSaturation(a) (1.0 + ((a)*1.0)/1000.0)
+#define RTFBrightness(a) (((a)*1.0)/2000.0)
+#define RTFIntensity(a) (((a)*1.0)/2000.0)
+#define RTFContrast(a) (1.0 + ((a)*1.0)/1000.0)
+#define RTFHue(a) (((a)*3.1416)/1000.0)
+
+static const char *xv_vs= "attribute vec4 v_position;\n"
+ "attribute vec4 v_texcoord0;\n"
+ "varying vec2 tcs;\n"
+ "void main()\n" "{\n" " gl_Position = v_position;\n"
+ "tcs = v_texcoord0.xy;\n"
+ "}\n";
+
+static const char *xv_ps = GLAMOR_DEFAULT_PRECISION
+ "uniform sampler2D y_sampler;\n"
+ "uniform sampler2D u_sampler;\n"
+ "uniform sampler2D v_sampler;\n"
+ "uniform vec4 offsetyco;\n"
+ "uniform vec4 ucogamma;\n"
+ "uniform vec4 vco;\n"
+ "varying vec2 tcs;\n"
+ "float sample;\n"
+ "vec4 temp1;\n"
+ "void main()\n" "{\n"
+ "sample = texture2D(y_sampler, tcs).w;\n"
+ "temp1.xyz = offsetyco.www * vec3(sample) + offsetyco.xyz;\n"
+ "sample = texture2D(u_sampler, tcs).w;\n"
+ "temp1.xyz = ucogamma.xyz * vec3(sample) + temp1.xyz;\n"
+ "sample = texture2D(v_sampler, tcs).w;\n"
+ "temp1.xyz = clamp(vco.xyz * vec3(sample) + temp1.xyz, 0.0, 1.0);\n"
+ "temp1.w = 1.0;\n"
+ "gl_FragColor = temp1;\n"
+ "}\n";
+
+void
+glamor_init_xv_shader(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv;
+ glamor_gl_dispatch *dispatch;
+ GLint fs_prog, vs_prog;
+
+ glamor_priv = glamor_get_screen_private(screen);
+ dispatch = glamor_get_dispatch(glamor_priv);
+ glamor_priv->xv_prog = dispatch->glCreateProgram();
+
+ vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, xv_vs);
+ fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER, xv_ps);
+ dispatch->glAttachShader(glamor_priv->xv_prog, vs_prog);
+ dispatch->glAttachShader(glamor_priv->xv_prog, fs_prog);
+
+ dispatch->glBindAttribLocation(glamor_priv->xv_prog,
+ GLAMOR_VERTEX_POS, "v_position");
+ dispatch->glBindAttribLocation(glamor_priv->xv_prog,
+ GLAMOR_VERTEX_SOURCE, "v_texcoord0");
+ glamor_link_glsl_prog(dispatch, glamor_priv->xv_prog);
+
+ glamor_put_dispatch(glamor_priv);
+}
+
+void
+glamor_fini_xv_shader(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv;
+ glamor_gl_dispatch *dispatch;
+
+ glamor_priv = glamor_get_screen_private(screen);
+ dispatch = glamor_get_dispatch(glamor_priv);
+
+ dispatch->glDeleteProgram(glamor_priv->xv_prog);
+ glamor_put_dispatch(glamor_priv);
+}
+
+#define ClipValue(v,min,max) ((v) < (min) ? (min) : (v) > (max) ? (max) : (v))
+#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
+
+static Atom xvBrightness, xvContrast, xvSaturation, xvHue, xvColorspace, xvGamma;
+
+#define NUM_ATTRIBUTES 5
+static XF86AttributeRec Attributes_glamor[NUM_ATTRIBUTES+1] =
+{
+ {XvSettable | XvGettable, -1000, 1000, "XV_BRIGHTNESS"},
+ {XvSettable | XvGettable, -1000, 1000, "XV_CONTRAST"},
+ {XvSettable | XvGettable, -1000, 1000, "XV_SATURATION"},
+ {XvSettable | XvGettable, -1000, 1000, "XV_HUE"},
+ {XvSettable | XvGettable, 0, 1, "XV_COLORSPACE"},
+ {0, 0, 0, NULL}
+ };
+
+#define NUM_FORMATS 3
+
+static XF86VideoFormatRec Formats[NUM_FORMATS] =
+{
+ {15, TrueColor}, {16, TrueColor}, {24, TrueColor}
+ };
+
+#define NUM_IMAGES 2
+
+static XF86ImageRec Images[NUM_IMAGES] =
+{
+XVIMAGE_YV12,
+ XVIMAGE_I420,
+ };
+
+static void
+glamor_xv_stop_video(ScrnInfoPtr pScrn, pointer data, Bool cleanup)
+{
+glamor_port_private *port_priv = (glamor_port_private *)data;
+int i;
+if (!cleanup)
+ return;
+
+for (i = 0; i < 3; i++) {
+if (port_priv->src_pix[i]) {
+glamor_destroy_pixmap(port_priv->src_pix[i]);
+port_priv->src_pix[i] = NULL;
+}
+}
+}
+
+static int
+glamor_xv_set_port_attribute(ScrnInfoPtr pScrn,
+ Atom attribute,
+ INT32 value,
+ pointer data)
+{
+glamor_port_private *port_priv = (glamor_port_private *)data;
+if (attribute == xvBrightness)
+ port_priv->brightness = ClipValue(value, -1000, 1000);
+else if (attribute == xvHue)
+ port_priv->hue = ClipValue(value, -1000, 1000);
+else if (attribute == xvContrast)
+ port_priv->contrast = ClipValue(value, -1000, 1000);
+else if (attribute == xvSaturation)
+ port_priv->saturation = ClipValue(value, -1000, 1000);
+else if (attribute == xvGamma)
+ port_priv->gamma = ClipValue (value, 100, 10000);
+else if(attribute == xvColorspace)
+ port_priv->transform_index = ClipValue (value, 0, 1);
+else
+ return BadMatch;
+return Success;
+}
+
+static int
+glamor_xv_get_port_attribute(ScrnInfoPtr pScrn,
+ Atom attribute,
+ INT32 *value,
+ pointer data)
+{
+glamor_port_private *port_priv = (glamor_port_private *)data;
+if (attribute == xvBrightness)
+ *value = port_priv->brightness;
+else if (attribute == xvHue)
+ *value = port_priv->hue;
+else if (attribute == xvContrast)
+ *value = port_priv->contrast;
+else if (attribute == xvSaturation)
+ *value = port_priv->saturation;
+else if (attribute == xvGamma)
+ *value = port_priv->gamma;
+else if(attribute == xvColorspace)
+ *value = port_priv->transform_index;
+else
+ return BadMatch;
+
+return Success;
+}
+
+static void
+glamor_xv_query_best_size(ScrnInfoPtr pScrn,
+ Bool motion,
+ short vid_w, short vid_h,
+ short drw_w, short drw_h,
+ unsigned int *p_w, unsigned int *p_h,
+ pointer data)
+{
+*p_w = drw_w;
+*p_h = drw_h;
+}
+
+static int
+glamor_xv_query_image_attributes(ScrnInfoPtr pScrn,
+ int id,
+ unsigned short *w, unsigned short *h,
+ int *pitches, int *offsets)
+{
+int size = 0, tmp;
+
+if (offsets) offsets[0] = 0;
+switch (id) {
+case FOURCC_YV12:
+case FOURCC_I420:
+*h = *h;
+*w = *w;
+size = *w;
+if (pitches) pitches[0] = size;
+size *= *h;
+if (offsets) offsets[1] = size;
+tmp = *w >> 1;
+if (pitches) pitches[1] = pitches[2] = tmp;
+tmp *= (*h >> 1);
+size += tmp;
+if (offsets) offsets[2] = size;
+size += tmp;
+break;
+}
+return size;
+}
+/* Parameters for ITU-R BT.601 and ITU-R BT.709 colour spaces
+ note the difference to the parameters used in overlay are due
+ to 10bit vs. float calcs */
+static REF_TRANSFORM trans[2] =
+{
+ {1.1643, 0.0, 1.5960, -0.3918, -0.8129, 2.0172, 0.0}, /* BT.601 */
+ {1.1643, 0.0, 1.7927, -0.2132, -0.5329, 2.1124, 0.0} /* BT.709 */
+ };
+
+static void
+glamor_display_textured_video(glamor_port_private *port_priv)
+{
+ScreenPtr screen = port_priv->pPixmap->drawable.pScreen;
+glamor_screen_private *glamor_priv =
+ glamor_get_screen_private(screen);
+glamor_pixmap_private *pixmap_priv =
+ glamor_get_pixmap_private(port_priv->pPixmap);
+glamor_pixmap_private *src_pixmap_priv[3];
+glamor_gl_dispatch *dispatch;
+float vertices[32], texcoords[8];
+BoxPtr box = REGION_RECTS(&port_priv->clip);
+int nBox = REGION_NUM_RECTS(&port_priv->clip);
+int dst_x_off, dst_y_off;
+GLfloat dst_xscale, dst_yscale;
+GLfloat src_xscale[3], src_yscale[3];
+int i;
+const float Loff = -0.0627;
+const float Coff = -0.502;
+float uvcosf, uvsinf;
+float yco;
+float uco[3], vco[3], off[3];
+float bright, cont, gamma;
+int ref = port_priv->transform_index;
+GLint uloc, sampler_loc;
+
+cont = RTFContrast(port_priv->contrast);
+bright = RTFBrightness(port_priv->brightness);
+gamma = (float)port_priv->gamma / 1000.0;
+uvcosf = RTFSaturation(port_priv->saturation) * cos(RTFHue(port_priv->hue));
+uvsinf = RTFSaturation(port_priv->saturation) * sin(RTFHue(port_priv->hue));
+/* overlay video also does pre-gamma contrast/sat adjust, should we? */
+
+yco = trans[ref].RefLuma * cont;
+uco[0] = -trans[ref].RefRCr * uvsinf;
+uco[1] = trans[ref].RefGCb * uvcosf - trans[ref].RefGCr * uvsinf;
+uco[2] = trans[ref].RefBCb * uvcosf;
+vco[0] = trans[ref].RefRCr * uvcosf;
+vco[1] = trans[ref].RefGCb * uvsinf + trans[ref].RefGCr * uvcosf;
+vco[2] = trans[ref].RefBCb * uvsinf;
+off[0] = Loff * yco + Coff * (uco[0] + vco[0]) + bright;
+off[1] = Loff * yco + Coff * (uco[1] + vco[1]) + bright;
+off[2] = Loff * yco + Coff * (uco[2] + vco[2]) + bright;
+gamma = 1.0;
+
+pixmap_priv_get_dest_scale(pixmap_priv, &dst_xscale, &dst_yscale);
+glamor_get_drawable_deltas(port_priv->pDraw, port_priv->pPixmap, &dst_x_off,
+ &dst_y_off);
+glamor_set_destination_pixmap_priv_nc(pixmap_priv);
+
+for (i = 0; i < 3; i++) {
+if (port_priv->src_pix[i]) {
+src_pixmap_priv[i] = glamor_get_pixmap_private(port_priv->src_pix[i]);
+pixmap_priv_get_scale(src_pixmap_priv[i], &src_xscale[i], &src_yscale[i]);
+}
+}
+dispatch = glamor_get_dispatch(glamor_priv);
+dispatch->glUseProgram(glamor_priv->xv_prog);
+
+uloc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "offsetyco");
+dispatch->glUniform4f(uloc, off[0], off[1], off[2], yco);
+uloc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "ucogamma");
+dispatch->glUniform4f(uloc, uco[0], uco[1], uco[2], gamma);
+uloc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "vco");
+dispatch->glUniform4f(uloc, vco[0], vco[1], vco[2], 0);
+
+dispatch->glActiveTexture(GL_TEXTURE0);
+dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[0]->base.fbo->tex);
+dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_MIN_FILTER,
+ GL_LINEAR);
+dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_MAG_FILTER,
+ GL_LINEAR);
+dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_WRAP_S,
+ GL_CLAMP_TO_EDGE);
+dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_WRAP_T,
+ GL_CLAMP_TO_EDGE);
+
+dispatch->glActiveTexture(GL_TEXTURE1);
+dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[1]->base.fbo->tex);
+dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_MIN_FILTER,
+ GL_LINEAR);
+dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_MAG_FILTER,
+ GL_LINEAR);
+dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_WRAP_S,
+ GL_CLAMP_TO_EDGE);
+dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_WRAP_T,
+ GL_CLAMP_TO_EDGE);
+
+dispatch->glActiveTexture(GL_TEXTURE2);
+dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv[2]->base.fbo->tex);
+dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_MIN_FILTER,
+ GL_LINEAR);
+dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_MAG_FILTER,
+ GL_LINEAR);
+dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_WRAP_S,
+ GL_CLAMP_TO_EDGE);
+dispatch->glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_WRAP_T,
+ GL_CLAMP_TO_EDGE);
+
+sampler_loc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "y_sampler");
+dispatch->glUniform1i(sampler_loc, 0);
+sampler_loc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "u_sampler");
+dispatch->glUniform1i(sampler_loc, 1);
+sampler_loc = dispatch->glGetUniformLocation(glamor_priv->xv_prog, "v_sampler");
+dispatch->glUniform1i(sampler_loc, 2);
+
+dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
+ GL_FLOAT, GL_FALSE,
+ 2 * sizeof(float),
+ texcoords);
+dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+
+dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
+ GL_FALSE, 2 * sizeof(float),
+ vertices);
+
+dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+for (i = 0; i < nBox; i++) {
+float off_x = box[i].x1 - port_priv->drw_x;
+float off_y = box[i].y1 - port_priv->drw_y;
+float diff_x = (float)port_priv->src_w / (float)port_priv->dst_w;
+float diff_y = (float)port_priv->src_h / (float)port_priv->dst_h;
+float srcx, srcy, srcw, srch;
+int dstx, dsty, dstw, dsth;
+
+
+dstx = box[i].x1 + dst_x_off;
+dsty = box[i].y1 + dst_y_off;
+dstw = box[i].x2 - box[i].x1;
+dsth = box[i].y2 - box[i].y1;
+
+srcx = port_priv->src_x + off_x * diff_x;
+srcy = port_priv->src_y + off_y * diff_y;
+srcw = (port_priv->src_w * dstw) / (float)port_priv->dst_w;
+srch = (port_priv->src_h * dsth) / (float)port_priv->dst_h;
+
+glamor_set_normalize_vcoords(pixmap_priv,
+ dst_xscale, dst_yscale,
+ dstx,
+ dsty,
+ dstx + dstw,
+ dsty + dsth,
+ glamor_priv->yInverted,
+ vertices);
+
+glamor_set_normalize_tcoords(src_pixmap_priv[0],
+ src_xscale[0],
+ src_yscale[0],
+ srcx,
+ srcy,
+ srcx + srcw,
+ srcy + srch,
+ glamor_priv->yInverted,
+ texcoords);
+
+dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+}
+
+dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+
+dispatch->glUseProgram(0);
+glamor_put_dispatch(glamor_priv);
+DamageDamageRegion(port_priv->pDraw, &port_priv->clip);
+}
+
+static int glamor_xv_put_image(ScrnInfoPtr pScrn,
+ short src_x, short src_y,
+ short drw_x, short drw_y,
+ short src_w, short src_h,
+ short drw_w, short drw_h,
+ int id,
+ unsigned char *buf,
+ short width,
+ short height,
+ Bool sync,
+ RegionPtr clipBoxes,
+ pointer data,
+ DrawablePtr pDrawable)
+{
+ ScreenPtr screen = xf86ScrnToScreen(pScrn);
+ glamor_port_private *port_priv = (glamor_port_private *)data;
+ INT32 x1, x2, y1, y2;
+ int srcPitch, srcPitch2;
+ BoxRec dstBox;
+ int top, nlines;
+ int s2offset, s3offset, tmp;
+
+ s2offset = s3offset = srcPitch2 = 0;
+
+ /* Clip */
+ x1 = src_x;
+ x2 = src_x + src_w;
+ y1 = src_y;
+ y2 = src_y + src_h;
+
+ dstBox.x1 = drw_x;
+ dstBox.x2 = drw_x + drw_w;
+ dstBox.y1 = drw_y;
+ dstBox.y2 = drw_y + drw_h;
+ if (!xf86XVClipVideoHelper(&dstBox, &x1, &x2, &y1, &y2, clipBoxes, width, height))
+ return Success;
+
+ if ((x1 >= x2) || (y1 >= y2))
+ return Success;
+
+ srcPitch = width;
+ srcPitch2 = width >> 1;
+
+ if (!port_priv->src_pix[0] || (width != port_priv->src_pix_w || height != port_priv->src_pix_h)) {
+ int i;
+ for (i = 0; i < 3; i++)
+ if (port_priv->src_pix[i])
+ glamor_destroy_pixmap(port_priv->src_pix[i]);
+
+ port_priv->src_pix[0] = glamor_create_pixmap(screen, width, height, 8, 0);
+ port_priv->src_pix[1] = glamor_create_pixmap(screen, width >> 1, height >> 1, 8, 0);
+ port_priv->src_pix[2] = glamor_create_pixmap(screen, width >> 1, height >> 1, 8, 0);
+ port_priv->src_pix_w = width;
+ port_priv->src_pix_h = height;
+
+ if (!port_priv->src_pix[0] || !port_priv->src_pix[1] || !port_priv->src_pix[2])
+ return BadAlloc;
+ }
+
+ top = (y1 >> 16) & ~1;
+ nlines = ((y2 + 0xffff) >> 16) - top;
+
+ switch (id) {
+ case FOURCC_YV12:
+ case FOURCC_I420:
+ s2offset = srcPitch * height;
+ s3offset = s2offset + (srcPitch2 * ((height + 1) >> 1));
+ s2offset += ((top >> 1) * srcPitch2);
+ s3offset += ((top >> 1) * srcPitch2);
+ if (id == FOURCC_YV12) {
+ tmp = s2offset;
+ s2offset = s3offset;
+ s3offset = tmp;
+ }
+ glamor_upload_sub_pixmap_to_texture(port_priv->src_pix[0],
+ 0, 0, srcPitch, nlines,
+ port_priv->src_pix[0]->devKind,
+ buf + (top * srcPitch), 0);
+
+ glamor_upload_sub_pixmap_to_texture(port_priv->src_pix[1],
+ 0, 0, srcPitch2, (nlines + 1) >> 1,
+ port_priv->src_pix[1]->devKind,
+ buf + s2offset, 0);
+
+ glamor_upload_sub_pixmap_to_texture(port_priv->src_pix[2],
+ 0, 0, srcPitch2, (nlines + 1) >> 1,
+ port_priv->src_pix[2]->devKind,
+ buf + s3offset, 0);
+ break;
+ default:
+ return BadMatch;
+ }
+
+ if (pDrawable->type == DRAWABLE_WINDOW)
+ port_priv->pPixmap = (*screen->GetWindowPixmap)((WindowPtr)pDrawable);
+ else
+ port_priv->pPixmap = (PixmapPtr)pDrawable;
+
+ if (!RegionEqual(&port_priv->clip, clipBoxes)) {
+ RegionCopy(&port_priv->clip, clipBoxes);
+ }
+
+ port_priv->src_x = src_x;
+ port_priv->src_y = src_y;
+ port_priv->src_w = src_w;
+ port_priv->src_h = src_h;
+ port_priv->dst_w = drw_w;
+ port_priv->dst_h = drw_h;
+ port_priv->drw_x = drw_x;
+ port_priv->drw_y = drw_y;
+ port_priv->w = width;
+ port_priv->h = height;
+ port_priv->pDraw = pDrawable;
+ glamor_display_textured_video(port_priv);
+ return Success;
+}
+
+static XF86VideoEncodingRec DummyEncodingGLAMOR[1] =
+{
+ {
+ 0,
+ "XV_IMAGE",
+ 8192, 8192,
+ {1, 1}
+ }
+};
+
+XF86VideoAdaptorPtr
+glamor_xv_init(ScreenPtr screen, int num_texture_ports)
+{
+ glamor_port_private *port_priv;
+ XF86VideoAdaptorPtr adapt;
+ int i;
+
+ adapt = calloc(1, sizeof(XF86VideoAdaptorRec) + num_texture_ports *
+ (sizeof(glamor_port_private) + sizeof(DevUnion)));
+ if (adapt == NULL)
+ return NULL;
+
+ xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
+ xvContrast = MAKE_ATOM("XV_CONTRAST");
+ xvSaturation = MAKE_ATOM("XV_SATURATION");
+ xvHue = MAKE_ATOM("XV_HUE");
+ xvGamma = MAKE_ATOM("XV_GAMMA");
+ xvColorspace = MAKE_ATOM("XV_COLORSPACE");
+
+ adapt->type = XvWindowMask | XvInputMask | XvImageMask;
+ adapt->flags = 0;
+ adapt->name = "GLAMOR Textured Video";
+ adapt->nEncodings = 1;
+ adapt->pEncodings = DummyEncodingGLAMOR;
+
+ adapt->nFormats = NUM_FORMATS;
+ adapt->pFormats = Formats;
+ adapt->nPorts = num_texture_ports;
+ adapt->pPortPrivates = (DevUnion*)(&adapt[1]);
+
+ adapt->pAttributes = Attributes_glamor;
+ adapt->nAttributes = NUM_ATTRIBUTES;
+
+ port_priv = (glamor_port_private *)(&adapt->pPortPrivates[num_texture_ports]);
+ adapt->pImages = Images;
+ adapt->nImages = NUM_IMAGES;
+ adapt->PutVideo = NULL;
+ adapt->PutStill = NULL;
+ adapt->GetVideo = NULL;
+ adapt->GetStill = NULL;
+ adapt->StopVideo = glamor_xv_stop_video;
+ adapt->SetPortAttribute = glamor_xv_set_port_attribute;
+ adapt->GetPortAttribute = glamor_xv_get_port_attribute;
+ adapt->QueryBestSize = glamor_xv_query_best_size;
+ adapt->PutImage = glamor_xv_put_image;
+ adapt->ReputImage = NULL;
+ adapt->QueryImageAttributes = glamor_xv_query_image_attributes;
+
+ for (i = 0; i < num_texture_ports; i++) {
+ glamor_port_private *pPriv = &port_priv[i];
+
+ pPriv->brightness = 0;
+ pPriv->contrast = 0;
+ pPriv->saturation = 0;
+ pPriv->hue = 0;
+ pPriv->gamma = 1000;
+ pPriv->transform_index = 0;
+
+ REGION_NULL(pScreen, &pPriv->clip);
+
+ adapt->pPortPrivates[i].ptr = (pointer)(pPriv);
+ }
+ return adapt;
+}
+#else
+XF86VideoAdaptorPtr
+glamor_xv_init(ScreenPtr screen, int num_texture_ports)
+{
+ return NULL;
+}
+#endif
diff --git a/xorg-server/glamor/glapi.h b/xorg-server/glamor/glapi.h
new file mode 100644
index 000000000..d510dac1d
--- /dev/null
+++ b/xorg-server/glamor/glapi.h
@@ -0,0 +1,121 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.1
+ *
+ * Copyright (C) 1999-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.
+ */
+
+
+/**
+ * \mainpage Mesa GL API Module
+ *
+ * \section GLAPIIntroduction Introduction
+ *
+ * The Mesa GL API module is responsible for dispatching all the
+ * gl*() functions. All GL functions are dispatched by jumping through
+ * the current dispatch table (basically a struct full of function
+ * pointers.)
+ *
+ * A per-thread current dispatch table and per-thread current context
+ * pointer are managed by this module too.
+ *
+ * This module is intended to be non-Mesa-specific so it can be used
+ * with the X/DRI libGL also.
+ */
+
+#ifndef _GLAPI_H
+#define _GLAPI_H
+
+#define GL_GLEXT_PROTOTYPES
+
+#if GLAMOR_GLES2
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#else
+#include <GL/gl.h>
+#include "GL/glext.h"
+#endif
+
+/* Is this needed? It is incomplete anyway. */
+#ifdef USE_MGL_NAMESPACE
+#define _glapi_set_dispatch _mglapi_set_dispatch
+#define _glapi_get_dispatch _mglapi_get_dispatch
+#define _glapi_set_context _mglapi_set_context
+#define _glapi_get_context _mglapi_get_context
+#define _glapi_Dispatch _mglapi_Dispatch
+#define _glapi_Context _mglapi_Context
+#endif
+
+typedef void (*_glapi_proc)(void);
+struct _glapi_table;
+
+
+#if defined (GLX_USE_TLS)
+
+extern __thread struct _glapi_table * _glapi_tls_Dispatch
+ __attribute__((tls_model("initial-exec")));
+
+extern __thread void * _glapi_tls_Context
+ __attribute__((tls_model("initial-exec")));
+
+extern const struct _glapi_table *_glapi_Dispatch;
+extern const void *_glapi_Context;
+
+# define GET_DISPATCH() _glapi_tls_Dispatch
+# define GET_CURRENT_CONTEXT(C) C = (typeof(C)) _glapi_tls_Context
+# define SET_CURRENT_CONTEXT(C) _glapi_tls_Context = (void*)C
+
+#else
+
+extern struct _glapi_table *_glapi_Dispatch;
+extern void *_glapi_Context;
+
+# ifdef THREADS
+
+# define GET_DISPATCH() \
+ (likely(_glapi_Dispatch) ? _glapi_Dispatch : _glapi_get_dispatch())
+
+# define GET_CURRENT_CONTEXT(C) C = (typeof(C)) \
+ (likely(_glapi_Context) ? _glapi_Context : _glapi_get_context())
+
+
+# define SET_CURRENT_CONTEXT(C) do { if (likely(_glapi_Context)) \
+ _glapi_Context = (void*)C; \
+ else \
+ _glapi_set_context(C); } while(0)
+
+# else
+
+# define GET_DISPATCH() _glapi_Dispatch
+# define GET_CURRENT_CONTEXT(C) C = (typeof(C)) _glapi_Context
+# define SET_CURRENT_CONTEXT(C) _glapi_Context = (void*)C
+
+# endif
+
+#endif /* defined (GLX_USE_TLS) */
+
+
+extern void
+_glapi_set_context(void *context);
+
+extern void *
+_glapi_get_context(void);
+
+#endif
diff --git a/xorg-server/glx/glxdri2.c b/xorg-server/glx/glxdri2.c
index b2f3d6ee8..8c1058613 100644
--- a/xorg-server/glx/glxdri2.c
+++ b/xorg-server/glx/glxdri2.c
@@ -55,14 +55,9 @@ typedef struct __GLXDRIscreen __GLXDRIscreen;
typedef struct __GLXDRIcontext __GLXDRIcontext;
typedef struct __GLXDRIdrawable __GLXDRIdrawable;
-#ifdef __DRI2_ROBUSTNESS
#define ALL_DRI_CTX_FLAGS (__DRI_CTX_FLAG_DEBUG \
| __DRI_CTX_FLAG_FORWARD_COMPATIBLE \
| __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS)
-#else
-#define ALL_DRI_CTX_FLAGS (__DRI_CTX_FLAG_DEBUG \
- | __DRI_CTX_FLAG_FORWARD_COMPATIBLE)
-#endif
struct __GLXDRIscreen {
__GLXscreen base;
@@ -210,15 +205,10 @@ __glXDRIdrawableSwapBuffers(ClientPtr client, __GLXdrawable * drawable)
__GLXDRIscreen *screen = priv->screen;
CARD64 unused;
-#if __DRI2_FLUSH_VERSION >= 3
if (screen->flush) {
(*screen->flush->flush) (priv->driDrawable);
(*screen->flush->invalidate) (priv->driDrawable);
}
-#else
- if (screen->flush)
- (*screen->flush->flushInvalidate) (priv->driDrawable);
-#endif
if (DRI2SwapBuffers(client, drawable->pDraw, 0, 0, 0, &unused,
__glXdriSwapEvent, drawable) != Success)
@@ -294,8 +284,6 @@ __glXDRIcontextWait(__GLXcontext * baseContext,
return FALSE;
}
-#ifdef __DRI_TEX_BUFFER
-
static int
__glXDRIbindTexImage(__GLXcontext * baseContext,
int buffer, __GLXdrawable * glxPixmap)
@@ -307,14 +295,12 @@ __glXDRIbindTexImage(__GLXcontext * baseContext,
if (texBuffer == NULL)
return Success;
-#if __DRI_TEX_BUFFER_VERSION >= 2
if (texBuffer->base.version >= 2 && texBuffer->setTexBuffer2 != NULL) {
(*texBuffer->setTexBuffer2) (context->driContext,
glxPixmap->target,
glxPixmap->format, drawable->driDrawable);
}
else
-#endif
{
texBuffer->setTexBuffer(context->driContext,
glxPixmap->target, drawable->driDrawable);
@@ -331,24 +317,6 @@ __glXDRIreleaseTexImage(__GLXcontext * baseContext,
return Success;
}
-#else
-
-static int
-__glXDRIbindTexImage(__GLXcontext * baseContext,
- int buffer, __GLXdrawable * glxPixmap)
-{
- return Success;
-}
-
-static int
-__glXDRIreleaseTexImage(__GLXcontext * baseContext,
- int buffer, __GLXdrawable * pixmap)
-{
- return Success;
-}
-
-#endif
-
static __GLXtextureFromPixmap __glXDRItextureFromPixmap = {
__glXDRIbindTexImage,
__glXDRIreleaseTexImage
@@ -398,11 +366,7 @@ dri2_convert_glx_attribs(__GLXDRIscreen *screen, unsigned num_attribs,
*major_ver = 1;
*minor_ver = 0;
-#ifdef __DRI2_ROBUSTNESS
*reset = __DRI_CTX_RESET_NO_NOTIFICATION;
-#else
- (void) reset;
-#endif
for (i = 0; i < num_attribs; i++) {
switch (attribs[i * 2]) {
@@ -433,7 +397,6 @@ dri2_convert_glx_attribs(__GLXDRIscreen *screen, unsigned num_attribs,
return False;
}
break;
-#ifdef __DRI2_ROBUSTNESS
case GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB:
if (screen->dri2->base.version >= 4) {
*error = BadValue;
@@ -452,7 +415,6 @@ dri2_convert_glx_attribs(__GLXDRIscreen *screen, unsigned num_attribs,
return False;
}
break;
-#endif
default:
/* If an unknown attribute is received, fail.
*/
@@ -493,7 +455,6 @@ create_driver_context(__GLXDRIcontext * context,
{
context->driContext = NULL;
-#if __DRI_DRI2_VERSION >= 3
if (screen->dri2->base.version >= 3) {
uint32_t ctx_attribs[3 * 2];
unsigned num_ctx_attribs = 0;
@@ -525,13 +486,11 @@ create_driver_context(__GLXDRIcontext * context,
ctx_attribs[num_ctx_attribs++] = flags;
}
-#ifdef __DRI2_ROBUSTNESS
if (reset != __DRI_CTX_RESET_NO_NOTIFICATION) {
ctx_attribs[num_ctx_attribs++] =
__DRI_CTX_ATTRIB_RESET_STRATEGY;
ctx_attribs[num_ctx_attribs++] = reset;
}
-#endif
}
context->driContext =
@@ -567,7 +526,6 @@ create_driver_context(__GLXDRIcontext * context,
return;
}
-#endif
if (num_attribs != 0) {
*error = BadValue;
@@ -625,13 +583,11 @@ __glXDRIscreenCreateContext(__GLXscreen * baseScreen,
static void
__glXDRIinvalidateBuffers(DrawablePtr pDraw, void *priv, XID id)
{
-#if __DRI2_FLUSH_VERSION >= 3
__GLXDRIdrawable *private = priv;
__GLXDRIscreen *screen = private->screen;
if (screen->flush)
(*screen->flush->invalidate) (private->driDrawable);
-#endif
}
static __GLXdrawable *
@@ -778,18 +734,14 @@ static const __DRIdri2LoaderExtension loaderExtension = {
dri2GetBuffersWithFormat,
};
-#ifdef __DRI_USE_INVALIDATE
static const __DRIuseInvalidateExtension dri2UseInvalidate = {
{__DRI_USE_INVALIDATE, 1}
};
-#endif
static const __DRIextension *loader_extensions[] = {
&systemTimeExtension.base,
&loaderExtension.base,
-#ifdef __DRI_USE_INVALIDATE
&dri2UseInvalidate.base,
-#endif
NULL
};
@@ -850,8 +802,6 @@ initializeExtensions(__GLXDRIscreen * screen)
__glXEnableExtension(screen->glx_enable_bits, "GLX_MESA_copy_sub_buffer");
LogMessage(X_INFO, "AIGLX: enabled GLX_MESA_copy_sub_buffer\n");
-
-#if __DRI_DRI2_VERSION >= 3
if (screen->dri2->base.version >= 3) {
__glXEnableExtension(screen->glx_enable_bits,
"GLX_ARB_create_context");
@@ -864,7 +814,6 @@ initializeExtensions(__GLXDRIscreen * screen)
LogMessage(X_INFO,
"AIGLX: enabled GLX_EXT_create_context_es2_profile\n");
}
-#endif
if (DRI2HasSwapControl(pScreen)) {
__glXEnableExtension(screen->glx_enable_bits, "GLX_INTEL_swap_event");
@@ -889,32 +838,25 @@ initializeExtensions(__GLXDRIscreen * screen)
}
for (i = 0; extensions[i]; i++) {
-#ifdef __DRI_READ_DRAWABLE
if (strcmp(extensions[i]->name, __DRI_READ_DRAWABLE) == 0) {
__glXEnableExtension(screen->glx_enable_bits,
"GLX_SGI_make_current_read");
LogMessage(X_INFO, "AIGLX: enabled GLX_SGI_make_current_read\n");
}
-#endif
-#ifdef __DRI_TEX_BUFFER
if (strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0) {
screen->texBuffer = (const __DRItexBufferExtension *) extensions[i];
/* GLX_EXT_texture_from_pixmap is always enabled. */
LogMessage(X_INFO,
"AIGLX: GLX_EXT_texture_from_pixmap backed by buffer objects\n");
}
-#endif
-#ifdef __DRI2_FLUSH
if (strcmp(extensions[i]->name, __DRI2_FLUSH) == 0 &&
extensions[i]->version >= 3) {
screen->flush = (__DRI2flushExtension *) extensions[i];
}
-#endif
-#ifdef __DRI2_ROBUSTNESS
if (strcmp(extensions[i]->name, __DRI2_ROBUSTNESS) == 0 &&
screen->dri2->base.version >= 3) {
__glXEnableExtension(screen->glx_enable_bits,
@@ -922,7 +864,6 @@ initializeExtensions(__GLXDRIscreen * screen)
LogMessage(X_INFO,
"AIGLX: enabled GLX_ARB_create_context_robustness\n");
}
-#endif
/* Ignore unknown extensions */
}
diff --git a/xorg-server/glx/glxdriswrast.c b/xorg-server/glx/glxdriswrast.c
index cbc109a6d..6fa328831 100644
--- a/xorg-server/glx/glxdriswrast.c
+++ b/xorg-server/glx/glxdriswrast.c
@@ -170,8 +170,6 @@ __glXDRIcontextCopy(__GLXcontext * baseDst, __GLXcontext * baseSrc,
src->driContext, mask);
}
-#ifdef __DRI_TEX_BUFFER
-
static int
__glXDRIbindTexImage(__GLXcontext * baseContext,
int buffer, __GLXdrawable * glxPixmap)
@@ -205,24 +203,6 @@ __glXDRIreleaseTexImage(__GLXcontext * baseContext,
return Success;
}
-#else
-
-static int
-__glXDRIbindTexImage(__GLXcontext * baseContext,
- int buffer, __GLXdrawable * glxPixmap)
-{
- return Success;
-}
-
-static int
-__glXDRIreleaseTexImage(__GLXcontext * baseContext,
- int buffer, __GLXdrawable * pixmap)
-{
- return Success;
-}
-
-#endif
-
static __GLXtextureFromPixmap __glXDRItextureFromPixmap = {
__glXDRIbindTexImage,
__glXDRIreleaseTexImage
@@ -407,20 +387,17 @@ initializeExtensions(__GLXDRIscreen * screen)
extensions = screen->core->getExtensions(screen->driScreen);
for (i = 0; extensions[i]; i++) {
-#ifdef __DRI_COPY_SUB_BUFFER
if (strcmp(extensions[i]->name, __DRI_COPY_SUB_BUFFER) == 0) {
screen->copySubBuffer =
(const __DRIcopySubBufferExtension *) extensions[i];
/* GLX_MESA_copy_sub_buffer is always enabled. */
}
-#endif
-#ifdef __DRI_TEX_BUFFER
if (strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0) {
screen->texBuffer = (const __DRItexBufferExtension *) extensions[i];
/* GLX_EXT_texture_from_pixmap is always enabled. */
}
-#endif
+
/* Ignore unknown extensions */
}
}
diff --git a/xorg-server/hw/kdrive/ephyr/ephyr.c b/xorg-server/hw/kdrive/ephyr/ephyr.c
index 12c708616..da80c9577 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyr.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyr.c
@@ -1008,6 +1008,29 @@ ephyrProcessButtonRelease(xcb_generic_event_t *xev)
KdEnqueuePointerEvent(ephyrMouse, mouseState | KD_MOUSE_DELTA, 0, 0, 0);
}
+/* Xephyr wants ctrl+shift to grab the window, but that conflicts with
+ ctrl+alt+shift key combos. Remember the modifier state on key presses and
+ releases, if mod1 is pressed, we need ctrl, shift and mod1 released
+ before we allow a shift-ctrl grab activation.
+
+ note: a key event contains the mask _before_ the current key takes
+ effect, so mod1_was_down will be reset on the first key press after all
+ three were released, not on the last release. That'd require some more
+ effort.
+ */
+static int
+ephyrUpdateGrabModifierState(int state)
+{
+ static int mod1_was_down = 0;
+
+ if ((state & (XCB_MOD_MASK_CONTROL|XCB_MOD_MASK_SHIFT|XCB_MOD_MASK_1)) == 0)
+ mod1_was_down = 0;
+ else if (state & XCB_MOD_MASK_1)
+ mod1_was_down = 1;
+
+ return mod1_was_down;
+}
+
static void
ephyrProcessKeyPress(xcb_generic_event_t *xev)
{
@@ -1018,6 +1041,7 @@ ephyrProcessKeyPress(xcb_generic_event_t *xev)
return;
}
+ ephyrUpdateGrabModifierState(key->state);
ephyrUpdateModifierState(key->state);
KdEnqueueKeyboardEvent(ephyrKbd, key->detail, FALSE);
}
@@ -1029,6 +1053,7 @@ ephyrProcessKeyRelease(xcb_generic_event_t *xev)
xcb_key_release_event_t *key = (xcb_key_release_event_t *)xev;
static xcb_key_symbols_t *keysyms;
static int grabbed_screen = -1;
+ int mod1_down = ephyrUpdateGrabModifierState(key->state);
if (!keysyms)
keysyms = xcb_key_symbols_alloc(conn);
@@ -1049,7 +1074,7 @@ ephyrProcessKeyRelease(xcb_generic_event_t *xev)
hostx_set_win_title(screen,
"(ctrl+shift grabs mouse and keyboard)");
}
- else {
+ else if (!mod1_down) {
/* Attempt grab */
xcb_grab_keyboard_cookie_t kbgrabc =
xcb_grab_keyboard(conn,
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrdriext.c b/xorg-server/hw/kdrive/ephyr/ephyrdriext.c
index e2b33db03..8368d1233 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrdriext.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrdriext.c
@@ -1098,7 +1098,6 @@ ProcXF86DRIGetDrawableInfo(register ClientPtr client)
if (rep.numClipRects) {
if (clipRects) {
ScreenPtr pScreen = screenInfo.screens[stuff->screen];
- int i = 0;
EPHYR_LOG("clip list of host gl drawable:\n");
for (i = 0; i < rep.numClipRects; i++) {
diff --git a/xorg-server/hw/kdrive/src/kinput.c b/xorg-server/hw/kdrive/src/kinput.c
index 7d09e282f..a539ca513 100644
--- a/xorg-server/hw/kdrive/src/kinput.c
+++ b/xorg-server/hw/kdrive/src/kinput.c
@@ -1940,7 +1940,7 @@ _KdEnqueuePointerEvent(KdPointerInfo * pi, int type, int x, int y, int z,
}
void
-KdBlockHandler(ScreenPtr pScreen, void *timeout, void *readmask)
+KdBlockHandler(ScreenPtr pScreen, void *timeo, void *readmask)
{
KdPointerInfo *pi;
int myTimeout = 0;
@@ -1962,7 +1962,7 @@ KdBlockHandler(ScreenPtr pScreen, void *timeout, void *readmask)
myTimeout = 20;
}
if (myTimeout > 0)
- AdjustWaitForDelay(timeout, myTimeout);
+ AdjustWaitForDelay(timeo, myTimeout);
}
void
diff --git a/xorg-server/hw/kdrive/src/kxv.c b/xorg-server/hw/kdrive/src/kxv.c
index 9e76eadf0..445eb605b 100644
--- a/xorg-server/hw/kdrive/src/kxv.c
+++ b/xorg-server/hw/kdrive/src/kxv.c
@@ -1821,14 +1821,14 @@ KdXVCopyPlanarData(KdScreenInfo * screen, CARD8 *src, CARD8 *dst, int randr,
w >>= 1;
for (j = 0; j < h; j++) {
- CARD32 *dst = (CARD32 *) dst1;
+ CARD32 *dst32 = (CARD32 *) dst1;
CARD8 *s1l = src1;
CARD8 *s1r = src1 + srcNext;
CARD8 *s2 = src2;
CARD8 *s3 = src3;
for (i = 0; i < w; i++) {
- *dst++ = *s1l | (*s1r << 16) | (*s3 << 8) | (*s2 << 24);
+ *dst32++ = *s1l | (*s1r << 16) | (*s3 << 8) | (*s2 << 24);
s1l += srcRight;
s1r += srcRight;
s2 += srcRight2;
diff --git a/xorg-server/hw/vfb/InitOutput.c b/xorg-server/hw/vfb/InitOutput.c
index d10272244..2175ac685 100644
--- a/xorg-server/hw/vfb/InitOutput.c
+++ b/xorg-server/hw/vfb/InitOutput.c
@@ -899,7 +899,7 @@ void vfbExtensionInit(void)
}
void
-InitOutput(ScreenInfo * screenInfo, int argc, char **argv)
+InitOutput(ScreenInfo * screen_info, int argc, char **argv)
{
int i;
int NumFormats = 0;
@@ -935,18 +935,18 @@ InitOutput(ScreenInfo * screenInfo, int argc, char **argv)
if (vfbPixmapDepths[i]) {
if (NumFormats >= MAXFORMATS)
FatalError("MAXFORMATS is too small for this server\n");
- screenInfo->formats[NumFormats].depth = i;
- screenInfo->formats[NumFormats].bitsPerPixel = vfbBitsPerPixel(i);
- screenInfo->formats[NumFormats].scanlinePad = BITMAP_SCANLINE_PAD;
+ screen_info->formats[NumFormats].depth = i;
+ screen_info->formats[NumFormats].bitsPerPixel = vfbBitsPerPixel(i);
+ screen_info->formats[NumFormats].scanlinePad = BITMAP_SCANLINE_PAD;
NumFormats++;
}
}
- screenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
- screenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
- screenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
- screenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
- screenInfo->numPixmapFormats = NumFormats;
+ screen_info->imageByteOrder = IMAGE_BYTE_ORDER;
+ screen_info->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+ screen_info->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+ screen_info->bitmapBitOrder = BITMAP_BIT_ORDER;
+ screen_info->numPixmapFormats = NumFormats;
/* initialize screens */
diff --git a/xorg-server/hw/xfree86/common/xf86Config.c b/xorg-server/hw/xfree86/common/xf86Config.c
index 5be1693d8..258b22bfe 100644
--- a/xorg-server/hw/xfree86/common/xf86Config.c
+++ b/xorg-server/hw/xfree86/common/xf86Config.c
@@ -1677,7 +1677,7 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
*/
static Bool
configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen,
- XF86ConfigPtr xf86configptr)
+ XF86ConfigPtr conf_ptr)
{
MessageType from;
XF86ConfScreenPtr s;
@@ -1722,7 +1722,7 @@ configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen,
memset(&layout, 0, sizeof(layout));
layout.lay_identifier = servlayoutp->id;
- if (xf86layoutAddInputDevices(xf86configptr, &layout) > 0) {
+ if (xf86layoutAddInputDevices(conf_ptr, &layout) > 0) {
if (!configInputDevices(&layout, servlayoutp))
return FALSE;
from = X_DEFAULT;
diff --git a/xorg-server/hw/xfree86/common/xf86Configure.c b/xorg-server/hw/xfree86/common/xf86Configure.c
index 1348b2753..30dc5505c 100644
--- a/xorg-server/hw/xfree86/common/xf86Configure.c
+++ b/xorg-server/hw/xfree86/common/xf86Configure.c
@@ -206,17 +206,17 @@ configureScreenSection(int screennum)
ptr->scrn_device_str = tmp;
for (i = 0; i < sizeof(depths) / sizeof(depths[0]); i++) {
- XF86ConfDisplayPtr display;
+ XF86ConfDisplayPtr conf_display;
- display = calloc(1, sizeof(XF86ConfDisplayRec));
- display->disp_depth = depths[i];
- display->disp_black.red = display->disp_white.red = -1;
- display->disp_black.green = display->disp_white.green = -1;
- display->disp_black.blue = display->disp_white.blue = -1;
+ conf_display = calloc(1, sizeof(XF86ConfDisplayRec));
+ conf_display->disp_depth = depths[i];
+ conf_display->disp_black.red = conf_display->disp_white.red = -1;
+ conf_display->disp_black.green = conf_display->disp_white.green = -1;
+ conf_display->disp_black.blue = conf_display->disp_white.blue = -1;
ptr->scrn_display_lst = (XF86ConfDisplayPtr) xf86addListItem((glp) ptr->
scrn_display_lst,
(glp)
- display);
+ conf_display);
}
return ptr;
@@ -375,7 +375,6 @@ configureLayoutSection(void)
aptr->adj_refscreen = NULL;
}
else {
- char *tmp;
aptr->adj_where = CONF_ADJ_RIGHTOF;
XNFasprintf(&tmp, "Screen%d", scrnum - 1);
aptr->adj_refscreen = tmp;
@@ -586,24 +585,24 @@ DoConfigure(void)
/* Add device, monitor and screen sections for detected devices */
for (screennum = 0; screennum < nDevToConfig; screennum++) {
- XF86ConfDevicePtr DevicePtr;
- XF86ConfMonitorPtr MonitorPtr;
- XF86ConfScreenPtr ScreenPtr;
+ XF86ConfDevicePtr device_ptr;
+ XF86ConfMonitorPtr monitor_ptr;
+ XF86ConfScreenPtr screen_ptr;
- DevicePtr = configureDeviceSection(screennum);
+ device_ptr = configureDeviceSection(screennum);
xf86config->conf_device_lst = (XF86ConfDevicePtr) xf86addListItem((glp)
xf86config->
conf_device_lst,
(glp)
- DevicePtr);
- MonitorPtr = configureMonitorSection(screennum);
- xf86config->conf_monitor_lst = (XF86ConfMonitorPtr) xf86addListItem((glp) xf86config->conf_monitor_lst, (glp) MonitorPtr);
- ScreenPtr = configureScreenSection(screennum);
+ device_ptr);
+ monitor_ptr = configureMonitorSection(screennum);
+ xf86config->conf_monitor_lst = (XF86ConfMonitorPtr) xf86addListItem((glp) xf86config->conf_monitor_lst, (glp) monitor_ptr);
+ screen_ptr = configureScreenSection(screennum);
xf86config->conf_screen_lst = (XF86ConfScreenPtr) xf86addListItem((glp)
xf86config->
conf_screen_lst,
(glp)
- ScreenPtr);
+ screen_ptr);
}
xf86config->conf_files = configureFilesSection();
@@ -714,27 +713,27 @@ DoConfigure(void)
xf86freeScreenList(xf86config->conf_screen_lst);
xf86config->conf_screen_lst = NULL;
for (j = 0; j < xf86NumScreens; j++) {
- XF86ConfMonitorPtr MonitorPtr;
- XF86ConfScreenPtr ScreenPtr;
+ XF86ConfMonitorPtr monitor_ptr;
+ XF86ConfScreenPtr screen_ptr;
ConfiguredMonitor = NULL;
if ((*xf86Screens[dev2screen[j]]->PreInit) (xf86Screens[dev2screen[j]],
PROBE_DETECT) &&
ConfiguredMonitor) {
- MonitorPtr = configureDDCMonitorSection(j);
+ monitor_ptr = configureDDCMonitorSection(j);
}
else {
- MonitorPtr = configureMonitorSection(j);
+ monitor_ptr = configureMonitorSection(j);
}
- ScreenPtr = configureScreenSection(j);
+ screen_ptr = configureScreenSection(j);
- xf86config->conf_monitor_lst = (XF86ConfMonitorPtr) xf86addListItem((glp) xf86config->conf_monitor_lst, (glp) MonitorPtr);
+ xf86config->conf_monitor_lst = (XF86ConfMonitorPtr) xf86addListItem((glp) xf86config->conf_monitor_lst, (glp) monitor_ptr);
xf86config->conf_screen_lst = (XF86ConfScreenPtr) xf86addListItem((glp)
xf86config->
conf_screen_lst,
(glp)
- ScreenPtr);
+ screen_ptr);
}
if (xf86writeConfigFile(filename, xf86config) == 0) {
diff --git a/xorg-server/hw/xfree86/common/xf86Helper.c b/xorg-server/hw/xfree86/common/xf86Helper.c
index 0916deccf..2c0629d64 100644
--- a/xorg-server/hw/xfree86/common/xf86Helper.c
+++ b/xorg-server/hw/xfree86/common/xf86Helper.c
@@ -421,7 +421,6 @@ xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int dummy, int fbbpp,
* Check for DefaultDepth and DefaultFbBpp options in the
* Device sections.
*/
- int i;
GDevPtr device;
Bool found = FALSE;
diff --git a/xorg-server/hw/xfree86/common/xf86Init.c b/xorg-server/hw/xfree86/common/xf86Init.c
index 7c72aa964..9c8a86a39 100644
--- a/xorg-server/hw/xfree86/common/xf86Init.c
+++ b/xorg-server/hw/xfree86/common/xf86Init.c
@@ -309,7 +309,7 @@ xf86CreateRootWindow(WindowPtr pWin)
int err = Success;
ScreenPtr pScreen = pWin->drawable.pScreen;
RootWinPropPtr pProp;
- CreateWindowProcPtr CreateWindow = (CreateWindowProcPtr)
+ CreateWindowProcPtr create_window = (CreateWindowProcPtr)
dixLookupPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey);
DebugF("xf86CreateRootWindow(%p)\n", pWin);
@@ -323,7 +323,7 @@ xf86CreateRootWindow(WindowPtr pWin)
}
/* Unhook this function ... */
- pScreen->CreateWindow = CreateWindow;
+ pScreen->CreateWindow = create_window;
dixSetPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey, NULL);
/* ... and call the previous CreateWindow fuction, if any */
diff --git a/xorg-server/hw/xfree86/common/xf86fbman.c b/xorg-server/hw/xfree86/common/xf86fbman.c
index dafaad304..db715bd2f 100644
--- a/xorg-server/hw/xfree86/common/xf86fbman.c
+++ b/xorg-server/hw/xfree86/common/xf86fbman.c
@@ -1122,11 +1122,8 @@ localQueryLargestOffscreenLinear(ScreenPtr pScreen,
if (localQueryLargestOffscreenArea(pScreen, &w, &h, gran,
FAVOR_WIDTH_THEN_AREA, priority)) {
- FBManagerPtr offman;
BoxPtr extents;
- offman = (FBManagerPtr) dixLookupPrivate(&pScreen->devPrivates,
- xf86FBScreenKey);
extents = RegionExtents(offman->InitialBoxes);
if ((extents->x2 - extents->x1) == w)
*size = w * h;
diff --git a/xorg-server/hw/xfree86/ddc/interpret_edid.c b/xorg-server/hw/xfree86/ddc/interpret_edid.c
index 882a6b201..17a8f81c0 100644
--- a/xorg-server/hw/xfree86/ddc/interpret_edid.c
+++ b/xorg-server/hw/xfree86/ddc/interpret_edid.c
@@ -332,6 +332,97 @@ xf86ForEachVideoBlock(xf86MonPtr mon, handle_video_fn fn, void *data)
}
}
+static Bool
+cea_db_offsets(Uchar *cea, int *start, int *end)
+{
+ /* Data block offset in CEA extension block */
+ *start = CEA_EXT_MIN_DATA_OFFSET;
+ *end = cea[2];
+ if (*end == 0)
+ *end = CEA_EXT_MAX_DATA_OFFSET;
+ if (*end < CEA_EXT_MIN_DATA_OFFSET || *end > CEA_EXT_MAX_DATA_OFFSET)
+ return FALSE;
+ return TRUE;
+}
+
+static int
+cea_db_len(Uchar *db)
+{
+ return db[0] & 0x1f;
+}
+
+static int
+cea_db_tag(Uchar *db)
+{
+ return db[0] >> 5;
+}
+
+typedef void (*handle_cea_db_fn) (Uchar *, void *);
+
+static void
+cea_for_each_db(xf86MonPtr mon, handle_cea_db_fn fn, void *data)
+{
+ int i;
+
+ if (!mon)
+ return;
+
+ if (!(mon->flags & EDID_COMPLETE_RAWDATA))
+ return;
+
+ if (!mon->no_sections)
+ return;
+
+ if (!mon->rawData)
+ return;
+
+ for (i = 0; i < mon->no_sections; i++) {
+ int start, end, offset;
+ Uchar *ext;
+
+ ext = mon->rawData + EDID1_LEN * (i + 1);
+ if (ext[EXT_TAG] != CEA_EXT)
+ continue;
+
+ if (!cea_db_offsets(ext, &start, &end))
+ continue;
+
+ for (offset = start;
+ offset < end && offset + cea_db_len(&ext[offset]) < end;
+ offset += cea_db_len(&ext[offset]) + 1)
+ fn(&ext[offset], data);
+ }
+}
+
+struct find_hdmi_block_data {
+ struct cea_data_block *hdmi;
+};
+
+static void find_hdmi_block(Uchar *db, void *data)
+{
+ struct find_hdmi_block_data *result = data;
+ int oui;
+
+ if (cea_db_tag(db) != CEA_VENDOR_BLK)
+ return;
+
+ if (cea_db_len(db) < 5)
+ return;
+
+ oui = (db[3] << 16) | (db[2] << 8) | db[1];
+ if (oui == IEEE_ID_HDMI)
+ result->hdmi = (struct cea_data_block *)db;
+}
+
+struct cea_data_block *xf86MonitorFindHDMIBlock(xf86MonPtr mon)
+{
+ struct find_hdmi_block_data result = { NULL };
+
+ cea_for_each_db(mon, find_hdmi_block, &result);
+
+ return result.hdmi;
+}
+
xf86MonPtr
xf86InterpretEEDID(int scrnIndex, Uchar * block)
{
@@ -666,49 +757,5 @@ validate_version(int scrnIndex, struct edid_version *r)
Bool
xf86MonitorIsHDMI(xf86MonPtr mon)
{
- int i = 0, version, offset;
- char *edid = NULL;
-
- if (!mon)
- return FALSE;
-
- if (!(mon->flags & EDID_COMPLETE_RAWDATA))
- return FALSE;
-
- if (!mon->no_sections)
- return FALSE;
-
- edid = (char *) mon->rawData;
- if (!edid)
- return FALSE;
-
- /* find the CEA extension block */
- for (i = 1; i <= mon->no_sections; i++)
- if (edid[i * 128] == 0x02)
- break;
- if (i == mon->no_sections + 1)
- return FALSE;
- edid += (i * 128);
-
- version = edid[1];
- offset = edid[2];
- if (version < 3 || offset < 4)
- return FALSE;
-
- /* walk the cea data blocks */
- for (i = 4; i < offset; i += (edid[i] & 0x1f) + 1) {
- char *x = edid + i;
-
- /* find a vendor specific block */
- if ((x[0] & 0xe0) >> 5 == 0x03) {
- int oui = (x[3] << 16) + (x[2] << 8) + x[1];
-
- /* find the HDMI vendor OUI */
- if (oui == 0x000c03)
- return TRUE;
- }
- }
-
- /* guess it's not HDMI after all */
- return FALSE;
+ return xf86MonitorFindHDMIBlock(mon) != NULL;
}
diff --git a/xorg-server/hw/xfree86/ddc/xf86DDC.h b/xorg-server/hw/xfree86/ddc/xf86DDC.h
index bdc7648a9..de8e71831 100644
--- a/xorg-server/hw/xfree86/ddc/xf86DDC.h
+++ b/xorg-server/hw/xfree86/ddc/xf86DDC.h
@@ -98,4 +98,6 @@ typedef void (*handle_video_fn) (struct cea_video_block *, void *);
void xf86ForEachVideoBlock(xf86MonPtr, handle_video_fn, void *);
+struct cea_data_block *xf86MonitorFindHDMIBlock(xf86MonPtr mon);
+
#endif
diff --git a/xorg-server/hw/xfree86/dri/dri.c b/xorg-server/hw/xfree86/dri/dri.c
index 38bfc1def..60339995d 100644
--- a/xorg-server/hw/xfree86/dri/dri.c
+++ b/xorg-server/hw/xfree86/dri/dri.c
@@ -460,14 +460,14 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
/* Add tags for reserved contexts */
if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD,
&reserved_count))) {
- int i;
+ int r;
void *tag;
- for (i = 0; i < reserved_count; i++) {
+ for (r = 0; r < reserved_count; r++) {
tag = DRICreateContextPrivFromHandle(pScreen,
- reserved[i],
+ reserved[r],
DRI_CONTEXT_RESERVED);
- drmAddContextTag(pDRIPriv->drmFD, reserved[i], tag);
+ drmAddContextTag(pDRIPriv->drmFD, reserved[r], tag);
}
drmFreeReservedContextList(reserved);
DRIDrvMsg(pScreen->myNum, X_INFO,
@@ -684,9 +684,9 @@ DRICloseScreen(ScreenPtr pScreen)
pDRIPriv->wrap.ClipNotify = NULL;
}
if (pDRIInfo->wrap.AdjustFrame) {
- ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
+ ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
- pScrn->AdjustFrame = pDRIPriv->wrap.AdjustFrame;
+ scrn->AdjustFrame = pDRIPriv->wrap.AdjustFrame;
pDRIPriv->wrap.AdjustFrame = NULL;
}
diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.c b/xorg-server/hw/xfree86/modes/xf86Crtc.c
index b2eb72e8e..87ba0b74e 100644
--- a/xorg-server/hw/xfree86/modes/xf86Crtc.c
+++ b/xorg-server/hw/xfree86/modes/xf86Crtc.c
@@ -185,10 +185,10 @@ xf86CrtcSetScreenSubpixelOrder(ScreenPtr pScreen)
Bool has_none = FALSE;
ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
- int c, o;
+ int icrtc, o;
- for (c = 0; c < xf86_config->num_crtc; c++) {
- xf86CrtcPtr crtc = xf86_config->crtc[c];
+ for (icrtc = 0; icrtc < xf86_config->num_crtc; icrtc++) {
+ xf86CrtcPtr crtc = xf86_config->crtc[icrtc];
for (o = 0; o < xf86_config->num_output; o++) {
xf86OutputPtr output = xf86_config->output[o];
@@ -216,20 +216,20 @@ xf86CrtcSetScreenSubpixelOrder(ScreenPtr pScreen)
SubPixelVerticalBGR,
};
int rotate;
- int c;
+ int sc;
for (rotate = 0; rotate < 4; rotate++)
if (crtc->rotation & (1 << rotate))
break;
- for (c = 0; c < 4; c++)
- if (circle[c] == subpixel_order)
+ for (sc = 0; sc < 4; sc++)
+ if (circle[sc] == subpixel_order)
break;
- c = (c + rotate) & 0x3;
- if ((crtc->rotation & RR_Reflect_X) && !(c & 1))
- c ^= 2;
- if ((crtc->rotation & RR_Reflect_Y) && (c & 1))
- c ^= 2;
- subpixel_order = circle[c];
+ sc = (sc + rotate) & 0x3;
+ if ((crtc->rotation & RR_Reflect_X) && !(sc & 1))
+ sc ^= 2;
+ if ((crtc->rotation & RR_Reflect_Y) && (sc & 1))
+ sc ^= 2;
+ subpixel_order = circle[sc];
break;
}
}
@@ -1673,6 +1673,7 @@ xf86ProbeOutputModes(ScrnInfoPtr scrn, int maxX, int maxY)
if (edid_monitor) {
struct det_monrec_parameter p;
struct disp_features *features = &edid_monitor->features;
+ struct cea_data_block *hdmi_db;
/* if display is not continuous-frequency, don't add default modes */
if (!GTF_SUPPORTED(features->msc))
@@ -1685,6 +1686,16 @@ xf86ProbeOutputModes(ScrnInfoPtr scrn, int maxX, int maxY)
p.sync_source = &sync_source;
xf86ForEachDetailedBlock(edid_monitor, handle_detailed_monrec, &p);
+
+ /* Look at the CEA HDMI vendor block for the max TMDS freq */
+ hdmi_db = xf86MonitorFindHDMIBlock(edid_monitor);
+ if (hdmi_db && hdmi_db->len >= 7) {
+ int tmds_freq = hdmi_db->u.vendor.hdmi.max_tmds_clock * 5000;
+ xf86DrvMsg(scrn->scrnIndex, X_PROBED,
+ "HDMI max TMDS frequency %dKHz\n", tmds_freq);
+ if (tmds_freq > max_clock)
+ max_clock = tmds_freq;
+ }
}
if (xf86GetOptValFreq(output->options, OPTION_MIN_CLOCK,
@@ -2137,10 +2148,10 @@ xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
}
else {
for (mode = output->probed_modes; mode; mode = mode->next) {
- Rotation r = output->initial_rotation;
+ Rotation ir = output->initial_rotation;
- if (xf86ModeWidth(mode, r) == pref_width &&
- xf86ModeHeight(mode, r) == pref_height) {
+ if (xf86ModeWidth(mode, ir) == pref_width &&
+ xf86ModeHeight(mode, ir) == pref_height) {
preferred[o] = mode;
match = TRUE;
}
diff --git a/xorg-server/hw/xfree86/modes/xf86EdidModes.c b/xorg-server/hw/xfree86/modes/xf86EdidModes.c
index 4ee862da0..a56f6ba23 100644
--- a/xorg-server/hw/xfree86/modes/xf86EdidModes.c
+++ b/xorg-server/hw/xfree86/modes/xf86EdidModes.c
@@ -973,11 +973,11 @@ handle_cea_svd(struct cea_video_block *video, void *data)
}
static DisplayModePtr
-DDCModesFromCEAExtension(int scrnIndex, xf86MonPtr MonPtr)
+DDCModesFromCEAExtension(int scrnIndex, xf86MonPtr mon_ptr)
{
DisplayModePtr Modes = NULL;
- xf86ForEachVideoBlock(MonPtr, handle_cea_svd, &Modes);
+ xf86ForEachVideoBlock(mon_ptr, handle_cea_svd, &Modes);
return Modes;
}
diff --git a/xorg-server/hw/xfree86/modes/xf86RandR12.c b/xorg-server/hw/xfree86/modes/xf86RandR12.c
index f7a7d44d9..66139dcf0 100644
--- a/xorg-server/hw/xfree86/modes/xf86RandR12.c
+++ b/xorg-server/hw/xfree86/modes/xf86RandR12.c
@@ -1202,7 +1202,6 @@ xf86RandR12CrtcSet(ScreenPtr pScreen,
if (randr_mode) {
DisplayModeRec mode;
- RRTransformPtr transform = RRCrtcGetTransform(randr_crtc);
xf86RandRModeConvert(pScrn, randr_mode, &mode);
if (!xf86CrtcSetModeTransform
diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_init.c b/xorg-server/hw/xfree86/os-support/linux/lnx_init.c
index e2e8d0826..46438e655 100644
--- a/xorg-server/hw/xfree86/os-support/linux/lnx_init.c
+++ b/xorg-server/hw/xfree86/os-support/linux/lnx_init.c
@@ -155,6 +155,7 @@ xf86OpenConsole(void)
i = 0;
while (vcs[i] != NULL) {
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
snprintf(vtname, sizeof(vtname), vcs[i], xf86Info.vtno); /* /dev/tty1-64 */
if ((xf86Info.consoleFd = open(vtname, O_RDWR | O_NDELAY, 0)) >= 0)
break;
diff --git a/xorg-server/hw/xfree86/parser/Configint.h b/xorg-server/hw/xfree86/parser/Configint.h
index 62e514201..e85322006 100644
--- a/xorg-server/hw/xfree86/parser/Configint.h
+++ b/xorg-server/hw/xfree86/parser/Configint.h
@@ -79,6 +79,8 @@ typedef struct {
ParserNumType numType; /* used to enforce correct number formatting */
} LexRec, *LexPtr;
+extern LexRec xf86_lex_val;
+
#ifndef TRUE
#define TRUE 1
#endif
diff --git a/xorg-server/hw/xfree86/parser/DRI.c b/xorg-server/hw/xfree86/parser/DRI.c
index e8d26255f..ad053f746 100644
--- a/xorg-server/hw/xfree86/parser/DRI.c
+++ b/xorg-server/hw/xfree86/parser/DRI.c
@@ -35,7 +35,6 @@
#include "xf86tokens.h"
#include "Configint.h"
-extern LexRec val;
static xf86ConfigSymTabRec DRITab[] = {
{ENDSECTION, "endsection"},
@@ -59,24 +58,24 @@ xf86parseDRISection(void)
switch (token) {
case GROUP:
if ((token = xf86getSubToken(&(ptr->dri_comment))) == STRING)
- ptr->dri_group_name = val.str;
+ ptr->dri_group_name = xf86_lex_val.str;
else if (token == NUMBER)
- ptr->dri_group = val.num;
+ ptr->dri_group = xf86_lex_val.num;
else
Error(GROUP_MSG);
break;
case MODE:
if (xf86getSubToken(&(ptr->dri_comment)) != NUMBER)
Error(NUMBER_MSG, "Mode");
- if (val.numType != PARSE_OCTAL)
- Error(MUST_BE_OCTAL_MSG, val.num);
- ptr->dri_mode = val.num;
+ if (xf86_lex_val.numType != PARSE_OCTAL)
+ Error(MUST_BE_OCTAL_MSG, xf86_lex_val.num);
+ ptr->dri_mode = xf86_lex_val.num;
break;
case EOF_TOKEN:
Error(UNEXPECTED_EOF_MSG);
break;
case COMMENT:
- ptr->dri_comment = xf86addComment(ptr->dri_comment, val.str);
+ ptr->dri_comment = xf86addComment(ptr->dri_comment, xf86_lex_val.str);
break;
default:
Error(INVALID_KEYWORD_MSG, xf86tokenString());
diff --git a/xorg-server/hw/xfree86/parser/Device.c b/xorg-server/hw/xfree86/parser/Device.c
index bb1ba88fb..073171f22 100644
--- a/xorg-server/hw/xfree86/parser/Device.c
+++ b/xorg-server/hw/xfree86/parser/Device.c
@@ -60,7 +60,6 @@
#include "xf86tokens.h"
#include "Configint.h"
-extern LexRec val;
static
xf86ConfigSymTabRec DeviceTab[] = {
@@ -107,45 +106,45 @@ xf86parseDeviceSection(void)
while ((token = xf86getToken(DeviceTab)) != ENDSECTION) {
switch (token) {
case COMMENT:
- ptr->dev_comment = xf86addComment(ptr->dev_comment, val.str);
+ ptr->dev_comment = xf86addComment(ptr->dev_comment, xf86_lex_val.str);
break;
case IDENTIFIER:
if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
Error(QUOTE_MSG, "Identifier");
if (has_ident == TRUE)
Error(MULTIPLE_MSG, "Identifier");
- ptr->dev_identifier = val.str;
+ ptr->dev_identifier = xf86_lex_val.str;
has_ident = TRUE;
break;
case VENDOR:
if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
Error(QUOTE_MSG, "Vendor");
- ptr->dev_vendor = val.str;
+ ptr->dev_vendor = xf86_lex_val.str;
break;
case BOARD:
if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
Error(QUOTE_MSG, "Board");
- ptr->dev_board = val.str;
+ ptr->dev_board = xf86_lex_val.str;
break;
case CHIPSET:
if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
Error(QUOTE_MSG, "Chipset");
- ptr->dev_chipset = val.str;
+ ptr->dev_chipset = xf86_lex_val.str;
break;
case CARD:
if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
Error(QUOTE_MSG, "Card");
- ptr->dev_card = val.str;
+ ptr->dev_card = xf86_lex_val.str;
break;
case DRIVER:
if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
Error(QUOTE_MSG, "Driver");
- ptr->dev_driver = val.str;
+ ptr->dev_driver = xf86_lex_val.str;
break;
case RAMDAC:
if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
Error(QUOTE_MSG, "Ramdac");
- ptr->dev_ramdac = val.str;
+ ptr->dev_ramdac = xf86_lex_val.str;
break;
case DACSPEED:
for (i = 0; i < CONF_MAXDACSPEEDS; i++)
@@ -154,11 +153,11 @@ xf86parseDeviceSection(void)
Error(DACSPEED_MSG, CONF_MAXDACSPEEDS);
}
else {
- ptr->dev_dacSpeeds[0] = (int) (val.realnum * 1000.0 + 0.5);
+ ptr->dev_dacSpeeds[0] = (int) (xf86_lex_val.realnum * 1000.0 + 0.5);
for (i = 1; i < CONF_MAXDACSPEEDS; i++) {
if (xf86getSubToken(&(ptr->dev_comment)) == NUMBER)
ptr->dev_dacSpeeds[i] = (int)
- (val.realnum * 1000.0 + 0.5);
+ (xf86_lex_val.realnum * 1000.0 + 0.5);
else {
xf86unGetToken(token);
break;
@@ -169,44 +168,44 @@ xf86parseDeviceSection(void)
case VIDEORAM:
if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
Error(NUMBER_MSG, "VideoRam");
- ptr->dev_videoram = val.num;
+ ptr->dev_videoram = xf86_lex_val.num;
break;
case BIOSBASE:
if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
Error(NUMBER_MSG, "BIOSBase");
- ptr->dev_bios_base = val.num;
+ ptr->dev_bios_base = xf86_lex_val.num;
break;
case MEMBASE:
if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
Error(NUMBER_MSG, "MemBase");
- ptr->dev_mem_base = val.num;
+ ptr->dev_mem_base = xf86_lex_val.num;
break;
case IOBASE:
if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
Error(NUMBER_MSG, "IOBase");
- ptr->dev_io_base = val.num;
+ ptr->dev_io_base = xf86_lex_val.num;
break;
case CLOCKCHIP:
if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
Error(QUOTE_MSG, "ClockChip");
- ptr->dev_clockchip = val.str;
+ ptr->dev_clockchip = xf86_lex_val.str;
break;
case CHIPID:
if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
Error(NUMBER_MSG, "ChipID");
- ptr->dev_chipid = val.num;
+ ptr->dev_chipid = xf86_lex_val.num;
break;
case CHIPREV:
if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
Error(NUMBER_MSG, "ChipRev");
- ptr->dev_chiprev = val.num;
+ ptr->dev_chiprev = xf86_lex_val.num;
break;
case CLOCKS:
token = xf86getSubToken(&(ptr->dev_comment));
for (i = ptr->dev_clocks;
token == NUMBER && i < CONF_MAXCLOCKS; i++) {
- ptr->dev_clock[i] = (int) (val.realnum * 1000.0 + 0.5);
+ ptr->dev_clock[i] = (int) (xf86_lex_val.realnum * 1000.0 + 0.5);
token = xf86getSubToken(&(ptr->dev_comment));
}
ptr->dev_clocks = i;
@@ -215,7 +214,7 @@ xf86parseDeviceSection(void)
case TEXTCLOCKFRQ:
if ((token = xf86getSubToken(&(ptr->dev_comment))) != NUMBER)
Error(NUMBER_MSG, "TextClockFreq");
- ptr->dev_textclockfreq = (int) (val.realnum * 1000.0 + 0.5);
+ ptr->dev_textclockfreq = (int) (xf86_lex_val.realnum * 1000.0 + 0.5);
break;
case OPTION:
ptr->dev_option_lst = xf86parseOption(ptr->dev_option_lst);
@@ -223,17 +222,17 @@ xf86parseDeviceSection(void)
case BUSID:
if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
Error(QUOTE_MSG, "BusID");
- ptr->dev_busid = val.str;
+ ptr->dev_busid = xf86_lex_val.str;
break;
case IRQ:
if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
Error(QUOTE_MSG, "IRQ");
- ptr->dev_irq = val.num;
+ ptr->dev_irq = xf86_lex_val.num;
break;
case SCREEN:
if (xf86getSubToken(&(ptr->dev_comment)) != NUMBER)
Error(NUMBER_MSG, "Screen");
- ptr->dev_screen = val.num;
+ ptr->dev_screen = xf86_lex_val.num;
break;
case EOF_TOKEN:
Error(UNEXPECTED_EOF_MSG);
diff --git a/xorg-server/hw/xfree86/parser/Extensions.c b/xorg-server/hw/xfree86/parser/Extensions.c
index ec0bda4c0..b5ba72e5f 100644
--- a/xorg-server/hw/xfree86/parser/Extensions.c
+++ b/xorg-server/hw/xfree86/parser/Extensions.c
@@ -39,7 +39,6 @@
#include "xf86tokens.h"
#include "Configint.h"
-extern LexRec val;
static xf86ConfigSymTabRec ExtensionsTab[] = {
{ENDSECTION, "endsection"},
@@ -66,7 +65,7 @@ xf86parseExtensionsSection(void)
break;
case COMMENT:
ptr->extensions_comment =
- xf86addComment(ptr->extensions_comment, val.str);
+ xf86addComment(ptr->extensions_comment, xf86_lex_val.str);
break;
default:
Error(INVALID_KEYWORD_MSG, xf86tokenString());
diff --git a/xorg-server/hw/xfree86/parser/Files.c b/xorg-server/hw/xfree86/parser/Files.c
index a6e18dd2c..24940a9c2 100644
--- a/xorg-server/hw/xfree86/parser/Files.c
+++ b/xorg-server/hw/xfree86/parser/Files.c
@@ -60,7 +60,6 @@
#include "xf86tokens.h"
#include "Configint.h"
-extern LexRec val;
static xf86ConfigSymTabRec FilesTab[] = {
{ENDSECTION, "endsection"},
@@ -89,13 +88,13 @@ xf86parseFilesSection(void)
while ((token = xf86getToken(FilesTab)) != ENDSECTION) {
switch (token) {
case COMMENT:
- ptr->file_comment = xf86addComment(ptr->file_comment, val.str);
+ ptr->file_comment = xf86addComment(ptr->file_comment, xf86_lex_val.str);
break;
case FONTPATH:
if (xf86getSubToken(&(ptr->file_comment)) != STRING)
Error(QUOTE_MSG, "FontPath");
j = FALSE;
- str = val.str;
+ str = xf86_lex_val.str;
if (ptr->file_fontpath == NULL) {
ptr->file_fontpath = calloc(1, 1);
i = strlen(str) + 1;
@@ -112,13 +111,13 @@ xf86parseFilesSection(void)
strcat(ptr->file_fontpath, ",");
strcat(ptr->file_fontpath, str);
- free(val.str);
+ free(xf86_lex_val.str);
break;
case MODULEPATH:
if (xf86getSubToken(&(ptr->file_comment)) != STRING)
Error(QUOTE_MSG, "ModulePath");
l = FALSE;
- str = val.str;
+ str = xf86_lex_val.str;
if (ptr->file_modulepath == NULL) {
ptr->file_modulepath = malloc(1);
ptr->file_modulepath[0] = '\0';
@@ -137,17 +136,17 @@ xf86parseFilesSection(void)
strcat(ptr->file_modulepath, ",");
strcat(ptr->file_modulepath, str);
- free(val.str);
+ free(xf86_lex_val.str);
break;
case LOGFILEPATH:
if (xf86getSubToken(&(ptr->file_comment)) != STRING)
Error(QUOTE_MSG, "LogFile");
- ptr->file_logfile = val.str;
+ ptr->file_logfile = xf86_lex_val.str;
break;
case XKBDIR:
if (xf86getSubToken(&(ptr->file_xkbdir)) != STRING)
Error(QUOTE_MSG, "XkbDir");
- ptr->file_xkbdir = val.str;
+ ptr->file_xkbdir = xf86_lex_val.str;
break;
case EOF_TOKEN:
Error(UNEXPECTED_EOF_MSG);
diff --git a/xorg-server/hw/xfree86/parser/Flags.c b/xorg-server/hw/xfree86/parser/Flags.c
index 326c6b77d..71b50acf7 100644
--- a/xorg-server/hw/xfree86/parser/Flags.c
+++ b/xorg-server/hw/xfree86/parser/Flags.c
@@ -62,7 +62,6 @@
#include "Xprintf.h"
#include "optionstr.h"
-extern LexRec val;
static xf86ConfigSymTabRec ServerFlagsTab[] = {
{ENDSECTION, "endsection"},
@@ -99,7 +98,7 @@ xf86parseFlagsSection(void)
switch (token) {
case COMMENT:
- ptr->flg_comment = xf86addComment(ptr->flg_comment, val.str);
+ ptr->flg_comment = xf86addComment(ptr->flg_comment, xf86_lex_val.str);
break;
/*
* these old keywords are turned into standard generic options.
@@ -135,12 +134,12 @@ xf86parseFlagsSection(void)
if (strvalue) {
if (tokentype != STRING)
Error(QUOTE_MSG, tmp);
- valstr = val.str;
+ valstr = xf86_lex_val.str;
}
else {
if (tokentype != NUMBER)
Error(NUMBER_MSG, tmp);
- if (asprintf(&valstr, "%d", val.num) == -1)
+ if (asprintf(&valstr, "%d", xf86_lex_val.num) == -1)
valstr = NULL;
}
}
@@ -435,12 +434,12 @@ xf86parseOption(XF86OptionPtr head)
return head;
}
- name = val.str;
+ name = xf86_lex_val.str;
if ((token = xf86getSubToken(&comment)) == STRING) {
- option = xf86newOption(name, val.str);
+ option = xf86newOption(name, xf86_lex_val.str);
option->opt_comment = comment;
if ((token = xf86getToken(NULL)) == COMMENT)
- option->opt_comment = xf86addComment(option->opt_comment, val.str);
+ option->opt_comment = xf86addComment(option->opt_comment, xf86_lex_val.str);
else
xf86unGetToken(token);
}
@@ -448,7 +447,7 @@ xf86parseOption(XF86OptionPtr head)
option = xf86newOption(name, NULL);
option->opt_comment = comment;
if (token == COMMENT)
- option->opt_comment = xf86addComment(option->opt_comment, val.str);
+ option->opt_comment = xf86addComment(option->opt_comment, xf86_lex_val.str);
else
xf86unGetToken(token);
}
diff --git a/xorg-server/hw/xfree86/parser/Input.c b/xorg-server/hw/xfree86/parser/Input.c
index ff2b9acbc..1bfe5c100 100644
--- a/xorg-server/hw/xfree86/parser/Input.c
+++ b/xorg-server/hw/xfree86/parser/Input.c
@@ -61,7 +61,6 @@
#include "xf86tokens.h"
#include "Configint.h"
-extern LexRec val;
static
xf86ConfigSymTabRec InputTab[] = {
@@ -85,25 +84,25 @@ xf86parseInputSection(void)
while ((token = xf86getToken(InputTab)) != ENDSECTION) {
switch (token) {
case COMMENT:
- ptr->inp_comment = xf86addComment(ptr->inp_comment, val.str);
+ ptr->inp_comment = xf86addComment(ptr->inp_comment, xf86_lex_val.str);
break;
case IDENTIFIER:
if (xf86getSubToken(&(ptr->inp_comment)) != STRING)
Error(QUOTE_MSG, "Identifier");
if (has_ident == TRUE)
Error(MULTIPLE_MSG, "Identifier");
- ptr->inp_identifier = val.str;
+ ptr->inp_identifier = xf86_lex_val.str;
has_ident = TRUE;
break;
case DRIVER:
if (xf86getSubToken(&(ptr->inp_comment)) != STRING)
Error(QUOTE_MSG, "Driver");
- if (strcmp(val.str, "keyboard") == 0) {
+ if (strcmp(xf86_lex_val.str, "keyboard") == 0) {
ptr->inp_driver = strdup("kbd");
- free(val.str);
+ free(xf86_lex_val.str);
}
else
- ptr->inp_driver = val.str;
+ ptr->inp_driver = xf86_lex_val.str;
break;
case OPTION:
ptr->inp_option_lst = xf86parseOption(ptr->inp_option_lst);
diff --git a/xorg-server/hw/xfree86/parser/InputClass.c b/xorg-server/hw/xfree86/parser/InputClass.c
index a7f573e70..24a124691 100644
--- a/xorg-server/hw/xfree86/parser/InputClass.c
+++ b/xorg-server/hw/xfree86/parser/InputClass.c
@@ -33,7 +33,6 @@
#include "xf86tokens.h"
#include "Configint.h"
-extern LexRec val;
static
xf86ConfigSymTabRec InputClassTab[] = {
@@ -97,25 +96,25 @@ xf86parseInputClassSection(void)
while ((token = xf86getToken(InputClassTab)) != ENDSECTION) {
switch (token) {
case COMMENT:
- ptr->comment = xf86addComment(ptr->comment, val.str);
+ ptr->comment = xf86addComment(ptr->comment, xf86_lex_val.str);
break;
case IDENTIFIER:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "Identifier");
if (has_ident == TRUE)
Error(MULTIPLE_MSG, "Identifier");
- ptr->identifier = val.str;
+ ptr->identifier = xf86_lex_val.str;
has_ident = TRUE;
break;
case DRIVER:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "Driver");
- if (strcmp(val.str, "keyboard") == 0) {
+ if (strcmp(xf86_lex_val.str, "keyboard") == 0) {
ptr->driver = strdup("kbd");
- free(val.str);
+ free(xf86_lex_val.str);
}
else
- ptr->driver = val.str;
+ ptr->driver = xf86_lex_val.str;
break;
case OPTION:
ptr->option_lst = xf86parseOption(ptr->option_lst);
@@ -124,69 +123,69 @@ xf86parseInputClassSection(void)
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchProduct");
add_group_entry(&ptr->match_product,
- xstrtokenize(val.str, TOKEN_SEP));
- free(val.str);
+ xstrtokenize(xf86_lex_val.str, TOKEN_SEP));
+ free(xf86_lex_val.str);
break;
case MATCH_VENDOR:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchVendor");
add_group_entry(&ptr->match_vendor,
- xstrtokenize(val.str, TOKEN_SEP));
- free(val.str);
+ xstrtokenize(xf86_lex_val.str, TOKEN_SEP));
+ free(xf86_lex_val.str);
break;
case MATCH_DEVICE_PATH:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchDevicePath");
add_group_entry(&ptr->match_device,
- xstrtokenize(val.str, TOKEN_SEP));
- free(val.str);
+ xstrtokenize(xf86_lex_val.str, TOKEN_SEP));
+ free(xf86_lex_val.str);
break;
case MATCH_OS:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchOS");
- add_group_entry(&ptr->match_os, xstrtokenize(val.str, TOKEN_SEP));
- free(val.str);
+ add_group_entry(&ptr->match_os, xstrtokenize(xf86_lex_val.str, TOKEN_SEP));
+ free(xf86_lex_val.str);
break;
case MATCH_PNPID:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchPnPID");
add_group_entry(&ptr->match_pnpid,
- xstrtokenize(val.str, TOKEN_SEP));
- free(val.str);
+ xstrtokenize(xf86_lex_val.str, TOKEN_SEP));
+ free(xf86_lex_val.str);
break;
case MATCH_USBID:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchUSBID");
add_group_entry(&ptr->match_usbid,
- xstrtokenize(val.str, TOKEN_SEP));
- free(val.str);
+ xstrtokenize(xf86_lex_val.str, TOKEN_SEP));
+ free(xf86_lex_val.str);
break;
case MATCH_DRIVER:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchDriver");
add_group_entry(&ptr->match_driver,
- xstrtokenize(val.str, TOKEN_SEP));
- free(val.str);
+ xstrtokenize(xf86_lex_val.str, TOKEN_SEP));
+ free(xf86_lex_val.str);
break;
case MATCH_TAG:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchTag");
- add_group_entry(&ptr->match_tag, xstrtokenize(val.str, TOKEN_SEP));
- free(val.str);
+ add_group_entry(&ptr->match_tag, xstrtokenize(xf86_lex_val.str, TOKEN_SEP));
+ free(xf86_lex_val.str);
break;
case MATCH_LAYOUT:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchLayout");
add_group_entry(&ptr->match_layout,
- xstrtokenize(val.str, TOKEN_SEP));
- free(val.str);
+ xstrtokenize(xf86_lex_val.str, TOKEN_SEP));
+ free(xf86_lex_val.str);
break;
case MATCH_IS_KEYBOARD:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchIsKeyboard");
ptr->is_keyboard.set = xf86getBoolValue(&ptr->is_keyboard.val,
- val.str);
- free(val.str);
+ xf86_lex_val.str);
+ free(xf86_lex_val.str);
if (!ptr->is_keyboard.set)
Error(BOOL_MSG, "MatchIsKeyboard");
break;
@@ -194,8 +193,8 @@ xf86parseInputClassSection(void)
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchIsPointer");
ptr->is_pointer.set = xf86getBoolValue(&ptr->is_pointer.val,
- val.str);
- free(val.str);
+ xf86_lex_val.str);
+ free(xf86_lex_val.str);
if (!ptr->is_pointer.set)
Error(BOOL_MSG, "MatchIsPointer");
break;
@@ -203,16 +202,16 @@ xf86parseInputClassSection(void)
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchIsJoystick");
ptr->is_joystick.set = xf86getBoolValue(&ptr->is_joystick.val,
- val.str);
- free(val.str);
+ xf86_lex_val.str);
+ free(xf86_lex_val.str);
if (!ptr->is_joystick.set)
Error(BOOL_MSG, "MatchIsJoystick");
break;
case MATCH_IS_TABLET:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchIsTablet");
- ptr->is_tablet.set = xf86getBoolValue(&ptr->is_tablet.val, val.str);
- free(val.str);
+ ptr->is_tablet.set = xf86getBoolValue(&ptr->is_tablet.val, xf86_lex_val.str);
+ free(xf86_lex_val.str);
if (!ptr->is_tablet.set)
Error(BOOL_MSG, "MatchIsTablet");
break;
@@ -220,8 +219,8 @@ xf86parseInputClassSection(void)
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchIsTouchpad");
ptr->is_touchpad.set = xf86getBoolValue(&ptr->is_touchpad.val,
- val.str);
- free(val.str);
+ xf86_lex_val.str);
+ free(xf86_lex_val.str);
if (!ptr->is_touchpad.set)
Error(BOOL_MSG, "MatchIsTouchpad");
break;
@@ -229,8 +228,8 @@ xf86parseInputClassSection(void)
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchIsTouchscreen");
ptr->is_touchscreen.set = xf86getBoolValue(&ptr->is_touchscreen.val,
- val.str);
- free(val.str);
+ xf86_lex_val.str);
+ free(xf86_lex_val.str);
if (!ptr->is_touchscreen.set)
Error(BOOL_MSG, "MatchIsTouchscreen");
break;
diff --git a/xorg-server/hw/xfree86/parser/Layout.c b/xorg-server/hw/xfree86/parser/Layout.c
index cbd8d247a..7be746f04 100644
--- a/xorg-server/hw/xfree86/parser/Layout.c
+++ b/xorg-server/hw/xfree86/parser/Layout.c
@@ -65,7 +65,6 @@
/* Needed for auto server layout */
extern int xf86CheckBoolOption(void *optlist, const char *name, int deflt);
-extern LexRec val;
static xf86ConfigSymTabRec LayoutTab[] = {
{ENDSECTION, "endsection"},
@@ -100,14 +99,14 @@ xf86parseLayoutSection(void)
while ((token = xf86getToken(LayoutTab)) != ENDSECTION) {
switch (token) {
case COMMENT:
- ptr->lay_comment = xf86addComment(ptr->lay_comment, val.str);
+ ptr->lay_comment = xf86addComment(ptr->lay_comment, xf86_lex_val.str);
break;
case IDENTIFIER:
if (xf86getSubToken(&(ptr->lay_comment)) != STRING)
Error(QUOTE_MSG, "Identifier");
if (has_ident == TRUE)
Error(MULTIPLE_MSG, "Identifier");
- ptr->lay_identifier = val.str;
+ ptr->lay_identifier = xf86_lex_val.str;
has_ident = TRUE;
break;
case INACTIVE:
@@ -120,7 +119,7 @@ xf86parseLayoutSection(void)
free(iptr);
Error(INACTIVE_MSG);
}
- iptr->inactive_device_str = val.str;
+ iptr->inactive_device_str = xf86_lex_val.str;
ptr->lay_inactive_lst = (XF86ConfInactivePtr)
xf86addListItem((glp) ptr->lay_inactive_lst, (glp) iptr);
}
@@ -138,7 +137,7 @@ xf86parseLayoutSection(void)
aptr->adj_y = 0;
aptr->adj_refscreen = NULL;
if ((token = xf86getSubToken(&(ptr->lay_comment))) == NUMBER)
- aptr->adj_scrnum = val.num;
+ aptr->adj_scrnum = xf86_lex_val.num;
else
xf86unGetToken(token);
token = xf86getSubToken(&(ptr->lay_comment));
@@ -146,7 +145,7 @@ xf86parseLayoutSection(void)
free(aptr);
Error(SCREEN_MSG);
}
- aptr->adj_screen_str = val.str;
+ aptr->adj_screen_str = xf86_lex_val.str;
token = xf86getSubTokenWithTab(&(ptr->lay_comment), AdjTab);
switch (token) {
@@ -186,13 +185,13 @@ xf86parseLayoutSection(void)
if (absKeyword)
token = xf86getSubToken(&(ptr->lay_comment));
if (token == NUMBER) {
- aptr->adj_x = val.num;
+ aptr->adj_x = xf86_lex_val.num;
token = xf86getSubToken(&(ptr->lay_comment));
if (token != NUMBER) {
free(aptr);
Error(INVALID_SCR_MSG);
}
- aptr->adj_y = val.num;
+ aptr->adj_y = xf86_lex_val.num;
}
else {
if (absKeyword) {
@@ -213,46 +212,46 @@ xf86parseLayoutSection(void)
free(aptr);
Error(INVALID_SCR_MSG);
}
- aptr->adj_refscreen = val.str;
+ aptr->adj_refscreen = xf86_lex_val.str;
if (aptr->adj_where == CONF_ADJ_RELATIVE) {
token = xf86getSubToken(&(ptr->lay_comment));
if (token != NUMBER) {
free(aptr);
Error(INVALID_SCR_MSG);
}
- aptr->adj_x = val.num;
+ aptr->adj_x = xf86_lex_val.num;
token = xf86getSubToken(&(ptr->lay_comment));
if (token != NUMBER) {
free(aptr);
Error(INVALID_SCR_MSG);
}
- aptr->adj_y = val.num;
+ aptr->adj_y = xf86_lex_val.num;
}
break;
case CONF_ADJ_OBSOLETE:
/* top */
- aptr->adj_top_str = val.str;
+ aptr->adj_top_str = xf86_lex_val.str;
/* bottom */
if (xf86getSubToken(&(ptr->lay_comment)) != STRING) {
free(aptr);
Error(SCREEN_MSG);
}
- aptr->adj_bottom_str = val.str;
+ aptr->adj_bottom_str = xf86_lex_val.str;
/* left */
if (xf86getSubToken(&(ptr->lay_comment)) != STRING) {
free(aptr);
Error(SCREEN_MSG);
}
- aptr->adj_left_str = val.str;
+ aptr->adj_left_str = xf86_lex_val.str;
/* right */
if (xf86getSubToken(&(ptr->lay_comment)) != STRING) {
free(aptr);
Error(SCREEN_MSG);
}
- aptr->adj_right_str = val.str;
+ aptr->adj_right_str = xf86_lex_val.str;
}
ptr->lay_adjacency_lst = (XF86ConfAdjacencyPtr)
@@ -270,10 +269,10 @@ xf86parseLayoutSection(void)
free(iptr);
Error(INPUTDEV_MSG);
}
- iptr->iref_inputdev_str = val.str;
+ iptr->iref_inputdev_str = xf86_lex_val.str;
while ((token = xf86getSubToken(&(ptr->lay_comment))) == STRING) {
iptr->iref_option_lst =
- xf86addNewOption(iptr->iref_option_lst, val.str, NULL);
+ xf86addNewOption(iptr->iref_option_lst, xf86_lex_val.str, NULL);
}
xf86unGetToken(token);
ptr->lay_input_lst = (XF86ConfInputrefPtr)
diff --git a/xorg-server/hw/xfree86/parser/Module.c b/xorg-server/hw/xfree86/parser/Module.c
index 243ba9195..e2d9120cb 100644
--- a/xorg-server/hw/xfree86/parser/Module.c
+++ b/xorg-server/hw/xfree86/parser/Module.c
@@ -60,7 +60,6 @@
#include "xf86tokens.h"
#include "Configint.h"
-extern LexRec val;
static xf86ConfigSymTabRec SubModuleTab[] = {
{ENDSUBSECTION, "endsubsection"},
@@ -95,7 +94,7 @@ xf86parseModuleSubSection(XF86LoadPtr head, char *name)
while ((token = xf86getToken(SubModuleTab)) != ENDSUBSECTION) {
switch (token) {
case COMMENT:
- ptr->load_comment = xf86addComment(ptr->load_comment, val.str);
+ ptr->load_comment = xf86addComment(ptr->load_comment, xf86_lex_val.str);
break;
case OPTION:
ptr->load_opt = xf86parseOption(ptr->load_opt);
@@ -126,34 +125,34 @@ xf86parseModuleSection(void)
while ((token = xf86getToken(ModuleTab)) != ENDSECTION) {
switch (token) {
case COMMENT:
- ptr->mod_comment = xf86addComment(ptr->mod_comment, val.str);
+ ptr->mod_comment = xf86addComment(ptr->mod_comment, xf86_lex_val.str);
break;
case LOAD:
if (xf86getSubToken(&(ptr->mod_comment)) != STRING)
Error(QUOTE_MSG, "Load");
ptr->mod_load_lst =
- xf86addNewLoadDirective(ptr->mod_load_lst, val.str,
+ xf86addNewLoadDirective(ptr->mod_load_lst, xf86_lex_val.str,
XF86_LOAD_MODULE, NULL);
break;
case DISABLE:
if (xf86getSubToken(&(ptr->mod_comment)) != STRING)
Error(QUOTE_MSG, "Disable");
ptr->mod_disable_lst =
- xf86addNewLoadDirective(ptr->mod_disable_lst, val.str,
+ xf86addNewLoadDirective(ptr->mod_disable_lst, xf86_lex_val.str,
XF86_DISABLE_MODULE, NULL);
break;
case LOAD_DRIVER:
if (xf86getSubToken(&(ptr->mod_comment)) != STRING)
Error(QUOTE_MSG, "LoadDriver");
ptr->mod_load_lst =
- xf86addNewLoadDirective(ptr->mod_load_lst, val.str,
+ xf86addNewLoadDirective(ptr->mod_load_lst, xf86_lex_val.str,
XF86_LOAD_DRIVER, NULL);
break;
case SUBSECTION:
if (xf86getSubToken(&(ptr->mod_comment)) != STRING)
Error(QUOTE_MSG, "SubSection");
ptr->mod_load_lst =
- xf86parseModuleSubSection(ptr->mod_load_lst, val.str);
+ xf86parseModuleSubSection(ptr->mod_load_lst, xf86_lex_val.str);
break;
case EOF_TOKEN:
Error(UNEXPECTED_EOF_MSG);
@@ -232,7 +231,7 @@ xf86addNewLoadDirective(XF86LoadPtr head, const char *name, int type,
new->list.next = NULL;
if ((token = xf86getToken(NULL)) == COMMENT)
- new->load_comment = xf86addComment(new->load_comment, val.str);
+ new->load_comment = xf86addComment(new->load_comment, xf86_lex_val.str);
else
xf86unGetToken(token);
diff --git a/xorg-server/hw/xfree86/parser/Monitor.c b/xorg-server/hw/xfree86/parser/Monitor.c
index 36b4ebe35..8aebce079 100644
--- a/xorg-server/hw/xfree86/parser/Monitor.c
+++ b/xorg-server/hw/xfree86/parser/Monitor.c
@@ -60,7 +60,6 @@
#include "xf86tokens.h"
#include "Configint.h"
-extern LexRec val;
static xf86ConfigSymTabRec MonitorTab[] = {
{ENDSECTION, "endsection"},
@@ -140,52 +139,52 @@ xf86parseModeLine(void)
/* Identifier */
if (xf86getSubToken(&(ptr->ml_comment)) != STRING)
Error("ModeLine identifier expected");
- ptr->ml_identifier = val.str;
+ ptr->ml_identifier = xf86_lex_val.str;
/* DotClock */
if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
Error("ModeLine dotclock expected");
- ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5);
+ ptr->ml_clock = (int) (xf86_lex_val.realnum * 1000.0 + 0.5);
/* HDisplay */
if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
Error("ModeLine Hdisplay expected");
- ptr->ml_hdisplay = val.num;
+ ptr->ml_hdisplay = xf86_lex_val.num;
/* HSyncStart */
if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
Error("ModeLine HSyncStart expected");
- ptr->ml_hsyncstart = val.num;
+ ptr->ml_hsyncstart = xf86_lex_val.num;
/* HSyncEnd */
if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
Error("ModeLine HSyncEnd expected");
- ptr->ml_hsyncend = val.num;
+ ptr->ml_hsyncend = xf86_lex_val.num;
/* HTotal */
if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
Error("ModeLine HTotal expected");
- ptr->ml_htotal = val.num;
+ ptr->ml_htotal = xf86_lex_val.num;
/* VDisplay */
if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
Error("ModeLine Vdisplay expected");
- ptr->ml_vdisplay = val.num;
+ ptr->ml_vdisplay = xf86_lex_val.num;
/* VSyncStart */
if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
Error("ModeLine VSyncStart expected");
- ptr->ml_vsyncstart = val.num;
+ ptr->ml_vsyncstart = xf86_lex_val.num;
/* VSyncEnd */
if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
Error("ModeLine VSyncEnd expected");
- ptr->ml_vsyncend = val.num;
+ ptr->ml_vsyncend = xf86_lex_val.num;
/* VTotal */
if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
Error("ModeLine VTotal expected");
- ptr->ml_vtotal = val.num;
+ ptr->ml_vtotal = xf86_lex_val.num;
token = xf86getSubTokenWithTab(&(ptr->ml_comment), TimingTab);
while ((token == TT_INTERLACE) || (token == TT_PHSYNC) ||
@@ -226,7 +225,7 @@ xf86parseModeLine(void)
case TT_HSKEW:
if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
Error(NUMBER_MSG, "Hskew");
- ptr->ml_hskew = val.num;
+ ptr->ml_hskew = xf86_lex_val.num;
ptr->ml_flags |= XF86CONF_HSKEW;
break;
case TT_BCAST:
@@ -235,7 +234,7 @@ xf86parseModeLine(void)
case TT_VSCAN:
if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
Error(NUMBER_MSG, "Vscan");
- ptr->ml_vscan = val.num;
+ ptr->ml_vscan = xf86_lex_val.num;
ptr->ml_flags |= XF86CONF_VSCAN;
break;
case EOF_TOKEN:
@@ -265,58 +264,58 @@ xf86parseVerboseMode(void)
if (xf86getSubToken(&(ptr->ml_comment)) != STRING)
Error("Mode name expected");
- ptr->ml_identifier = val.str;
+ ptr->ml_identifier = xf86_lex_val.str;
while ((token = xf86getToken(ModeTab)) != ENDMODE) {
switch (token) {
case COMMENT:
- ptr->ml_comment = xf86addComment(ptr->ml_comment, val.str);
+ ptr->ml_comment = xf86addComment(ptr->ml_comment, xf86_lex_val.str);
break;
case DOTCLOCK:
if ((token = xf86getSubToken(&(ptr->ml_comment))) != NUMBER)
Error(NUMBER_MSG, "DotClock");
- ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5);
+ ptr->ml_clock = (int) (xf86_lex_val.realnum * 1000.0 + 0.5);
had_dotclock = 1;
break;
case HTIMINGS:
if (xf86getSubToken(&(ptr->ml_comment)) == NUMBER)
- ptr->ml_hdisplay = val.num;
+ ptr->ml_hdisplay = xf86_lex_val.num;
else
Error("Horizontal display expected");
if (xf86getSubToken(&(ptr->ml_comment)) == NUMBER)
- ptr->ml_hsyncstart = val.num;
+ ptr->ml_hsyncstart = xf86_lex_val.num;
else
Error("Horizontal sync start expected");
if (xf86getSubToken(&(ptr->ml_comment)) == NUMBER)
- ptr->ml_hsyncend = val.num;
+ ptr->ml_hsyncend = xf86_lex_val.num;
else
Error("Horizontal sync end expected");
if (xf86getSubToken(&(ptr->ml_comment)) == NUMBER)
- ptr->ml_htotal = val.num;
+ ptr->ml_htotal = xf86_lex_val.num;
else
Error("Horizontal total expected");
had_htimings = 1;
break;
case VTIMINGS:
if (xf86getSubToken(&(ptr->ml_comment)) == NUMBER)
- ptr->ml_vdisplay = val.num;
+ ptr->ml_vdisplay = xf86_lex_val.num;
else
Error("Vertical display expected");
if (xf86getSubToken(&(ptr->ml_comment)) == NUMBER)
- ptr->ml_vsyncstart = val.num;
+ ptr->ml_vsyncstart = xf86_lex_val.num;
else
Error("Vertical sync start expected");
if (xf86getSubToken(&(ptr->ml_comment)) == NUMBER)
- ptr->ml_vsyncend = val.num;
+ ptr->ml_vsyncend = xf86_lex_val.num;
else
Error("Vertical sync end expected");
if (xf86getSubToken(&(ptr->ml_comment)) == NUMBER)
- ptr->ml_vtotal = val.num;
+ ptr->ml_vtotal = xf86_lex_val.num;
else
Error("Vertical total expected");
had_vtimings = 1;
@@ -370,13 +369,13 @@ xf86parseVerboseMode(void)
if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
Error("Horizontal skew expected");
ptr->ml_flags |= XF86CONF_HSKEW;
- ptr->ml_hskew = val.num;
+ ptr->ml_hskew = xf86_lex_val.num;
break;
case VSCAN:
if (xf86getSubToken(&(ptr->ml_comment)) != NUMBER)
Error("Vertical scan count expected");
ptr->ml_flags |= XF86CONF_VSCAN;
- ptr->ml_vscan = val.num;
+ ptr->ml_vscan = xf86_lex_val.num;
break;
case EOF_TOKEN:
Error(UNEXPECTED_EOF_MSG);
@@ -413,25 +412,25 @@ xf86parseMonitorSection(void)
while ((token = xf86getToken(MonitorTab)) != ENDSECTION) {
switch (token) {
case COMMENT:
- ptr->mon_comment = xf86addComment(ptr->mon_comment, val.str);
+ ptr->mon_comment = xf86addComment(ptr->mon_comment, xf86_lex_val.str);
break;
case IDENTIFIER:
if (xf86getSubToken(&(ptr->mon_comment)) != STRING)
Error(QUOTE_MSG, "Identifier");
if (has_ident == TRUE)
Error(MULTIPLE_MSG, "Identifier");
- ptr->mon_identifier = val.str;
+ ptr->mon_identifier = xf86_lex_val.str;
has_ident = TRUE;
break;
case VENDOR:
if (xf86getSubToken(&(ptr->mon_comment)) != STRING)
Error(QUOTE_MSG, "Vendor");
- ptr->mon_vendor = val.str;
+ ptr->mon_vendor = xf86_lex_val.str;
break;
case MODEL:
if (xf86getSubToken(&(ptr->mon_comment)) != STRING)
Error(QUOTE_MSG, "ModelName");
- ptr->mon_modelname = val.str;
+ ptr->mon_modelname = xf86_lex_val.str;
break;
case MODE:
HANDLE_LIST(mon_modeline_lst, xf86parseVerboseMode,
@@ -444,10 +443,10 @@ xf86parseMonitorSection(void)
case DISPLAYSIZE:
if (xf86getSubToken(&(ptr->mon_comment)) != NUMBER)
Error(DISPLAYSIZE_MSG);
- ptr->mon_width = val.realnum;
+ ptr->mon_width = xf86_lex_val.realnum;
if (xf86getSubToken(&(ptr->mon_comment)) != NUMBER)
Error(DISPLAYSIZE_MSG);
- ptr->mon_height = val.realnum;
+ ptr->mon_height = xf86_lex_val.realnum;
break;
case HORIZSYNC:
@@ -456,7 +455,7 @@ xf86parseMonitorSection(void)
do {
if (ptr->mon_n_hsync >= CONF_MAX_HSYNC)
Error("Sorry. Too many horizontal sync intervals.");
- ptr->mon_hsync[ptr->mon_n_hsync].lo = val.realnum;
+ ptr->mon_hsync[ptr->mon_n_hsync].lo = xf86_lex_val.realnum;
switch (token = xf86getSubToken(&(ptr->mon_comment))) {
case COMMA:
ptr->mon_hsync[ptr->mon_n_hsync].hi =
@@ -464,10 +463,10 @@ xf86parseMonitorSection(void)
break;
case DASH:
if (xf86getSubToken(&(ptr->mon_comment)) != NUMBER ||
- (float) val.realnum <
+ (float) xf86_lex_val.realnum <
ptr->mon_hsync[ptr->mon_n_hsync].lo)
Error(HORIZSYNC_MSG);
- ptr->mon_hsync[ptr->mon_n_hsync].hi = val.realnum;
+ ptr->mon_hsync[ptr->mon_n_hsync].hi = xf86_lex_val.realnum;
if ((token = xf86getSubToken(&(ptr->mon_comment))) == COMMA)
break;
ptr->mon_n_hsync++;
@@ -491,7 +490,7 @@ xf86parseMonitorSection(void)
if (xf86getSubToken(&(ptr->mon_comment)) != NUMBER)
Error(VERTREFRESH_MSG);
do {
- ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo = val.realnum;
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo = xf86_lex_val.realnum;
switch (token = xf86getSubToken(&(ptr->mon_comment))) {
case COMMA:
ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi =
@@ -499,10 +498,10 @@ xf86parseMonitorSection(void)
break;
case DASH:
if (xf86getSubToken(&(ptr->mon_comment)) != NUMBER ||
- (float) val.realnum <
+ (float) xf86_lex_val.realnum <
ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo)
Error(VERTREFRESH_MSG);
- ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = val.realnum;
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = xf86_lex_val.realnum;
if ((token = xf86getSubToken(&(ptr->mon_comment))) == COMMA)
break;
ptr->mon_n_vrefresh++;
@@ -530,11 +529,11 @@ xf86parseMonitorSection(void)
}
else {
ptr->mon_gamma_red = ptr->mon_gamma_green =
- ptr->mon_gamma_blue = val.realnum;
+ ptr->mon_gamma_blue = xf86_lex_val.realnum;
if (xf86getSubToken(&(ptr->mon_comment)) == NUMBER) {
- ptr->mon_gamma_green = val.realnum;
+ ptr->mon_gamma_green = xf86_lex_val.realnum;
if (xf86getSubToken(&(ptr->mon_comment)) == NUMBER) {
- ptr->mon_gamma_blue = val.realnum;
+ ptr->mon_gamma_blue = xf86_lex_val.realnum;
}
else {
Error(INVALID_GAMMA_MSG);
@@ -558,7 +557,7 @@ xf86parseMonitorSection(void)
referenced here */
mptr = calloc(1, sizeof(XF86ConfModesLinkRec));
mptr->list.next = NULL;
- mptr->ml_modes_str = val.str;
+ mptr->ml_modes_str = xf86_lex_val.str;
mptr->ml_modes = NULL;
ptr->mon_modes_sect_lst = (XF86ConfModesLinkPtr)
xf86addListItem((GenericListPtr) ptr->mon_modes_sect_lst,
@@ -599,14 +598,14 @@ xf86parseModesSection(void)
while ((token = xf86getToken(ModesTab)) != ENDSECTION) {
switch (token) {
case COMMENT:
- ptr->modes_comment = xf86addComment(ptr->modes_comment, val.str);
+ ptr->modes_comment = xf86addComment(ptr->modes_comment, xf86_lex_val.str);
break;
case IDENTIFIER:
if (xf86getSubToken(&(ptr->modes_comment)) != STRING)
Error(QUOTE_MSG, "Identifier");
if (has_ident == TRUE)
Error(MULTIPLE_MSG, "Identifier");
- ptr->modes_identifier = val.str;
+ ptr->modes_identifier = xf86_lex_val.str;
has_ident = TRUE;
break;
case MODE:
diff --git a/xorg-server/hw/xfree86/parser/Pointer.c b/xorg-server/hw/xfree86/parser/Pointer.c
index ff748d99a..fe60d95aa 100644
--- a/xorg-server/hw/xfree86/parser/Pointer.c
+++ b/xorg-server/hw/xfree86/parser/Pointer.c
@@ -61,7 +61,6 @@
#include "Configint.h"
#include "Xprintf.h"
-extern LexRec val;
static xf86ConfigSymTabRec PointerTab[] = {
{PROTOCOL, "protocol"},
@@ -104,19 +103,19 @@ xf86parsePointerSection(void)
while ((token = xf86getToken(PointerTab)) != ENDSECTION) {
switch (token) {
case COMMENT:
- ptr->inp_comment = xf86addComment(ptr->inp_comment, val.str);
+ ptr->inp_comment = xf86addComment(ptr->inp_comment, xf86_lex_val.str);
break;
case PROTOCOL:
if (xf86getSubToken(&(ptr->inp_comment)) != STRING)
Error(QUOTE_MSG, "Protocol");
ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
- strdup("Protocol"), val.str);
+ strdup("Protocol"), xf86_lex_val.str);
break;
case PDEVICE:
if (xf86getSubToken(&(ptr->inp_comment)) != STRING)
Error(QUOTE_MSG, "Device");
ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
- strdup("Device"), val.str);
+ strdup("Device"), xf86_lex_val.str);
break;
case EMULATE3:
ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
@@ -124,9 +123,9 @@ xf86parsePointerSection(void)
NULL);
break;
case EM3TIMEOUT:
- if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || val.num < 0)
+ if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || xf86_lex_val.num < 0)
Error(POSITIVE_INT_MSG, "Emulate3Timeout");
- s = xf86uLongToString(val.num);
+ s = xf86uLongToString(xf86_lex_val.num);
ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
strdup("Emulate3Timeout"),
s);
@@ -136,30 +135,30 @@ xf86parsePointerSection(void)
strdup("ChordMiddle"), NULL);
break;
case PBUTTONS:
- if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || val.num < 0)
+ if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || xf86_lex_val.num < 0)
Error(POSITIVE_INT_MSG, "Buttons");
- s = xf86uLongToString(val.num);
+ s = xf86uLongToString(xf86_lex_val.num);
ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
strdup("Buttons"), s);
break;
case BAUDRATE:
- if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || val.num < 0)
+ if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || xf86_lex_val.num < 0)
Error(POSITIVE_INT_MSG, "BaudRate");
- s = xf86uLongToString(val.num);
+ s = xf86uLongToString(xf86_lex_val.num);
ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
strdup("BaudRate"), s);
break;
case SAMPLERATE:
- if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || val.num < 0)
+ if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || xf86_lex_val.num < 0)
Error(POSITIVE_INT_MSG, "SampleRate");
- s = xf86uLongToString(val.num);
+ s = xf86uLongToString(xf86_lex_val.num);
ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
strdup("SampleRate"), s);
break;
case PRESOLUTION:
- if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || val.num < 0)
+ if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER || xf86_lex_val.num < 0)
Error(POSITIVE_INT_MSG, "Resolution");
- s = xf86uLongToString(val.num);
+ s = xf86uLongToString(xf86_lex_val.num);
ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
strdup("Resolution"), s);
break;
@@ -174,14 +173,14 @@ xf86parsePointerSection(void)
case ZAXISMAPPING:
switch (xf86getToken(ZMapTab)) {
case NUMBER:
- if (val.num < 0)
+ if (xf86_lex_val.num < 0)
Error(ZAXISMAPPING_MSG);
- val1 = val.num;
+ val1 = xf86_lex_val.num;
if (xf86getSubToken(&(ptr->inp_comment)) != NUMBER ||
- val.num < 0) {
+ xf86_lex_val.num < 0) {
Error(ZAXISMAPPING_MSG);
}
- if (asprintf(&s, "%lu %u", val1, val.num) == -1)
+ if (asprintf(&s, "%lu %u", val1, xf86_lex_val.num) == -1)
s = NULL;
break;
case XAXIS:
diff --git a/xorg-server/hw/xfree86/parser/Screen.c b/xorg-server/hw/xfree86/parser/Screen.c
index f294ec490..fecd57c0c 100644
--- a/xorg-server/hw/xfree86/parser/Screen.c
+++ b/xorg-server/hw/xfree86/parser/Screen.c
@@ -60,7 +60,6 @@
#include "xf86tokens.h"
#include "Configint.h"
-extern LexRec val;
static xf86ConfigSymTabRec DisplayTab[] = {
{ENDSUBSECTION, "endsubsection"},
@@ -92,71 +91,71 @@ xf86parseDisplaySubSection(void)
while ((token = xf86getToken(DisplayTab)) != ENDSUBSECTION) {
switch (token) {
case COMMENT:
- ptr->disp_comment = xf86addComment(ptr->disp_comment, val.str);
+ ptr->disp_comment = xf86addComment(ptr->disp_comment, xf86_lex_val.str);
break;
case VIEWPORT:
if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
Error(VIEWPORT_MSG);
- ptr->disp_frameX0 = val.num;
+ ptr->disp_frameX0 = xf86_lex_val.num;
if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
Error(VIEWPORT_MSG);
- ptr->disp_frameY0 = val.num;
+ ptr->disp_frameY0 = xf86_lex_val.num;
break;
case VIRTUAL:
if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
Error(VIRTUAL_MSG);
- ptr->disp_virtualX = val.num;
+ ptr->disp_virtualX = xf86_lex_val.num;
if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
Error(VIRTUAL_MSG);
- ptr->disp_virtualY = val.num;
+ ptr->disp_virtualY = xf86_lex_val.num;
break;
case DEPTH:
if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
Error(NUMBER_MSG, "Display");
- ptr->disp_depth = val.num;
+ ptr->disp_depth = xf86_lex_val.num;
break;
case BPP:
if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
Error(NUMBER_MSG, "Display");
- ptr->disp_bpp = val.num;
+ ptr->disp_bpp = xf86_lex_val.num;
break;
case VISUAL:
if (xf86getSubToken(&(ptr->disp_comment)) != STRING)
Error(QUOTE_MSG, "Display");
- ptr->disp_visual = val.str;
+ ptr->disp_visual = xf86_lex_val.str;
break;
case WEIGHT:
if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
Error(WEIGHT_MSG);
- ptr->disp_weight.red = val.num;
+ ptr->disp_weight.red = xf86_lex_val.num;
if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
Error(WEIGHT_MSG);
- ptr->disp_weight.green = val.num;
+ ptr->disp_weight.green = xf86_lex_val.num;
if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
Error(WEIGHT_MSG);
- ptr->disp_weight.blue = val.num;
+ ptr->disp_weight.blue = xf86_lex_val.num;
break;
case BLACK_TOK:
if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
Error(BLACK_MSG);
- ptr->disp_black.red = val.num;
+ ptr->disp_black.red = xf86_lex_val.num;
if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
Error(BLACK_MSG);
- ptr->disp_black.green = val.num;
+ ptr->disp_black.green = xf86_lex_val.num;
if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
Error(BLACK_MSG);
- ptr->disp_black.blue = val.num;
+ ptr->disp_black.blue = xf86_lex_val.num;
break;
case WHITE_TOK:
if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
Error(WHITE_MSG);
- ptr->disp_white.red = val.num;
+ ptr->disp_white.red = xf86_lex_val.num;
if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
Error(WHITE_MSG);
- ptr->disp_white.green = val.num;
+ ptr->disp_white.green = xf86_lex_val.num;
if (xf86getSubToken(&(ptr->disp_comment)) != NUMBER)
Error(WHITE_MSG);
- ptr->disp_white.blue = val.num;
+ ptr->disp_white.blue = xf86_lex_val.num;
break;
case MODES:
{
@@ -166,7 +165,7 @@ xf86parseDisplaySubSection(void)
xf86getSubTokenWithTab(&(ptr->disp_comment),
DisplayTab)) == STRING) {
mptr = calloc(1, sizeof(XF86ModeRec));
- mptr->mode_name = val.str;
+ mptr->mode_name = xf86_lex_val.str;
mptr->list.next = NULL;
ptr->disp_mode_lst = (XF86ModePtr)
xf86addListItem((glp) ptr->disp_mode_lst, (glp) mptr);
@@ -227,12 +226,12 @@ xf86parseScreenSection(void)
while ((token = xf86getToken(ScreenTab)) != ENDSECTION) {
switch (token) {
case COMMENT:
- ptr->scrn_comment = xf86addComment(ptr->scrn_comment, val.str);
+ ptr->scrn_comment = xf86addComment(ptr->scrn_comment, xf86_lex_val.str);
break;
case IDENTIFIER:
if (xf86getSubToken(&(ptr->scrn_comment)) != STRING)
Error(QUOTE_MSG, "Identifier");
- ptr->scrn_identifier = val.str;
+ ptr->scrn_identifier = xf86_lex_val.str;
if (has_ident || has_driver)
Error(ONLY_ONE_MSG, "Identifier or Driver");
has_ident = TRUE;
@@ -240,7 +239,7 @@ xf86parseScreenSection(void)
case OBSDRIVER:
if (xf86getSubToken(&(ptr->scrn_comment)) != STRING)
Error(QUOTE_MSG, "Driver");
- ptr->scrn_obso_driver = val.str;
+ ptr->scrn_obso_driver = xf86_lex_val.str;
if (has_ident || has_driver)
Error(ONLY_ONE_MSG, "Identifier or Driver");
has_driver = TRUE;
@@ -248,27 +247,27 @@ xf86parseScreenSection(void)
case DEFAULTDEPTH:
if (xf86getSubToken(&(ptr->scrn_comment)) != NUMBER)
Error(NUMBER_MSG, "DefaultDepth");
- ptr->scrn_defaultdepth = val.num;
+ ptr->scrn_defaultdepth = xf86_lex_val.num;
break;
case DEFAULTBPP:
if (xf86getSubToken(&(ptr->scrn_comment)) != NUMBER)
Error(NUMBER_MSG, "DefaultBPP");
- ptr->scrn_defaultbpp = val.num;
+ ptr->scrn_defaultbpp = xf86_lex_val.num;
break;
case DEFAULTFBBPP:
if (xf86getSubToken(&(ptr->scrn_comment)) != NUMBER)
Error(NUMBER_MSG, "DefaultFbBPP");
- ptr->scrn_defaultfbbpp = val.num;
+ ptr->scrn_defaultfbbpp = xf86_lex_val.num;
break;
case MDEVICE:
if (xf86getSubToken(&(ptr->scrn_comment)) != STRING)
Error(QUOTE_MSG, "Device");
- ptr->scrn_device_str = val.str;
+ ptr->scrn_device_str = xf86_lex_val.str;
break;
case MONITOR:
if (xf86getSubToken(&(ptr->scrn_comment)) != STRING)
Error(QUOTE_MSG, "Monitor");
- ptr->scrn_monitor_str = val.str;
+ ptr->scrn_monitor_str = xf86_lex_val.str;
break;
case VIDEOADAPTOR:
{
@@ -280,13 +279,13 @@ xf86parseScreenSection(void)
/* Don't allow duplicates */
for (aptr = ptr->scrn_adaptor_lst; aptr;
aptr = (XF86ConfAdaptorLinkPtr) aptr->list.next)
- if (xf86nameCompare(val.str, aptr->al_adaptor_str) == 0)
+ if (xf86nameCompare(xf86_lex_val.str, aptr->al_adaptor_str) == 0)
break;
if (aptr == NULL) {
aptr = calloc(1, sizeof(XF86ConfAdaptorLinkRec));
aptr->list.next = NULL;
- aptr->al_adaptor_str = val.str;
+ aptr->al_adaptor_str = xf86_lex_val.str;
ptr->scrn_adaptor_lst = (XF86ConfAdaptorLinkPtr)
xf86addListItem((glp) ptr->scrn_adaptor_lst, (glp) aptr);
}
@@ -295,10 +294,10 @@ xf86parseScreenSection(void)
case VIRTUAL:
if (xf86getSubToken(&(ptr->scrn_comment)) != NUMBER)
Error(VIRTUAL_MSG);
- ptr->scrn_virtualX = val.num;
+ ptr->scrn_virtualX = xf86_lex_val.num;
if (xf86getSubToken(&(ptr->scrn_comment)) != NUMBER)
Error(VIRTUAL_MSG);
- ptr->scrn_virtualY = val.num;
+ ptr->scrn_virtualY = xf86_lex_val.num;
break;
case OPTION:
ptr->scrn_option_lst = xf86parseOption(ptr->scrn_option_lst);
@@ -307,7 +306,7 @@ xf86parseScreenSection(void)
if (xf86getSubToken(&(ptr->scrn_comment)) != STRING)
Error(QUOTE_MSG, "SubSection");
{
- free(val.str);
+ free(xf86_lex_val.str);
HANDLE_LIST(scrn_display_lst, xf86parseDisplaySubSection,
XF86ConfDisplayPtr);
}
diff --git a/xorg-server/hw/xfree86/parser/Vendor.c b/xorg-server/hw/xfree86/parser/Vendor.c
index 9b7695c8e..2c870ae7f 100644
--- a/xorg-server/hw/xfree86/parser/Vendor.c
+++ b/xorg-server/hw/xfree86/parser/Vendor.c
@@ -60,7 +60,6 @@
#include "xf86tokens.h"
#include "Configint.h"
-extern LexRec val;
static xf86ConfigSymTabRec VendorSubTab[] = {
{ENDSUBSECTION, "endsubsection"},
@@ -82,14 +81,14 @@ xf86parseVendorSubSection(void)
while ((token = xf86getToken(VendorSubTab)) != ENDSUBSECTION) {
switch (token) {
case COMMENT:
- ptr->vs_comment = xf86addComment(ptr->vs_comment, val.str);
+ ptr->vs_comment = xf86addComment(ptr->vs_comment, xf86_lex_val.str);
break;
case IDENTIFIER:
if (xf86getSubToken(&(ptr->vs_comment)))
Error(QUOTE_MSG, "Identifier");
if (has_ident == TRUE)
Error(MULTIPLE_MSG, "Identifier");
- ptr->vs_identifier = val.str;
+ ptr->vs_identifier = xf86_lex_val.str;
has_ident = TRUE;
break;
case OPTION:
@@ -135,14 +134,14 @@ xf86parseVendorSection(void)
while ((token = xf86getToken(VendorTab)) != ENDSECTION) {
switch (token) {
case COMMENT:
- ptr->vnd_comment = xf86addComment(ptr->vnd_comment, val.str);
+ ptr->vnd_comment = xf86addComment(ptr->vnd_comment, xf86_lex_val.str);
break;
case IDENTIFIER:
if (xf86getSubToken(&(ptr->vnd_comment)) != STRING)
Error(QUOTE_MSG, "Identifier");
if (has_ident == TRUE)
Error(MULTIPLE_MSG, "Identifier");
- ptr->vnd_identifier = val.str;
+ ptr->vnd_identifier = xf86_lex_val.str;
has_ident = TRUE;
break;
case OPTION:
diff --git a/xorg-server/hw/xfree86/parser/Video.c b/xorg-server/hw/xfree86/parser/Video.c
index 68d611ae7..93209c499 100644
--- a/xorg-server/hw/xfree86/parser/Video.c
+++ b/xorg-server/hw/xfree86/parser/Video.c
@@ -60,7 +60,6 @@
#include "xf86tokens.h"
#include "Configint.h"
-extern LexRec val;
static xf86ConfigSymTabRec VideoPortTab[] = {
{ENDSUBSECTION, "endsubsection"},
@@ -97,14 +96,14 @@ xf86parseVideoPortSubSection(void)
while ((token = xf86getToken(VideoPortTab)) != ENDSUBSECTION) {
switch (token) {
case COMMENT:
- ptr->vp_comment = xf86addComment(ptr->vp_comment, val.str);
+ ptr->vp_comment = xf86addComment(ptr->vp_comment, xf86_lex_val.str);
break;
case IDENTIFIER:
if (xf86getSubToken(&(ptr->vp_comment)) != STRING)
Error(QUOTE_MSG, "Identifier");
if (has_ident == TRUE)
Error(MULTIPLE_MSG, "Identifier");
- ptr->vp_identifier = val.str;
+ ptr->vp_identifier = xf86_lex_val.str;
has_ident = TRUE;
break;
case OPTION:
@@ -154,12 +153,12 @@ xf86parseVideoAdaptorSection(void)
while ((token = xf86getToken(VideoAdaptorTab)) != ENDSECTION) {
switch (token) {
case COMMENT:
- ptr->va_comment = xf86addComment(ptr->va_comment, val.str);
+ ptr->va_comment = xf86addComment(ptr->va_comment, xf86_lex_val.str);
break;
case IDENTIFIER:
if (xf86getSubToken(&(ptr->va_comment)) != STRING)
Error(QUOTE_MSG, "Identifier");
- ptr->va_identifier = val.str;
+ ptr->va_identifier = xf86_lex_val.str;
if (has_ident == TRUE)
Error(MULTIPLE_MSG, "Identifier");
has_ident = TRUE;
@@ -167,22 +166,22 @@ xf86parseVideoAdaptorSection(void)
case VENDOR:
if (xf86getSubToken(&(ptr->va_comment)) != STRING)
Error(QUOTE_MSG, "Vendor");
- ptr->va_vendor = val.str;
+ ptr->va_vendor = xf86_lex_val.str;
break;
case BOARD:
if (xf86getSubToken(&(ptr->va_comment)) != STRING)
Error(QUOTE_MSG, "Board");
- ptr->va_board = val.str;
+ ptr->va_board = xf86_lex_val.str;
break;
case BUSID:
if (xf86getSubToken(&(ptr->va_comment)) != STRING)
Error(QUOTE_MSG, "BusID");
- ptr->va_busid = val.str;
+ ptr->va_busid = xf86_lex_val.str;
break;
case DRIVER:
if (xf86getSubToken(&(ptr->va_comment)) != STRING)
Error(QUOTE_MSG, "Driver");
- ptr->va_driver = val.str;
+ ptr->va_driver = xf86_lex_val.str;
break;
case OPTION:
ptr->va_option_lst = xf86parseOption(ptr->va_option_lst);
diff --git a/xorg-server/hw/xfree86/parser/read.c b/xorg-server/hw/xfree86/parser/read.c
index 6545bcdae..2478b074b 100644
--- a/xorg-server/hw/xfree86/parser/read.c
+++ b/xorg-server/hw/xfree86/parser/read.c
@@ -60,7 +60,6 @@
#include "xf86tokens.h"
#include "Configint.h"
-extern LexRec val;
static xf86ConfigSymTabRec TopLevelTab[] = {
{SECTION, "section"},
@@ -99,7 +98,7 @@ xf86readConfigFile(void)
while ((token = xf86getToken(TopLevelTab)) != EOF_TOKEN) {
switch (token) {
case COMMENT:
- ptr->conf_comment = xf86addComment(ptr->conf_comment, val.str);
+ ptr->conf_comment = xf86addComment(ptr->conf_comment, xf86_lex_val.str);
break;
case SECTION:
if (xf86getSubToken(&(ptr->conf_comment)) != STRING) {
@@ -107,101 +106,101 @@ xf86readConfigFile(void)
CLEANUP(ptr);
return NULL;
}
- xf86setSection(val.str);
- if (xf86nameCompare(val.str, "files") == 0) {
- free(val.str);
- val.str = NULL;
+ xf86setSection(xf86_lex_val.str);
+ if (xf86nameCompare(xf86_lex_val.str, "files") == 0) {
+ free(xf86_lex_val.str);
+ xf86_lex_val.str = NULL;
HANDLE_RETURN(conf_files, xf86parseFilesSection());
}
- else if (xf86nameCompare(val.str, "serverflags") == 0) {
- free(val.str);
- val.str = NULL;
+ else if (xf86nameCompare(xf86_lex_val.str, "serverflags") == 0) {
+ free(xf86_lex_val.str);
+ xf86_lex_val.str = NULL;
HANDLE_RETURN(conf_flags, xf86parseFlagsSection());
}
- else if (xf86nameCompare(val.str, "pointer") == 0) {
- free(val.str);
- val.str = NULL;
+ else if (xf86nameCompare(xf86_lex_val.str, "pointer") == 0) {
+ free(xf86_lex_val.str);
+ xf86_lex_val.str = NULL;
HANDLE_LIST(conf_input_lst, xf86parsePointerSection,
XF86ConfInputPtr);
}
- else if (xf86nameCompare(val.str, "videoadaptor") == 0) {
- free(val.str);
- val.str = NULL;
+ else if (xf86nameCompare(xf86_lex_val.str, "videoadaptor") == 0) {
+ free(xf86_lex_val.str);
+ xf86_lex_val.str = NULL;
HANDLE_LIST(conf_videoadaptor_lst, xf86parseVideoAdaptorSection,
XF86ConfVideoAdaptorPtr);
}
- else if (xf86nameCompare(val.str, "device") == 0) {
- free(val.str);
- val.str = NULL;
+ else if (xf86nameCompare(xf86_lex_val.str, "device") == 0) {
+ free(xf86_lex_val.str);
+ xf86_lex_val.str = NULL;
HANDLE_LIST(conf_device_lst, xf86parseDeviceSection,
XF86ConfDevicePtr);
}
- else if (xf86nameCompare(val.str, "monitor") == 0) {
- free(val.str);
- val.str = NULL;
+ else if (xf86nameCompare(xf86_lex_val.str, "monitor") == 0) {
+ free(xf86_lex_val.str);
+ xf86_lex_val.str = NULL;
HANDLE_LIST(conf_monitor_lst, xf86parseMonitorSection,
XF86ConfMonitorPtr);
}
- else if (xf86nameCompare(val.str, "modes") == 0) {
- free(val.str);
- val.str = NULL;
+ else if (xf86nameCompare(xf86_lex_val.str, "modes") == 0) {
+ free(xf86_lex_val.str);
+ xf86_lex_val.str = NULL;
HANDLE_LIST(conf_modes_lst, xf86parseModesSection,
XF86ConfModesPtr);
}
- else if (xf86nameCompare(val.str, "screen") == 0) {
- free(val.str);
- val.str = NULL;
+ else if (xf86nameCompare(xf86_lex_val.str, "screen") == 0) {
+ free(xf86_lex_val.str);
+ xf86_lex_val.str = NULL;
HANDLE_LIST(conf_screen_lst, xf86parseScreenSection,
XF86ConfScreenPtr);
}
- else if (xf86nameCompare(val.str, "inputdevice") == 0) {
- free(val.str);
- val.str = NULL;
+ else if (xf86nameCompare(xf86_lex_val.str, "inputdevice") == 0) {
+ free(xf86_lex_val.str);
+ xf86_lex_val.str = NULL;
HANDLE_LIST(conf_input_lst, xf86parseInputSection,
XF86ConfInputPtr);
}
- else if (xf86nameCompare(val.str, "inputclass") == 0) {
- free(val.str);
- val.str = NULL;
+ else if (xf86nameCompare(xf86_lex_val.str, "inputclass") == 0) {
+ free(xf86_lex_val.str);
+ xf86_lex_val.str = NULL;
HANDLE_LIST(conf_inputclass_lst,
xf86parseInputClassSection, XF86ConfInputClassPtr);
}
- else if (xf86nameCompare(val.str, "module") == 0) {
- free(val.str);
- val.str = NULL;
+ else if (xf86nameCompare(xf86_lex_val.str, "module") == 0) {
+ free(xf86_lex_val.str);
+ xf86_lex_val.str = NULL;
HANDLE_RETURN(conf_modules, xf86parseModuleSection());
}
- else if (xf86nameCompare(val.str, "serverlayout") == 0) {
- free(val.str);
- val.str = NULL;
+ else if (xf86nameCompare(xf86_lex_val.str, "serverlayout") == 0) {
+ free(xf86_lex_val.str);
+ xf86_lex_val.str = NULL;
HANDLE_LIST(conf_layout_lst, xf86parseLayoutSection,
XF86ConfLayoutPtr);
}
- else if (xf86nameCompare(val.str, "vendor") == 0) {
- free(val.str);
- val.str = NULL;
+ else if (xf86nameCompare(xf86_lex_val.str, "vendor") == 0) {
+ free(xf86_lex_val.str);
+ xf86_lex_val.str = NULL;
HANDLE_LIST(conf_vendor_lst, xf86parseVendorSection,
XF86ConfVendorPtr);
}
- else if (xf86nameCompare(val.str, "dri") == 0) {
- free(val.str);
- val.str = NULL;
+ else if (xf86nameCompare(xf86_lex_val.str, "dri") == 0) {
+ free(xf86_lex_val.str);
+ xf86_lex_val.str = NULL;
HANDLE_RETURN(conf_dri, xf86parseDRISection());
}
- else if (xf86nameCompare(val.str, "extensions") == 0) {
- free(val.str);
- val.str = NULL;
+ else if (xf86nameCompare(xf86_lex_val.str, "extensions") == 0) {
+ free(xf86_lex_val.str);
+ xf86_lex_val.str = NULL;
HANDLE_RETURN(conf_extensions, xf86parseExtensionsSection());
}
else {
- free(val.str);
- val.str = NULL;
+ free(xf86_lex_val.str);
+ xf86_lex_val.str = NULL;
Error(INVALID_SECTION_MSG, xf86tokenString());
}
break;
default:
- free(val.str);
- val.str = NULL;
+ free(xf86_lex_val.str);
+ xf86_lex_val.str = NULL;
Error(INVALID_KEYWORD_MSG, xf86tokenString());
}
}
diff --git a/xorg-server/hw/xfree86/parser/scan.c b/xorg-server/hw/xfree86/parser/scan.c
index 55a84426d..a6c12957b 100644
--- a/xorg-server/hw/xfree86/parser/scan.c
+++ b/xorg-server/hw/xfree86/parser/scan.c
@@ -103,7 +103,7 @@ static int numFiles = 0; /* number of config files */
static int curFileIndex = 0; /* index of current config file */
static int pushToken = LOCK_TOKEN;
static int eol_seen = 0; /* private state to handle comments */
-LexRec val;
+LexRec xf86_lex_val;
/*
* xf86getNextLine --
@@ -332,7 +332,7 @@ xf86getToken(xf86ConfigSymTabRec * tab)
/* XXX no private copy.
* Use xf86addComment when setting a comment.
*/
- val.str = configRBuf;
+ xf86_lex_val.str = configRBuf;
return COMMENT;
}
@@ -354,15 +354,15 @@ xf86getToken(xf86ConfigSymTabRec * tab)
if ((configBuf[configPos] == 'x') ||
(configBuf[configPos] == 'X')) {
base = 16;
- val.numType = PARSE_HEX;
+ xf86_lex_val.numType = PARSE_HEX;
}
else {
base = 8;
- val.numType = PARSE_OCTAL;
+ xf86_lex_val.numType = PARSE_OCTAL;
}
else {
base = 10;
- val.numType = PARSE_DECIMAL;
+ xf86_lex_val.numType = PARSE_DECIMAL;
}
configRBuf[0] = c;
@@ -374,8 +374,8 @@ xf86getToken(xf86ConfigSymTabRec * tab)
configRBuf[i++] = c;
configPos--; /* GJA -- one too far */
configRBuf[i] = '\0';
- val.num = strtoul(configRBuf, NULL, 0);
- val.realnum = atof(configRBuf);
+ xf86_lex_val.num = strtoul(configRBuf, NULL, 0);
+ xf86_lex_val.realnum = atof(configRBuf);
return NUMBER;
}
@@ -389,8 +389,8 @@ xf86getToken(xf86ConfigSymTabRec * tab)
}
while ((c != '\"') && (c != '\n') && (c != '\r') && (c != '\0'));
configRBuf[i] = '\0';
- val.str = malloc(strlen(configRBuf) + 1);
- strcpy(val.str, configRBuf); /* private copy ! */
+ xf86_lex_val.str = malloc(strlen(configRBuf) + 1);
+ strcpy(xf86_lex_val.str, configRBuf); /* private copy ! */
return STRING;
}
@@ -452,7 +452,7 @@ xf86getSubToken(char **comment)
token = xf86getToken(NULL);
if (token == COMMENT) {
if (comment)
- *comment = xf86addComment(*comment, val.str);
+ *comment = xf86addComment(*comment, xf86_lex_val.str);
}
else
return token;
@@ -468,7 +468,7 @@ xf86getSubTokenWithTab(char **comment, xf86ConfigSymTabRec * tab)
token = xf86getToken(tab);
if (token == COMMENT) {
if (comment)
- *comment = xf86addComment(*comment, val.str);
+ *comment = xf86addComment(*comment, xf86_lex_val.str);
}
else
return token;
@@ -1025,7 +1025,7 @@ xf86setSection(const char *section)
int
xf86getStringToken(xf86ConfigSymTabRec * tab)
{
- return StringToToken(val.str, tab);
+ return StringToToken(xf86_lex_val.str, tab);
}
static int
diff --git a/xorg-server/hw/xfree86/x86emu/ops.c b/xorg-server/hw/xfree86/x86emu/ops.c
index 8af1df47a..b50badb28 100644
--- a/xorg-server/hw/xfree86/x86emu/ops.c
+++ b/xorg-server/hw/xfree86/x86emu/ops.c
@@ -11705,38 +11705,38 @@ x86emuOp_opcFF_word_RM(u8 X86EMU_UNUSED(op1))
switch (rh) {
case 0: /* inc word ptr ... */
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
+ u32 destval32;
- destval = fetch_data_long(destoffset);
+ destval32 = fetch_data_long(destoffset);
TRACE_AND_STEP();
- destval = inc_long(destval);
- store_data_long(destoffset, destval);
+ destval32 = inc_long(destval32);
+ store_data_long(destoffset, destval32);
}
else {
- u16 destval;
+ u16 destval16;
- destval = fetch_data_word(destoffset);
+ destval16 = fetch_data_word(destoffset);
TRACE_AND_STEP();
- destval = inc_word(destval);
- store_data_word(destoffset, destval);
+ destval16 = inc_word(destval16);
+ store_data_word(destoffset, destval16);
}
break;
case 1: /* dec word ptr ... */
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
+ u32 destval32;
- destval = fetch_data_long(destoffset);
+ destval32 = fetch_data_long(destoffset);
TRACE_AND_STEP();
- destval = dec_long(destval);
- store_data_long(destoffset, destval);
+ destval32 = dec_long(destval32);
+ store_data_long(destoffset, destval32);
}
else {
- u16 destval;
+ u16 destval16;
- destval = fetch_data_word(destoffset);
+ destval16 = fetch_data_word(destoffset);
TRACE_AND_STEP();
- destval = dec_word(destval);
- store_data_word(destoffset, destval);
+ destval16 = dec_word(destval16);
+ store_data_word(destoffset, destval16);
}
break;
case 2: /* call word ptr ... */
@@ -11768,18 +11768,18 @@ x86emuOp_opcFF_word_RM(u8 X86EMU_UNUSED(op1))
break;
case 6: /* push word ptr ... */
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
+ u32 destval32;
- destval = fetch_data_long(destoffset);
+ destval32 = fetch_data_long(destoffset);
TRACE_AND_STEP();
- push_long(destval);
+ push_long(destval32);
}
else {
- u16 destval;
+ u16 destval16;
- destval = fetch_data_word(destoffset);
+ destval16 = fetch_data_word(destoffset);
TRACE_AND_STEP();
- push_word(destval);
+ push_word(destval16);
}
break;
}
@@ -11790,38 +11790,38 @@ x86emuOp_opcFF_word_RM(u8 X86EMU_UNUSED(op1))
switch (rh) {
case 0:
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
+ u32 destval32;
- destval = fetch_data_long(destoffset);
+ destval32 = fetch_data_long(destoffset);
TRACE_AND_STEP();
- destval = inc_long(destval);
- store_data_long(destoffset, destval);
+ destval32 = inc_long(destval32);
+ store_data_long(destoffset, destval32);
}
else {
- u16 destval;
+ u16 destval16;
- destval = fetch_data_word(destoffset);
+ destval16 = fetch_data_word(destoffset);
TRACE_AND_STEP();
- destval = inc_word(destval);
- store_data_word(destoffset, destval);
+ destval16 = inc_word(destval16);
+ store_data_word(destoffset, destval16);
}
break;
case 1:
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
+ u32 destval32;
- destval = fetch_data_long(destoffset);
+ destval32 = fetch_data_long(destoffset);
TRACE_AND_STEP();
- destval = dec_long(destval);
- store_data_long(destoffset, destval);
+ destval32 = dec_long(destval32);
+ store_data_long(destoffset, destval32);
}
else {
- u16 destval;
+ u16 destval16;
- destval = fetch_data_word(destoffset);
+ destval16 = fetch_data_word(destoffset);
TRACE_AND_STEP();
- destval = dec_word(destval);
- store_data_word(destoffset, destval);
+ destval16 = dec_word(destval16);
+ store_data_word(destoffset, destval16);
}
break;
case 2: /* call word ptr ... */
@@ -11853,18 +11853,18 @@ x86emuOp_opcFF_word_RM(u8 X86EMU_UNUSED(op1))
break;
case 6: /* push word ptr ... */
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
+ u32 destval32;
- destval = fetch_data_long(destoffset);
+ destval32 = fetch_data_long(destoffset);
TRACE_AND_STEP();
- push_long(destval);
+ push_long(destval32);
}
else {
- u16 destval;
+ u16 destval16;
- destval = fetch_data_word(destoffset);
+ destval16 = fetch_data_word(destoffset);
TRACE_AND_STEP();
- push_word(destval);
+ push_word(destval16);
}
break;
}
@@ -11875,38 +11875,38 @@ x86emuOp_opcFF_word_RM(u8 X86EMU_UNUSED(op1))
switch (rh) {
case 0:
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
+ u32 destval32;
- destval = fetch_data_long(destoffset);
+ destval32 = fetch_data_long(destoffset);
TRACE_AND_STEP();
- destval = inc_long(destval);
- store_data_long(destoffset, destval);
+ destval32 = inc_long(destval32);
+ store_data_long(destoffset, destval32);
}
else {
- u16 destval;
+ u16 destval16;
- destval = fetch_data_word(destoffset);
+ destval16 = fetch_data_word(destoffset);
TRACE_AND_STEP();
- destval = inc_word(destval);
- store_data_word(destoffset, destval);
+ destval16 = inc_word(destval16);
+ store_data_word(destoffset, destval16);
}
break;
case 1:
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
+ u32 destval32;
- destval = fetch_data_long(destoffset);
+ destval32 = fetch_data_long(destoffset);
TRACE_AND_STEP();
- destval = dec_long(destval);
- store_data_long(destoffset, destval);
+ destval32 = dec_long(destval32);
+ store_data_long(destoffset, destval32);
}
else {
- u16 destval;
+ u16 destval16;
- destval = fetch_data_word(destoffset);
+ destval16 = fetch_data_word(destoffset);
TRACE_AND_STEP();
- destval = dec_word(destval);
- store_data_word(destoffset, destval);
+ destval16 = dec_word(destval16);
+ store_data_word(destoffset, destval16);
}
break;
case 2: /* call word ptr ... */
@@ -11938,18 +11938,18 @@ x86emuOp_opcFF_word_RM(u8 X86EMU_UNUSED(op1))
break;
case 6: /* push word ptr ... */
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 destval;
+ u32 destval32;
- destval = fetch_data_long(destoffset);
+ destval32 = fetch_data_long(destoffset);
TRACE_AND_STEP();
- push_long(destval);
+ push_long(destval32);
}
else {
- u16 destval;
+ u16 destval16;
- destval = fetch_data_word(destoffset);
+ destval16 = fetch_data_word(destoffset);
TRACE_AND_STEP();
- push_word(destval);
+ push_word(destval16);
}
break;
}
@@ -11958,38 +11958,38 @@ x86emuOp_opcFF_word_RM(u8 X86EMU_UNUSED(op1))
switch (rh) {
case 0:
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
+ u32 *destreg32;
- destreg = DECODE_RM_LONG_REGISTER(rl);
+ destreg32 = DECODE_RM_LONG_REGISTER(rl);
DECODE_PRINTF("\n");
TRACE_AND_STEP();
- *destreg = inc_long(*destreg);
+ *destreg32 = inc_long(*destreg32);
}
else {
- u16 *destreg;
+ u16 *destreg16;
- destreg = DECODE_RM_WORD_REGISTER(rl);
+ destreg16 = DECODE_RM_WORD_REGISTER(rl);
DECODE_PRINTF("\n");
TRACE_AND_STEP();
- *destreg = inc_word(*destreg);
+ *destreg16 = inc_word(*destreg16);
}
break;
case 1:
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
+ u32 *destreg32;
- destreg = DECODE_RM_LONG_REGISTER(rl);
+ destreg32 = DECODE_RM_LONG_REGISTER(rl);
DECODE_PRINTF("\n");
TRACE_AND_STEP();
- *destreg = dec_long(*destreg);
+ *destreg32 = dec_long(*destreg32);
}
else {
- u16 *destreg;
+ u16 *destreg16;
- destreg = DECODE_RM_WORD_REGISTER(rl);
+ destreg16 = DECODE_RM_WORD_REGISTER(rl);
DECODE_PRINTF("\n");
TRACE_AND_STEP();
- *destreg = dec_word(*destreg);
+ *destreg16 = dec_word(*destreg16);
}
break;
case 2: /* call word ptr ... */
@@ -12018,20 +12018,20 @@ x86emuOp_opcFF_word_RM(u8 X86EMU_UNUSED(op1))
break;
case 6:
if (M.x86.mode & SYSMODE_PREFIX_DATA) {
- u32 *destreg;
+ u32 *destreg32;
- destreg = DECODE_RM_LONG_REGISTER(rl);
+ destreg32 = DECODE_RM_LONG_REGISTER(rl);
DECODE_PRINTF("\n");
TRACE_AND_STEP();
- push_long(*destreg);
+ push_long(*destreg32);
}
else {
- u16 *destreg;
+ u16 *destreg16;
- destreg = DECODE_RM_WORD_REGISTER(rl);
+ destreg16 = DECODE_RM_WORD_REGISTER(rl);
DECODE_PRINTF("\n");
TRACE_AND_STEP();
- push_word(*destreg);
+ push_word(*destreg16);
}
break;
}
diff --git a/xorg-server/hw/xnest/Events.c b/xorg-server/hw/xnest/Events.c
index 447d5a72b..3ff095bb8 100644
--- a/xorg-server/hw/xnest/Events.c
+++ b/xorg-server/hw/xnest/Events.c
@@ -64,15 +64,15 @@ SetTimeSinceLastInputEvent(void)
}
static Bool
-xnestExposurePredicate(Display * display, XEvent * event, char *args)
+xnestExposurePredicate(Display * dpy, XEvent * event, char *args)
{
return event->type == Expose || event->type == ProcessedExpose;
}
static Bool
-xnestNotExposurePredicate(Display * display, XEvent * event, char *args)
+xnestNotExposurePredicate(Display * dpy, XEvent * event, char *args)
{
- return !xnestExposurePredicate(display, event, args);
+ return !xnestExposurePredicate(dpy, event, args);
}
void
diff --git a/xorg-server/hw/xnest/GCOps.c b/xorg-server/hw/xnest/GCOps.c
index fa602314b..e1cf9d65f 100644
--- a/xorg-server/hw/xnest/GCOps.c
+++ b/xorg-server/hw/xnest/GCOps.c
@@ -95,7 +95,7 @@ xnestPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
}
static int
-xnestIgnoreErrorHandler (Display *display,
+xnestIgnoreErrorHandler (Display *dpy,
XErrorEvent *event)
{
return False; /* return value is ignored */
@@ -127,7 +127,7 @@ xnestGetImage(DrawablePtr pDrawable, int x, int y, int w, int h,
}
static Bool
-xnestBitBlitPredicate(Display * display, XEvent * event, char *args)
+xnestBitBlitPredicate(Display * dpy, XEvent * event, char *args)
{
return event->type == GraphicsExpose || event->type == NoExpose;
}
diff --git a/xorg-server/hw/xnest/Init.c b/xorg-server/hw/xnest/Init.c
index 330b8ca17..d9f490b85 100644
--- a/xorg-server/hw/xnest/Init.c
+++ b/xorg-server/hw/xnest/Init.c
@@ -46,29 +46,29 @@ is" without express or implied warranty.
Bool xnestDoFullGeneration = True;
void
-InitOutput(ScreenInfo * screenInfo, int argc, char *argv[])
+InitOutput(ScreenInfo * screen_info, int argc, char *argv[])
{
int i, j;
xnestOpenDisplay(argc, argv);
- screenInfo->imageByteOrder = ImageByteOrder(xnestDisplay);
- screenInfo->bitmapScanlineUnit = BitmapUnit(xnestDisplay);
- screenInfo->bitmapScanlinePad = BitmapPad(xnestDisplay);
- screenInfo->bitmapBitOrder = BitmapBitOrder(xnestDisplay);
+ screen_info->imageByteOrder = ImageByteOrder(xnestDisplay);
+ screen_info->bitmapScanlineUnit = BitmapUnit(xnestDisplay);
+ screen_info->bitmapScanlinePad = BitmapPad(xnestDisplay);
+ screen_info->bitmapBitOrder = BitmapBitOrder(xnestDisplay);
- screenInfo->numPixmapFormats = 0;
+ screen_info->numPixmapFormats = 0;
for (i = 0; i < xnestNumPixmapFormats; i++)
for (j = 0; j < xnestNumDepths; j++)
if ((xnestPixmapFormats[i].depth == 1) ||
(xnestPixmapFormats[i].depth == xnestDepths[j])) {
- screenInfo->formats[screenInfo->numPixmapFormats].depth =
+ screen_info->formats[screen_info->numPixmapFormats].depth =
xnestPixmapFormats[i].depth;
- screenInfo->formats[screenInfo->numPixmapFormats].bitsPerPixel =
+ screen_info->formats[screen_info->numPixmapFormats].bitsPerPixel =
xnestPixmapFormats[i].bits_per_pixel;
- screenInfo->formats[screenInfo->numPixmapFormats].scanlinePad =
+ screen_info->formats[screen_info->numPixmapFormats].scanlinePad =
xnestPixmapFormats[i].scanline_pad;
- screenInfo->numPixmapFormats++;
+ screen_info->numPixmapFormats++;
break;
}
@@ -80,7 +80,7 @@ InitOutput(ScreenInfo * screenInfo, int argc, char *argv[])
for (i = 0; i < xnestNumScreens; i++)
AddScreen(xnestOpenScreen, argc, argv);
- xnestNumScreens = screenInfo->numScreens;
+ xnestNumScreens = screen_info->numScreens;
xnestDoFullGeneration = xnestFullGeneration;
}
diff --git a/xorg-server/hw/xnest/Window.c b/xorg-server/hw/xnest/Window.c
index c33cbaa2b..fc87e823e 100644
--- a/xorg-server/hw/xnest/Window.c
+++ b/xorg-server/hw/xnest/Window.c
@@ -380,7 +380,7 @@ xnestClipNotify(WindowPtr pWin, int dx, int dy)
}
static Bool
-xnestWindowExposurePredicate(Display * display, XEvent * event, XPointer ptr)
+xnestWindowExposurePredicate(Display * dpy, XEvent * event, XPointer ptr)
{
return (event->type == Expose && event->xexpose.window == *(Window *) ptr);
}
diff --git a/xorg-server/hw/xquartz/GL/indirect.c b/xorg-server/hw/xquartz/GL/indirect.c
index 8dabda14d..19b7d86e7 100644
--- a/xorg-server/hw/xquartz/GL/indirect.c
+++ b/xorg-server/hw/xquartz/GL/indirect.c
@@ -643,10 +643,10 @@ __glFloorLog2(GLuint val)
static void *opengl_framework_handle;
-static glx_gpa_proc
+static glx_func_ptr
get_proc_address(const char *sym)
{
- return (glx_gpa_proc) dlsym(opengl_framework_handle, sym);
+ return (glx_func_ptr) dlsym(opengl_framework_handle, sym);
}
static void
diff --git a/xorg-server/hw/xquartz/X11Application.m b/xorg-server/hw/xquartz/X11Application.m
index 1f9b05dd1..2efbd658b 100644
--- a/xorg-server/hw/xquartz/X11Application.m
+++ b/xorg-server/hw/xquartz/X11Application.m
@@ -70,6 +70,18 @@ xpbproxy_run(void);
static dispatch_queue_t eventTranslationQueue;
#endif
+#ifndef __has_feature
+#define __has_feature(x) 0
+#endif
+
+#ifndef CF_RETURNS_RETAINED
+#if __has_feature(attribute_cf_returns_retained)
+#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
+#else
+#define CF_RETURNS_RETAINED
+#endif
+#endif
+
extern Bool noTestExtensions;
extern Bool noRenderExtension;
extern BOOL serverRunning;
@@ -526,6 +538,7 @@ cfrelease(CFAllocatorRef a, const void *b)
CFRelease(b);
}
+CF_RETURNS_RETAINED
static CFMutableArrayRef
nsarray_to_cfarray(NSArray *in)
{
diff --git a/xorg-server/hw/xquartz/X11Controller.m b/xorg-server/hw/xquartz/X11Controller.m
index 752bda35c..5445c6f3a 100644
--- a/xorg-server/hw/xquartz/X11Controller.m
+++ b/xorg-server/hw/xquartz/X11Controller.m
@@ -934,7 +934,7 @@ extern char *bundle_id_prefix;
== NSAlertDefaultReturn) ? NSTerminateNow : NSTerminateCancel;
}
-- (void) applicationWillTerminate:(NSNotification *)aNotification
+- (void) applicationWillTerminate:(NSNotification *)aNotification _X_NORETURN
{
int remain;
[X11App prefs_synchronize];
diff --git a/xorg-server/hw/xquartz/applewm.c b/xorg-server/hw/xquartz/applewm.c
index 4409d4bf6..cc91c9608 100644
--- a/xorg-server/hw/xquartz/applewm.c
+++ b/xorg-server/hw/xquartz/applewm.c
@@ -378,6 +378,13 @@ ProcAppleWMSetWindowMenu(register ClientPtr client)
items = malloc(sizeof(char *) * nitems);
shortcuts = malloc(sizeof(char) * nitems);
+ if (!items || !shortcuts) {
+ free(items);
+ free(shortcuts);
+
+ return BadAlloc;
+ }
+
max_len = (stuff->length << 2) - sizeof(xAppleWMSetWindowMenuReq);
bytes = (char *)&stuff[1];
@@ -391,6 +398,15 @@ ProcAppleWMSetWindowMenu(register ClientPtr client)
break;
}
}
+
+ /* Check if we bailed out of the above loop due to a request that was too long */
+ if (j < nitems) {
+ free(items);
+ free(shortcuts);
+
+ return BadRequest;
+ }
+
X11ApplicationSetWindowMenu(nitems, items, shortcuts);
free(items);
free(shortcuts);
diff --git a/xorg-server/hw/xquartz/darwinfb.h b/xorg-server/hw/xquartz/darwinfb.h
index 5de360d75..541128b8e 100644
--- a/xorg-server/hw/xquartz/darwinfb.h
+++ b/xorg-server/hw/xquartz/darwinfb.h
@@ -26,7 +26,7 @@
*/
#ifndef _DARWIN_FB_H
-#define _DARWIN_DB_H
+#define _DARWIN_FB_H
#include "scrnintstr.h"
diff --git a/xorg-server/hw/xquartz/mach-startup/stub.c b/xorg-server/hw/xquartz/mach-startup/stub.c
index b5a3168ca..756e4ef2d 100644
--- a/xorg-server/hw/xquartz/mach-startup/stub.c
+++ b/xorg-server/hw/xquartz/mach-startup/stub.c
@@ -353,6 +353,10 @@ main(int argc, char **argv, char **envp)
newenvp = (string_array_t)calloc((1 + envpc), sizeof(string_t));
if (!newargv || !newenvp) {
+ /* Silence the clang static analyzer */
+ free(newargv);
+ free(newenvp);
+
asl_log(aslc, NULL, ASL_LEVEL_ERR,
"Xquartz: Memory allocation failure");
return EXIT_FAILURE;
diff --git a/xorg-server/hw/xquartz/quartz.c b/xorg-server/hw/xquartz/quartz.c
index 5b977c7f9..bc6c8d048 100644
--- a/xorg-server/hw/xquartz/quartz.c
+++ b/xorg-server/hw/xquartz/quartz.c
@@ -109,11 +109,14 @@ Bool
QuartzAddScreen(int index,
ScreenPtr pScreen)
{
+ // The clang static analyzer thinks we leak displayInfo here
+#ifndef __clang_analyzer__
// allocate space for private per screen Quartz specific storage
QuartzScreenPtr displayInfo = calloc(sizeof(QuartzScreenRec), 1);
// QUARTZ_PRIV(pScreen) = displayInfo;
dixSetPrivate(&pScreen->devPrivates, quartzScreenKey, displayInfo);
+#endif /* __clang_analyzer__ */
// do Quartz mode specific initialization
return quartzProcs->AddScreen(index, pScreen);
diff --git a/xorg-server/hw/xquartz/xpr/appledri.c b/xorg-server/hw/xquartz/xpr/appledri.c
index 9aac07240..77574655b 100644
--- a/xorg-server/hw/xquartz/xpr/appledri.c
+++ b/xorg-server/hw/xquartz/xpr/appledri.c
@@ -123,6 +123,10 @@ ProcAppleDRIQueryDirectRenderingCapable(register ClientPtr client)
rep.length = 0;
rep.sequenceNumber = client->sequence;
+ if (stuff->screen >= screenInfo.numScreens) {
+ return BadValue;
+ }
+
if (!DRIQueryDirectRenderingCapable(screenInfo.screens[stuff->screen],
&isCapable)) {
return BadValue;
@@ -402,6 +406,7 @@ SProcAppleDRIQueryDirectRenderingCapable(register ClientPtr client)
{
REQUEST(xAppleDRIQueryDirectRenderingCapableReq);
swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xAppleDRIQueryDirectRenderingCapableReq);
swapl(&stuff->screen);
return ProcAppleDRIQueryDirectRenderingCapable(client);
}
@@ -411,6 +416,7 @@ SProcAppleDRIAuthConnection(register ClientPtr client)
{
REQUEST(xAppleDRIAuthConnectionReq);
swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xAppleDRIAuthConnectionReq);
swapl(&stuff->screen);
swapl(&stuff->magic);
return ProcAppleDRIAuthConnection(client);
@@ -421,6 +427,7 @@ SProcAppleDRICreateSurface(register ClientPtr client)
{
REQUEST(xAppleDRICreateSurfaceReq);
swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xAppleDRICreateSurfaceReq);
swapl(&stuff->screen);
swapl(&stuff->drawable);
swapl(&stuff->client_id);
@@ -432,6 +439,7 @@ SProcAppleDRIDestroySurface(register ClientPtr client)
{
REQUEST(xAppleDRIDestroySurfaceReq);
swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xAppleDRIDestroySurfaceReq);
swapl(&stuff->screen);
swapl(&stuff->drawable);
return ProcAppleDRIDestroySurface(client);
@@ -442,6 +450,7 @@ SProcAppleDRICreatePixmap(register ClientPtr client)
{
REQUEST(xAppleDRICreatePixmapReq);
swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xAppleDRICreatePixmapReq);
swapl(&stuff->screen);
swapl(&stuff->drawable);
return ProcAppleDRICreatePixmap(client);
@@ -452,6 +461,7 @@ SProcAppleDRIDestroyPixmap(register ClientPtr client)
{
REQUEST(xAppleDRIDestroyPixmapReq);
swaps(&stuff->length);
+ REQUEST_SIZE_MATCH(xAppleDRIDestroyPixmapReq);
swapl(&stuff->drawable);
return ProcAppleDRIDestroyPixmap(client);
}
diff --git a/xorg-server/hw/xquartz/xpr/x-hook.c b/xorg-server/hw/xquartz/xpr/x-hook.c
index b5d8ab90e..3922bb86c 100644
--- a/xorg-server/hw/xquartz/xpr/x-hook.c
+++ b/xorg-server/hw/xquartz/xpr/x-hook.c
@@ -70,34 +70,19 @@ X_PFX(hook_remove) (x_list * lst, x_hook_function * fun, void *data) {
X_EXTERN void
X_PFX(hook_run) (x_list * lst, void *arg) {
- x_list *node, *cell;
- x_hook_function **fun;
- void **data;
- int length, i;
+ x_list *node;
if (!lst)
return;
- length = X_PFX(list_length) (lst);
- fun = malloc(sizeof(x_hook_function *) * length);
- data = malloc(sizeof(void *) * length);
-
- if (!fun || !data) {
- FatalError("Failed to allocate memory in %s\n", __func__);
- }
+ for (node = lst; node != NULL; node = node->next) {
+ x_list *cell = node->data;
- for (i = 0, node = lst; node != NULL; node = node->next, i++) {
- cell = node->data;
- fun[i] = CELL_FUN(cell);
- data[i] = CELL_DATA(cell);
- }
+ x_hook_function *fun = CELL_FUN(cell);
+ void *data = CELL_DATA(cell);
- for (i = 0; i < length; i++) {
- (*fun[i])(arg, data[i]);
+ (*fun)(arg, data);
}
-
- free(fun);
- free(data);
}
X_EXTERN void
diff --git a/xorg-server/include/dix-config.h.in b/xorg-server/include/dix-config.h.in
index 957257b12..55cfe4710 100644
--- a/xorg-server/include/dix-config.h.in
+++ b/xorg-server/include/dix-config.h.in
@@ -472,4 +472,7 @@
/* Don't let Xdefs.h define 'pointer' */
#define _XTYPEDEF_POINTER 1
+/* Ask fontsproto to make font path element names const */
+#define FONT_PATH_ELEMENT_NAME_CONST 1
+
#endif /* _DIX_CONFIG_H_ */
diff --git a/xorg-server/include/dixfontstubs.h b/xorg-server/include/dixfontstubs.h
index 0454ffa6c..535d312e6 100644
--- a/xorg-server/include/dixfontstubs.h
+++ b/xorg-server/include/dixfontstubs.h
@@ -11,8 +11,6 @@ extern _X_EXPORT int client_auth_generation(ClientPtr client);
extern _X_EXPORT void DeleteFontClientID(Font id);
-extern _X_EXPORT FontResolutionPtr GetClientResolutions(int *num);
-
extern _X_EXPORT int GetDefaultPointSize(void);
extern _X_EXPORT Font GetNewFontClientID(void);
diff --git a/xorg-server/include/dixstruct.h b/xorg-server/include/dixstruct.h
index a11729bdf..6c13895d7 100644
--- a/xorg-server/include/dixstruct.h
+++ b/xorg-server/include/dixstruct.h
@@ -106,7 +106,6 @@ typedef struct _Client {
int smart_start_tick;
int smart_stop_tick;
- int smart_check_tick;
DeviceIntPtr clientPtr;
ClientIdPtr clientIds;
diff --git a/xorg-server/include/xorg-server.h.in b/xorg-server/include/xorg-server.h.in
index 0c651bfab..8bf9d38f2 100644
--- a/xorg-server/include/xorg-server.h.in
+++ b/xorg-server/include/xorg-server.h.in
@@ -224,4 +224,7 @@
/* Use XTrans FD passing support */
#undef XTRANS_SEND_FDS
+/* Ask fontsproto to make font path element names const */
+#define FONT_PATH_ELEMENT_NAME_CONST 1
+
#endif /* _XORG_SERVER_H_ */
diff --git a/xorg-server/m4/xorg-tls.m4 b/xorg-server/m4/xorg-tls.m4
index e04f1ff56..57687758f 100644
--- a/xorg-server/m4/xorg-tls.m4
+++ b/xorg-server/m4/xorg-tls.m4
@@ -28,7 +28,7 @@ AC_DEFUN([XORG_TLS], [
ac_cv_tls=none
keywords="__thread __declspec(thread)"
for kw in $keywords ; do
- AC_TRY_COMPILE([int $kw test;], [], ac_cv_tls=$kw ; break ;)
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int $kw test;]], [])], ac_cv_tls=$kw ; break ;)
done
])
AC_MSG_RESULT($ac_cv_tls)
@@ -38,7 +38,7 @@ AC_DEFUN([XORG_TLS], [
AC_CACHE_VAL(ac_cv_tls_model, [
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $STRICT_CFLAGS"
- AC_TRY_COMPILE([int $ac_cv_tls __attribute__((tls_model("initial-exec"))) test;], [],
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int $ac_cv_tls __attribute__((tls_model("initial-exec"))) test;]], [])],
ac_cv_tls_model=yes, ac_cv_tls_model=no)
CFLAGS="$save_CFLAGS"
])
diff --git a/xorg-server/os/io.c b/xorg-server/os/io.c
index cf5e8f933..8181a8639 100644
--- a/xorg-server/os/io.c
+++ b/xorg-server/os/io.c
@@ -102,12 +102,17 @@ typedef struct _connectionOutput {
static ConnectionInputPtr AllocateInputBuffer(void);
static ConnectionOutputPtr AllocateOutputBuffer(void);
-/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
+/* If EAGAIN and EWOULDBLOCK are distinct errno values, then we check errno
+ * for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
* systems are broken and return EWOULDBLOCK when they should return EAGAIN
*/
#ifndef WIN32
-#define ETEST(err) (err == EAGAIN || err == EWOULDBLOCK)
-#else /* WIN32 The socket errorcodes differ from the normal errors */
+# if (EAGAIN != EWOULDBLOCK)
+# define ETEST(err) (err == EAGAIN || err == EWOULDBLOCK)
+# else
+# define ETEST(err) (err == EAGAIN)
+# endif
+#else /* WIN32 The socket errorcodes differ from the normal errors */
#define ETEST(err) (err == EAGAIN || err == WSAEWOULDBLOCK)
#endif
diff --git a/xorg-server/os/log.c b/xorg-server/os/log.c
index 792b79e93..8deb81040 100644
--- a/xorg-server/os/log.c
+++ b/xorg-server/os/log.c
@@ -195,6 +195,7 @@ LogInit(const char *fname, const char *backup)
char *logFileName = NULL;
if (fname && *fname) {
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
if (asprintf(&logFileName, fname, display) == -1)
FatalError("Cannot allocate space for the log file name\n");
@@ -205,6 +206,7 @@ LogInit(const char *fname, const char *backup)
char *suffix;
char *oldLog;
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
if ((asprintf(&suffix, backup, display) == -1) ||
(asprintf(&oldLog, "%s%s", logFileName, suffix) == -1))
FatalError("Cannot allocate space for the log file name\n");
diff --git a/xorg-server/os/utils.c b/xorg-server/os/utils.c
index 6f83a089b..dc18a67b1 100644
--- a/xorg-server/os/utils.c
+++ b/xorg-server/os/utils.c
@@ -600,6 +600,10 @@ UseMsg(void)
static int
VerifyDisplayName(const char *d)
{
+ int i;
+ int period_found = FALSE;
+ int after_period = 0;
+
if (d == (char *) 0)
return 0; /* null */
if (*d == '\0')
@@ -610,6 +614,29 @@ VerifyDisplayName(const char *d)
return 0; /* must not equal "." or ".." */
if (strchr(d, '/') != (char *) 0)
return 0; /* very important!!! */
+
+ /* Since we run atoi() on the display later, only allow
+ for digits, or exception of :0.0 and similar (two decimal points max)
+ */
+ for (i = 0; i < strlen(d); i++) {
+ if (!isdigit(d[i])) {
+ if (d[i] != '.' || period_found)
+ return 0;
+ period_found = TRUE;
+ } else if (period_found)
+ after_period++;
+
+ if (after_period > 2)
+ return 0;
+ }
+
+ /* don't allow for :0. */
+ if (period_found && after_period == 0)
+ return 0;
+
+ if (atol(d) > INT_MAX)
+ return 0;
+
return 1;
}
diff --git a/xorg-server/os/xdmauth.c b/xorg-server/os/xdmauth.c
index 28584d2e8..f11cbb997 100644
--- a/xorg-server/os/xdmauth.c
+++ b/xorg-server/os/xdmauth.c
@@ -62,7 +62,7 @@ static XdmAuthKeyRec privateKey;
static char XdmAuthenticationName[] = "XDM-AUTHENTICATION-1";
#define XdmAuthenticationNameLen (sizeof XdmAuthenticationName - 1)
-static XdmAuthKeyRec rho;
+static XdmAuthKeyRec global_rho;
static Bool
XdmAuthenticationValidator(ARRAY8Ptr privateData, ARRAY8Ptr incomingData,
@@ -77,7 +77,7 @@ XdmAuthenticationValidator(ARRAY8Ptr privateData, ARRAY8Ptr incomingData,
return FALSE;
incoming = (XdmAuthKeyPtr) incomingData->data;
XdmcpDecrementKey(incoming);
- return XdmcpCompareKeys(incoming, &rho);
+ return XdmcpCompareKeys(incoming, &global_rho);
}
return FALSE;
}
@@ -90,7 +90,7 @@ XdmAuthenticationGenerator(ARRAY8Ptr privateData, ARRAY8Ptr outgoingData,
outgoingData->data = 0;
if (packet_type == REQUEST) {
if (XdmcpAllocARRAY8(outgoingData, 8))
- XdmcpWrap((unsigned char *) &rho, (unsigned char *) &privateKey,
+ XdmcpWrap((unsigned char *) &global_rho, (unsigned char *) &privateKey,
outgoingData->data, 8);
}
return TRUE;
@@ -150,10 +150,10 @@ XdmAuthenticationInit(const char *cookie, int cookie_len)
cookie_len = 7;
memmove(privateKey.data + 1, cookie, cookie_len);
}
- XdmcpGenerateKey(&rho);
+ XdmcpGenerateKey(&global_rho);
XdmcpRegisterAuthentication(XdmAuthenticationName, XdmAuthenticationNameLen,
- (char *) &rho,
- sizeof(rho),
+ (char *) &global_rho,
+ sizeof(global_rho),
(ValidatorFunc) XdmAuthenticationValidator,
(GeneratorFunc) XdmAuthenticationGenerator,
(AddAuthorFunc) XdmAuthenticationAddAuth);
@@ -328,7 +328,7 @@ XdmAddCookie(unsigned short data_length, const char *data, XID id)
if (authFromXDMCP) {
/* R5 xdm sent bogus authorization data in the accept packet,
* but we can recover */
- rho_bits = rho.data;
+ rho_bits = global_rho.data;
key_bits = (unsigned char *) data;
key_bits[0] = '\0';
}
@@ -341,7 +341,7 @@ XdmAddCookie(unsigned short data_length, const char *data, XID id)
break;
#ifdef XDMCP
case 8: /* auth from XDMCP is 8 bytes long */
- rho_bits = rho.data;
+ rho_bits = global_rho.data;
key_bits = (unsigned char *) data;
break;
#endif
@@ -466,7 +466,7 @@ XdmRemoveCookie(unsigned short data_length, const char *data)
break;
#ifdef XDMCP
case 8:
- rho_bits = &rho;
+ rho_bits = &global_rho;
key_bits = (XdmAuthKeyPtr) data;
break;
#endif
diff --git a/xorg-server/os/xdmcp.c b/xorg-server/os/xdmcp.c
index fd8ae588a..99616d94b 100644
--- a/xorg-server/os/xdmcp.c
+++ b/xorg-server/os/xdmcp.c
@@ -641,15 +641,15 @@ XdmcpCloseDisplay(int sock)
XdmcpBlockHandler(void *data, /* unused */
struct timeval **wt, void *pReadmask)
{
- fd_set *LastSelectMask = (fd_set *) pReadmask;
+ fd_set *last_select_mask = (fd_set *) pReadmask;
CARD32 millisToGo;
if (state == XDM_OFF)
return;
- FD_SET(xdmcpSocket, LastSelectMask);
+ FD_SET(xdmcpSocket, last_select_mask);
#if defined(IPv6) && defined(AF_INET6)
if (xdmcpSocket6 >= 0)
- FD_SET(xdmcpSocket6, LastSelectMask);
+ FD_SET(xdmcpSocket6, last_select_mask);
#endif
if (timeOutTime == 0)
return;
@@ -669,23 +669,23 @@ XdmcpBlockHandler(void *data, /* unused */
XdmcpWakeupHandler(void *data, /* unused */
int i, void *pReadmask)
{
- fd_set *LastSelectMask = (fd_set *) pReadmask;
+ fd_set *last_select_mask = (fd_set *) pReadmask;
fd_set devicesReadable;
if (state == XDM_OFF)
return;
if (i > 0) {
- if (FD_ISSET(xdmcpSocket, LastSelectMask)) {
+ if (FD_ISSET(xdmcpSocket, last_select_mask)) {
receive_packet(xdmcpSocket);
- FD_CLR(xdmcpSocket, LastSelectMask);
+ FD_CLR(xdmcpSocket, last_select_mask);
}
#if defined(IPv6) && defined(AF_INET6)
- if (xdmcpSocket6 >= 0 && FD_ISSET(xdmcpSocket6, LastSelectMask)) {
+ if (xdmcpSocket6 >= 0 && FD_ISSET(xdmcpSocket6, last_select_mask)) {
receive_packet(xdmcpSocket6);
- FD_CLR(xdmcpSocket6, LastSelectMask);
+ FD_CLR(xdmcpSocket6, last_select_mask);
}
#endif
- XFD_ANDSET(&devicesReadable, LastSelectMask, &EnabledDevices);
+ XFD_ANDSET(&devicesReadable, last_select_mask, &EnabledDevices);
if (XFD_ANYSET(&devicesReadable)) {
if (state == XDM_AWAIT_USER_INPUT)
restart();
@@ -712,12 +712,12 @@ XdmcpWakeupHandler(void *data, /* unused */
static void
XdmcpSelectHost(const struct sockaddr *host_sockaddr,
- int host_len, ARRAY8Ptr AuthenticationName)
+ int host_len, ARRAY8Ptr auth_name)
{
state = XDM_START_CONNECTION;
memmove(&req_sockaddr, host_sockaddr, host_len);
req_socklen = host_len;
- XdmcpSetAuthentication(AuthenticationName);
+ XdmcpSetAuthentication(auth_name);
send_packet();
}
@@ -730,9 +730,9 @@ XdmcpSelectHost(const struct sockaddr *host_sockaddr,
/*ARGSUSED*/ static void
XdmcpAddHost(const struct sockaddr *from,
int fromlen,
- ARRAY8Ptr AuthenticationName, ARRAY8Ptr hostname, ARRAY8Ptr status)
+ ARRAY8Ptr auth_name, ARRAY8Ptr hostname, ARRAY8Ptr status)
{
- XdmcpSelectHost(from, fromlen, AuthenticationName);
+ XdmcpSelectHost(from, fromlen, auth_name);
}
/*
@@ -1058,8 +1058,6 @@ send_query_msg(void)
XdmcpWriteHeader(&buffer, &header);
XdmcpWriteARRAYofARRAY8(&buffer, &AuthenticationNames);
if (broadcast) {
- int i;
-
for (i = 0; i < NumBroadcastAddresses; i++)
XdmcpFlush(xdmcpSocket, &buffer,
(XdmcpNetaddr) &BroadcastAddresses[i],
diff --git a/xorg-server/randr/rrcrtc.c b/xorg-server/randr/rrcrtc.c
index df1e3f13e..6e181ba2c 100644
--- a/xorg-server/randr/rrcrtc.c
+++ b/xorg-server/randr/rrcrtc.c
@@ -475,21 +475,21 @@ rrCheckPixmapBounding(ScreenPtr pScreen,
}
xorg_list_for_each_entry(slave, &pScreen->output_slave_list, output_head) {
- rrScrPriv(slave);
- for (c = 0; c < pScrPriv->numCrtcs; c++)
- if (pScrPriv->crtcs[c] == rr_crtc) {
+ rrScrPrivPtr slave_priv = rrGetScrPriv(slave);
+ for (c = 0; c < slave_priv->numCrtcs; c++)
+ if (slave_priv->crtcs[c] == rr_crtc) {
newbox.x1 = x;
newbox.x2 = x + w;
newbox.y1 = y;
newbox.y2 = y + h;
}
else {
- if (!pScrPriv->crtcs[c]->mode)
+ if (!slave_priv->crtcs[c]->mode)
continue;
- newbox.x1 = pScrPriv->crtcs[c]->x;
- newbox.x2 = pScrPriv->crtcs[c]->x + pScrPriv->crtcs[c]->mode->mode.width;
- newbox.y1 = pScrPriv->crtcs[c]->y;
- newbox.y2 = pScrPriv->crtcs[c]->y + pScrPriv->crtcs[c]->mode->mode.height;
+ newbox.x1 = slave_priv->crtcs[c]->x;
+ newbox.x2 = slave_priv->crtcs[c]->x + slave_priv->crtcs[c]->mode->mode.width;
+ newbox.y1 = slave_priv->crtcs[c]->y;
+ newbox.y2 = slave_priv->crtcs[c]->y + slave_priv->crtcs[c]->mode->mode.height;
}
RegionInit(&new_crtc_region, &newbox, 1);
RegionUnion(&total_region, &total_region, &new_crtc_region);
@@ -503,7 +503,6 @@ rrCheckPixmapBounding(ScreenPtr pScreen,
new_height == screen_pixmap->drawable.height) {
ErrorF("adjust shatters %d %d\n", newsize->x1, newsize->x2);
} else {
- rrScrPriv(pScreen);
pScrPriv->rrScreenSetSize(pScreen, new_width, new_height, 0, 0);
}
diff --git a/xorg-server/test/hashtabletest.c b/xorg-server/test/hashtabletest.c
index 6af14a8e6..ceadfa7a3 100644
--- a/xorg-server/test/hashtabletest.c
+++ b/xorg-server/test/hashtabletest.c
@@ -26,7 +26,6 @@ static int
test1(void)
{
HashTable h;
- XID id;
int c;
int ok = 1;
const int numKeys = 420;
@@ -36,7 +35,7 @@ test1(void)
for (c = 0; c < numKeys; ++c) {
int *dest;
- id = c;
+ XID id = c;
dest = ht_add(h, &id);
if (dest) {
*dest = 2 * c;
@@ -85,7 +84,6 @@ static int
test2(void)
{
HashTable h;
- XID id;
int c;
int ok = 1;
const int numKeys = 420;
@@ -94,7 +92,7 @@ test2(void)
h = ht_create(sizeof(XID), 0, ht_resourceid_hash, ht_resourceid_compare, NULL);
for (c = 0; c < numKeys; ++c) {
- id = c;
+ XID id = c;
ht_add(h, &id);
}
diff --git a/xorg-server/test/signal-logging.c b/xorg-server/test/signal-logging.c
index 7bbd9105e..d894373f0 100644
--- a/xorg-server/test/signal-logging.c
+++ b/xorg-server/test/signal-logging.c
@@ -117,6 +117,8 @@ static void
number_formatting(void)
{
int i;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Woverflow"
long unsigned int unsigned_tests[] = { 0,/* Zero */
5, /* Single digit number */
12, /* Two digit decimal number */
@@ -139,6 +141,7 @@ number_formatting(void)
-0x15D027BF211B37A, /* Large > 32 bit number */
-0x7FFFFFFFFFFFFFFF, /* Maximum 64-bit signed number */
} ;
+#pragma GCC diagnostic pop
for (i = 0; i < sizeof(unsigned_tests) / sizeof(unsigned_tests[0]); i++)
assert(check_number_format_test(unsigned_tests[i]));
@@ -152,6 +155,8 @@ number_formatting(void)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-security"
+#pragma GCC diagnostic ignored "-Wformat"
+#pragma GCC diagnostic ignored "-Wformat-extra-args"
static void logging_format(void)
{
const char *log_file_path = "/tmp/Xorg-logging-test.log";
@@ -220,14 +225,12 @@ static void logging_format(void)
assert(strcmp(logmsg, "(EE) substituted string\n") == 0);
/* Invalid format */
-#warning Ignore compiler warning below "lacks type at end of format". This is intentional.
LogMessageVerbSigSafe(X_ERROR, -1, "%4", 4);
read_log_msg(logmsg);
assert(strcmp(logmsg, "(EE) ") == 0);
LogMessageVerbSigSafe(X_ERROR, -1, "\n");
fseek(f, 0, SEEK_END);
-#warning Ignore compiler warning below "unknown conversion type character". This is intentional.
/* %hld is bogus */
LogMessageVerbSigSafe(X_ERROR, -1, "%hld\n", 4);
read_log_msg(logmsg);
diff --git a/xorg-server/test/xi2/protocol-common.c b/xorg-server/test/xi2/protocol-common.c
index e171115d3..9a429e49f 100644
--- a/xorg-server/test/xi2/protocol-common.c
+++ b/xorg-server/test/xi2/protocol-common.c
@@ -41,7 +41,7 @@ WindowRec root;
WindowRec window;
static ClientRec server_client;
-void *userdata;
+void *global_userdata;
static void
fake_init_sprite(DeviceIntPtr dev)
@@ -136,34 +136,34 @@ struct devices
init_devices(void)
{
ClientRec client;
- struct devices devices;
+ struct devices local_devices;
client = init_client(0, NULL);
- AllocDevicePair(&client, "Virtual core", &devices.vcp, &devices.vck,
+ AllocDevicePair(&client, "Virtual core", &local_devices.vcp, &local_devices.vck,
CorePointerProc, CoreKeyboardProc, TRUE);
- inputInfo.pointer = devices.vcp;
+ inputInfo.pointer = local_devices.vcp;
- inputInfo.keyboard = devices.vck;
- ActivateDevice(devices.vcp, FALSE);
- ActivateDevice(devices.vck, FALSE);
- EnableDevice(devices.vcp, FALSE);
- EnableDevice(devices.vck, FALSE);
+ inputInfo.keyboard = local_devices.vck;
+ ActivateDevice(local_devices.vcp, FALSE);
+ ActivateDevice(local_devices.vck, FALSE);
+ EnableDevice(local_devices.vcp, FALSE);
+ EnableDevice(local_devices.vck, FALSE);
- AllocDevicePair(&client, "", &devices.mouse, &devices.kbd,
+ AllocDevicePair(&client, "", &local_devices.mouse, &local_devices.kbd,
TestPointerProc, CoreKeyboardProc, FALSE);
- ActivateDevice(devices.mouse, FALSE);
- ActivateDevice(devices.kbd, FALSE);
- EnableDevice(devices.mouse, FALSE);
- EnableDevice(devices.kbd, FALSE);
+ ActivateDevice(local_devices.mouse, FALSE);
+ ActivateDevice(local_devices.kbd, FALSE);
+ EnableDevice(local_devices.mouse, FALSE);
+ EnableDevice(local_devices.kbd, FALSE);
- devices.num_devices = 4;
- devices.num_master_devices = 2;
+ local_devices.num_devices = 4;
+ local_devices.num_master_devices = 2;
- fake_init_sprite(devices.mouse);
- fake_init_sprite(devices.vcp);
+ fake_init_sprite(local_devices.mouse);
+ fake_init_sprite(local_devices.vcp);
- return devices;
+ return local_devices;
}
/* Create minimal client, with the given buffer and len as request buffer */
@@ -187,20 +187,20 @@ init_client(int len, void *data)
}
void
-init_window(WindowPtr window, WindowPtr parent, int id)
+init_window(WindowPtr local_window, WindowPtr parent, int id)
{
- memset(window, 0, sizeof(*window));
+ memset(local_window, 0, sizeof(*local_window));
- window->drawable.id = id;
+ local_window->drawable.id = id;
if (parent) {
- window->drawable.x = 30;
- window->drawable.y = 50;
- window->drawable.width = 100;
- window->drawable.height = 200;
+ local_window->drawable.x = 30;
+ local_window->drawable.y = 50;
+ local_window->drawable.width = 100;
+ local_window->drawable.height = 200;
}
- window->parent = parent;
- window->optional = calloc(1, sizeof(WindowOptRec));
- assert(window->optional);
+ local_window->parent = parent;
+ local_window->optional = calloc(1, sizeof(WindowOptRec));
+ assert(local_window->optional);
}
extern DevPrivateKeyRec miPointerScreenKeyRec;
@@ -208,18 +208,18 @@ extern DevPrivateKeyRec miPointerPrivKeyRec;
/* Needed for the screen setup, otherwise we crash during sprite initialization */
static Bool
-device_cursor_init(DeviceIntPtr dev, ScreenPtr screen)
+device_cursor_init(DeviceIntPtr dev, ScreenPtr local_screen)
{
return TRUE;
}
static void
-device_cursor_cleanup(DeviceIntPtr dev, ScreenPtr screen)
+device_cursor_cleanup(DeviceIntPtr dev, ScreenPtr local_screen)
{
}
static Bool
-set_cursor_pos(DeviceIntPtr dev, ScreenPtr screen, int x, int y, Bool event)
+set_cursor_pos(DeviceIntPtr dev, ScreenPtr local_screen, int x, int y, Bool event)
{
return TRUE;
}
@@ -264,5 +264,5 @@ __wrap_WriteToClient(ClientPtr client, int len, void *data)
{
assert(reply_handler != NULL);
- (*reply_handler) (client, len, data, userdata);
+ (*reply_handler) (client, len, data, global_userdata);
}
diff --git a/xorg-server/test/xi2/protocol-common.h b/xorg-server/test/xi2/protocol-common.h
index d30306886..f8504787f 100644
--- a/xorg-server/test/xi2/protocol-common.h
+++ b/xorg-server/test/xi2/protocol-common.h
@@ -91,7 +91,7 @@ extern struct devices devices;
/**
* test-specific userdata, passed into the reply handler.
*/
-extern void *userdata;
+extern void *global_userdata;
/**
* The reply handler called from WriteToClient. Set this handler if you need
diff --git a/xorg-server/test/xi2/protocol-xipassivegrabdevice.c b/xorg-server/test/xi2/protocol-xipassivegrabdevice.c
index 84b386bf3..1e2341eb7 100644
--- a/xorg-server/test/xi2/protocol-xipassivegrabdevice.c
+++ b/xorg-server/test/xi2/protocol-xipassivegrabdevice.c
@@ -136,7 +136,7 @@ request_XIPassiveGrabDevice(ClientPtr client, xXIPassiveGrabDeviceReq * req,
int error, int errval)
{
int rc;
- int modifiers;
+ int local_modifiers;
rc = ProcXIPassiveGrabDevice(&client_request);
assert(rc == error);
@@ -151,12 +151,12 @@ request_XIPassiveGrabDevice(ClientPtr client, xXIPassiveGrabDeviceReq * req,
swapl(&req->cursor);
swapl(&req->detail);
swaps(&req->deviceid);
- modifiers = req->num_modifiers;
+ local_modifiers = req->num_modifiers;
swaps(&req->num_modifiers);
swaps(&req->mask_len);
- while (modifiers--) {
- CARD32 *mod = ((CARD32 *) (req + 1)) + modifiers;
+ while (local_modifiers--) {
+ CARD32 *mod = ((CARD32 *) (req + 1)) + local_modifiers;
swapl(mod);
}
diff --git a/xorg-server/test/xi2/protocol-xiquerydevice.c b/xorg-server/test/xi2/protocol-xiquerydevice.c
index c066daa35..deef1f180 100644
--- a/xorg-server/test/xi2/protocol-xiquerydevice.c
+++ b/xorg-server/test/xi2/protocol-xiquerydevice.c
@@ -312,7 +312,7 @@ test_XIQueryDevice(void)
struct test_data data;
reply_handler = reply_XIQueryDevice;
- userdata = &data;
+ global_userdata = &data;
request_init(&request, XIQueryDevice);
printf("Testing XIAllDevices.\n");
diff --git a/xorg-server/test/xi2/protocol-xiqueryversion.c b/xorg-server/test/xi2/protocol-xiqueryversion.c
index ed75c89db..3749b3041 100644
--- a/xorg-server/test/xi2/protocol-xiqueryversion.c
+++ b/xorg-server/test/xi2/protocol-xiqueryversion.c
@@ -113,7 +113,7 @@ request_XIQueryVersion(int smaj, int smin, int cmaj, int cmin, int error)
request_init(&request, XIQueryVersion);
client = init_client(request.length, &request);
- userdata = (void *) &versions;
+ global_userdata = (void *) &versions;
/* Change the server to support smaj.smin */
XIVersion.major_version = smaj;
@@ -206,7 +206,7 @@ test_XIQueryVersion_multiple(void)
XIVersion.minor_version = 2;
reply_handler = reply_XIQueryVersion_multiple;
- userdata = (void *) &versions;
+ global_userdata = (void *) &versions;
/* run 1 */