Commit Graph

114 Commits

Author SHA1 Message Date
Tomasz Lis a92cd5b245 glx: Retrieve the value of RENDER_TYPE from GLX attribs array
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-18 16:03:42 -07:00
Tomasz Lis 36259a16fe glx: Store the value of renderType while creating context
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-07-18 16:03:42 -07:00
Rob Clark 4e8f5c52bb DRI2: HACK: no GLX_INTEL_swap_event if no ScheduleSwap
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-03-18 14:16:43 -04:00
Zack Rusin 076403c30d DRI2: Don't disable GLX_INTEL_swap_event unconditionally
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-19 12:50:16 -08:00
Eric Anholt 7242b03622 glx: Centralize the code for context flushing.
Reviewed-by: Marek Olšák <maraeo@gmail.com>
2013-02-07 13:13:02 -08:00
Eric Anholt 95080ca8d4 glx: Add a little comment about what dri2FlushFrontBuffer() does.
Reviewed-by: Marek Olšák <maraeo@gmail.com>
2013-02-07 13:13:02 -08:00
Stéphane Marchesin 67e7263e45 glx: Check that swap_buffers_reply is non-NULL before using it
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-29 11:15:22 -08:00
Zack Rusin dbb2d192de glx: only advertise GLX_INTEL_swap_event if it's supported
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>
2013-01-24 19:13:05 -08:00
Marek Olšák 5fb2b1f4d4 glx/dri2: set the __DRI2_FLUSH_DRAWABLE flag where it should be set
Sorry, I accidentally omitted this.

It only broke MLAA.

