diff options
Diffstat (limited to 'hw/kdrive/ephyr/ephyrglxext.c')
-rw-r--r-- | hw/kdrive/ephyr/ephyrglxext.c | 179 |
1 files changed, 160 insertions, 19 deletions
diff --git a/hw/kdrive/ephyr/ephyrglxext.c b/hw/kdrive/ephyr/ephyrglxext.c index df285cfcb..22d510891 100644 --- a/hw/kdrive/ephyr/ephyrglxext.c +++ b/hw/kdrive/ephyr/ephyrglxext.c @@ -61,10 +61,16 @@ int ephyrGLXGetFBConfigsSGIX(__GLXclientState * a_cl, GLbyte * a_pc); int ephyrGLXGetFBConfigsSGIXSwap(__GLXclientState * a_cl, GLbyte * a_pc); int ephyrGLXCreateContext(__GLXclientState * a_cl, GLbyte * a_pc); int ephyrGLXCreateContextSwap(__GLXclientState * a_cl, GLbyte * a_pc); +int ephyrGLXCreateNewContext(__GLXclientState * a_cl, GLbyte * a_pc); +int ephyrGLXCreateNewContextSwap(__GLXclientState * a_cl, GLbyte * a_pc); int ephyrGLXDestroyContext(__GLXclientState * a_cl, GLbyte * a_pc); int ephyrGLXDestroyContextSwap(__GLXclientState * a_cl, GLbyte * a_pc); int ephyrGLXMakeCurrent(__GLXclientState * a_cl, GLbyte * a_pc); int ephyrGLXMakeCurrentSwap(__GLXclientState * a_cl, GLbyte * a_pc); +int ephyrGLXMakeCurrentReadSGI(__GLXclientState * a_cl, GLbyte * a_pc); +int ephyrGLXMakeCurrentReadSGISwap(__GLXclientState * a_cl, GLbyte * a_pc); +int ephyrGLXMakeContextCurrent(__GLXclientState * a_cl, GLbyte * a_pc); +int ephyrGLXMakeContextCurrentSwap(__GLXclientState * a_cl, GLbyte * a_pc); int ephyrGLXGetString(__GLXclientState * a_cl, GLbyte * a_pc); int ephyrGLXGetStringSwap(__GLXclientState * a_cl, GLbyte * a_pc); int ephyrGLXGetIntegerv(__GLXclientState * a_cl, GLbyte * a_pc); @@ -108,6 +114,9 @@ ephyrHijackGLXExtension(void) dispatch_functions[X_GLXCreateContext][0] = ephyrGLXCreateContext; dispatch_functions[X_GLXCreateContext][1] = ephyrGLXCreateContextSwap; + dispatch_functions[X_GLXCreateNewContext][0] = ephyrGLXCreateNewContext; + dispatch_functions[X_GLXCreateNewContext][1] = ephyrGLXCreateNewContextSwap; + dispatch_functions[X_GLXDestroyContext][0] = ephyrGLXDestroyContext; dispatch_functions[X_GLXDestroyContext][1] = ephyrGLXDestroyContextSwap; @@ -123,14 +132,24 @@ ephyrHijackGLXExtension(void) dispatch_functions[61][0] = ephyrGLXGetIntegerv; dispatch_functions[61][1] = ephyrGLXGetIntegervSwap; + dispatch_functions[X_GLXMakeContextCurrent][0] = + ephyrGLXMakeContextCurrent; + dispatch_functions[X_GLXMakeContextCurrent][1] = + ephyrGLXMakeContextCurrentSwap; + /* * 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; + + dispatch_functions[89][0] = ephyrGLXMakeCurrentReadSGI; + dispatch_functions[89][1] = ephyrGLXMakeCurrentReadSGISwap; + EPHYR_LOG("hijacked glx entry points to forward requests to host X\n"); + return TRUE; } @@ -445,7 +464,8 @@ ephyrGLXCreateContextReal(xGLXCreateContextReq * a_req, Bool a_do_swap) if (!ephyrHostGLXCreateContext(a_req->screen, host_w_attrs.visualid, a_req->context, - a_req->shareList, a_req->isDirect)) { + a_req->shareList, 0, + a_req->isDirect, X_GLXCreateContext)) { EPHYR_LOG_ERROR("ephyrHostGLXCreateContext() failed\n"); goto out; } @@ -455,6 +475,45 @@ ephyrGLXCreateContextReal(xGLXCreateContextReq * a_req, Bool a_do_swap) return res; } +static int +ephyrGLXCreateNewContextReal(xGLXCreateNewContextReq * a_req, Bool a_do_swap) +{ + int res = BadImplementation; + + __GLX_DECLARE_SWAP_VARIABLES; + + EPHYR_RETURN_VAL_IF_FAIL(a_req, BadValue); + EPHYR_LOG("enter\n"); + + if (a_do_swap) { + __GLX_SWAP_SHORT(&a_req->length); + __GLX_SWAP_INT(&a_req->context); + __GLX_SWAP_INT(&a_req->fbconfig); + __GLX_SWAP_INT(&a_req->screen); + __GLX_SWAP_INT(&a_req->renderType); + __GLX_SWAP_INT(&a_req->shareList); + } + + EPHYR_LOG("context creation requested. localid:%d, " + "screen:%d, fbconfig:%d, renderType:%d, direct:%d\n", + (int) a_req->context, (int) a_req->screen, + (int) a_req->fbconfig, (int) a_req->renderType, + (int) a_req->isDirect); + + if (!ephyrHostGLXCreateContext(a_req->screen, + a_req->fbconfig, + a_req->context, + a_req->shareList, a_req->renderType, + a_req->isDirect, X_GLXCreateNewContext)) { + EPHYR_LOG_ERROR("ephyrHostGLXCreateNewContext() failed\n"); + goto out; + } + res = Success; + out: + EPHYR_LOG("leave\n"); + return res; +} + int ephyrGLXCreateContext(__GLXclientState * cl, GLbyte * pc) { @@ -471,6 +530,22 @@ ephyrGLXCreateContextSwap(__GLXclientState * cl, GLbyte * pc) return ephyrGLXCreateContextReal(req, TRUE); } +int +ephyrGLXCreateNewContext(__GLXclientState * cl, GLbyte * pc) +{ + xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc; + + return ephyrGLXCreateNewContextReal(req, FALSE); +} + +int +ephyrGLXCreateNewContextSwap(__GLXclientState * cl, GLbyte * pc) +{ + xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc; + + return ephyrGLXCreateNewContextReal(req, TRUE); +} + static int ephyrGLXDestroyContextReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap) @@ -505,26 +580,34 @@ ephyrGLXDestroyContextSwap(__GLXclientState * a_cl, GLbyte * a_pc) } static int -ephyrGLXMakeCurrentReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap) +ephyrGLXMakeCurrentReal(__GLXclientState * a_cl, GLXDrawable write, + GLXDrawable read, GLXContextTag ctx, + GLXContextTag old_ctx, Bool a_do_swap) { int res = BadImplementation; - xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) a_pc; xGLXMakeCurrentReply reply; - DrawablePtr drawable = NULL; - GLXContextTag contextTag = 0; - int rc = 0; + DrawablePtr drawableR = NULL, drawableW = NULL; + GLXContextTag new_ctx = 0; EPHYR_LOG("enter\n"); - rc = dixLookupDrawable(&drawable, - req->drawable, a_cl->client, 0, DixReadAccess); - EPHYR_RETURN_VAL_IF_FAIL(drawable, BadValue); - EPHYR_RETURN_VAL_IF_FAIL(drawable->pScreen, BadValue); - EPHYR_LOG("screen nummber requested:%d\n", drawable->pScreen->myNum); - - if (!ephyrHostGLXMakeCurrent(hostx_get_window(drawable->pScreen->myNum), - req->context, - req->oldContextTag, - (int *) &contextTag)) { + res = dixLookupDrawable(&drawableW, write, a_cl->client, 0, DixReadAccess); + EPHYR_RETURN_VAL_IF_FAIL(drawableW, BadValue); + EPHYR_RETURN_VAL_IF_FAIL(drawableW->pScreen, BadValue); + EPHYR_LOG("screen nummber requested:%d\n", drawableW->pScreen->myNum); + + if (read != write) { + res = dixLookupDrawable(&drawableR, read, a_cl->client, 0, + DixReadAccess); + EPHYR_RETURN_VAL_IF_FAIL(drawableR, BadValue); + EPHYR_RETURN_VAL_IF_FAIL(drawableR->pScreen, BadValue); + } + else { + drawableR = drawableW; + } + + if (!ephyrHostGLXMakeCurrent(hostx_get_window(drawableW->pScreen->myNum), + hostx_get_window(drawableR->pScreen->myNum), + ctx, old_ctx, (int *) &new_ctx)) { EPHYR_LOG_ERROR("ephyrHostGLXMakeCurrent() failed\n"); goto out; } @@ -532,7 +615,7 @@ ephyrGLXMakeCurrentReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap) .type = X_Reply, .sequenceNumber = a_cl->client->sequence, .length = 0, - .contextTag = contextTag + .contextTag = new_ctx }; if (a_do_swap) { __GLX_DECLARE_SWAP_VARIABLES; @@ -551,13 +634,71 @@ ephyrGLXMakeCurrentReal(__GLXclientState * a_cl, GLbyte * a_pc, Bool a_do_swap) int ephyrGLXMakeCurrent(__GLXclientState * a_cl, GLbyte * a_pc) { - return ephyrGLXMakeCurrentReal(a_cl, a_pc, FALSE); + xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) a_pc; + return ephyrGLXMakeCurrentReal(a_cl, req->drawable, req->drawable, + req->context, req->oldContextTag, FALSE); } int ephyrGLXMakeCurrentSwap(__GLXclientState * a_cl, GLbyte * a_pc) { - return ephyrGLXMakeCurrentReal(a_cl, a_pc, TRUE); + xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) a_pc; + __GLX_DECLARE_SWAP_VARIABLES; + + __GLX_SWAP_INT(&req->drawable); + __GLX_SWAP_INT(&req->context); + __GLX_SWAP_INT(&req->oldContextTag); + + return ephyrGLXMakeCurrentReal(a_cl, req->drawable, req->drawable, + req->context, req->oldContextTag, TRUE); +} + +int +ephyrGLXMakeCurrentReadSGI(__GLXclientState * a_cl, GLbyte * a_pc) +{ + xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) a_pc; + + return ephyrGLXMakeCurrentReal(a_cl, req->drawable, req->readable, + req->context, req->oldContextTag, FALSE); +} + +int +ephyrGLXMakeCurrentReadSGISwap(__GLXclientState * a_cl, GLbyte * a_pc) +{ + xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) a_pc; + __GLX_DECLARE_SWAP_VARIABLES; + + __GLX_SWAP_INT(&req->drawable); + __GLX_SWAP_INT(&req->readable); + __GLX_SWAP_INT(&req->context); + __GLX_SWAP_INT(&req->oldContextTag); + + return ephyrGLXMakeCurrentReal(a_cl, req->drawable, req->readable, + req->context, req->oldContextTag, TRUE); +} + +int +ephyrGLXMakeContextCurrent(__GLXclientState * a_cl, GLbyte * a_pc) +{ + xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) a_pc; + + return ephyrGLXMakeCurrentReal(a_cl, req->drawable, req->readdrawable, + req->context, req->oldContextTag, FALSE); +} + +int +ephyrGLXMakeContextCurrentSwap(__GLXclientState * a_cl, GLbyte * a_pc) +{ + xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) a_pc; + __GLX_DECLARE_SWAP_VARIABLES; + + __GLX_SWAP_INT(&req->drawable); + __GLX_SWAP_INT(&req->readdrawable); + __GLX_SWAP_INT(&req->context); + __GLX_SWAP_INT(&req->oldContextTag); + + return ephyrGLXMakeCurrentReal(a_cl, req->drawable, req->readdrawable, + req->context, req->oldContextTag, TRUE); } static int |