Commit Graph

179 Commits

Author SHA1 Message Date
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
Henri Verbeet 7d9e0ea739 glx: Properly check for a valid fd in dri2CreateScreen().
Signed-off-by: Brian Paul <brianp@vmware.com>
2011-01-31 10:54:04 -07:00
Henri Verbeet bfc889517a glx: Fix leaks in DRI2 screen creation error paths.
Signed-off-by: Brian Paul <brianp@vmware.com>
2011-01-31 09:29:54 -07:00
Juan Zhao e59fa4c46c dri2: release texture image.
Add release function for texture_from_pixmap extension.
Some platform need to release texture image for texture_from_pixmap
extension, add this interface for those platforms.
2011-01-09 14:55:16 -05:00
Kristian Høgsberg 86a1938aa5 glx: Invalidate buffers after binding a drawable
If the server doesn't send invalidate events, we may miss a
resize before the rendering starts.  Invalidate the buffers now
so the driver will recheck before rendering starts.

https://bugs.freedesktop.org/show_bug.cgi?id=29984
https://bugs.freedesktop.org/show_bug.cgi?id=30155
2010-09-22 17:36:19 -04:00
Luca Barbieri a0e5103200 glx: decouple dri2.c and GLX, fixing Gallium EGL and d3d1x build
The Gallium EGL state tracker reuses dri2.c but not the GLX code.

Currently there is a bit of code in dri2.c that is incorrectly tied
to GLX: instead, make it call an helper that both GLX and Gallium EGL
implement, like dri2InvalidateBuffers.

This avoids a link error complaining that dri2GetGlxDrawableFromXDrawableId
is undefined.

Note that we might want to move the whole event translation elsewhere,
and probably stop using non-XCB DRI2 altogether, but this seems to be
the minimal fix.
2010-09-22 08:01:49 +02:00
Kristian Høgsberg 441344ba7e glx: Hold on to drawables if we're just switching to another context
https://bugs.freedesktop.org/show_bug.cgi?id=30234
2010-09-21 10:20:23 -04:00
Kristian Høgsberg 4ebf07a426 glx: Don't destroy DRI2 drawables for legacy glx drawables
For GLX 1.3 drawables, we can destroy the DRI2 drawable when the GLX
drawable is destroyed.  However, for legacy drawables, there os no
good way of knowing when the application is done with it, so we just
let the DRI2 drawable linger on the server.  The server will destroy
the DRI2 drawable when it destroys the X drawable or the client exits
anyway.

https://bugs.freedesktop.org/show_bug.cgi?id=30109
2010-09-13 08:42:22 -04:00
Kristian Høgsberg 16887d042a glx: Drop broken drawable garbage collection
Doesn't work for pixmaps, was looking up the GLX XID and was never thread
safe.  Instead, just destroy the client side structures when the
drawable is no long current for a context.
2010-09-08 09:20:42 -04:00
Kristian Høgsberg 2542d8e0c2 glx: Move deref after NULL check 2010-08-04 12:51:26 -04:00
Kristian Høgsberg 9da1c9da13 glx: dri2InvalidateBuffers() needs the X drawable XID not the GLX one
This never ceases to entertain.
2010-08-04 08:47:36 -04:00
Kristian Høgsberg c491e585e4 glx: Move bind and unbind to context vtable 2010-07-28 16:45:25 -04:00
Kristian Høgsberg c356f5867f glx: Rename __GLXcontext and __GLXdisplayPrivate to struct types. 2010-07-28 16:45:25 -04:00
Kristian Høgsberg 66fc35cde9 glx: Rename __GLXscreenConfigs to struct glx_screen
Because double underscores in private type names is painful.
2010-07-28 16:42:00 -04:00
Kristian Høgsberg 6ddf66e923 glx: Rename __GLcontextModes to struct glx_config
With this rename, we use 'config' consitently to refer to GLX configurations
instead of the modes/configs/visual mess before.
2010-07-28 16:42:00 -04:00
Carl Worth db011c8141 Avoid a compiler warning about a potentially unused variable.
There is no assignment to the "ret" variable if X_DRI2SwapBuffers is
not defined. In this case, the earlier explicit "return 0" is likely
to be used, but the compiler can't be sure of that, (nor can I for
that matter).