Reviewed-by: Brian Paul <brianp@vmware.com>
2012-12-07 14:19:28 +01:00
Marek Olšák 4a486f8bf2 glx/dri2: add and use new driver hook flush_with_flags 2012-12-02 00:19:00 +01:00
Marek Olšák 5b7e9b7360 glx: move the glFlush call one layer down 2012-12-02 00:15:00 +01:00
Owen W. Taylor 1d0c621121 glx: Fix listing of INTEL_swap_event in glXQueryExtensionsString()
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-17 10:16:23 -07:00
Fredrik Höglund 0978707917 glx: Fix a regression in the new XCB code
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-16 02:24:42 +02:00
Eric Anholt 8c472b8f6a glx: Replace DRI2SwapBuffers() custom protocol with XCB.
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
2012-10-09 14:32:03 -07:00
Eric Anholt f02242a4fa glx: Fix some indentation.
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
2012-10-09 14:32:03 -07:00
Eric Anholt 811602885b glx: Replace DRI2SwapInterval custom protocol with XCB.
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
2012-10-09 14:32:03 -07:00
Eric Anholt 7acf8ae0e1 glx: Reuse setSwapInterval for setting initial swap interval. 2012-10-09 14:32:03 -07:00
Eric Anholt d0937759db glx: Allow glXSwapInterval(0) when vblank_mode=0.
There's no reason to say no in this case.
2012-10-09 14:32:03 -07:00
Eric Anholt ab8ae9301f glx: Replace DRI2GetMSC custom protocol with XCB.
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
2012-10-09 14:32:03 -07:00
Eric Anholt 8e61b9028a glx: Replace DRI2WaitForMSC custom protocol with XCB.
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
2012-10-09 14:32:03 -07:00
Eric Anholt 183ab9e14e glx: Replace DRI2WaitForSBC custom protocol with XCB.
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
2012-10-09 14:32:03 -07:00
Eric Anholt c35a9388a3 glx: Unifdef some dri_interface.h defines.
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-09 14:32:02 -07:00
Marek Olšák 53d06ecdd0 glx/dri2: use uint64_t instead of double to represent time for FPS calculation
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-10-03 16:55:48 +02:00
Matt Turner 6bda027e01 Use calloc instead of malloc/memset-0
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-05 22:28:50 -07:00
Matt Turner 5067506ea6 Remove useless checks for NULL before freeing
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-05 22:28:50 -07:00
Matt Turner 7c7b7b068b Remove Xcalloc/Xmalloc/Xfree calls
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-09-05 22:28:49 -07:00
Kenneth Graunke 68bccc40f5 glx/dri: Initialize reset to __DRI_CTX_RESET_NO_NOTIFICATION.
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 a8724d85f8
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-08-08 17:15:21 -07:00
Ian Romanick a8724d85f8 glx/dri2: Add support for GLX_ARB_create_context_robustness
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-07-11 08:54:50 -07:00
David Fries b60120608f Set close on exec flag FD_CLOEXEC
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-03-11 19:05:50 +00:00
Carl Worth 6c9af97740 dri: Emit a critical error if a named driver fails to load.
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-02-08 17:07:53 -08:00
Marek Olšák f82d40d4b1 glx/dri2: print FPS when env var LIBGL_SHOW_FPS is 1 (v2)
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-05 18:29:11 +01:00
Ian Romanick e6280c3ba9 glx: Enable GLX_EXT_create_context_es2_profile
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-02 12:41:45 -08:00
Ian Romanick 48ffc6a155 glx/dri2: Implement glx_screen_vtable::create_context_attribs for DRI2 contexts
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-02 12:41:44 -08:00
Ian Romanick 43409fa7b0 glx: Add glx_screen_vtable::create_context_attribs
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
2012-01-02 12:41:44 -08:00
Ian Romanick 4dbd13cb3f glx: Send DestroyContext protocol at the correct times
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-19 14:55:31 -08:00
Ian Romanick c4a8c54c3b glx: Don't create a shared context if the other context isn't the same kind
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-19 14:55:30 -08:00
Aaron Plattner 63a6fd6603 glx: Fix indirect fallback when a non-Mesa GLX extension is present.
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-12-07 17:20:10 -07:00
Thomas Hellstrom 511dc295f8 dri2: Implement a throttle dri extension.
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-10-14 09:52:53 +02:00
Matt Turner 116e896aaf Remove unneeded xdamages header from dri2_glx.c.
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-19 07:34:46 -06:00
Michel Dänzer d8c443ddde glx/dri2: Don't call X server for SwapBuffers when there's no back buffer.
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-14 18:40:16 +02:00
Andrew Deason 45e0a7a51d GLX: Say something if we cannot connect via DRI2
See https://bugs.freedesktop.org/show_bug.cgi?id=40437
2011-09-14 18:37:48 +02:00
Kristian Høgsberg 4a7667b96b glx: Don't flush twice if we fallback to dri2CopySubBuffer
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.
2011-08-18 09:46:06 -04:00
Brian Paul e0496b63ff glx: move declarations before code 2011-08-09 08:58:20 -06:00
Jeremy Huddleston 559e4f8ebc glx: Allow a context-specific fallback for glXGetProcAddress
In applegl, GLX advertises the same extensions provided by OpenGL.framework
even if such extensions are not provided by glapi.  This allows a client
to get access to such API.

Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-06-20 16:54:58 -07:00
Stéphane Marchesin bf69ce37f0 glx: implement drawable refcounting.
The current dri context unbind logic will leak drawables until the process
dies (they will then get released by the GEM code). There are two ways to fix
this: either always call driReleaseDrawables every time we unbind a context
(but that costs us round trips to the X server at getbuffers() time) or
implement proper drawable refcounting. This patch implements the latter.

Signed-off-by: Antoine Labour <piman@chromium.org>
Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2011-06-17 11:20:19 -07:00
Stéphane Marchesin 3d3ecb8520 dri2: protect dri2FlushFrontBuffer against NULL buffers. 2011-06-06 12:35:59 -07:00
Eric Anholt 164108e3db glx: Fix use-before-null-check in dri2InvalidateBuffers().
The compiler used our dereference here to skip the NULL check below.
Fixes window resize in "jconsole -J-Dsun.java2d.opengl=True" under
OpenJDK 6.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=37766
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2011-06-03 16:03:34 -07:00
nobled a3e2c8f31f glx: Check flush DRI extension version at runtime
The DRI driver itself might not have version 3 of the
DRI2 flush extension, in which case this would've
pointed to out of bounds memory...
2011-05-06 09:39:24 +02:00
Henri Verbeet a75de67c51 glx: Destroy dri2Hash on DRI2 display destruction.
Signed-off-by: Henri Verbeet <hverbeet@gmail.com>
2011-04-10 18:53:33 +02:00
Eric Anholt 74cde6505c dri2: Don't call the dri2 flush hook for swapbuffers unless we have a context.
The driver only has one reasonable place to look for its context to
flush anything, which is the current context.  Don't bother it with
having to check.
2011-02-26 12:43:15 -08:00