Commit Graph

79 Commits

Author SHA1 Message Date
Dave Airlie dadffd0061 intel: fix fullscreen damage posting on pageflip
While playing with MPX and sw cursor I noticed page flips won't
end up misrendering some bits, so the sw cursor was replacing the
bits on the wrong pixmap.

Fix the damage handling to be correct and append damage before swapping
the pointers and process damage after.

This fixes misrendering with MPX cursors under a fullscreen compositor,
that pageflips.

Signed-off-by: Dave Airlie <airlied@redhat.com>
[ickle: The secret is that damage is sometimes reported before the
rendering in DamageRegionAppend, and sometimes afterwards in
DamageRegionProcessPending. For instance, the software cursor operates
prior to being rendered over.]
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-10-11 09:24:12 +01:00
Chris Wilson cb0b72c4fb uxa: Fixup the last couple of commits after realising I didn't have uxa enabled
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-09-27 14:53:46 +01:00
Chris Wilson feef53005b uxa: Do not attempt to pageflip whilst not master
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-09-27 14:40:58 +01:00
Chris Wilson edc5b7f741 uxa/dri: Confirm Drawable is still attached to an active pipe before flipping
If we schedule a flip to happen on a far distant vblank, it is possible
for us to disable the pipes with a modeset, whilst maintaining the fb
size, or with a DPMS command. If the pipe is disabled and we still try
to flip, then we trigger an EINVAL error from the kernel.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-09-27 13:27:20 +01:00
Chris Wilson 39c4be2b0b uxa: Distinguish forms of pinning
This allows us to replace the prime bo to meet sharing requirements, but
still maintain the integrity with other users.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-09-06 11:28:49 +01:00
Chris Wilson 6211d0914e uxa: Flush batch immediately after queuing a WAIT_FOR_EVENT
We still encounter hangs with kernel-3.5 with the culprit being a wait
on a disabled pipe. As we thoroughly check before that the pipe is still
disabled and flush before a modeset, the only possibility that remains
is that DPMS is disabling the pipe before we submit. Close that race by
always submitting the batch immediately after a WAIT_FOR_EVENT.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-09-05 12:33:08 +01:00
Zhigang Gong 717823a9f7 uxa/dri (glamor): Use exchange buffer in glamor fixup.
The previous implementation is to create a new textured
pixmap based on the newly created pixmap's buffer object.

This is not efficient, as we already created it when we
call CreatePixmap. We can just exchange the underlying
texture/image buffers by calling intel_glamor_exchange_buffers().

And this commit seems also fix a weird rendering problem
when working with compiz/mutter.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-07-27 11:23:35 +01:00
Chris Wilson 0c32be15b0 uxa: Remove Shadow hack
This was an incomplete hack so deprecate in favour of Shadow-on-Steriods,
SNA.

References: https://bugs.freedesktop.org/show_bug.cgi?id=47324
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-07-15 20:56:58 +01:00
Zhigang Gong 1d9ab2e710 uxa/dri: Fix a buffer leak on pageflipping when enabling glamor.
We need to put current front_buffer to back buffer thus we
don't need to create a new back buffer next time. This behaviou
should be the same with or without glamor. Previous code
incorrectly discard the previous front_buffer and cause a
big buffer leak problem.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-07-12 12:46:16 +01:00
Chris Wilson d02e6d8142 Encode the third pipe using the HIGH_CRTC shift for vblanks
The original vblank interface only understood 2 pipes (primary and
secondary) and so selecting the third pipe (introduced with IvyBridge)
requires use of the HIGH_CRTC. Using the second pipe where we meant the
third pipe could result in some spurious timings when waiting on the
vblank.

Reported-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-06-21 16:54:35 +01:00
Chris Wilson 99845dcb3b Post Damage on the Screen Pixmap after a pageflip
This issue was raised by Dave Airlie as he is trying to integrate
multiple GPUs into the xserver, and a particular setup has a slave
rendering device that copies the contents from the GPU over a
DisplayLink USB adaptor. As such the slave device is listening for
Damage on the Screen Pixmap and needs the update following pageflips.
Since we already are posting damage for all the SwapBuffers paths other
than pageflip, for consistency we should post damage along the pageflip
path as well.

