2007-08-23 11:53:02 +02:00
|
|
|
/*
|
|
|
|
* Xephyr - A kdrive X server thats runs in a host X window.
|
|
|
|
* Authored by Matthew Allum <mallum@openedhand.com>
|
|
|
|
*
|
|
|
|
* Copyright © 2007 OpenedHand Ltd
|
|
|
|
*
|
|
|
|
* 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 OpenedHand Ltd not be used in
|
|
|
|
* advertising or publicity pertaining to distribution of the software without
|
|
|
|
* specific, written prior permission. OpenedHand Ltd makes no
|
|
|
|
* representations about the suitability of this software for any purpose. It
|
|
|
|
* is provided "as is" without express or implied warranty.
|
|
|
|
*
|
|
|
|
* OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
|
|
* EVENT SHALL OpenedHand Ltd 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.
|
|
|
|
*
|
|
|
|
* a lots of the content of this file has been adapted from the mesa source
|
|
|
|
* code.
|
|
|
|
* Authors:
|
|
|
|
* Dodji Seketeli <dodji@openedhand.com>
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <kdrive-config.h>
|
|
|
|
#endif
|
|
|
|
|
2010-06-21 15:39:03 +02:00
|
|
|
#include <X11/Xdefs.h>
|
|
|
|
#include <X11/Xmd.h>
|
2007-08-23 11:53:02 +02:00
|
|
|
#include <GL/glxproto.h>
|
2010-06-21 15:39:03 +02:00
|
|
|
#include <xcb/glx.h>
|
2007-08-23 11:53:02 +02:00
|
|
|
#include "ephyrhostglx.h"
|
|
|
|
#define _HAVE_XALLOC_DECLS
|
|
|
|
#include "ephyrlog.h"
|
2007-08-30 23:54:49 +02:00
|
|
|
#include "hostx.h"
|
2007-08-23 11:53:02 +02:00
|
|
|
|
2012-09-07 19:10:35 +02:00
|
|
|
static int glx_major, glx_minor;
|
|
|
|
|
2007-08-28 15:55:05 +02:00
|
|
|
enum VisualConfRequestType {
|
|
|
|
EPHYR_GET_FB_CONFIG,
|
|
|
|
EPHYR_VENDOR_PRIV_GET_FB_CONFIG_SGIX,
|
|
|
|
EPHYR_GET_VISUAL_CONFIGS
|
|
|
|
};
|
|
|
|
|
|
|
|
static Bool ephyrHostGLXGetVisualConfigsInternal
|
2012-03-21 20:55:09 +01:00
|
|
|
(enum VisualConfRequestType a_type,
|
2010-06-21 15:39:03 +02:00
|
|
|
xcb_glx_get_visual_configs_reply_t *reply,
|
2012-03-21 20:55:09 +01:00
|
|
|
int32_t a_screen,
|
2010-06-21 15:39:03 +02:00
|
|
|
int32_t *a_num_visuals,
|
|
|
|
int32_t *a_num_props,
|
|
|
|
int32_t *a_props_buf_size,
|
|
|
|
int32_t **a_props_buf);
|
2007-08-23 11:53:02 +02:00
|
|
|
|
|
|
|
Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
ephyrHostGLXQueryVersion(int *a_major, int *a_minor)
|
2007-08-23 11:53:02 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
Bool is_ok = FALSE;
|
2010-06-21 15:39:03 +02:00
|
|
|
xcb_connection_t *conn = hostx_get_xcbconn();
|
|
|
|
xcb_glx_query_version_cookie_t cookie;
|
|
|
|
xcb_glx_query_version_reply_t *reply;
|
2007-08-23 11:53:02 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(a_major && a_minor, FALSE);
|
|
|
|
EPHYR_LOG("enter\n");
|
2007-08-23 11:53:02 +02:00
|
|
|
|
2012-09-07 19:10:35 +02:00
|
|
|
if (glx_major) {
|
|
|
|
*a_major = glx_major;
|
|
|
|
*a_minor = glx_minor;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-09-19 15:46:09 +02:00
|
|
|
/* Send the glXQueryVersion request */
|
2010-06-21 15:39:03 +02:00
|
|
|
cookie = xcb_glx_query_version(conn, 2, 1);
|
|
|
|
reply = xcb_glx_query_version_reply(conn, cookie, NULL);
|
|
|
|
if (!reply)
|
|
|
|
goto out;
|
|
|
|
*a_major = reply->major_version;
|
|
|
|
*a_minor = reply->minor_version;
|
|
|
|
free(reply);
|
2007-09-19 15:46:09 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
EPHYR_LOG("major:%d, minor:%d\n", *a_major, *a_minor);
|
2007-08-23 11:53:02 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
is_ok = TRUE;
|
|
|
|
out:
|
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return is_ok;
|
2007-08-23 11:53:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
2010-06-21 15:39:03 +02:00
|
|
|
ephyrHostGLXGetString(int a_context_tag,
|
|
|
|
int a_string_name,
|
|
|
|
char **a_string)
|
2007-08-23 11:53:02 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
Bool is_ok = FALSE;
|
2010-06-21 15:39:03 +02:00
|
|
|
xcb_connection_t *conn = hostx_get_xcbconn();
|
|
|
|
xcb_glx_get_string_cookie_t cookie;
|
|
|
|
xcb_glx_get_string_reply_t *reply;
|
2007-08-23 11:53:02 +02:00
|
|
|
|
2010-06-21 15:39:03 +02:00
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(conn && a_string, FALSE);
|
2007-08-23 11:53:02 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
EPHYR_LOG("enter\n");
|
2010-06-21 15:39:03 +02:00
|
|
|
cookie = xcb_glx_get_string(conn, a_context_tag, a_string_name);
|
|
|
|
reply = xcb_glx_get_string_reply(conn, cookie, NULL);
|
|
|
|
if (!reply)
|
2012-03-21 20:55:09 +01:00
|
|
|
goto out;
|
2010-06-21 15:39:03 +02:00
|
|
|
*a_string = malloc(reply->n + 1);
|
|
|
|
memcpy(*a_string, xcb_glx_get_string_string(reply), reply->n);
|
|
|
|
(*a_string)[reply->n] = '\0';
|
|
|
|
free(reply);
|
|
|
|
is_ok = TRUE;
|
|
|
|
out:
|
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return is_ok;
|
|
|
|
}
|
2007-08-31 14:43:39 +02:00
|
|
|
|
2010-06-21 15:39:03 +02:00
|
|
|
Bool ephyrHostGLXQueryServerString(int a_screen_number,
|
|
|
|
int a_string_name,
|
|
|
|
char **a_string)
|
|
|
|
{
|
|
|
|
Bool is_ok = FALSE;
|
|
|
|
xcb_connection_t *conn = hostx_get_xcbconn();
|
|
|
|
int default_screen = hostx_get_screen();
|
|
|
|
xcb_glx_query_server_string_cookie_t cookie;
|
|
|
|
xcb_glx_query_server_string_reply_t *reply;
|
2013-04-14 19:50:50 +02:00
|
|
|
|
2010-06-21 15:39:03 +02:00
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(conn && a_string, FALSE);
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2010-06-21 15:39:03 +02:00
|
|
|
EPHYR_LOG("enter\n");
|
|
|
|
cookie = xcb_glx_query_server_string(conn, default_screen, a_string_name);
|
|
|
|
reply = xcb_glx_query_server_string_reply(conn, cookie, NULL);
|
|
|
|
if (!reply)
|
|
|
|
goto out;
|
|
|
|
*a_string = malloc(reply->str_len + 1);
|
|
|
|
memcpy(*a_string, xcb_glx_query_server_string_string(reply), reply->str_len);
|
|
|
|
(*a_string)[reply->str_len] = '\0';
|
|
|
|
free(reply);
|
|
|
|
is_ok = TRUE;
|
|
|
|
out:
|
2012-03-21 20:55:09 +01:00
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return is_ok;
|
2007-08-23 11:53:02 +02:00
|
|
|
}
|
|
|
|
|
2007-08-28 15:55:05 +02:00
|
|
|
static Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
ephyrHostGLXGetVisualConfigsInternal(enum VisualConfRequestType a_type,
|
2010-06-21 15:39:03 +02:00
|
|
|
xcb_glx_get_visual_configs_reply_t *reply,
|
2012-03-21 20:55:09 +01:00
|
|
|
int32_t a_screen,
|
|
|
|
int32_t * a_num_visuals,
|
|
|
|
int32_t * a_num_props,
|
|
|
|
int32_t * a_props_buf_size,
|
|
|
|
int32_t ** a_props_buf)
|
2007-08-23 11:53:02 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
Bool is_ok = FALSE;
|
2010-06-21 15:39:03 +02:00
|
|
|
int num_props = 0, num_visuals = 0, props_buf_size = 0;
|
|
|
|
int props_per_visual_size = 0;
|
2012-03-21 20:55:09 +01:00
|
|
|
int32_t *props_buf = NULL;
|
|
|
|
|
2010-06-21 15:39:03 +02:00
|
|
|
if (!reply->num_visuals) {
|
2012-03-21 20:55:09 +01:00
|
|
|
EPHYR_LOG_ERROR("screen does not support GL rendering\n");
|
|
|
|
goto out;
|
2007-08-23 11:53:02 +02:00
|
|
|
}
|
2010-06-21 15:39:03 +02:00
|
|
|
num_visuals = reply->num_visuals;
|
|
|
|
|
|
|
|
num_props = reply->num_properties;
|
2007-08-23 11:53:02 +02:00
|
|
|
|
2007-08-28 15:55:05 +02:00
|
|
|
if (a_type != EPHYR_GET_VISUAL_CONFIGS) {
|
2007-08-23 11:53:02 +02:00
|
|
|
num_props *= 2;
|
|
|
|
}
|
2010-06-21 15:39:03 +02:00
|
|
|
props_per_visual_size = num_props * sizeof(uint32_t);
|
|
|
|
props_buf_size = props_per_visual_size * reply->num_visuals;
|
2012-03-21 20:55:09 +01:00
|
|
|
props_buf = malloc(props_buf_size);
|
2010-06-21 15:39:03 +02:00
|
|
|
if (!props_buf)
|
|
|
|
goto out;
|
|
|
|
memcpy(props_buf, xcb_glx_get_visual_configs_property_list(reply),
|
|
|
|
props_buf_size);
|
2007-08-23 11:53:02 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
*a_num_visuals = num_visuals;
|
2010-06-21 15:39:03 +02:00
|
|
|
*a_num_props = reply->num_properties;
|
2012-03-21 20:55:09 +01:00
|
|
|
*a_props_buf_size = props_buf_size;
|
|
|
|
*a_props_buf = props_buf;
|
|
|
|
is_ok = TRUE;
|
2007-08-23 11:53:02 +02:00
|
|
|
|
2010-06-21 15:39:03 +02:00
|
|
|
out:
|
2007-08-23 11:53:02 +02:00
|
|
|
return is_ok;
|
|
|
|
}
|
|
|
|
|
2007-08-28 15:55:05 +02:00
|
|
|
Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
ephyrHostGLXGetVisualConfigs(int32_t a_screen,
|
|
|
|
int32_t * a_num_visuals,
|
|
|
|
int32_t * a_num_props,
|
|
|
|
int32_t * a_props_buf_size, int32_t ** a_props_buf)
|
2007-08-28 15:55:05 +02:00
|
|
|
{
|
|
|
|
Bool is_ok = FALSE;
|
2010-06-21 15:39:03 +02:00
|
|
|
xcb_glx_get_visual_configs_cookie_t cookie;
|
|
|
|
xcb_glx_get_visual_configs_reply_t *reply;
|
|
|
|
xcb_connection_t *conn = hostx_get_xcbconn();
|
|
|
|
int screen = hostx_get_screen();
|
2007-08-28 15:55:05 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
EPHYR_LOG("enter\n");
|
2010-06-21 15:39:03 +02:00
|
|
|
cookie = xcb_glx_get_visual_configs(conn, screen);
|
|
|
|
reply = xcb_glx_get_visual_configs_reply(conn, cookie, NULL);
|
|
|
|
if (!reply)
|
|
|
|
goto out;
|
|
|
|
is_ok = ephyrHostGLXGetVisualConfigsInternal
|
|
|
|
(EPHYR_GET_VISUAL_CONFIGS,
|
|
|
|
reply,
|
|
|
|
a_screen,
|
|
|
|
a_num_visuals,
|
|
|
|
a_num_props,
|
|
|
|
a_props_buf_size,
|
|
|
|
a_props_buf);
|
|
|
|
|
|
|
|
out:
|
|
|
|
free(reply);
|
2012-03-21 20:55:09 +01:00
|
|
|
EPHYR_LOG("leave:%d\n", is_ok);
|
2007-08-28 15:55:05 +02:00
|
|
|
return is_ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
ephyrHostGLXVendorPrivGetFBConfigsSGIX(int a_screen,
|
|
|
|
int32_t * a_num_visuals,
|
|
|
|
int32_t * a_num_props,
|
|
|
|
int32_t * a_props_buf_size,
|
|
|
|
int32_t ** a_props_buf)
|
2007-08-28 15:55:05 +02:00
|
|
|
{
|
2010-06-21 15:39:03 +02:00
|
|
|
Bool is_ok=FALSE;
|
|
|
|
xcb_connection_t *conn = hostx_get_xcbconn();
|
|
|
|
int screen = hostx_get_screen();
|
|
|
|
xcb_glx_vendor_private_with_reply_cookie_t cookie;
|
|
|
|
union {
|
|
|
|
xcb_glx_vendor_private_with_reply_reply_t *vprep;
|
|
|
|
xcb_glx_get_visual_configs_reply_t *rep;
|
|
|
|
} reply;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
|
|
|
EPHYR_LOG("enter\n");
|
2010-06-21 15:39:03 +02:00
|
|
|
cookie = xcb_glx_vendor_private_with_reply(conn,
|
|
|
|
X_GLXvop_GetFBConfigsSGIX,
|
|
|
|
0, 4, (uint8_t *)&screen);
|
|
|
|
reply.vprep = xcb_glx_vendor_private_with_reply_reply(conn, cookie, NULL);
|
|
|
|
if (!reply.vprep)
|
|
|
|
goto out;
|
2007-08-28 15:55:05 +02:00
|
|
|
is_ok = ephyrHostGLXGetVisualConfigsInternal
|
2012-03-21 20:55:09 +01:00
|
|
|
(EPHYR_VENDOR_PRIV_GET_FB_CONFIG_SGIX,
|
2010-06-21 15:39:03 +02:00
|
|
|
reply.rep,
|
|
|
|
a_screen,
|
|
|
|
a_num_visuals,
|
|
|
|
a_num_props,
|
|
|
|
a_props_buf_size,
|
|
|
|
a_props_buf);
|
|
|
|
out:
|
|
|
|
free(reply.vprep);
|
2012-03-21 20:55:09 +01:00
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return is_ok;
|
2007-08-28 15:55:05 +02:00
|
|
|
}
|
|
|
|
|
2007-08-23 11:53:02 +02:00
|
|
|
Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
ephyrHostGLXSendClientInfo(int32_t a_major, int32_t a_minor,
|
|
|
|
const char *a_extension_list)
|
2007-08-23 11:53:02 +02:00
|
|
|
{
|
2010-06-21 15:39:03 +02:00
|
|
|
xcb_connection_t *conn = hostx_get_xcbconn();
|
2007-08-23 11:53:02 +02:00
|
|
|
int size;
|
|
|
|
|
2010-06-21 15:39:03 +02:00
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(conn && a_extension_list, FALSE);
|
2007-08-23 11:53:02 +02:00
|
|
|
|
2010-06-21 15:39:03 +02:00
|
|
|
size = strlen (a_extension_list) + 1;
|
|
|
|
xcb_glx_client_info(conn, a_major, a_minor, size, a_extension_list);
|
2007-08-31 14:43:39 +02:00
|
|
|
|
2010-06-21 15:39:03 +02:00
|
|
|
return TRUE;
|
2007-08-23 11:53:02 +02:00
|
|
|
}
|
|
|
|
|
2007-08-30 23:54:49 +02:00
|
|
|
Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
ephyrHostGLXCreateContext(int a_screen,
|
2012-09-12 16:48:32 +02:00
|
|
|
int a_generic_id,
|
2012-03-21 20:55:09 +01:00
|
|
|
int a_context_id,
|
2012-09-12 16:48:32 +02:00
|
|
|
int a_share_list_ctxt_id,
|
|
|
|
int a_render_type,
|
|
|
|
Bool a_direct,
|
|
|
|
int code)
|
2007-08-30 23:54:49 +02:00
|
|
|
{
|
2010-06-21 15:39:03 +02:00
|
|
|
xcb_connection_t *conn = hostx_get_xcbconn();
|
2007-08-30 23:54:49 +02:00
|
|
|
Bool is_ok = FALSE;
|
2010-06-21 15:39:03 +02:00
|
|
|
int remote_context_id = 0;
|
2007-08-30 23:54:49 +02:00
|
|
|
|
2012-09-12 16:48:32 +02:00
|
|
|
EPHYR_LOG("enter. screen:%d, generic_id:%d, contextid:%d, rendertype:%d, "
|
|
|
|
"direct:%d\n", a_screen, a_generic_id, a_context_id,
|
|
|
|
a_render_type, a_direct);
|
2007-08-30 23:54:49 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!hostx_allocate_resource_id_peer(a_context_id, &remote_context_id)) {
|
|
|
|
EPHYR_LOG_ERROR("failed to peer the context id %d host X",
|
|
|
|
remote_context_id);
|
|
|
|
goto out;
|
2007-08-30 23:54:49 +02:00
|
|
|
}
|
|
|
|
|
2012-09-12 16:48:32 +02:00
|
|
|
switch (code) {
|
|
|
|
case X_GLXCreateContext: {
|
2010-06-21 15:39:03 +02:00
|
|
|
xcb_glx_create_context(conn,
|
|
|
|
remote_context_id,
|
|
|
|
a_generic_id,
|
|
|
|
hostx_get_screen(),
|
|
|
|
a_share_list_ctxt_id,
|
|
|
|
a_direct);
|
|
|
|
}
|
2012-09-12 16:48:32 +02:00
|
|
|
|
|
|
|
case X_GLXCreateNewContext: {
|
2010-06-21 15:39:03 +02:00
|
|
|
xcb_glx_create_new_context(conn,
|
|
|
|
remote_context_id,
|
|
|
|
a_generic_id,
|
|
|
|
hostx_get_screen(),
|
|
|
|
a_render_type,
|
|
|
|
a_share_list_ctxt_id,
|
|
|
|
a_direct);
|
2012-09-12 16:48:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* This should never be reached !*/
|
|
|
|
EPHYR_LOG("Internal error! Invalid CreateContext code!\n");
|
|
|
|
}
|
2007-08-30 23:54:49 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
is_ok = TRUE;
|
2007-08-30 23:54:49 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
out:
|
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return is_ok;
|
2007-08-30 23:54:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
ephyrHostDestroyContext(int a_ctxt_id)
|
2007-08-30 23:54:49 +02:00
|
|
|
{
|
2010-06-21 15:39:03 +02:00
|
|
|
xcb_connection_t *conn = hostx_get_xcbconn();
|
2012-03-21 20:55:09 +01:00
|
|
|
Bool is_ok = FALSE;
|
2010-06-21 15:39:03 +02:00
|
|
|
int remote_ctxt_id = 0;
|
2007-08-30 23:54:49 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
EPHYR_LOG("enter:%d\n", a_ctxt_id);
|
2007-08-30 23:54:49 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!hostx_get_resource_id_peer(a_ctxt_id, &remote_ctxt_id)) {
|
|
|
|
EPHYR_LOG_ERROR("failed to get remote glx ctxt id\n");
|
|
|
|
goto out;
|
2007-08-30 23:54:49 +02:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
EPHYR_LOG("host context id:%d\n", remote_ctxt_id);
|
2007-08-30 23:54:49 +02:00
|
|
|
|
2010-06-21 15:39:03 +02:00
|
|
|
xcb_glx_destroy_context(conn, remote_ctxt_id);
|
2007-08-30 23:54:49 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
is_ok = TRUE;
|
2007-08-30 23:54:49 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
out:
|
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return is_ok;
|
2007-08-30 23:54:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
2012-09-07 19:10:35 +02:00
|
|
|
ephyrHostGLXMakeCurrent(int a_drawable, int a_readable,
|
2012-03-21 20:55:09 +01:00
|
|
|
int a_glx_ctxt_id, int a_old_ctxt_tag, int *a_ctxt_tag)
|
2007-08-30 23:54:49 +02:00
|
|
|
{
|
2010-06-21 15:39:03 +02:00
|
|
|
xcb_connection_t *conn = hostx_get_xcbconn();
|
2012-03-21 20:55:09 +01:00
|
|
|
Bool is_ok = FALSE;
|
|
|
|
int remote_glx_ctxt_id = 0;
|
2007-08-30 23:54:49 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(a_ctxt_tag, FALSE);
|
2007-08-30 23:54:49 +02:00
|
|
|
|
2012-09-07 19:10:35 +02:00
|
|
|
EPHYR_LOG("enter. drawable:%d, read:%d, context:%d, oldtag:%d\n",
|
|
|
|
a_drawable, a_readable, a_glx_ctxt_id, a_old_ctxt_tag);
|
2007-08-30 23:54:49 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!hostx_get_resource_id_peer(a_glx_ctxt_id, &remote_glx_ctxt_id)) {
|
|
|
|
EPHYR_LOG_ERROR("failed to get remote glx ctxt id\n");
|
|
|
|
goto out;
|
2007-08-30 23:54:49 +02:00
|
|
|
}
|
|
|
|
|
2012-09-07 19:10:35 +02:00
|
|
|
/* If both drawables are the same, use the old MakeCurrent request.
|
|
|
|
* Otherwise, if we have GLX 1.3 or higher, use the MakeContextCurrent
|
|
|
|
* request which supports separate read and draw targets. Failing that,
|
|
|
|
* try the SGI MakeCurrentRead extension. Logic cribbed from Mesa. */
|
|
|
|
if (a_drawable == a_readable) {
|
2010-06-21 15:39:03 +02:00
|
|
|
xcb_glx_make_current_cookie_t cookie;
|
|
|
|
xcb_glx_make_current_reply_t *reply;
|
|
|
|
cookie = xcb_glx_make_current(conn,
|
|
|
|
a_drawable,
|
|
|
|
remote_glx_ctxt_id,
|
|
|
|
a_old_ctxt_tag);
|
|
|
|
reply = xcb_glx_make_current_reply(conn, cookie, NULL);
|
|
|
|
if (!reply)
|
|
|
|
goto out;
|
|
|
|
*a_ctxt_tag = reply->context_tag;
|
|
|
|
free(reply);
|
2012-09-07 19:10:35 +02:00
|
|
|
}
|
|
|
|
else if (glx_major > 1 || glx_minor >= 3) {
|
2010-06-21 15:39:03 +02:00
|
|
|
xcb_glx_make_context_current_cookie_t cookie;
|
|
|
|
xcb_glx_make_context_current_reply_t *reply;
|
|
|
|
cookie = xcb_glx_make_context_current(conn,
|
|
|
|
a_old_ctxt_tag,
|
|
|
|
a_drawable,
|
|
|
|
a_readable,
|
|
|
|
remote_glx_ctxt_id);
|
|
|
|
reply = xcb_glx_make_context_current_reply(conn, cookie, NULL);
|
|
|
|
if (!reply)
|
|
|
|
goto out;
|
|
|
|
*a_ctxt_tag = reply->context_tag;
|
|
|
|
free(reply);
|
2012-09-07 19:10:35 +02:00
|
|
|
}
|
|
|
|
else {
|
2010-06-21 15:39:03 +02:00
|
|
|
xcb_glx_vendor_private_with_reply_cookie_t cookie;
|
|
|
|
xcb_glx_vendor_private_with_reply_reply_t *reply;
|
|
|
|
uint32_t data[3] = {
|
|
|
|
a_drawable, a_readable, remote_glx_ctxt_id,
|
|
|
|
};
|
2007-08-30 23:54:49 +02:00
|
|
|
|
2010-06-21 15:39:03 +02:00
|
|
|
EPHYR_LOG("enter\n");
|
|
|
|
cookie = xcb_glx_vendor_private_with_reply(conn,
|
|
|
|
X_GLXvop_MakeCurrentReadSGI,
|
|
|
|
a_old_ctxt_tag,
|
|
|
|
sizeof(data),
|
|
|
|
(uint8_t *)data);
|
|
|
|
reply = xcb_glx_vendor_private_with_reply_reply(conn, cookie, NULL);
|
|
|
|
|
|
|
|
*a_ctxt_tag = reply->retval;
|
|
|
|
|
|
|
|
free(reply);
|
2007-08-30 23:54:49 +02:00
|
|
|
}
|
2010-06-21 15:39:03 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
EPHYR_LOG("context tag:%d\n", *a_ctxt_tag);
|
|
|
|
is_ok = TRUE;
|
|
|
|
|
|
|
|
out:
|
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return is_ok;
|
2007-08-30 23:54:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
ephyrHostGetIntegerValue(int a_current_context_tag, int a_int, int *a_val)
|
2007-08-30 23:54:49 +02:00
|
|
|
{
|
2010-06-21 15:39:03 +02:00
|
|
|
xcb_connection_t *conn = hostx_get_xcbconn();
|
2012-03-21 20:55:09 +01:00
|
|
|
Bool is_ok = FALSE;
|
2010-06-21 15:39:03 +02:00
|
|
|
int size = 0;
|
|
|
|
xcb_glx_get_integerv_cookie_t cookie;
|
|
|
|
xcb_glx_get_integerv_reply_t *reply;
|
2007-08-30 23:54:49 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
EPHYR_RETURN_VAL_IF_FAIL(a_val, FALSE);
|
2007-08-30 23:54:49 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
EPHYR_LOG("enter\n");
|
2010-06-21 15:39:03 +02:00
|
|
|
cookie = xcb_glx_get_integerv(conn, a_current_context_tag, a_int);
|
|
|
|
reply = xcb_glx_get_integerv_reply(conn, cookie, NULL);
|
|
|
|
if (!reply)
|
2012-03-21 20:55:09 +01:00
|
|
|
goto out;
|
2010-06-21 15:39:03 +02:00
|
|
|
size = reply->n;
|
2007-08-30 23:54:49 +02:00
|
|
|
if (!size) {
|
2012-03-21 20:55:09 +01:00
|
|
|
EPHYR_LOG_ERROR("X_GLsop_GetIngerv failed\n");
|
|
|
|
goto out;
|
2007-08-30 23:54:49 +02:00
|
|
|
}
|
2010-06-21 15:39:03 +02:00
|
|
|
*a_val = reply->datum;
|
2012-03-21 20:55:09 +01:00
|
|
|
is_ok = TRUE;
|
|
|
|
|
2010-06-21 15:39:03 +02:00
|
|
|
out:
|
|
|
|
free(reply);
|
2012-03-21 20:55:09 +01:00
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return is_ok;
|
2007-08-30 23:54:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
ephyrHostIsContextDirect(int a_ctxt_id, int *a_is_direct)
|
2007-08-30 23:54:49 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
Bool is_ok = FALSE;
|
2010-06-21 15:39:03 +02:00
|
|
|
xcb_connection_t *conn = hostx_get_xcbconn();
|
|
|
|
xcb_glx_is_direct_cookie_t cookie;
|
|
|
|
xcb_glx_is_direct_reply_t *reply = NULL;
|
|
|
|
int remote_glx_ctxt_id = 0;
|
2007-08-30 23:54:49 +02:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
EPHYR_LOG("enter\n");
|
2010-06-21 15:39:03 +02:00
|
|
|
if (!hostx_get_resource_id_peer (a_ctxt_id, &remote_glx_ctxt_id)) {
|
|
|
|
EPHYR_LOG_ERROR ("failed to get remote glx ctxt id\n");
|
2012-03-21 20:55:09 +01:00
|
|
|
goto out;
|
2007-08-30 23:54:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Send the glXIsDirect request */
|
2010-06-21 15:39:03 +02:00
|
|
|
cookie = xcb_glx_is_direct(conn, remote_glx_ctxt_id);
|
|
|
|
reply = xcb_glx_is_direct_reply(conn, cookie, NULL);
|
|
|
|
if (!reply) {
|
2012-03-21 20:55:09 +01:00
|
|
|
EPHYR_LOG_ERROR("fail in reading reply from host\n");
|
|
|
|
goto out;
|
2007-08-30 23:54:49 +02:00
|
|
|
}
|
2010-06-21 15:39:03 +02:00
|
|
|
*a_is_direct = reply->is_direct;
|
2012-03-21 20:55:09 +01:00
|
|
|
is_ok = TRUE;
|
|
|
|
|
2010-06-21 15:39:03 +02:00
|
|
|
out:
|
|
|
|
free(reply);
|
2012-03-21 20:55:09 +01:00
|
|
|
EPHYR_LOG("leave\n");
|
|
|
|
return is_ok;
|
2007-08-30 23:54:49 +02:00
|
|
|
}
|