summaryrefslogtreecommitdiff
path: root/src/glx/dri2_glx.c
AgeCommit message (Collapse)AuthorFilesLines
2013-11-07glx/dri2: Add DRI2 support for GLX_MESA_query_rendererIan Romanick1-1/+12
The new functions for this extension were added to a separate file (dri2_query_renderer.c) to facilitate unit testing. I tried putting them in dri2_glx.c, and it resulting in an unending chain of dependencies. It was the proverbial threading hanging from a sweater. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2013-11-07glx/dri2: Pull some internal structures out to a separate header fileIan Romanick1-20/+1
This structures will be accessed by internal functions that will be added in a file separate from dri2_glx.c. The new code will be added to a new file to facilitate unit testing. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2013-10-24dri: Pass in the dlsym()ed driver extension to screen creation.Eric Anholt1-9/+14
This will allow a megadrivers build to reference the actual driver being loaded from the shared dri_util screen creation code. v2: Fix indentation, fallback case in EGL (review by Emil). Reviewed-by: Matt Turner <mattst88@gmail.com> (v1) Reviewed-by: Chad Versace <chad.versace@linux.intel.com> (v1) Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2013-10-24glx: Add an optional function call for getting the DRI driver interface.Eric Anholt1-1/+1
The previous interface relied on a static struct, which meant that the driver didn't get a chance to edit the struct before the struct got used. For megadrivers, I want struct specific to the driver being loaded. v2: Fix the prototype in the docs (caught by Marek). Since the driver name was in the function, we didn't need to also pass it in. v3: Fix asprintf error checking (caught by Matt's gcc). Reviewed-by: Matt Turner <mattst88@gmail.com> (v1) Reviewed-by: Chad Versace <chad.versace@linux.intel.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2013-10-24glx: Move the driver extension-loading to a helper function.Eric Anholt1-4/+2
I'm planning on doing driver extension parsing from 3 places, and making the extension loading step a bit longer. Reviewed-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Chad Versace <chad.versace@linux.intel.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2013-09-04glx: Initialize OpenGL version to 1.0Rico Schüller1-5/+5
The old code in dri2_glx suffered from a typographical error that caused the default version to be 2.1 instead of 1.2 (minimum required by the Linux OpenGL ABI). drisw_glx had a similar error resulting in a default version of 0.1. Some driver/card combinations (r200/RV280, i915/915G) don't support OpenGL 2.1. These create in some corner cases an indirect context instead of a direct context when calling glXCreateContextAttribsARB(). This happens because of a bad default value. To avoid this, just used the default value specified by the GLX_ARB_create_context specification: "The default values for GLX_CONTEXT_MAJOR_VERSION_ARB and GLX_CONTEXT_MINOR_VERSION_ARB are 1 and 0 respectively. In this case, implementations will typically return the most recent version of OpenGL they support which is backwards compatible with OpenGL 1.0 (e.g. 3.0, 3.1 + GL_ARB_compatibility, or 3.2 compatibility profile)" Refactor all the default value setting to dri2_convert_glx_attribs, and make sure the correct defaults are set in that one place. Signed-off-by: Rico Schüller <kgbricola@web.de> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Bugzilla http://bugs.winehq.org/show_bug.cgi?id=34238 Cc: "9.1 9.2" <mesa-stable@lists.freedesktop.org>
2013-09-02glx: make the interval of LIBGL_SHOW_FPS adjustableChia-I Wu1-4/+8
LIBGL_SHOW_FPS=1 makes GLX print FPS every second while other values do nothing. Extend it so that LIBGL_SHOW_FPS=N will print the FPS every N seconds. Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com>
2013-07-18glx: Validate the GLX_RENDER_TYPE valueTomasz Lis1-0/+8
Correctly handle the value of renderType in GLX context. In case of the value being incorrect, context creation fails. v2 (idr): indirect_create_context is just a memory allocator, so don't validate the GLX_RENDER_TYPE there. Fixes regressions in several GLX_ARB_create_context piglit tests. Signed-off-by: Tomasz Lis <tomasz.lis@intel.com> Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-07-18glx: Retrieve the value of RENDER_TYPE from GLX attribs arrayTomasz Lis1-2/+2
Make sure that context creation routines are provided with the value of RENDER_TYPE retrieved from GLX attribs. v2 (idr): Minor formatting changes. Change type of dri2_convert_glx_attribs render_type parameter to uint32_t to silence some GCC warnings. Signed-off-by: Tomasz Lis <tomasz.lis@intel.com> Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-07-18glx: Store the value of renderType while creating contextTomasz Lis1-0/+8
Make sure that renderType property value is stored in GLX context while it's being created. Further patches will be provided to make the value correspond to fbconfig's renderType. v2 (idr): Move a hunk from the next patch to this patch to prevent a build break. Signed-off-by: Tomasz Lis <tomasz.lis@intel.com> Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-03-18DRI2: HACK: no GLX_INTEL_swap_event if no ScheduleSwapRob Clark1-6/+15
If ddx does not support swap, don't advertise it. This is a hack to work around current xservers which advertise this extension even when it is clearly not supported. When: http://lists.x.org/archives/xorg-devel/2013-February/035449.html is merged in upstream xserver and makes it's way into most distros then this hack can be removed. In the mean time, it is required to allow gnome-shell/clutter/etc to work properly with a DDX driver which does not support ScheduleSwap. Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-02-19DRI2: Don't disable GLX_INTEL_swap_event unconditionallyZack Rusin1-3/+12
GLX_INTEL_swap_event is broken on the server side, where it's currently unconditionally enabled. This completely breaks systems running on drivers which don't support that extension. There's no way to test for its presence on this side, so instead of disabling it uncondtionally, just disable it for drivers which are known to not support it. It makes sense because most drivers do support it right now. We'll be able to remove this once Xserver properly advertises GLX_INTEL_swap_event. Note: This is a candidate for stable branch branches. Signed-off-by: Zack Rusin <zackr@vmware.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=60052 Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org> Reviewed-by: Brian Paul <brianp@vmware.com> Tested-by: Ian Romanick <ian.d.romanick@intel.com>
2013-02-07glx: Centralize the code for context flushing.Eric Anholt1-45/+37
Reviewed-by: Marek Olšák <maraeo@gmail.com>
2013-02-07glx: Add a little comment about what dri2FlushFrontBuffer() does.Eric Anholt1-0/+4
Reviewed-by: Marek Olšák <maraeo@gmail.com>
2013-01-29glx: Check that swap_buffers_reply is non-NULL before using itStéphane Marchesin1-3/+5
Check that the return value from xcb_dri2_swap_buffers_reply is non-NULL before accessing the struct members. Note: This is a candidate for the 9.0 branch. Reviewed-by: Brian Paul <brianp@vmware.com>
2013-01-24glx: only advertise GLX_INTEL_swap_event if it's supportedZack Rusin1-2/+3
Only drivers supporting DRI2 version >=4 support GLX_INTEL_swap_event. So lets mark it as such otherwise applications which use this extension (i.e. everything based on Clutter, e.g. gnome-shell) break horribly on drivers supporting DRI2 versions only up to 3. Note: This is a candidate for the 9.0 branch. Reviewed-by: Brian Paul <brianp@vmware.com>
2012-12-07glx/dri2: set the __DRI2_FLUSH_DRAWABLE flag where it should be setMarek Olšák1-2/+4
Sorry, I accidentally omitted this. It only broke MLAA. Reviewed-by: Brian Paul <brianp@vmware.com>
2012-12-02glx/dri2: add and use new driver hook flush_with_flagsMarek Olšák1-49/+92
2012-12-02glx: move the glFlush call one layer downMarek Olšák1-5/+13
2012-10-17glx: Fix listing of INTEL_swap_event in glXQueryExtensionsString()Owen W. Taylor1-1/+1
Due to a string mismatch, INTEL_swap_event wasn't listed among GLX extensions for the connection, even when present on both client and server. That is, glXQueryServerString and glXGetClientString reported the extension, but glXQueryExtensionsString did not. Note: This is a candidate for the stable branches. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=56057 Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
2012-10-16glx: Fix a regression in the new XCB codeFredrik Höglund1-3/+15
dri2DrawableGetMSC(), dri2WaitForMSC() and dri2WaitForSBC() were inadvertently changed to return 0 on success. This resulted in the callers returning an error to the client. Restore the previous behavior and also check that the reply pointers are valid before accessing them. Reviewed-by: Eric Anholt <eric@anholt.net>
2012-10-09glx: Replace DRI2SwapBuffers() custom protocol with XCB.Eric Anholt1-4/+31
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
2012-10-09glx: Fix some indentation.Eric Anholt1-5/+5
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
2012-10-09glx: Replace DRI2SwapInterval custom protocol with XCB.Eric Anholt1-7/+2
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
2012-10-09glx: Reuse setSwapInterval for setting initial swap interval.Eric Anholt1-5/+2
2012-10-09glx: Allow glXSwapInterval(0) when vblank_mode=0.Eric Anholt1-1/+3
There's no reason to say no in this case.
2012-10-09glx: Replace DRI2GetMSC custom protocol with XCB.Eric Anholt1-16/+10
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
2012-10-09glx: Replace DRI2WaitForMSC custom protocol with XCB.Eric Anholt1-16/+21
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
2012-10-09glx: Replace DRI2WaitForSBC custom protocol with XCB.Eric Anholt1-9/+34
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
2012-10-09glx: Unifdef some dri_interface.h defines.Eric Anholt1-14/+1
dri_interface.h comes from our tree, so why litter our tree with ifdefs for older versions of it? I left in the DRI_TEX_BUFFER_VERSION ifdefs, which is broken and uncompiled (the version wasn't bumped from 2 to 3 when the patch was landed), but I don't know what should be done with it. Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
2012-10-03glx/dri2: use uint64_t instead of double to represent time for FPS calculationMarek Olšák1-5/+6
Wine or a windows app changes fpucw to 0x7f, causing doubles to be equivalent to floats, which broke the calculation of FPS. We should be very careful about using doubles in Mesa. Henri Verbeet adds: For reference, this is done by for example d3d9 when a D3D device is created without D3DCREATE_FPU_PRESERVE set. In the general case applications can do all kinds of terrible things to the FPU control word of course.
2012-09-05Use calloc instead of malloc/memset-0Matt Turner1-8/+4
This patch has been generated by the following Coccinelle semantic patch: @@ expression E; identifier I; @@ - I = malloc(E); + I = calloc(1, E); ... - memset(I, 0, sizeof *I); Reviewed-by: Brian Paul <brianp@vmware.com>
2012-09-05Remove useless checks for NULL before freeingMatt Turner1-4/+2
This patch has been generated by the following Coccinelle semantic patch: // Remove useless checks for NULL before freeing // // free (NULL) is a no-op, so there is no need to avoid it @@ expression E; @@ + free (E); + E = NULL; - if (unlikely (E != NULL)) { - free(E); ( - E = NULL; | - E = 0; ) ... - } @@ expression E; type T; @@ + free ((T) E); + E = NULL; - if (unlikely (E != NULL)) { - free((T) E); ( - E = NULL; | - E = 0; ) ... - } @@ expression E; @@ + free (E); - if (unlikely (E != NULL)) { - free (E); - } @@ expression E; type T; @@ + free ((T) E); - if (unlikely (E != NULL)) { - free ((T) E); - } Reviewed-by: Brian Paul <brianp@vmware.com>
2012-09-05Remove Xcalloc/Xmalloc/Xfree callsMatt Turner1-26/+26
These calls allowed Xlib to use a custom memory allocator, but Xlib has used the standard C library functions since at least its initial import into git in 2003. It seems unlikely that it will grow a custom memory allocator. The functions now just add extra overhead. Replacing them will make future Coccinelle patches simpler. This patch has been generated by the following Coccinelle semantic patch: // Remove Xcalloc/Xmalloc/Xfree calls @@ expression E1, E2; @@ - Xcalloc (E1, E2) + calloc (E1, E2) @@ expression E; @@ - Xmalloc (E) + malloc (E) @@ expression E; @@ - Xfree (E) + free (E) @@ expression E; @@ - XFree (E) + free (E) Reviewed-by: Brian Paul <brianp@vmware.com>
2012-08-08glx/dri: Initialize reset to __DRI_CTX_RESET_NO_NOTIFICATION.Kenneth Graunke1-1/+1
If the application has requested reset notification, then dri2_convert_glx_attribs will initialize this to the correct value. Otherwise, it's supposed to initialize this to NO_NOTIFICATION, but doesn't when num_attribs == 0. (The consensus seems to be that we should make it do so, but that's more invasive, so I'm pushing this for now.) Fixes a regression since a8724d85f8cb2f0fb73b9c6c1f268f9084c6d473 where trying to run OilRush_x86 or apitrace heaven_x64 would result in: dri_util.c:221: dri2CreateContextAttribs: Assertion `!"Should not get here."' failed. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=53076 Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
2012-07-11glx/dri2: Add support for GLX_ARB_create_context_robustnessIan Romanick1-2/+21
Add the infrastructure required for this extension. There is no xserver support and no driver support yet. Drivers can enable this be advertising DRI2 version 4 and accepting the __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS flag and the __DRI_CTX_ATTRIB_RESET_STRATEGY attribute in create context. Some additional Mesa infrastructure is needed before drivers can do this. The GL_ARB_robustness spec, which all Mesa drivers already advertise, requires: "If the behavior is LOSE_CONTEXT_ON_RESET_ARB, a graphics reset will result in the loss of all context state, requiring the recreation of all associated objects." It is necessary to land this infrastructure now so that the related infrastructure can land in the xserver. The xserver has very long release schedules, and the remaining Mesa parts should land long, long before the next xserver merge window opens. v2: Expose robustness as a DRI2 extension rather than bumping __DRI_DRI2_VERSION. v3: Add a comment explaining why dri2->base.version >= 3 is also required for GLX_ARB_create_context_robustness. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Eric Anholt <eric@anholt.net>
2012-03-11Set close on exec flag FD_CLOEXECDavid Fries1-1/+9
Set the close on exec flag when opening dri character devices, so they will be closed and free any resouces allocated in exec. Signed-off-by: David Fries <David@Fries.net> Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-02-08dri: Emit a critical error if a named driver fails to load.Carl Worth1-0/+2
Something has gone wrong if we were asked to load a driver of a specific name, but it failed to load for some reason. The user really should be made aware of this, (and instructed to set LIBGL_DEBUG for more details). Reviewed-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
2012-01-05glx/dri2: print FPS when env var LIBGL_SHOW_FPS is 1 (v2)Marek Olšák1-1/+34
This is useful for apps which don't print FPS. Only enabled in SwapBuffers. v2: track state per drawable, use libGL prefix Reviewed-by: Michel Dänzer <michel@daenzer.net>
2012-01-02glx: Enable GLX_EXT_create_context_es2_profileIan Romanick1-0/+6
This extension is only enabled if the underlying driver advertises support for OpenGL ES 2.0. This happens either through the getAPIMask function in version 2 of the DRI2 extension or implicity through version 2 of the DRISW extension. Since there is no OpenGL ES 2.0 protocol, this extension is marked as only available with direct-rendering. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
2012-01-02glx/dri2: Implement glx_screen_vtable::create_context_attribs for DRI2 contextsIan Romanick1-1/+91
This also enables GLX_ARB_create_context and GLX_ARB_create_context_profile if the driver supports DRI_DRI2 version 3 or greater. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
2012-01-02glx: Add glx_screen_vtable::create_context_attribsIan Romanick1-1/+2
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
2011-12-19glx: Send DestroyContext protocol at the correct timesIan Romanick1-3/+0
Send the DestroyContext protocol immediately when glXDestroyContext is called, and never call it when glXFreeContextEXT is called. In both cases, either destroy the client-side structures or, if the context is current, set xid to None so that the client-side structures will be destroyed later. I believe this restores the behavior of the original SGI code. See src/glx/x11 around commit 5df82c8. The spec doesn't say anything about glXDestroyContext not really destroying imported contexts (it acts like glXFreeContextEXT instead), but that's what the original code did. Note that glXFreeContextEXT on a non-imported context does not destroy it either. Fixes the piglit test glx-free-context. NOTE: This is a candidate for the 7.11 branch. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Eric Anholt <eric@anholt.net>
2011-12-19glx: Don't create a shared context if the other context isn't the same kindIan Romanick1-0/+7
Each of the DRI, DRI2, and DRISW backends contain code like the following in their create-context routine: if (shareList) { pcp_shared = (struct dri2_context *) shareList; shared = pcp_shared->driContext; } This assumes that the glx_context *shareList is actually the correct derived type. However, if shareList was created as an indirect-rendering context, it will not be the expected type. As a result, shared will contain garbage. This garbage will be passed to the driver, and the driver will probably segfault. This can be observed with the following GLX code: ctx0 = glXCreateContext(dpy, visinfo, NULL, False); ctx1 = glXCreateContext(dpy, visinfo, ctx0, True); Create-context is the only case where this occurs. All other cases where a context is passed to the backend, it is the 'this' pointer (i.e., we got to the backend by call something from ctx->vtable). To work around this, check that the shareList->vtable->destroy method is the same as the destroy method of the expected type. We could also check that shareList->vtable matches the vtable or by adding a "tag" to glx_context to identify the derived type. NOTE: This is a candidate for the 7.11 branch. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Eric Anholt <eric@anholt.net>
2011-12-07glx: Fix indirect fallback when a non-Mesa GLX extension is present.Aaron Plattner1-4/+19
When driCreateScreen calls driConvertConfigs to try to convert the configs for swrast, it fails and returns NULL. Instead of checking, it just clobbers psc->base.configs. Then, when the application asks for the FBconfigs, there aren't any. Instead, make the caller responsible for freeing the old modes lists if both calls to driConvertConfigs succeed. Without the second fix, glxinfo fails unless you run it with LIBGL_ALWAYS_INDIRECT: $ glxinfo name of display: :0.0 Error: couldn't find RGB GLX visual or fbconfig $ LIBGL_ALWAYS_INDIRECT=1 glxinfo name of display: :0.0 display: :0 screen: 0 direct rendering: No (LIBGL_ALWAYS_INDIRECT set) server glx vendor string: NVIDIA Corporation server glx version string: 1.4 [...] Signed-off-by: Aaron Plattner <aplattner@nvidia.com> Reviewed-and-tested-by: Ian Romanick <ian.d.romanick@intel.com> Signed-off-by: Brian Paul <brianp@vmware.com>
2011-10-14dri2: Implement a throttle dri extension.Thomas Hellstrom1-3/+50
The X server has limited throttle support on the server side, but doing this in the client has some benefits: 1) X server throttling is per client. Client side throttling can be done per drawable. 2) It's easier to control the throttling based on what client is run, for example using "driconf". 3) X server throttling requires drm swap complete events. So implement a dri2 throttling extension intended to be used by direct rendering clients. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Jakob Bornecrantz <jakob@vmware.com> Reviewed-by: Michel Dänzer <michel@daenzer.net>
2011-09-19Remove unneeded xdamages header from dri2_glx.c.Matt Turner1-1/+0
It's needed for dri1 but not dri2. Signed-off-by: Matt Turner <mattst88@gmail.com> Signed-off-by: Brian Paul <brianp@vmware.com>
2011-09-14glx/dri2: Don't call X server for SwapBuffers when there's no back buffer.Michel Dänzer1-0/+4
As already done in dri2CopySubBuffer(). Should fix: https://bugs.freedesktop.org/show_bug.cgi?id=36371 https://bugs.freedesktop.org/show_bug.cgi?id=40533 Might fix: https://bugs.freedesktop.org/show_bug.cgi?id=32589 Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
2011-09-14GLX: Say something if we cannot connect via DRI2Andrew Deason1-0/+1
See https://bugs.freedesktop.org/show_bug.cgi?id=40437
2011-08-18glx: Don't flush twice if we fallback to dri2CopySubBufferKristian Høgsberg1-11/+10
The flush extensions flush call indicates end of frame and should only be called once per frame. However, in the dri2SwapBuffer fallback path, we call flush and then call dri2CopySubBuffer, which also calls flush. Refactor the code to only call flush once.