Reported-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-06-19 10:43:09 +01:00
Chris Wilson 08010b23a3 uxa/dri: Silence static analyser for potential NULL intel_pixmap
If the intel_pixmap was NULL we should have failed to create the DRI2
buffer, so we can safely assert here to keep the analyser quiet.

Reported-by: Zdenek Kabelac <zkabelac@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-06-06 17:10:35 +01:00
Chris Wilson c433fb4521 uxa/dri: Fix up typo from f2513cb0f
s/true/FALSE/? Wrong.

Reported-by: Zdenek Kabelac <zkabelac@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-06-06 15:17:30 +01:00
Chris Wilson 1675f44104 uxa/dri: Transfer reference of the new_back buffer to the flip_chain
In order to prevent a leak of the bo when the chain is eventually
torn-down when the client exits.

Reported-by: Andreas Lampersperger <lampersperger.andreas@heidenhain.de>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=50670
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-06-06 12:55:13 +01:00
Chris Wilson f2513cb0fd uxa/dri: Do not use undeclared stdbool features
The header isn't pulled in, so stop using the undefined values of
true/false.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-06-06 10:41:35 +01:00
Chris Wilson 7424ea7dd0 uxa/dri: Free wait_info along DRI2WaitMSC error paths
Reported-by: Zdenek Kabelac <zkabelac@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-06-04 11:59:24 +01:00
Chris Wilson ebd6dea009 uxa/dri: Make sure is_glamor_pixmap is always initialised
The code paths are too twisty to be sure otherwise.

Reported-by: Zdenek Kabelac <zkabelac@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-06-04 11:56:11 +01:00
Chris Wilson d66ca06865 uxa: Intialize is_glamor_pixmap
It is not clear whether is_glamor_pixmap is always initialized prior to
use, so set it to a safe^W likely value.

Reported-by: Zdenek Kabelac <zkabelac@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-06-02 08:38:21 +01:00
Chris Wilson b83e2a79f2 uxa: Static analysis warning fixes
A smattering of bugs and confusing code.

Reported-by: Zdenek Kabelac <zkabelac@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-06-01 17:30:38 +01:00
Chris Wilson 5b99c7cd34 uxa/dri: Enable vblank scheduling even with pageflipping disabled
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-05-28 12:48:25 +01:00
Chris Wilson 810357ad65 uxa/dri: Fix ordering of setting vs using swap members
Trivial readibility fix, as the actual ordering is serialised through
there being only a single thread.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-05-28 12:48:25 +01:00
Dave Airlie 43a34186d1 intel: convert to new screen conversion APIs
The compat header takes care of the old server vs new server.

this commit was autogenerated from util/modular/x-driver-screen-scrn-conv.sh

Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-05-23 11:02:20 +01:00
Chris Wilson b817200371 Don't issue a scanline wait while VT switched
Be paranoid and check that we own the VT before emitting a scanline
wait. If we attempt to wait on a fb/pipe that we do not own, we may
issue an illegal command and cause a lockup.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-04-17 17:56:05 +01:00
Zhigang Gong d98b41ce43 uxa/glamor/dri: Should fixup the drawable pixmap.
Two fixes in this commit, first we only need to check the
front left buffer, for other attachment we don't need to
check them. The second is, we should fixup the pixmap's
drawable not the original drawable.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-21 08:42:54 +00:00
Zhigang Gong 1e0d702c3a uxa/glamor/dri: Enable the pageflip support on glamor.
To support easy buffer exchange at glamor layer, glamor
added a new API glamor_egl_exchange_buffers() to exchange
two pixmaps' EGL image and fbos and textures without
recreating any of them. But this simple method's requirement
is that there are two pixmaps. A exceptional case is:
If we are using triple buffer when do page flipping, we
will have an extra back_buffer which doesn't have a pixmap
attached to it. Then each time we set that buffer to a
pixmap, we will have to call the create_egl_textured_pixmap
to create the corresponding EGL image and fbo and texture
for it. This is not efficient.

