Commit Graph

116 Commits

Author SHA1 Message Date
Dave Airlie
ea47af87f6 xserver/output: rename some badly named variables/APIs.
This is an API and ABI break

Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-10 06:17:44 +10:00
Hans de Goede
f9e7cdf659 xf86: dri2: Use va_gl as VDPAU driver for Intel i965 GPUs
The modesetting driver (which now often is used with Intel GPUs),
relies on DRI2ScreenInit() to setup the DRI and VDPAU driver names.

Before this commit it would always assign the same name to the 2 names,
but the VDPAU driver for i965 GPUs should be va_gl.

This commit adds a special case for the i965 case, replacing the
VDPAU driver name with "va_gl" if the GPU is using the i965 driver
for DRI.

Note this commit adds a FIXME comment for a related memory leak, that leak
was already present and fixing it falls outside of the scope of this commit.

BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1413733
Cc: kwizart@gmail.com
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-08-06 16:25:39 +02:00
Adam Jackson
ff56048855 dri2: Stop pretending VGA arbitration matters
The VGA arbiter controls the PCI bus' routing of legacy VGA resources,
specifically the video memory aperture at 0xa0000-0xb0000 (640k should
be etc.) and a handful of I/O ports. Since 128k is far too small for a
real framebuffer these days, every driver instead maps a linear version
of VRAM through the PCI BAR. And no DRI2 drivers ever need I/O port
access, because all operations they might be used for (legacy VGA CRTC
setup, mostly) happen on the kernel side.

In other words, this just works, and we can stop breaking it.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2019-01-30 14:08:41 -05:00
Adam Jackson
899d260701 ci: Work around broken python UTF8 handling in the CI docker image
Gitlab very kindly exposes the details of the git commit message (among
much else) in the environment. Unfortunately, piglit tries to handle the
environment in non-UTF8-safe ways, which means if the top-of-tree commit
mentions non-ASCII characters (say, in the author's name) then all the
tests fail and so does the pipeline.

Fortunately none of those variables are things our piglit invocation
needs. Since I've failed to rebuild the docker image as yet, just clear
the likely variables from the environment before running piglit.

This-makes-me: ☹
2018-12-11 12:41:26 -05:00
Daniel Martin
d5379b350f Use ARRAY_SIZE all over the tree
Roundhouse kick replacing the various (sizeof(foo)/sizeof(foo[0])) with
the ARRAY_SIZE macro from dix.h when possible. A semantic patch for
coccinelle has been used first. Additionally, a few macros have been
inlined as they had only one or two users.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2017-10-30 13:45:20 -04:00
Emil Velikov
eac1a2e37b dri2: sort DRI2InfoPtr::version checking in ascending order
Makes it easer to follow if 8 is between 7 and 9 ;-)

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2017-09-13 14:38:06 -04:00
Qiang Yu
7617a0a180 dri2: refine dri2_probe_driver_name (v2)
V2:
1. update comment
2. check bustype if PCI
3. configure add libdrm version check for drmGetDevice

Get PCI information from info->fd with drmGetDevice instead of
assuming the info->fd is the first entity of scrn which is not
true for multi entities scrn.

Signed-off-by: Qiang Yu <Qiang.Yu@amd.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2017-01-25 15:13:33 -05:00
Hans de Goede
5c7af02b10 xrandrprovider: Do not use separate lists for unbound / source / offload slaves
A single provider can be both a offload and source slave at the same time,
the use of seperate lists breaks in this case e.g. :

xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x7b cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 2 associated providers: 0 name:modesetting
Provider 1: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 5 associated providers: 0 name:modesetting

xrandr --setprovideroutputsource 1 0x7b
xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x7b cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 2 associated providers: 1 name:modesetting
Provider 1: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 5 associated providers: 1 name:modesetting

xrandr --setprovideroffloadsink 1 0x7b
xrandr --listproviders
Providers: number : 3
Provider 0: id: 0x7b cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 2 associated providers: 2 name:modesetting
Provider 1: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 5 associated providers: 2 name:modesetting
Provider 2: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 2 outputs: 5 associated providers: 2 name:modesetting

Not good. The problem is that the provider with id 0x46 now is on both
the output_slave_list and the offload_slave_list of the master screen.

This commit fixes this by unifying all 3 lists into a single slaves list.

