Bug 8896 - X error when using off-screen rendering with DRI enabled
Summary: X error when using off-screen rendering with DRI enabled
Status: RESOLVED INVALID
Alias: None
Product: DRI
Classification: Unclassified
Component: General (show other bugs)
Version: unspecified
Hardware: x86 (IA32) Linux (All)
: high normal
Assignee: Default DRI bug account
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-05 08:16 UTC by cbeau
Modified: 2019-10-14 13:20 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description cbeau 2006-11-05 08:16:42 UTC
Hi,

I have written a small programme using GTK+ and GtkGLExt. When "dri" is
disabled, my programme runs fine. But when "dri" is enabled, my programme
crashes with the following error message:

myprompt> ./test_glext --sync

[*** I got as far as glXMakeCurrent ***]
The program 'test_glext' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadValue (integer parameter out of range for operation)'.
  (Details: serial 266 error_code 2 request_code 128 minor_code 7)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)

I originally suspected this could be a graphics driver problem. So I set out to
try my program out on both my systems. Here is what I found:

. First machine:
   Card: Intel 915 GM
   X Protocol Version 11, Revision 0, Release 7.0
      Build Operating System:Linux 2.6.12-1-686 i686
   Kernel:   2.6.18
   Processor: one Intel Pentium M processor 2.00GHz (32 bit)
   with Driver "i810" + Direct Rendering ENABLED   = X error
   with Driver "i810" + Direct Rendering DISABLED  = Works

. Second machine:
   Card: ATI Radeon 9200 PRO/SE (Rev 280)
   X Protocol Version 11, Revision 0, Release 7.0
      Build Operating System: Linux 2.6.16-1-vserver-amd64-k8 x86_64
   Kernel: 2.6.17-2-amd64
   Processor: two AMD Opteron Processor 250 (64 bit)
   with Driver "fglrx" + Direct Rendering ENABLED      = X error
   with Driver "ati" + Direct Rendering ENABLED        = X error
   with Driver "ati" + Direct Rendering DISABLED       = Works

So it then appeared as though the problem was with DRI. I started breaking down
my code to find exactly where the crash occurs and tracked it down to the 
function

   gdk_gl_drawable_gl_begin(gldrawable, glcontext)

I downloaded the code for GtkGLExt to find where within this function the crash
occurs. I tracked it down to the function

   glXMakeCurrent(xdisplay, glxpixmap, glxcontext)

So it would appear that the problem is not with GtkGLExt. Which brought me back
to suspecting a problem with "dri". I recently found on the DRI User Guide:

http://dri.sourceforge.net/doc/DRIuserguide.html

The following message:

11.2 GLX
...
GLXPixmap rendering is only supported for indirect rendering contexts. This is a
common OpenGL limitation. Attempting to use a direct rendering context with a
GLXPixmap will result in an X protocol error. 

This seems highly relevant to the bug I am experiencing so if someone could give
me details about this, I would greatly appreciate it.

Anyways, I pasted below the code which replicates the bug. Could someone help me
resolve this problem?

Thanks,
cbeau.

/* Test programme demonstrating the crash when "dri" is enabled */
#include <stdlib.h>
#include <gtk/gtk.h>
#include <gtk/gtkgl.h>
#include <gdk/x11/gdkglx.h>

int main(int argc, char **argv)
{
   GtkWidget *main_window, *image;
   GdkGLConfig *glconfig;
   GdkPixmap *pixmap;
   GdkGLPixmap *glpixmap;
   GdkGLContext *glcontext;
   GdkGLDrawable *gldrawable;
   GLXPixmap glxpixmap;
   GLXContext glxcontext;

   gtk_init(&argc,&argv);

   /* Allowing GtkGLExt to retreive its command line options */
   gdk_gl_init(&argc,&argv);

   /* Check if the OpenGL extension is supported. */
   if( gdk_gl_query_extension() == FALSE ) {
      g_print("OpenGL extension not supported\n");
      exit(1);
   }
   /* Create new top level window. */
   main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   /* Set the main window's title */
   gtk_window_set_title(GTK_WINDOW(main_window), "Testing GdkGLExt");
   /* Add the destroy even to the main window */
   gtk_quit_add_destroy(1,GTK_OBJECT(main_window));
   /* Connect the destroy event to gtk_main_quit */
  
gtk_signal_connect(GTK_OBJECT(main_window),"destroy",G_CALLBACK(gtk_main_quit),NULL);

   /* Create OpenGL config */
   /* No double-buffer because rendering to Off-screen Pixmap */
   glconfig = gdk_gl_config_new_by_mode(GDK_GL_MODE_RGBA|GDK_GL_MODE_DEPTH);
   if( glconfig == NULL ) {
      g_print ("*** Problem with GtkGLExt.\n");
      exit(1);
   }

   /* Create a GdkPixmap */
   pixmap = gdk_pixmap_new(NULL,100,100,gdk_gl_config_get_depth(glconfig));
   /* Set GL capability of GdkPixmap */
   glpixmap = gdk_pixmap_set_gl_capability(pixmap,glconfig,NULL);
   /* Bind GdkPixmap to the GtkImage for display */
   image = gtk_image_new_from_pixmap(pixmap,NULL);
   /* Get GL drawable (rendering surface) from GL-capable GdkPixmap */
   gldrawable = gdk_pixmap_get_gl_drawable(pixmap);
   /* Create a new GL context (rendering context) from GL drawable */
   glcontext = gdk_gl_context_new(gldrawable,NULL,TRUE,GDK_GL_RGBA_TYPE);
   /* Add GtkImage to which the GdkPixmap is attached to main_window */
   gtk_container_add(GTK_CONTAINER(main_window),image);

   gtk_widget_show_all(main_window);

   /* The code below is from the gl_begin function of gtkglext */
   /* as defined in gdk/x11/gdkglpixmap-x11.c (with slight modifs) */
   glxpixmap = GDK_GL_PIXMAP_GLXPIXMAP(glpixmap);
   glxcontext = GDK_GL_CONTEXT_GLXCONTEXT(glcontext);

   Display* xdisplay = GDK_GL_CONFIG_XDISPLAY(glconfig);
   /* This crashes if DRI enabled but works if DRI disabled */
   fprintf( stderr, "[*** I got as far as glXMakeCurrent ***]\n" );
   glXMakeCurrent(xdisplay,glxpixmap,glxcontext);
   fprintf( stderr, "[*** I survived glXMakeCurrent ***]\n" );

   gtk_main();

   return(0);
}
Comment 1 chemtech 2013-03-15 14:24:41 UTC
cbeau
Do you still experience this issue with newer soft ?
Please check the status of your issue.
Comment 2 Martin Peres 2019-10-14 13:20:01 UTC
Hi,

Freedesktop's Bugzilla instance is EOLed and open bugs are about to be migrated to http://gitlab.freedesktop.org.

To avoid migrating out of date bugs, I am now closing all the bugs that did not see any activity in the past year. If the issue is still happening, please create a new bug in the relevant project at https://gitlab.freedesktop.org/drm (use misc by default).

Sorry about the noise!


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.