[Xcb] Any xcb glx working examples?

Jeremy A. Kolb jkolb at brandeis.edu
Sat Jan 12 07:26:46 PST 2008


Mesa when compiled with the xcb target and used for indirect rendering 
uses a good chunk of xcb_glx.

On Fri, 11 Jan 2008, nulleight wrote:

>
> The code still crashes my xserver if i uncomment it. Is there any code that
> actually uses xcb_glx?
>
> Regards, Konstantin.
>
>
> nulleight wrote:
>>
>> Hi, I'm a guy who originally wrote this example and I found this forum
>> while checking out if someone made my or similar code to work. I am
>> running gentoo ~x86 everything compiled with "-O2 -pipe".
>> xorg-server is ver.  1.4.0.90 and xcb 1.1. I tried this example also from
>> time to time on older versions of xserver and xcb with the same result.
>> This problem was not critical for me so i stayed with xlib code and It
>> still works, which is also one of the reasons I haven't tried to debug
>> xserver(it would take me probably a great deal of time just to become
>> familiar with it).  Anyway it would be interesting if someone from the
>> more knowledgeble people would try the code out. I swapped out glxflush
>> for glxfinish and tried to check for glx errors but it didn't change
>> anything. I will try to uncommend the old code and see if it'll crash my
>> xserver and report latelty. I'll send the example as an attachment. There
>> are also kdevelop project files included.
>>
>>  http://www.nabble.com/file/p14755626/glxexample.7z glxexample.7z
>>
>> Jeremy Kolb wrote:
>>>
>>> Adam Burton wrote:
>>>> Hi,
>>>> So far the only example I found is this,
>>>> http://lists.freedesktop.org/archives/xcb/2007-July/002948.html
>>>> which doesn't appear to work (although I see no reason why). If you look
>>>> at
>>>> the source it attempts to get gl errors (commented out) which crashes
>>>> the
>>>> XServer, I can confirm the same happens to me (in 1.0 and 1.1), in fact
>>>> it
>>>> also happens when using xcb_glx_finish.
>>>> Using the x.h and x.c of the above example I converted the following ibm
>>>> glx
>>>> example to xcb and I run into the same problem (have attached my code).
>>>> http://publib.boulder.ibm.com/infocenter/systems/index.jsp?topic=/com.ibm.aix.opengl/doc/openglrf/HowRenderXdraw.htm
>>>>
>>>> I realise the glx guy is on vacation so I don't expect a speedy response
>>>> but
>>>> any assistance is appreciated.
>>>>
>>>> Regards,
>>>> Adam
>>>>
>>>>
>>>> ------------------------------------------------------------------------
>>>>
>>>> #include "GL/gl.h"
>>>> #include "x.h"
>>>>
>>>> static int AttributeList[] = { GLX_RGBA, 0 };
>>>>
>>>> xcb_glx_context_t glxcontext;
>>>> xcb_colormap_t    xcolormap;
>>>> xcb_window_t      xwindow;
>>>> xcb_glx_window_t  glxwindow;
>>>> xcb_glx_context_tag_t glxcontext_tag;
>>>> int32_t screen_number;
>>>> xcb_connection_t* xconnection;
>>>> xcb_screen_t* xscreen;
>>>>
>>>> void setup_glx13() {
>>>> 	/* Find a FBConfig that uses RGBA.  Note that no attribute list is */
>>>> 	/* needed since GLX_RGBA_BIT is a default attribute.*/
>>>> 	    uint32_t glxattribs[] = {
>>>>                                 GLX_DOUBLEBUFFER, 1,
>>>>                                 GLX_RED_SIZE, 8,
>>>>                                 GLX_GREEN_SIZE, 8,
>>>>                                 GLX_BLUE_SIZE, 8,
>>>>                                 GLX_ALPHA_SIZE, 8,
>>>>                                 GLX_STENCIL_SIZE, 8,
>>>>                                 GLX_DEPTH_SIZE, 24,
>>>>                                 GLX_BUFFER_SIZE, 32,
>>>>                                 GLX_RENDER_TYPE, GLX_RGBA_BIT,
>>>>                                 GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT |
>>>> GLX_PIXMAP_BIT | GLX_PBUFFER_BIT,
>>>>                                 GLX_X_RENDERABLE, true
>>>>                             };
>>>>
>>>> 	xcb_glx_fbconfig_t fbconfig = glx_choose_fbconfig( xconnection,
>>>> screen_number, glxattribs, sizeof(glxattribs)/2/sizeof(uint32_t));
>>>> 	xcb_visualid_t glxvisual = get_attrib_from_fbconfig( xconnection,
>>>> screen_number, fbconfig, GLX_VISUAL_ID );
>>>>
>>>> 	/* Create a GLX context using the first FBConfig in the list. */
>>>> 	xcb_glx_create_new_context( xconnection, glxcontext, fbconfig,
>>>> screen_number, GLX_RGBA_TYPE, 0, true, 0, 0 );
>>>>
>>>> 	/* Create a colormap */
>>>> 	xcb_create_colormap( xconnection , XCB_COLORMAP_ALLOC_NONE, xcolormap,
>>>> xscreen->root, glxvisual );
>>>>
>>>> 	/* Create a window */
>>>> 	uint32_t value_list[2], value_mask = XCB_CW_BACK_PIXEL |
>>>> XCB_CW_COLORMAP ;
>>>>     value_list[0] = xscreen->white_pixel;
>>>>     value_list[1] = xcolormap;
>>>>
>>>>     xcb_create_window( xconnection, xscreen->root_depth, xwindow,
>>>> xscreen->root, 0, 0, 100, 100, 0,
>>>>
>>>> XCB_WINDOW_CLASS_INPUT_OUTPUT,
>>>>                                                             glxvisual,
>>>>                                                             value_mask,
>>>>                                                             value_list
>>>> );
>>>>     xcb_map_window( xconnection, xwindow );
>>>> 	/* Create a GLX window using the same FBConfig that we used for the */
>>>> 	/* the GLX context.                                                 */
>>>> 	xcb_glx_create_window( xconnection, screen_number, fbconfig, xwindow,
>>>> glxwindow, 0, 0);
>>>> 	/* Connect the context to the window for read and write */
>>>>     xcb_glx_make_context_current_reply_t* reply_ctx =
>>>> xcb_glx_make_context_current_reply ( xconnection,
>>>> xcb_glx_make_context_current( xconnection, 0, glxwindow, glxwindow,
>>>> glxcontext ), 0);
>>>> 	glxcontext_tag = reply_ctx->context_tag;
>>>> }
>>>>
>>>> int main(int argc, char **argv) {
>>>>
>>>>     xconnection = xcb_connect( NULL, &screen_number );
>>>>
>>>>     // getting the default screen
>>>>     xscreen = xcb_setup_roots_iterator( xcb_get_setup( xconnection
>>>> )).data;
>>>>
>>>> 	glxcontext = xcb_generate_id( xconnection );
>>>> 	xcolormap  = xcb_generate_id( xconnection );
>>>> 	xwindow    = xcb_generate_id( xconnection );
>>>> 	glxwindow  = xcb_generate_id( xconnection );
>>>>
>>>> 	setup_glx13();
>>>> 	xcb_flush(xconnection);
>>>> 	/* clear the buffer */
>>>> 	glClearColor(1,1,0,1);
>>>> 	glClear(GL_COLOR_BUFFER_BIT);
>>>> 	glFlush();
>>>>
>>>> 	//This kills xserver
>>>> 	//xcb_glx_finish_reply_t* reply = xcb_glx_finish_reply(xconnection,
>>>> xcb_glx_finish (xconnection, glxcontext_tag), 0);
>>>>
>>>> 	xcb_glx_swap_buffers( xconnection, glxcontext_tag, glxwindow );
>>>>
>>>> 	/* wait a while */
>>>> 	sleep(10);
>>>> }
>>>>
>>>>
>>>> ------------------------------------------------------------------------
>>>>
>>>> _______________________________________________
>>>> Xcb mailing list
>>>> Xcb at lists.freedesktop.org
>>>> http://lists.freedesktop.org/mailman/listinfo/xcb
>>>
>>> My guess on the crash is that instead of doing xcb_glx_finish you
>>> probably need to do glFinish as it probably does things that
>>> xcb_glx_finish doesn't do.  Also what are you using for GL
>>> (mesa/nvidia/fglrx)?  You'll have better luck if you stick to mesa
>>> indirect rendering, probably compiled xcb support.
>>>
>>> Jeremy
>>> _______________________________________________
>>> Xcb mailing list
>>> Xcb at lists.freedesktop.org
>>> http://lists.freedesktop.org/mailman/listinfo/xcb
>>>
>>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/Any-xcb-glx-working-examples--tp14543654p14756188.html
> Sent from the Free Desktop - xcb mailing list archive at Nabble.com.
>
> _______________________________________________
> Xcb mailing list
> Xcb at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xcb
>


More information about the Xcb mailing list