Note that this does change the struct _Screen definition, so this is an ABI
break. I do not expect any of the drivers to actually use the removed / changed
fields so a recompile should suffice.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
2016-06-17 11:35:58 +02:00
Dave Airlie
a6b6e8ba02 prime: clean up slave bo properly. (v3)
This is an ABI break, in that we now pass NULL to a function that hasn't
accepted it before.

Alex Goins had a different patch for this but it wasn't symmetrical, it
freed something in a very different place than it allocated it, this
attempts to retain symmetry in the releasing of the backing bo.

v2: use a new toplevel API, though it still passes NULL to something
that wasn't expecting it.
v3: pass -1 instead of 0.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Alex Goins <agoins at nvidia.com>
2016-06-08 12:51:51 -04:00
Chris Wilson
d888295457 dri2: Allow many blocked clients per-drawable
This patch was motivated by the need to fix the use-after-free in
dri2ClientWake, but in doing so removes an arbitrary restriction that
limits DRI2 to only blocking the first client on each drawable. In order
to fix the use-after-free, we need to avoid touching our privates in the
ClientSleep callback and so we want to only use that external list as
our means of controlling sleeps and wakeups. We thus have a list of
sleeping clients at our disposal and can manage multiple events and
sources.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-02-29 14:33:20 -05:00
Adam Jackson
eddf848c44 dri2: Use the work queue to manage client sleeps
In  commit e43abdce96
    Author: Chris Wilson <chris@chris-wilson.co.uk>
    Date:   Wed Feb 3 09:54:46 2016 +0000

        dri2: Unblock Clients on Drawable release

we try to wake up any blocked clients at drawable destruction. But by
the time we get there, CloseDownConnection has already torn down state
that AttendClient wants to modify.

Using ClientSleep instead of IgnoreClient puts a wakeup function on a
workqueue, and the queue will be cleared for us in CloseDownClient
before (non-neverretain) resource teardown.

Tested-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2016-02-11 13:58:13 -05:00
Chris Wilson
e43abdce96 dri2: Unblock Clients on Drawable release
If the Window is destroyed by another client, such as the window
manager, the original client may be blocked by DRI2 awaiting a vblank
event. When this happens, DRI2DrawableGone forgets to unblock that
client and so the wait never completes.

Note Present/xshmfence is also suspectible to this race.

Testcase: dri2-race/manager
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2016-02-08 21:47:18 -05:00
Chris Wilson
b7d392931a dri2: Only invalidate the immediate Window upon SetWindowPixmap
All callers of SetWindowPixmap will themselves be traversing the Window
heirarchy updating the backing Pixmap of each child and so we can forgo
doing the identical traversal inside the DRI2SetWindowPixmap handler.

Reported-by: Loïc Yhuel <loic.yhuel@gmail.com>
Link: http://lists.x.org/archives/xorg-devel/2015-February/045638.html
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
2016-02-08 17:07:32 -05:00
Alan Coopersmith
4cb1034906 Convert hw/xfree86 to new *allocarray functions
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2015-04-21 16:58:08 -07:00
Adel Gadllah
62fcd364ac dri2: Set vdpau driver name if ddx does not provide any driver name
Currently when the ddx does not set any driver name we set DRI2 driver but
not the VDPAU driver name. The result is that VDPAU drivers will not get found
by libvdpau when the modesetting driver is being used.

Just assume that the VDPAU driver matches the DRI2 driver name, this is true
for nouveau, r300, r600 and radeonsi i.e all VDPAU drivers currently supported
by mesa.

Signed-off-by: Adel Gadllah <adel.gadllah@gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2015-01-26 10:42:26 -08:00
Chris Wilson
0829310148 dri2: SourceOffloads may be for DRI3 only
As a DDX may declare offload support without supporting DRI2
(because it is using an alternative acceleration mechanism like DRI3),
when iterating the list of offload_source Screens to find a matching
DRI2 provider we need to check before assuming it is DRI2 capable.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=88514
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2015-01-23 10:11:30 -08:00
Eric Anholt
34a98c8103 dri2: Automatically fill in the driver name if the DDX doesn't provide it.
This will be used by the modesetting driver to support DRI2 across all
hardware that can support glamor, and could potentially be used by
other drivers that have to support DRI2 on sets of hardware with
multiple Mesa drivers.