To fix this issue, this commit introduces a new back_pixmap
to intel structure to hold the back buffer and corresponding
glamor resources. Then we will just need to do the light
weight buffer exchanging at both DDX and glamor layer.

As the new back pixmap is similar to the screen pixmap
and need to be handled carefully when close screen. As the
glamor data structure is a per screen data, and will be
released at its close screen method. The glamor's close
screen method must cleanup the screen pixmap and back
pixmap's glamor resources. screen pixmap is easy to get,
but there is no good way to store the back pixmap.

So the glamor add a new API glamor_egl_create_textured_screen_ext
function to pass the back pixmap's pointer to glamor layer.

This commit make us depend on glamor commit: 4e58c4f.
And we increased the required glamor version from 0.3.0 to 0.3.1

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-21 08:42:12 +00:00
Zhigang Gong ce7a57994d uxa/dri: Refine the pageflip processing.
Add a new element back_name to intel structure to track
the back bo's name then avoid flink every time.
And at function I830DRI2ExchangeBuffers, after finish
the BO exchange between info's front and back pixmap,
it set the new front bo to the screen pixmap. But the
screen pixmap should be the same as front's pixmap,
so this is a duplicate operation and can be removed.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
2012-02-21 08:40:10 +00:00
Zhigang Gong bf3518ea91 uxa/glamor/dri: Fix a typo bug when fixup glamor pixmap.
Should modify the old pixmap's header not the new one which
was already destroyed.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-02-07 08:43:08 +00:00
Chris Wilson 15a150579c intel: Trivially remove a piece of XAA dependency for shadow
The wolves are gathering at the door baying for the removal of XAA from
Xorg.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-01-18 10:27:17 +00:00
Zhigang Gong 2f09363a6e uxa/glamor: Create glamor pixmap by default.
When creating native glamor pixmaps we will get much better performance
than using the textured-drm pixmap, this commit is to make that the
default behaviour when configured to use glamor. Another advantage
of this commit is that  we reduce the risk of encountering the
"incompatible region exists for this name" and the associated
render corruption. And since we now never intentionally allocate
a reusable pixmap we could just make all (intel_glamor) allocations
non-reusable without incurring too great an overhead.

A side effect is that those glamor pixmaps do not have a
valid BO attached to them and thus it fails to get a DRI drawable. This
commit also fixes that problem by adjusting the fixup_shadow mechanism
to recreate a textured-drm pixmap from the native glamor pixmap. I tested
this with mutter, and it works fine.

The performance gain to apply this patch is about 10% to 20% with
different workload.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-01-16 10:49:21 +00:00
Chris Wilson 4db1bb3fd8 Removed deprecated xf86PciInfo.h includes
The driver should and does provide its own PCI-IDs.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2012-01-08 17:34:48 +00:00
Chris Wilson a8fe50ab65 uxa: Explicitly check for libdrm_intel in configure
And remove the excess dependencies from the common files.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-12-17 21:26:34 +00:00
Chris Wilson 3771387ad1 Compile out UXA if so desired
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-11-16 22:15:39 +00:00
Chris Wilson 63518c4223 dri: Build fix for xserver-1.7.7
Back in the olden days before the introduction of dixRegisterPrivate().

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-08-01 13:37:31 +01:00
Chad Versace 3e55f3e88b dri: Do not tile stencil buffer
Until now, the stencil buffer was allocated as a Y tiled buffer, because
in several locations the PRM states that it is. However, it is actually
W tiled. From the PRM, 2011 Sandy Bridge, Volume 1, Part 2, Section
4.5.2.1 W-Major Format:
    W-Major Tile Format is used for separate stencil.

The GTT is incapable of W fencing, so we allocate the stencil buffer with
I915_TILING_NONE and decode the tile's layout in software.

This commit mutually depends on the mesa commit:
    intel: Fix stencil buffer to be W tiled
    Author: Chad Versace <chad@chad-versace.us>
    Date:   Mon Jul 18 00:37:45 2011 -0700