We cover this case by explicitly initializing "ret" to 0.
2010-07-28 10:42:46 -07:00
Eric Anholt af6a2aede6 glx: Fix another case of confusing driContext and dri2_context * 2010-07-23 20:58:12 -07:00
Eric Anholt 566373967a glx: Correctly look up the dri2 context pointer for SetTexBuffer.
gc->driContext points at the second member of the dri2 context.  The
dri2 context is just a subclass of the GLX context.

Fixes piglit tfp testcase.
2010-07-23 20:58:12 -07:00
Kristian Høgsberg d77bb8e059 glx: Don't destroy context with XID 0
We use XID 0 to indicate the context has already been destroyed, but it's
currently bound.
2010-07-23 22:05:53 -04:00
Kristian Høgsberg 6393a33944 glx: zero out drawable structs after allocation 2010-07-23 22:05:53 -04:00
Kristian Høgsberg 6ec39db726 glx: Refactor and simplify context creation
This lets us better separate context creation between the different
backends.
2010-07-23 22:05:53 -04:00
Kristian Høgsberg c796bb0cc3 glx: Move context destroy to context vtable 2010-07-23 22:05:52 -04:00
Eric Anholt 9a12a3925a glx: Don't try to swap a front buffer if we don't have one.
Fixes glean glsl1 since 7b7845a076
2010-07-23 13:59:22 -07:00
Kristian Høgsberg eeaab2047c glx: Drop screen argument to GetGLXDRIDrawable
We'll just get it from the returned drawable when we need it.
2010-07-22 22:36:37 -04:00
Kristian Høgsberg 7b7845a076 glx: Move WaitGL, WaitX, UseXFont to context vtable functions 2010-07-22 22:24:00 -04:00
Kristian Høgsberg 31819830b6 glx: Allocate the __GLXcontext in the DRI drivers 2010-07-22 22:16:32 -04:00
Kristian Høgsberg f679640868 glx: Move __driContext field out of __GLXcontextRec 2010-07-21 22:17:24 -04:00
Michel Dänzer bd3d2724f5 glx/dri2: Fix dri2CopySubBuffer() again.
Only refresh the fake front buffer if there is one, and only destroy the region
once.