This logic is the same as what's present in the Mesa driver loader,
except for the lack of nouveau_vieux support (which requires a
predicate on the device).

v2: Fix duplicated assignment of info->driverName.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-10-27 13:16:23 -07:00
Chris Wilson
18744907d0 dri2: Invalidate DRI2Buffers upon SetWindowPixmap updates
When transitioning to a redirected or unredirected Window, the Composite
layer modifies the Window's Pixmap. However, the DRI2Buffer for the
Drawable is still pointing to the backing bo of the old Pixmap with the
result that rendering goes astray.

This now also effects DRI2 Drawables that are touched by PresentPixmap.

v2: Fixup the function name after rebasing

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Reinis Danne <reinis.danne@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Cc: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-06-23 15:05:08 -07:00
Chris Wilson
4d92fab39c dri2: Use the PrimeScreen when creating/reusing buffers
This fixes a segfault when we attempt to call ds->ReuseBufferNotify()
passing a Prime DRI2BufferPtr to the master backend.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=80001
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-06-23 14:54:54 -07:00
Michal Srb
3dba171f5e dri2: Fix detection of wrong prime_id in GetScreenPrime.
Checking the iterating variable ("slave") against null can not detect if the
xorg_list_for_each_entry finished without break being invoked - slave variable
will be always non-null. This caused segfault whenever someone tried to use
DRI_PRIME with incorrect id while having at least one render offloading slave
configured.

Restructurize the GetScreenPrime to work as expected.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-05-22 16:27:44 -07:00
Jamey Sharp
138bf5ac97 DRI2SwapBuffers: Fix uninitialized target SBC.
Fixes Piglit test "swapbuffersmsc-return swap_interval 0".

Ensure that *swap_target gets initialized on any 'return Success' path,
even if the swap request can't be completed by the driver and the server
falls back to a simple blit. That path can also be triggered by setting
swap_interval to 0, which disables sync to vertical retrace.

We originally found this bug because for some reason SDL2 automatically
sets swap_interval to 0, when we were trying to test OML_sync_control in
an SDL2 test application. We then discovered that the above-mentioned
Piglit test has been failing for the same reason since it was
introduced.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Theo Hill <Theo0x48@gmail.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-04-21 11:24:32 -07:00
Jamey Sharp
4927af4475 DRI2SwapBuffers: Don't reuse swap_target variable.
swap_target is an out-parameter that needs to be set to the value that
SBC will take on after this SwapBuffers request completes.

