proxy the glXGetFBConfigSGIX call
* hw/kdrive/ephyr/ephyrglxext.c: (ephyrGLXGetFBConfigsSGIX): proxy the GLXGetFBConfigsSGIX call. It is a vendor extension to get the visual configs as a list of name/value pairs. (ephyrHijackGLXExtension): hijack the VendorPriv_dispatch_info dispatch table to register our implementation of GLXGetFBConfigsSGIX (ephyrGLXGetFBConfigsSGIXReal): added this where the real implementation of GLXGetFBConfigsSGIX is. It support bytes swapping. (ephyrGLXGetFBConfigsSGIX,ephyrGLXGetFBConfigsSGIXSwap): these are the dispatch entry points. They just call ephyrGLXGetFBConfigsSGIXReal. * hw/kdrive/ephyr/ephyrhostglx.c,h: reorganize the proxies to get visual params from the host so that they clearly support the different methods of doing so.
This commit is contained in:
parent
5af73f98c4
commit
26da625055
|
@ -59,17 +59,22 @@ int ephyrGLXClientInfo(__GLXclientState *cl, GLbyte *pc) ;
|
|||
int ephyrGLXClientInfoSwap(__GLXclientState *cl, GLbyte *pc) ;
|
||||
int ephyrGLXQueryServerString(__GLXclientState *a_cl, GLbyte *a_pc) ;
|
||||
int ephyrGLXQueryServerStringSwap(__GLXclientState *a_cl, GLbyte *a_pc) ;
|
||||
int ephyrGLXGetFBConfigsSGIX (__GLXclientState *a_cl, GLbyte *a_pc);
|
||||
int ephyrGLXGetFBConfigsSGIXSwap (__GLXclientState *a_cl, GLbyte *a_pc);
|
||||
|
||||
Bool
|
||||
ephyrHijackGLXExtension (void)
|
||||
{
|
||||
const void *(*dispatch_functions)[2];
|
||||
|
||||
EPHYR_LOG ("Got GLX extension\n") ;
|
||||
EPHYR_LOG ("going to hijack some glx entry points ...\n") ;
|
||||
if (!Single_dispatch_info.dispatch_functions) {
|
||||
EPHYR_LOG_ERROR ("could not get dispatch functions table\n") ;
|
||||
return FALSE ;
|
||||
}
|
||||
/*
|
||||
* hijack some single entry point dispatch functions
|
||||
*/
|
||||
dispatch_functions = Single_dispatch_info.dispatch_functions ;
|
||||
EPHYR_RETURN_VAL_IF_FAIL (dispatch_functions, FALSE) ;
|
||||
|
||||
|
@ -83,9 +88,16 @@ ephyrHijackGLXExtension (void)
|
|||
dispatch_functions[X_GLXClientInfo][1] = ephyrGLXClientInfoSwap ;
|
||||
|
||||
dispatch_functions[X_GLXQueryServerString][0] = ephyrGLXQueryServerString ;
|
||||
dispatch_functions[X_GLXQueryServerString][1] = ephyrGLXQueryServerStringSwap ;
|
||||
dispatch_functions[X_GLXQueryServerString][1] =
|
||||
ephyrGLXQueryServerStringSwap ;
|
||||
|
||||
EPHYR_LOG ("hijacked mesa GL to forward requests to host X\n") ;
|
||||
/*
|
||||
* hijack some vendor priv entry point dispatch functions
|
||||
*/
|
||||
dispatch_functions = VendorPriv_dispatch_info.dispatch_functions ;
|
||||
dispatch_functions[92][0] = ephyrGLXGetFBConfigsSGIX;
|
||||
dispatch_functions[92][1] = ephyrGLXGetFBConfigsSGIXSwap;
|
||||
EPHYR_LOG ("hijacked glx entry points to forward requests to host X\n") ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
@ -114,6 +126,8 @@ ephyrGLXQueryVersion(__GLXclientState *a_cl, GLbyte *a_pc)
|
|||
EPHYR_LOG_ERROR ("ephyrHostGLXQueryVersion() failed\n") ;
|
||||
goto out ;
|
||||
}
|
||||
EPHYR_LOG ("major:%d, minor:%d\n",
|
||||
major, minor);
|
||||
reply.majorVersion = major ;
|
||||
reply.minorVersion = minor ;
|
||||
reply.length = 0 ;
|
||||
|
@ -145,7 +159,9 @@ ephyrGLXQueryVersionSwap (__GLXclientState *a_cl, GLbyte *a_pc)
|
|||
}
|
||||
|
||||
static int
|
||||
ephyrGLXGetVisualConfigsReal (__GLXclientState *a_cl, GLbyte *a_pc, Bool a_do_swap)
|
||||
ephyrGLXGetVisualConfigsReal (__GLXclientState *a_cl,
|
||||
GLbyte *a_pc,
|
||||
Bool a_do_swap)
|
||||
{
|
||||
xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) a_pc;
|
||||
ClientPtr client = a_cl->client;
|
||||
|
@ -200,6 +216,64 @@ out:
|
|||
return res ;
|
||||
}
|
||||
|
||||
static int
|
||||
ephyrGLXGetFBConfigsSGIXReal (__GLXclientState *a_cl,
|
||||
GLbyte *a_pc,
|
||||
Bool a_do_swap)
|
||||
{
|
||||
xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *)a_pc;
|
||||
ClientPtr client = a_cl->client;
|
||||
xGLXGetVisualConfigsReply reply;
|
||||
int32_t *props_buf=NULL, num_visuals=0,
|
||||
num_props=0, res=BadImplementation, i=0,
|
||||
props_per_visual_size=0,
|
||||
props_buf_size=0;
|
||||
__GLX_DECLARE_SWAP_VARIABLES;
|
||||
__GLX_DECLARE_SWAP_ARRAY_VARIABLES;
|
||||
|
||||
EPHYR_LOG ("enter\n") ;
|
||||
|
||||
if (!ephyrHostGLXVendorPrivGetFBConfigsSGIX (req->screen,
|
||||
&num_visuals,
|
||||
&num_props,
|
||||
&props_buf_size,
|
||||
&props_buf)) {
|
||||
EPHYR_LOG_ERROR ("ephyrHostGLXGetVisualConfigs() failed\n") ;
|
||||
goto out ;
|
||||
}
|
||||
EPHYR_LOG ("num_visuals:%d, num_props:%d\n", num_visuals, num_props) ;
|
||||
|
||||
reply.numVisuals = num_visuals;
|
||||
reply.numProps = num_props;
|
||||
reply.length = props_buf_size >> 2;
|
||||
reply.type = X_Reply;
|
||||
reply.sequenceNumber = client->sequence;
|
||||
|
||||
if (a_do_swap) {
|
||||
__GLX_SWAP_SHORT(&reply.sequenceNumber);
|
||||
__GLX_SWAP_INT(&reply.length);
|
||||
__GLX_SWAP_INT(&reply.numVisuals);
|
||||
__GLX_SWAP_INT(&reply.numProps);
|
||||
__GLX_SWAP_INT_ARRAY (props_buf, num_props) ;
|
||||
}
|
||||
WriteToClient(client, sz_xGLXGetVisualConfigsReply, (char*)&reply);
|
||||
props_per_visual_size = props_buf_size/num_visuals ;
|
||||
for (i=0; i < num_visuals; i++) {
|
||||
WriteToClient (client,
|
||||
props_per_visual_size,
|
||||
&((char*)props_buf)[i*props_per_visual_size]);
|
||||
}
|
||||
res = Success ;
|
||||
|
||||
out:
|
||||
EPHYR_LOG ("leave\n") ;
|
||||
if (props_buf) {
|
||||
xfree (props_buf) ;
|
||||
props_buf = NULL ;
|
||||
}
|
||||
return res ;
|
||||
}
|
||||
|
||||
int
|
||||
ephyrGLXGetVisualConfigs (__GLXclientState *a_cl, GLbyte *a_pc)
|
||||
{
|
||||
|
@ -256,10 +330,13 @@ ephyrGLXQueryServerString(__GLXclientState *a_cl, GLbyte *a_pc)
|
|||
int length=0 ;
|
||||
|
||||
EPHYR_LOG ("enter\n") ;
|
||||
if (!ephyrHostGLXGetStringFromServer (req->screen, req->name, &server_string)) {
|
||||
if (!ephyrHostGLXGetStringFromServer (req->screen,
|
||||
req->name,
|
||||
&server_string)) {
|
||||
EPHYR_LOG_ERROR ("failed to query string from host\n") ;
|
||||
goto out ;
|
||||
}
|
||||
EPHYR_LOG ("string: %s", server_string) ;
|
||||
length= strlen (server_string) + 1;
|
||||
reply.type = X_Reply ;
|
||||
reply.sequenceNumber = client->sequence ;
|
||||
|
@ -287,5 +364,18 @@ ephyrGLXQueryServerStringSwap(__GLXclientState *a_cl, GLbyte *a_pc)
|
|||
return BadImplementation ;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
ephyrGLXGetFBConfigsSGIX (__GLXclientState *a_cl, GLbyte *a_pc)
|
||||
{
|
||||
return ephyrGLXGetFBConfigsSGIXReal (a_cl, a_pc, FALSE) ;
|
||||
}
|
||||
|
||||
int
|
||||
ephyrGLXGetFBConfigsSGIXSwap (__GLXclientState *a_cl, GLbyte *a_pc)
|
||||
{
|
||||
return ephyrGLXGetFBConfigsSGIXReal (a_cl, a_pc, TRUE) ;
|
||||
}
|
||||
|
||||
#endif /*XEPHYR_DRI*/
|
||||
|
||||
|
|
|
@ -42,7 +42,20 @@
|
|||
#include "ephyrlog.h"
|
||||
|
||||
#ifdef XEPHYR_DRI
|
||||
enum VisualConfRequestType {
|
||||
EPHYR_GET_FB_CONFIG,
|
||||
EPHYR_VENDOR_PRIV_GET_FB_CONFIG_SGIX,
|
||||
EPHYR_GET_VISUAL_CONFIGS
|
||||
|
||||
};
|
||||
|
||||
static Bool ephyrHostGLXGetVisualConfigsInternal
|
||||
(enum VisualConfRequestType a_type,
|
||||
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);
|
||||
Bool
|
||||
ephyrHostGLXGetMajorOpcode (int *a_opcode)
|
||||
{
|
||||
|
@ -163,12 +176,13 @@ ephyrHostGLXGetStringFromServer (int a_screen_number,
|
|||
return TRUE ;
|
||||
}
|
||||
|
||||
Bool
|
||||
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)
|
||||
static Bool
|
||||
ephyrHostGLXGetVisualConfigsInternal (enum VisualConfRequestType a_type,
|
||||
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)
|
||||
{
|
||||
Bool is_ok = FALSE ;
|
||||
Display *dpy = hostx_get_display () ;
|
||||
|
@ -177,7 +191,6 @@ ephyrHostGLXGetVisualConfigs (int32_t a_screen,
|
|||
xGLXVendorPrivateWithReplyReq *vpreq;
|
||||
xGLXGetFBConfigsSGIXReq *sgi_req;
|
||||
xGLXGetVisualConfigsReply reply;
|
||||
unsigned supported_request=0;
|
||||
char *server_glx_version=NULL,
|
||||
*server_glx_extensions=NULL ;
|
||||
int j=0,
|
||||
|
@ -196,44 +209,22 @@ ephyrHostGLXGetVisualConfigs (int32_t a_screen,
|
|||
EPHYR_LOG_ERROR ("failed to get opcode\n") ;
|
||||
goto out ;
|
||||
}
|
||||
if (!ephyrHostGLXGetStringFromServer (0, GLX_VERSION,
|
||||
&server_glx_version)
|
||||
|| !server_glx_version) {
|
||||
EPHYR_LOG_ERROR ("failed to get glx version from server\n") ;
|
||||
goto out ;
|
||||
}
|
||||
|
||||
if (atof (server_glx_version) >= 1.3 ) {
|
||||
supported_request = 1;
|
||||
}
|
||||
|
||||
if (!ephyrHostGLXGetStringFromServer (a_screen, GLX_EXTENSIONS,
|
||||
&server_glx_extensions)) {
|
||||
EPHYR_LOG_ERROR ("failed to get glx extensions from server for screen: %d\n",
|
||||
a_screen) ;
|
||||
goto out ;
|
||||
}
|
||||
if (supported_request != 1) {
|
||||
if (server_glx_extensions
|
||||
&& strstr (server_glx_extensions, "GLX_SGIX_fbconfig" ) != NULL ) {
|
||||
supported_request = 2;
|
||||
} else {
|
||||
supported_request = 3;
|
||||
}
|
||||
}
|
||||
|
||||
LockDisplay(dpy);
|
||||
switch (supported_request) {
|
||||
case 1:
|
||||
switch (a_type) {
|
||||
case EPHYR_GET_FB_CONFIG:
|
||||
GetReq(GLXGetFBConfigs,fb_req);
|
||||
fb_req->reqType = major_opcode;
|
||||
fb_req->glxCode = X_GLXGetFBConfigs;
|
||||
fb_req->screen = a_screen;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case EPHYR_VENDOR_PRIV_GET_FB_CONFIG_SGIX:
|
||||
GetReqExtra(GLXVendorPrivateWithReply,
|
||||
sz_xGLXGetFBConfigsSGIXReq-sz_xGLXVendorPrivateWithReplyReq,vpreq);
|
||||
sz_xGLXGetFBConfigsSGIXReq
|
||||
-
|
||||
sz_xGLXVendorPrivateWithReplyReq,
|
||||
vpreq);
|
||||
sgi_req = (xGLXGetFBConfigsSGIXReq *) vpreq;
|
||||
sgi_req->reqType = major_opcode;
|
||||
sgi_req->glxCode = X_GLXVendorPrivateWithReply;
|
||||
|
@ -241,7 +232,7 @@ ephyrHostGLXGetVisualConfigs (int32_t a_screen,
|
|||
sgi_req->screen = a_screen;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
case EPHYR_GET_VISUAL_CONFIGS:
|
||||
GetReq(GLXGetVisualConfigs,req);
|
||||
req->reqType = major_opcode;
|
||||
req->glxCode = X_GLXGetVisualConfigs;
|
||||
|
@ -274,7 +265,7 @@ ephyrHostGLXGetVisualConfigs (int32_t a_screen,
|
|||
goto out ;
|
||||
}
|
||||
|
||||
if (supported_request != 3) {
|
||||
if (a_type != EPHYR_GET_VISUAL_CONFIGS) {
|
||||
num_props *= 2;
|
||||
}
|
||||
props_per_visual_size = num_props * __GLX_SIZE_INT32;
|
||||
|
@ -282,7 +273,7 @@ ephyrHostGLXGetVisualConfigs (int32_t a_screen,
|
|||
props_buf = malloc (props_buf_size) ;
|
||||
for (j = 0; j < reply.numVisuals; j++) {
|
||||
if (_XRead (dpy,
|
||||
(char*)props_buf + j*props_per_visual_size,
|
||||
&((char*)props_buf)[j*props_per_visual_size],
|
||||
props_per_visual_size) != Success) {
|
||||
EPHYR_LOG_ERROR ("read failed\n") ;
|
||||
}
|
||||
|
@ -290,7 +281,7 @@ ephyrHostGLXGetVisualConfigs (int32_t a_screen,
|
|||
UnlockDisplay(dpy);
|
||||
|
||||
*a_num_visuals = num_visuals ;
|
||||
*a_num_props = num_props ;
|
||||
*a_num_props = reply.numProps ;
|
||||
*a_props_buf_size = props_buf_size ;
|
||||
*a_props_buf = props_buf ;
|
||||
is_ok = TRUE ;
|
||||
|
@ -308,6 +299,47 @@ out:
|
|||
return is_ok;
|
||||
}
|
||||
|
||||
Bool
|
||||
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)
|
||||
{
|
||||
Bool is_ok = FALSE;
|
||||
|
||||
EPHYR_LOG ("enter\n") ;
|
||||
is_ok = ephyrHostGLXGetVisualConfigsInternal (EPHYR_GET_VISUAL_CONFIGS,
|
||||
a_screen,
|
||||
a_num_visuals,
|
||||
a_num_props,
|
||||
a_props_buf_size,
|
||||
a_props_buf) ;
|
||||
|
||||
EPHYR_LOG ("leave:%d\n", is_ok) ;
|
||||
return is_ok;
|
||||
}
|
||||
|
||||
Bool
|
||||
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)
|
||||
{
|
||||
Bool is_ok=FALSE ;
|
||||
EPHYR_LOG ("enter\n") ;
|
||||
is_ok = ephyrHostGLXGetVisualConfigsInternal
|
||||
(EPHYR_VENDOR_PRIV_GET_FB_CONFIG_SGIX,
|
||||
a_screen,
|
||||
a_num_visuals,
|
||||
a_num_props,
|
||||
a_props_buf_size,
|
||||
a_props_buf) ;
|
||||
EPHYR_LOG ("leave\n") ;
|
||||
return is_ok ;
|
||||
}
|
||||
|
||||
Bool
|
||||
ephyrHostGLXSendClientInfo (int32_t a_major, int32_t a_minor,
|
||||
const char* a_extension_list)
|
||||
|
|
|
@ -37,9 +37,13 @@ Bool ephyrHostGLXGetVisualConfigs (int a_screen,
|
|||
int32_t *a_num_props,
|
||||
int32_t *a_props_buf_size,
|
||||
int32_t **a_props_buf) ;
|
||||
|
||||
Bool
|
||||
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);
|
||||
Bool ephyrHostGLXGetMajorOpcode (int32_t *a_opcode) ;
|
||||
|
||||
Bool ephyrHostGLXSendClientInfo (int32_t a_major, int32_t a_minor,
|
||||
const char* a_extension_list) ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user