Signed-off-by: Chad Versace <chad@chad-versace.us>
Reviewed-by: Ian Romanick <ian.romanick@intel.com>
Acked-by: Kenneth Graunke <kenneth@whitecape.org>
2011-07-19 13:08:18 -07:00
Chris Wilson 644b1a9033 dri: Always initialise resource members of DRI2FrameEvent
As we now attempt to always decouple the lists upon freeing the frame
event, we need to initialise them along all code paths.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-12 11:51:58 +01:00
Chris Wilson 7538be3315 dri: Enable triple-bufferred pageflips
By popular demand.

Triple-buffering trade-offs output latency versus jitter. By having a
pre-rendered frame ready to swap in following a pageflip, we avoid the
scenario where the latency between receiving the flip complete signal
from the kernel, waking up the vsynced application, it render the new
frame and then for the server to process the swap request is greater
than the frame interval, causing us to miss the vblank. The result is
that application can become frame-locked to 30fps. Instead, we report to
the application that the first frame swap is immediately completed,
supply a new back buffer (or else the rendering would be blocked on
waiting for the front-buffer to be swapped away from the scanout) and
let them proceed to render the second frame. The second frame is added
to the swap queue, and the client throttled to vrefresh. (If the client
missed the vblank, the swap queue is empty and the client is immediately
woken again, whilst the pageflip is pending.)

Note, for practical reasons this only applies to page-flipping, for
example, calls to glXSwapBuffer() on fullscreen applications.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-11 22:13:01 +01:00
Chris Wilson 2608a367ac dri: Prevent abuse of the Resource database
The Resource database is only designed to store a single value for a
particular type associated with an XID. Due to the asynchronous nature
of the vblank/flip requests, we would often associate multiple frame
events with a particular drawable/client. Upon freeing the resource, we
would not necessarily decouple the right value, leaving a stale pointer
behind. Later when the client disappeared, we would write through that
stale pointer upsetting valgrind and causing memory corruption. MDK.

Instead, we need to implement an extra layer for tracking multiple
frames within a single Resource.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=37700
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-11 21:46:36 +01:00
Chris Wilson ab1000821a dri: Remove the shadow copy of attachment
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-07-09 19:47:00 +01:00
Adam Jackson 356ded1308 Don't include xf86Priv.h
I'd like it to not be in the SDK anymore, and we're not using anything
from it.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-06-22 22:39:37 +01:00
Chad Versace a62db5b050 dri: Add support for DRI2BufferStencil and DRI2BufferHiz
And bump configure.ac to require dri2proto >= 2.6, because
DRI2BufferStencil and DRI2BufferHiz were introduced in that version.

When a client requests DRI2BufferHiz or DRI2BufferStencil,
I830DRI2CreateBuffer() now returns a Y-tiled buffer. The stencil buffer is
handled as a special case due its quirky pitch requirements.

CC: Eric Anholt <eric@anholt.net>
CC: Ian Romanick <idr@freedesktop.org>
CC: Kristian Høgsberg <krh@bitplanet.net
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Chad Versace <chad@chad-versace.us>
2011-06-08 10:08:58 -07:00
Chad Versace 263daba7e6 dri: Do not create DRI2 buffers for unrecognized DRI2 buffer tokens
Before this commit, if a client were to request an unrecognized DRI2
buffer, such as DRI2BufferStencil, then I830DRI2CreateBuffer() allocated
and returned an X-tiled buffer by accident. The problem was that
unrecognized tokens were caught by the default case of a switch statement.

Now, when given unrecognized DRI2 tokens, I830DRI2CreateBuffers() returns
null.

This shouldn't break older Mesa versions, because they never query (via
DRI2GetBuffersWithFormat) for the drawable's DRI2BufferStencil.

CC: Eric Anholt <eric@anholt.net>
CC: Ian Romanick <idr@freedesktop.org>
CC: Kenneth Graunke <kenneth@whitecape.org>
CC: Kristian Høgsberg <krh@bitplanet.net
Signed-off-by: Chad Versace <chad@chad-versace.us>
2011-06-08 10:08:33 -07:00
Chris Wilson 895a46e8ff dri: Flush the batch after a DRI swap/copy event
To minimise lag in those every so critical games, we want to ensure that
the copy happens as soon as it is received, so we need to flush the
batch after processing a swap event and before we go to sleep.