However, it was also being used as a temporary variable to hold the MSC
at which the SwapBuffers request got scheduled to occur. This confusion
makes it harder to reason about whether swap_target is being set
correctly for its out-parameter usage. (Hint: It isn't.)

For the latter use, it makes more sense to use the existing target_msc
variable, which already has the right value unless target_msc, divisor,
and remainder are all 0, in which case we can set it using swap_interval
as usual.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Theo Hill <Theo0x48@gmail.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2014-04-21 11:23:58 -07:00
Keith Packard
60014a4a98 Replace 'pointer' type with 'void *'
This lets us stop using the 'pointer' typedef in Xdefs.h as 'pointer'
is used throughout the X server for other things, and having duplicate
names generates compiler warnings.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2014-01-12 10:24:11 -08:00
Keith Packard
c78be3a4b7 xfree86 warning reduction
This gets the easy warnings, mostly constant string problems.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-01-12 10:14:49 -08:00
Eric Anholt
77e51d5bbb Revert "DRI2: re-allocate DRI2 drawable if pixmap serial changes"
This reverts commit 3209b094a3.  After a
long debug session by Paul Berry, it appears that this was the commit
that has been producing sporadic failures in piglit front buffer
rendering tests for the last several years.

GetBuffers may return fresh buffers with invalid contents at a couple
reasonable times:

- When first asked for a non-fake-front buffer.
- When the drawable size is changed, an Invalidate has been sent, and
  obviously the app needs to redraw the whole buffer.
- After a glXSwapBuffers(), GL allows the backbuffer to be undefined,
  and an Invalidate was sent to tell the GL that it should grab these
  appropriate new buffers to avoid stalling.

But with the patch being reverted, GetBuffers would also return fresh
invalid buffers when the drawable serial number changed, which is
approximately "whenever, for any reason".  The app is not expecting
invalid buffer contents "whenever", nor is it valid.  Because the GL
usually only GetBuffers after an Invalidate is sent, and the new
buffer allocation only happened during a GetBuffers, most apps saw no
problems.  But apps that do (fake-)frontbuffer rendering do frequently
ask the server for the front buffer (since we drop the fake front
allocation when we're not doing front buffer rendering), and if the
drawable serial got bumped midway through a draw, the server would
pointlessly ditch the front *and* backbuffer full of important
drawing, resulting in bad rendering.

The patch was originally to fix bugzilla:
https://bugs.freedesktop.org/show_bug.cgi?id=28365
Specifically:

    To reproduce, start with a large-ish display (i.e. 1680x1050 on my
    laptop), use the patched glxgears from bug 28252 to add the
    -override option.  Then run glxgears -override -geometry 640x480
    to create a 640x480 window in the top left corner, which will work
    fine.  Next, run xrandr -s 640x480 and watch the fireworks.

I've tested with an override-redirect glxgears, both with vblank sync
enabled and disabled, both with gnome-shell and no window manager at
all, before and after this patch.  The only problem observed was that
before and after the revert, sometimes when alt-tabbing to kill my
gears after completing the test gnome-shell would get confused about
override-redirectness of the glxgears window (according to a log
message) and apparently not bother doing any further compositing.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Tested-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Keith Packard <keithp@keithp.com>
2013-06-18 10:54:22 -07:00
Dave Airlie
22746df15b dri2: invalidate drawable after sharing pixmap
After we share the pixmap, the backing storage may have changed,
and we need to invalidate and buffers pointing at it.

This fixes GL compositors and prime windows lacking contents initially.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-09-17 09:52:03 +10:00
Dave Airlie
ac09a4a091 dri2: fix master pixmap free and reset pointer
These are two minor changes, one to reset the pointer to NULL,
after freeing the pixmaps, one to make sure we use the right API for
the master pixmap, though I doubt it'll ever really matter.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2012-08-07 08:25:45 +10:00
Dave Airlie
64623ef90d dri2: free slave pixmap on app exit
When the drawable disappears we need to free the prime master/slave combos.

This fixes a leak after a prime app is run.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
2012-08-07 08:25:35 +10:00
Michel Dänzer
8a87acc9e5 dri2: Add DRI2CreateDrawable2.
Same as DRI2CreateDrawable, except it can return the DRI2 specific XID of the
DRI2 drawable reference to the base drawable.

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-12 15:08:37 -07:00
Daniel Stone
9a953e0e9d Move DRI2 from external module to built-in
Instead of keeping a tiny amount of code in an external module, just man
up and build it into the core server.

v2: Fix test/Makefile.am to only link libdri2.la if DRI2 is set

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-10 00:31:01 -07:00
Dave Airlie
329db32922 dri2/prime: allocate prime id at screen allocation time
Add a static mask of prime id and allocate them at screen time,
if the driver supports the prime interfaces and is a gpu screen.

This is instead of them changing due to user controlled randr commands,
as suggested by Keith.

Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-07-07 10:39:10 +01:00
Dave Airlie
3029801216 dri2: add initial prime support. (v1.2)
This adds the initial prime support for dri2 offload. The main thing is
when we get a connection from a prime client, we stored the information
and mark all drawables from that client as prime. We then create all
buffers for that drawable on the prime device dri2screen.

Then DRI2UpdatePrime is provided which drivers can call to get a shared
pixmap which they can use as the front buffer. The driver is then
responsible for doing the back->front copy to the shared buffer.

prime requires a compositing manager be run, but it handles the case where
a window get un-redirected by allocating a new pixmap and pointing the crtc
at it while the client is in that state.

Currently prime can't handle pageflipping, so always does straight copy swap,

v1.1: renumber on top of master.
v1.2: fix auth on top of master.

Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-07-07 10:39:10 +01:00
Christopher James Halse Rogers
a7b97b0fa8 dri2: Fix authentication for < v8 clients (v2).
The legacy logic was embarassingly wrong; AuthMagic should return errno,
so returning FALSE only when AuthMagic returns nonzero is exactly wrong.

v2: Match drmAuthMagic by returning -EINVAL rather than EINVAL
    Fix trailing whitespace

https://bugs.freedesktop.org/show_bug.cgi?id=51400
Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
Tested-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Tested-by: Knut Petersen <knut_petersen@t-online.de>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-06-28 10:40:34 -07:00
Christopher James Halse Rogers
3f97284b10 dri2: Pass a ScreenPtr through to the driver's AuthMagic function. (v3)
xwayland drivers need access to their screen private data to authenticate.
Now that drivers no longer have direct access to the global screen arrays,
this needs to be passed in as function context.

v2: Don't break ABI
v3: Paint the bikeshed blue; drop fd from AuthMagic2ProcPtr prototype

Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-06-20 11:56:55 -07:00
Chad Versace
78f0d9cdc4 dri2: Add DRI2GetParam request (v2)
Bump dri2proto dependency to 2.7.
Bump DRI2INFOREC_VERSION to 7.

This new protocol request effectively allows clients to perform feature
detection on the DDX. The request was added in DRI2 protocol 1.4.

If I had DRI2GetParam in June 2011, when I was implementing support in the
Intel DDX and Mesa for new hardware that required a new DRI2 attachment
format, then I could have avoided a week of pain caused by the necessity
to write a horrid feature detection hack [1] in Mesa. In the future, when
the work begins to add MSAA support to the Intel DDX, having a clean way
to do feature detection will allow us to avoid revisiting and expanding
that hack.

[1] mesa, commit aea2236a, function intel_verify_dri2_has_hiz

v2: If driver doesn't define ds->GetParam, dont' crash. Fall back to
    default behavior, per keithp.

Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net> (v1)
Reviewed-by: Ian Romanick <idr@freedesktop.org> (v1)
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
2012-05-31 12:14:17 -07:00
Keith Packard
9838b7032e Introduce a consistent coding style
This is strictly the application of the script 'x-indent-all.sh'
from util/modular. Compared to the patch that Daniel posted in
January, I've added a few indent flags:

	-bap
	-psl
	-T PrivatePtr
	-T pmWait
	-T _XFUNCPROTOBEGIN
	-T _XFUNCPROTOEND
	-T _X_EXPORT

The typedefs were needed to make the output of sdksyms.sh match the
previous output, otherwise, the code is formatted badly enough that
sdksyms.sh generates incorrect output.

The generated code was compared with the previous version and found to
be essentially identical -- "assert" line numbers and BUILD_TIME were
the only differences found.

The comparison was done with this script:

dir1=$1
dir2=$2

for dir in $dir1 $dir2; do
	(cd $dir && find . -name '*.o' | while read file; do
		dir=`dirname $file`
		base=`basename $file .o`
		dump=$dir/$base.dump
		objdump -d $file > $dump
	done)
done

find $dir1 -name '*.dump' | while read dump; do
	otherdump=`echo $dump | sed "s;$dir1;$dir2;"`
	diff -u $dump $otherdump
done

Signed-off-by: Keith Packard <keithp@keithp.com>
Acked-by: Daniel Stone <daniel@fooishbar.org>
Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-03-21 13:54:42 -07:00
Alan Coopersmith
ca64912c02 Namespace list api to reduce conflicts with similar system headers
Rename functions/macros from list_* to xorg_list_*
Rename struct from struct list to struct xorg_list.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
In-sed-I-trust: Peter Hutterer <peter.hutterer@who-t.net>
2012-02-03 14:23:24 -08:00
Ville Syrjälä
4df65d247b dri2: Invalidate window pixmaps
While a redirected window is flipped, its pixmap may still be used as
and EGL image and should also get invalidated. When sending invalidate
events for a window, also send the events for its pixmap.

Signed-off-by: Ville Syrjälä <syrjala@sci.fi>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2011-12-19 22:32:33 -08:00
Keith Packard
e8fd23fad0 dri2: Invalidate DRI2 buffers for all windows with the same pixmap on swap
Without this, when a compositing manager unredirects a fullscreen window which
uses DRI2 and page flipping, the DRI2 buffer information for the compositing
manager's output window (typically the Composite Overlay Window or root window)
may become stale, resulting in all kinds of hilarity.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=35452 .

[Original patch by Michel Dänzer <michel@daenzer.net>]
[Tree walk optimized version by Keith Packard <keithp@keithp.com>]

Signed-off-by: Ville Syrjälä <syrjala@sci.fi>
Signed-off-by: Keith Packard <keithp@keithp.com>
2011-12-19 22:31:14 -08:00
Michel Dänzer
6f916ffec7 dri2: Always re-generate front buffer information when asked for it.
Otherwise we might keep stale cached information, e.g. after the driver
performed page flipping.

This is part of the fix for
https://bugs.freedesktop.org/show_bug.cgi?id=35452 .

Signed-off-by: Michel Dänzer <daenzer@vmware.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@nokia.com>
Reviewed-by: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
Signed-off-by: Keith Packard <keithp@keithp.com>
2011-12-19 22:31:01 -08:00
Rami Ylimäki
603fcb3abf dri2: Initialize needInvalidate member of DRI2Drawable.
If the client is not behaving correctly and swaps buffers before
getting them, Valgrind will complain about uninitialized memory being
used in DRI2InvalidateDrawable.

Signed-off-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Reviewed-by: Ville Syrjälä <syrjala@sci.fi>
Signed-off-by: Keith Packard <keithp@keithp.com>
2011-12-19 22:30:11 -08:00
Chris Wilson
34b0e4eee9 dri2: Register the DRI2DrawableType after server regeneration
The Resource database is reset upon regeneration and so the dri2 module
needs to re-register its RESTYPE for the drawable or else it will
clobber the next unsuspecting user of the database. Fortunately, DRI2 is
loaded late in the initialisation sequence and was last up until
xf86-video-intel started using the Resource database to track
outstanding swaps...

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Tested-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
2011-11-18 11:26:03 -08:00
Chris Wilson
bfa1a0dd19 DRI2: Avoid a NULL pointer dereference
Bugzilla:  https://bugs.freedesktop.org/show_bug.cgi?id=41211

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-11-18 11:26:02 -08:00
Pauli Nieminen
871d65790e DRI2: Allow DDX to validate swap_limit changes
DDX can now implement validation for swap_limit changes to prevent
configurations that are not support in driver.

Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
CC: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
Reviewed-by: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2011-09-21 14:04:37 -07:00
Pauli Nieminen
b435e2aac1 DRI2: Expose API to set drawable swap limit.
This allows ddx to set swap_limit if there is more than one back
buffer for drawable. Setting swap_limit has to also check if change
affects a client that is blocked.

This can be used to implement N-buffering in driver with minimal
logic in allocation and selecting next back.

Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
Reviewed-by: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
Signed-off-by: Keith Packard <keithp@keithp.com>
2011-09-21 13:55:45 -07:00
Pauli Nieminen
86f8da0aa7 DRI2: Add ReuseBufferNotify hook
ReuseBufferNotify hook is called whenever old buffer is reused in DRI2
code.

Driver can use this hook to rewrite the buffer name if hardware requires
shared buffers. Shared buffer might be some hardware limited resources like
framebuffer that is preallocated in boot.

Signed-off-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Keith Packard <keithp@keithp.com>
2011-09-21 13:54:55 -07:00
Marcin Slusarz
b573cdd40e dri2: restore Screen->ConfigNotify on close
ConfigNotify is set by DRI2ScreenInit, but not restored to
previous state on close. Fix it.
(I'm preparing a patch for xf86-video-nouveau which detects GPU lockup
after dri2 init and it needs to reinitialize dri2)

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-06-30 16:38:23 +10:00
Ville Syrjälä
531869448d dri2: Don't send so many needless invalidate events
Only send invalidate events for drawables if some client has requested
some buffers.

Signed-off-by: Ville Syrjälä <ville.syrjala@nokia.com>
Reviewed-by: Michel Dänzer <michel@daenzer.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2011-05-13 14:05:11 -07:00
Ville Syrjälä
b3d2164a03 dri2: Pass out_count by value to update_dri2_drawable_buffers()
update_dri2_drawable_buffers() doesn't modify out_count, so pass it
by value.

Signed-off-by: Ville Syrjälä <ville.syrjala@nokia.com>
Reviewed-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2011-04-14 15:21:57 +03:00
Ville Syrjälä
93c833ee84 dri2: Handle calloc() failure
Don't access invalid memory if calloc() fails to allocate the buffers
array.

Signed-off-by: Ville Syrjälä <ville.syrjala@nokia.com>
Reviewed-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2011-04-14 15:21:57 +03:00