Fixes X11 protocol errors reported by 'mcgreg' on IRC.
2010-07-20 12:21:17 +02:00
Kristian Høgsberg a7292f2920 glx: Move DRI CopySubBuffer extension to DRI1 code
We do this in the X server for DRI2.
2010-07-19 22:45:51 -04:00
Kristian Høgsberg bab13969d8 glx: Move driver_configs to DRI screen privates 2010-07-19 22:45:51 -04:00
Kristian Høgsberg 037755122e glx: Don't use __glXInitialize() when we might be holding __glXLock() 2010-07-19 22:45:51 -04:00
Kristian Høgsberg 8d0228912b glx: Workaround mismatch in signedness between extensions and protocol
The DRI2 protocol for ust, msc and sbc are unsigned but the extensions
talk about int64_t.  Do a little dance to make the compiler shut up.
2010-07-19 22:45:50 -04:00
Kristian Høgsberg 271c3c3a90 glx: Move __DRIdrawable pointers to DRI drawable privates 2010-07-19 22:45:50 -04:00
Kristian Høgsberg 70887d5172 glx: Move __driScreen into the dri screen privates 2010-07-19 22:45:50 -04:00
Kristian Høgsberg 089fc37c6f glx: Move DRI1 specific extensions and code to DRI1 screen private 2010-07-19 22:45:50 -04:00
Kristian Høgsberg 9e546ecfd4 glx: Move DRI2 extensions to DRI2 screen private 2010-07-19 22:45:50 -04:00
Kristian Høgsberg f972115d33 glx: Add screen privates for dri drivers and moved some fields there
GLXscreenConfigs is badly named and a dumping ground for a lot of stuff.
This patch creates private screen structs for the dri drivers and moves
some of their fields over there.
2010-07-19 22:45:50 -04:00
Kristian Høgsberg a296d96de4 glx: Rename various DRI structs away from obnoxious __GLXfooRec convention
Enough is enough.
2010-07-19 22:45:50 -04:00
Kristian Høgsberg 308e13ecd1 glx: Factor out common code from dri2WaitGL() and dri2WaitX() 2010-07-19 22:45:50 -04:00
Kristian Høgsberg b006d465ea glx: Dont use dri2WaitX() to update fake front
This saves a superfluous flush and a create/destryo region.
2010-07-19 22:45:50 -04:00
Kristian Høgsberg 3750ebd540 glx: Fix drawable lookup in DRI2 event handler
DRI2 events are sent to the X drawable ID used to create the DRI2 drawable,
not the GLX drawable ID.  So when an event comes in, we need to look up
the __GLXDRIdrawable by its X drawable ID, which needs a new hash table.
2010-07-19 09:37:38 -04:00
Kristian Høgsberg ab780bccb7 glx: Invalidate drawable in glXBindTexImageEXT() if we don't get events
When we don't get invalidate events, we need to invalidate a drawable
before using it for tfp to make sure we have uptodate buffers.
2010-05-21 23:24:37 -04:00
Kristian Høgsberg 643b2af020 glx: Split tfp functions out to context vtable
This introduces a new per-context vtable, which lets us clean up all the
#ifdef's a bit and move the DRI2 specific implementation into dri2_glx.c.
2010-05-21 23:24:37 -04:00
Kristian Høgsberg 4cd259ca59 dri2_glx: Put the invalidate b/c code back in
The backwards compatibility code calls the DRI driver invalidate hook
on swap buffer and flush front buffer.  This lets the DRI driver rely
on invalidate callbacks and drop the glViewport() hack, even if the
server doesn't send invalidate events.  This is essentially a revert
of 2d00d16da7, except that we now also
pass the __DRI_USE_INVALIDATE extension even when the server doesn't
have DRI2 invalidate events.
2010-05-18 22:58:01 -04:00
Kristian Høgsberg c8f407bcec dri2_glx: Terminate loader extension list outside #ifdef 2010-05-18 22:58:01 -04:00
Kristian Høgsberg 4258e3a2e1 glx: Provide the __DRI_USE_INVALIDATE extension to the driver when we can
When we have DRI2 protocol at least 2.3, we get an event from the
server when the back buffers get invalidated.  When that's the case
let the driver know that it can rely on invalidate instead of the
glViewport polling.
2010-05-11 10:23:53 -04:00
Kristian Høgsberg 2d00d16da7 glx: Only call DRI2 invalidate when necessary
We only need this when the server may have swapped the buffers or
when we receive an invalidate event from the server.  The default
behaviour is still that the DRI driver will invalidate its own buffers
when glViewport is called.

https://bugs.freedesktop.org/show_bug.cgi?id=27277
2010-05-10 17:48:11 -04:00
Brian Paul 1fa7789e82 Merge branch '7.8'
Conflicts:

	src/glx/dri2_glx.c
	src/glx/glx_pbuffer.c
2010-04-28 07:21:25 -06:00
Pierre Willenbrock d20fce057e Initialize have_back.
There is a user somewhere that tests it before its initial set.