References: https://bugs.freedesktop.org/show_bug.cgi?id=37068
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-05-10 20:38:25 +01:00
Chris Wilson 1d102cc6ed Use SwapbuffersWait config option to control waiting on fullscreen swaps
As fullscreen swaps were going via a different path to the swapping of
ordinary windows, we were no longer honouring the xorg.conf option to
disable swapbuffer waiting.

This changes the code to only use pageflipping if the Option
"SwapbuffersWait" is set to "TRUE" (default).

Jesse's comment was that this should be superseded by actually
supporting asynchronous page flips. As we are missing kernel and dix level
support for that, in the meantime honour the config option.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: Kristian Høgsberg <krh@bitplanet.net>
2011-04-20 08:51:50 +01:00
Chris Wilson 3d2b79098c dri: Rearrange code to compile against xorg-server-1.7
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-04-11 15:23:56 +01:00
Chris Wilson 972569f6fd MI_LOAD_SCAN_LINES_INCL are inclusive and range [0, display height-1]
We have seen GPU hangs with:

batchbuffer at 0x0f9b4000:
0x0f9b4000:      0x09000000: MI_LOAD_SCAN_LINES_INCL
0x0f9b4004:      0x00000300:    dword 1
0x0f9b4008:      0x09000000: MI_LOAD_SCAN_LINES_INCL
0x0f9b400c:      0x00000300:    dword 1
0x0f9b4010:      0x01820000: MI_WAIT_FOR_EVENT
0x0f9b4014: HEAD 0x02000006: MI_FLUSH

on a 1366x768 display. That according to the specs an invalid command
for the pipe.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=35576
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-04-04 13:58:48 +01:00
Keith Packard 7ccbec801e Recover from i830_dri2_add_frame_event out-of-memory condition
If adding either the frame or client resources fails, we need to clean
up afterwards properly.

First, add_frame_event needs to internally clean up after itself by
undoing any partial execution. Second, the callers need to look at the
return value and free the swap/flip info structure when necessary.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Julien Cristau <jcristau@debian.org>
2011-03-24 17:12:00 -07:00
Keith Packard 86f23f21ab Skip client and drawable resource delete calls when deleting frame event
As the frame_event is about to be freed, there's no point in cleaning
up references to the drawable and client.

Signed-off-by: Keith Packard <keithp@keithp.com>
2011-03-23 17:14:12 -07:00
Keith Packard e1ff518230 Handle drawable/client destruction in pending swaps/flips
A pending swap or flip holds references to drawables and clients which
become invalid when destroyed. Add suitable resources to the database
to track those lifetimes and clean up the pending data structure then.

Later, when the pending swap or flip occurs, handle a missing drawable
by just discarding the flip or swap. Handle a missing client by not
sending an event or reply.

Signed-off-by: Keith Packard <keithp@keithp.com>
2011-03-23 17:14:12 -07:00
Keith Packard aa0328f342 dri2: Make DRI2FrameEvent public and use instead of void *
Instead of using void * for all of the flip_info and swap_info
pointers, just make the underlying structure a public data type and
use that.

Signed-off-by: Keith Packard <keithp@keithp.com>
2011-03-23 17:14:12 -07:00
Chris Wilson 014fc7abb7 dri: Disable page-flip between a tiled buffer and a linear scanout
Keith Packard pointed out a loophole that could cause the DDX to end up
with a tiled scanout even if the user required a linear framebuffer;
that is by using page-flipping we could replace the scanout pixmap with
another of our choosing, and not necessarily tiled.

Close that loophole by only allowing an exchange of buffers between
identical tiling modes. For the common case, this is fine since they
will indeed be allocated with the same tiling. For the linear
framebuffer case with mesa using a tiled pixmap, we force it to blit
onto the scanout instead.

Reported-by: Keith Packard <keith.packard@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2011-03-09 17:10:50 +00:00