X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fstate_trackers%2Fglx%2Fxlib%2Fglx_api.c;h=748efea864926639fd491fc0cfb6cde3c9e7ab02;hb=3dd299c3d5b88114894ec30d1fac85fba688201f;hp=ad80dc09d1cf66f0cc29d2da4cb5d415066b2694;hpb=8af4aaf351313f9d4692697bf28d3c3f84e01ca4;p=mesa.git diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c index ad80dc09d1c..748efea8649 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_api.c +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c @@ -33,11 +33,23 @@ #define GLX_GLXEXT_PROTOTYPES #include "GL/glx.h" +#include +#include #include #include #include "xm_api.h" +#include "main/imports.h" +#include "main/errors.h" +#include "util/u_math.h" +/* An "Atrribs/Attribs" typo was fixed in glxproto.h in Nov 2014. + * This is in case we don't have the updated header. + */ +#if !defined(X_GLXCreateContextAttribsARB) && \ + defined(X_GLXCreateContextAtrribsARB) +#define X_GLXCreateContextAttribsARB X_GLXCreateContextAtrribsARB +#endif /* This indicates the client-side GLX API and GLX encoder version. */ #define CLIENT_MAJOR_VERSION 1 @@ -172,7 +184,7 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, GLint depth_size, GLint stencil_size, GLint accumRedSize, GLint accumGreenSize, GLint accumBlueSize, GLint accumAlphaSize, - GLint level, GLint numAuxBuffers ) + GLint level, GLint numAuxBuffers, GLuint num_samples ) { GLboolean ximageFlag = GL_TRUE; XMesaVisual xmvis; @@ -220,6 +232,7 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, if (v->display == dpy && v->mesa_visual.level == level && v->mesa_visual.numAuxBuffers == numAuxBuffers + && v->mesa_visual.samples == num_samples && v->ximage_flag == ximageFlag && v->mesa_visual.rgbMode == rgbFlag && v->mesa_visual.doubleBufferMode == dbFlag @@ -245,7 +258,7 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, stereoFlag, ximageFlag, depth_size, stencil_size, accumRedSize, accumBlueSize, - accumBlueSize, accumAlphaSize, 0, level, + accumBlueSize, accumAlphaSize, num_samples, level, GLX_NONE_EXT ); if (xmvis) { /* Save a copy of the pointer now so we can find this visual again @@ -335,7 +348,8 @@ create_glx_visual( Display *dpy, XVisualInfo *visinfo ) accBits, /* b */ accBits, /* a */ 0, /* level */ - 0 /* numAux */ + 0, /* numAux */ + 0 /* numSamples */ ); } else { @@ -406,9 +420,9 @@ get_visual( Display *dpy, int scr, unsigned int depth, int xclass ) * 10 bits per color channel. Mesa's limited to a max of 8 bits/channel. */ if (vis && depth > 24 && (xclass==TrueColor || xclass==DirectColor)) { - if (_mesa_bitcount((GLuint) vis->red_mask ) <= 8 && - _mesa_bitcount((GLuint) vis->green_mask) <= 8 && - _mesa_bitcount((GLuint) vis->blue_mask ) <= 8) { + if (util_bitcount((GLuint) vis->red_mask ) <= 8 && + util_bitcount((GLuint) vis->green_mask) <= 8 && + util_bitcount((GLuint) vis->blue_mask ) <= 8) { return vis; } else { @@ -606,6 +620,7 @@ close_display_callback(Display *dpy, XExtCodes *codes) { xmesa_destroy_buffers_on_display(dpy); destroy_visuals_on_display(dpy); + xmesa_close_display(dpy); return 0; } @@ -643,7 +658,7 @@ register_with_display(Display *dpy) ext = dpy->ext_procs; /* new extension is at head of list */ assert(c->extension == ext->codes.extension); (void) c; - ext->name = _mesa_strdup(extName); + ext->name = strdup(extName); ext->close_display = close_display_callback; } } @@ -729,8 +744,12 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig ) XMesaVisual xmvis = NULL; int desiredVisualID = -1; int numAux = 0; + GLint num_samples = 0; - xmesa_init( dpy ); + if (xmesa_init( dpy ) != 0) { + _mesa_warning(NULL, "Failed to initialize display"); + return NULL; + } parselist = list; @@ -895,12 +914,13 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig ) * GLX_ARB_multisample */ case GLX_SAMPLE_BUFFERS_ARB: + /* ignore */ + parselist++; + parselist++; + break; case GLX_SAMPLES_ARB: parselist++; - if (*parselist++ != 0) { - /* ms not supported */ - return NULL; - } + num_samples = *parselist++; break; /* @@ -946,7 +966,6 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig ) parselist += 2; /* ignore the parameter */ break; -#ifdef GLX_EXT_texture_from_pixmap case GLX_BIND_TO_TEXTURE_RGB_EXT: parselist++; /*skip*/ break; @@ -968,7 +987,6 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig ) case GLX_Y_INVERTED_EXT: parselist++; /*skip*/ break; -#endif case None: /* end of list */ @@ -984,6 +1002,10 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig ) (void) caveat; + if (num_samples < 0) { + _mesa_warning(NULL, "GLX_SAMPLES_ARB: number of samples must not be negative"); + return NULL; + } /* * Since we're only simulating the GLX extension this function will never @@ -1059,7 +1081,8 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig ) xmvis = save_glx_visual( dpy, vis, rgb_flag, alpha_flag, double_flag, stereo_flag, depth_size, stencil_size, accumRedSize, accumGreenSize, - accumBlueSize, accumAlphaSize, level, numAux ); + accumBlueSize, accumAlphaSize, level, numAux, + num_samples ); } return xmvis; @@ -1483,7 +1506,7 @@ glXQueryVersion( Display *dpy, int *maj, int *min ) static int get_config( XMesaVisual xmvis, int attrib, int *value, GLboolean fbconfig ) { - ASSERT(xmvis); + assert(xmvis); switch(attrib) { case GLX_USE_GL: if (fbconfig) @@ -1594,10 +1617,10 @@ get_config( XMesaVisual xmvis, int attrib, int *value, GLboolean fbconfig ) * GLX_ARB_multisample */ case GLX_SAMPLE_BUFFERS_ARB: - *value = 0; + *value = xmvis->mesa_visual.sampleBuffers; return 0; case GLX_SAMPLES_ARB: - *value = 0; + *value = xmvis->mesa_visual.samples; return 0; /* @@ -1634,7 +1657,7 @@ get_config( XMesaVisual xmvis, int attrib, int *value, GLboolean fbconfig ) case GLX_MAX_PBUFFER_WIDTH: if (!fbconfig) return GLX_BAD_ATTRIBUTE; - /* XXX or MAX_WIDTH? */ + /* XXX should be same as ctx->Const.MaxRenderbufferSize */ *value = DisplayWidth(xmvis->display, xmvis->visinfo->screen); break; case GLX_MAX_PBUFFER_HEIGHT: @@ -1654,7 +1677,6 @@ get_config( XMesaVisual xmvis, int attrib, int *value, GLboolean fbconfig ) *value = xmvis->visinfo->visualid; break; -#ifdef GLX_EXT_texture_from_pixmap case GLX_BIND_TO_TEXTURE_RGB_EXT: *value = True; /*XXX*/ break; @@ -1673,7 +1695,6 @@ get_config( XMesaVisual xmvis, int attrib, int *value, GLboolean fbconfig ) case GLX_Y_INVERTED_EXT: *value = True; /*XXX*/ break; -#endif default: return GLX_BAD_ATTRIBUTE; @@ -2153,7 +2174,6 @@ glXQueryDrawable(Display *dpy, GLXDrawable draw, int attribute, case GLX_FBCONFIG_ID: *value = xmbuf->xm_visual->visinfo->visualid; return; -#ifdef GLX_EXT_texture_from_pixmap case GLX_TEXTURE_FORMAT_EXT: *value = xmbuf->TextureFormat; break; @@ -2163,10 +2183,9 @@ glXQueryDrawable(Display *dpy, GLXDrawable draw, int attribute, case GLX_MIPMAP_TEXTURE_EXT: *value = xmbuf->TextureMipmap; break; -#endif default: - generate_error(dpy, BadValue, 0, X_GLXCreateContextAtrribsARB, true); + generate_error(dpy, BadValue, 0, X_GLXCreateContextAttribsARB, true); return; } } @@ -2476,7 +2495,7 @@ glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf) } -PUBLIC int +PUBLIC void glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value) { @@ -2484,7 +2503,7 @@ glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, if (!xmbuf) { /* Generate GLXBadPbufferSGIX for bad pbuffer */ - return 0; + return; } switch (attribute) { @@ -2506,7 +2525,6 @@ glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, default: *value = 0; } - return 0; } @@ -2631,44 +2649,11 @@ glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, #endif -/*** GLX_SGIX_swap_group ***/ - -PUBLIC void -glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member) -{ - (void) dpy; - (void) drawable; - (void) member; -} - - - -/*** GLX_SGIX_swap_barrier ***/ - -PUBLIC void -glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier) -{ - (void) dpy; - (void) drawable; - (void) barrier; -} - -PUBLIC Bool -glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max) -{ - (void) dpy; - (void) screen; - (void) max; - return False; -} - - - /*** GLX_SUN_get_transparent_index ***/ PUBLIC Status glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, - long *pTransparent) + unsigned long *pTransparent) { (void) dpy; (void) overlay; @@ -2760,14 +2745,14 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, break; default: /* bad attribute */ - generate_error(dpy, BadValue, 0, X_GLXCreateContextAtrribsARB, True); + generate_error(dpy, BadValue, 0, X_GLXCreateContextAttribsARB, True); return NULL; } } /* check contextFlags */ if (contextFlags & ~contextFlagsAll) { - generate_error(dpy, BadValue, 0, X_GLXCreateContextAtrribsARB, True); + generate_error(dpy, BadValue, 0, X_GLXCreateContextAttribsARB, True); return NULL; } @@ -2775,14 +2760,14 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, if (profileMask != GLX_CONTEXT_CORE_PROFILE_BIT_ARB && profileMask != GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB && profileMask != GLX_CONTEXT_ES_PROFILE_BIT_EXT) { - generate_error(dpy, GLXBadProfileARB, 0, X_GLXCreateContextAtrribsARB, False); + generate_error(dpy, GLXBadProfileARB, 0, X_GLXCreateContextAttribsARB, False); return NULL; } /* check renderType */ if (renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE) { - generate_error(dpy, BadValue, 0, X_GLXCreateContextAtrribsARB, True); + generate_error(dpy, BadValue, 0, X_GLXCreateContextAttribsARB, True); return NULL; } @@ -2795,7 +2780,7 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, (majorVersion == 3 && minorVersion > 3) || (majorVersion == 4 && minorVersion > 5) || majorVersion > 4))) { - generate_error(dpy, BadMatch, 0, X_GLXCreateContextAtrribsARB, True); + generate_error(dpy, BadMatch, 0, X_GLXCreateContextAttribsARB, True); return NULL; } if (profileMask == GLX_CONTEXT_ES_PROFILE_BIT_EXT && @@ -2807,18 +2792,18 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, * different error code for invalid ES versions, but this is what NVIDIA * does and piglit expects. */ - generate_error(dpy, GLXBadProfileARB, 0, X_GLXCreateContextAtrribsARB, False); + generate_error(dpy, GLXBadProfileARB, 0, X_GLXCreateContextAttribsARB, False); return NULL; } if ((contextFlags & GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB) && majorVersion < 3) { - generate_error(dpy, BadMatch, 0, X_GLXCreateContextAtrribsARB, True); + generate_error(dpy, BadMatch, 0, X_GLXCreateContextAttribsARB, True); return NULL; } if (renderType == GLX_COLOR_INDEX_TYPE && majorVersion >= 3) { - generate_error(dpy, BadMatch, 0, X_GLXCreateContextAtrribsARB, True); + generate_error(dpy, BadMatch, 0, X_GLXCreateContextAttribsARB, True); return NULL; } @@ -2828,7 +2813,7 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, majorVersion, minorVersion, profileMask, contextFlags); if (!ctx) { - generate_error(dpy, GLXBadFBConfig, 0, X_GLXCreateContextAtrribsARB, False); + generate_error(dpy, GLXBadFBConfig, 0, X_GLXCreateContextAttribsARB, False); } return ctx;