Signed-off-by: Eric Anholt <eric@anholt.net>
2010-04-27 17:12:39 -07:00
Pierre Willenbrok cc806f70b2 glx: Initialize have_back.
Signed-off-by: Brian Paul <brianp@vmware.com>
2010-04-27 15:53:28 -06:00
Jeremy Huddleston 80b280db88 apple: Change ifdefs for DRI to be DRI && !APPLE
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-04-27 11:26:51 -07:00
Michel Dänzer ff20543c81 Merge branch '7.8' 2010-04-23 11:18:29 +02:00
Michel Dänzer c37e275e77 glx/dri2: Fix build with dri2proto which doesn't define X_DRI2SwapInterval. 2010-04-23 11:16:03 +02:00
Jesse Barnes 45e2b51c85 DRI2/GLX: check for vblank_mode in DRI2 GLX code
Re-add support for the vblank_mode environment and configuration
variable.  Useful for benchmarking and app control.
2010-04-22 12:49:45 -07:00
Jesse Barnes 0a18cdb0ed DRI2: check for swapAvailable before using swap interval protocol
This should have been part of the last change...
2010-04-19 14:20:21 -07:00
Jesse Barnes 385e2896eb DRI2: synchronize swap interval with server at startup time
In the direct rendered case, we need to tell the server our initial swap
interval.  If we don't, the local and server values will be out of sync,
since the server and client defaults may be different (as they were
before this patch).
2010-04-19 09:56:32 -07:00
Michael Schmidt d9793fc3ac Initialize DRI2 swap interval to 0
https://bugs.freedesktop.org/show_bug.cgi?id=27628
2010-04-14 10:15:47 -04:00
Jesse Barnes 2b4d8616f5 GLX/DRI2: pass GLX drawable ID to dri2InvalidateBuffers
The IDs will be the same in the case where an X window is used directly
as a GLX drawable, but will fail if a new GLX drawable is created
explicitly, as with glxgears_fbconfig.

Fixes fdo bug #27190.
2010-04-01 17:29:19 -07:00
Jeremy Huddleston 115203281c Revert accidental commits from the xquartz tree
This reverts commit 9aadc793f3.
This reverts commit 69ea4e7718.
This reverts commit dbe8b01393.
This reverts commit 23215ef4d6.
This reverts commit 9495e37030.
This reverts commit 0594cf7088.
This reverts commit 86a7978d37.
This reverts commit 437902ce97.
2010-04-01 17:01:51 -07:00
Jeremy Huddleston 23215ef4d6 apple: Change ifdefs for DRI to be DRI && !APPLE
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
2010-04-01 12:33:46 -07:00
Michel Dänzer 07c6d94cd7 glx/dri2: Fix debug build with old dri2proto.
Apparently the higher compiler optimization level in non-debug builds was
eliminating the unused functions referencing the unresolved DRI2 symbols...
2010-03-30 11:50:13 +02:00
Brian Paul ae7b3a632d glx: Move initialization of ext_list_first_time to where it's storage is allocated
Move the initialization of ext_list_first_time from all of the DRI loader's
CreateScreen routines, to where the storage for the screen config is
allocated.

It needs to get set in the screen-config even if DRI is forced off
using LIBGL_ALWAYS_INDIRECT, so that psc->direct_support is initialized
correctly, otherwise __glXExtensionBitIsEnabled() always returns FALSE

Specifically, this causes a problem with an X server which advertises
GLX<=1.2, and the GLX_SGIX_fbconfig extension.
glXGetFBConfigFromVisualSGIX() uses __glXExtensionBitIsEnabled() to
check if the GLX_SGIX_fbconfig extension is available, but that function
won't return correct information because that data has never been
initialized, because ext_list_first_time was never set...

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Signed-off-by: Brian Paul <brianp@vmware.com>

(cherry picked from commit 96ab4d2b84)
2010-03-05 17:32:36 -07:00
Jesse Barnes 1ca968363d DRI2: expose OML_sync_control if possible
If the server supports the OML related protocol, enable support for the
extension.
2010-03-05 11:22:05 -08:00
Francisco Jerez 61d26bc82e dri2: Event driven buffer validation.
When a buffer invalidation event is received from the X server, the
"invalidate" hook of the DRI2 flush extension is executed: A generic
implementation (dri2InvalidateDrawable) is provided that just bumps
the "pStamp" sequence number in __DRIdrawableRec.

For old servers not supporting buffer invalidation events, the
invalidate hook will be called before flushing the fake front/back
buffer (that's typically once per frame -- not a lot worse than the
situation we were in before).

No effort has been made on preserving backwards compatibility with
version 2 of the flush extension, but I think it's acceptable because
AFAIK no released stack is making use of it.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
2010-02-16 10:38:50 -05:00
Kristian Høgsberg 6e8897ff9f Retire miniglx and move the actual glx code up to src/glx 2010-02-09 09:58:36 -05:00
Renamed from src/glx/x11/dri2_glx.c (Browse further)