Commit Graph

33 Commits

Author SHA1 Message Date
Dave Airlie
15b7738389 exa: rename some badly named variables
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-10 06:17:40 +10: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
Alan Coopersmith
6c06c268ad Skip damage calls if DamageCreate fails in exa functions
Fixes parfait errors such as:
   Null pointer dereference (CWE 476): Write to null pointer pDamage
        at line 1833 of miext/damage/damage.c in function 'DamageRegister'.
          Function DamageCreate may return constant 'NULL' at line 1775,
              called at line 232 of exa/exa_migration_mixed.c
              in function 'exaPrepareAccessReg_mixed'.
          Constant 'NULL' passed into function DamageRegister,
              argument pDamage, from call at line 237.
          Null pointer introduced at line 1775 of miext/damage/damage.c
              in function 'DamageCreate'.
   Null pointer dereference (CWE 476): Write to null pointer pDamage
        at line 1833 of miext/damage/damage.c in function 'DamageRegister'.
          Function DamageCreate may return constant 'NULL' at line 1775,
              called at line 104 of exa/exa_mixed.c
              in function 'exaCreatePixmap_mixed'.
          Constant 'NULL' passed into function DamageRegister,
              argument pDamage, from call at line 109.
          Null pointer introduced at line 1775 of miext/damage/damage.c
              in function 'DamageCreate'.

Checks are similar to handling results of other calls to DamageCreate.

[ This bug was found by the Parfait 1.3.0 bug checking tool.
  http://labs.oracle.com/pls/apex/f?p=labs:49:::::P49_PROJECT_ID:13 ]

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-10-14 17:56:44 -07:00
Adam Jackson
28708a045d damage: Implicitly unregister on destroy
There's no reason not to, and it simplifies quite a few callers.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-09-10 14:28:09 -04:00
Dave Airlie
0b0e714892 exa: pixmap sharing infrastructure (v3)
This just adds exa interfaces for mixed exa so drivers can
share and set shared pixmaps up correctly.

v2: update for passing slave screen.
v3: update for void *

Reviewed-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
2012-07-07 10:37:10 +01: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
Michel Dänzer
4020cab88f EXA/mixed: Update sys_pitch in MPH even when there's no system memory copy.
Otherwise sys_pitch will be stale when a system memory copy is allocated.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=38322 and a crash when
unlocking the screen with xscreensaver, reported by Janne Huttunen.

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Tested-by: Janne Huttunen <jahuttun@gmail.com>
Tested-by: Jan Kriho <Erbureth@gmail.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2011-08-10 09:30:08 -07:00
Matěj Cepl
b27d61e443 Fix UTF-8 encoding
Report to find out all non-UTF-8 files created by

cat extensions |xargs -I XXXX find . -name \*.XXXX |while read FILE ; do
    if ( iconv -f utf8 -t ucs2 $FILE >/dev/null 2>/dev/null ) ; then
        /bin/true
    else
        echo $FILE
    fi
done >>report

Signed-off-by: Matěj Cepl <mcepl@redhat.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>

[Daniel: git am failed for me, so I redid it.  The method listed in the
         commit message also failed, so I just used file/grep/iconv.  The
         results are the same though.]
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-06-30 16:38:31 +10:00
Keith Packard
d5b16b037b Revert "dix: Remove usage_hint from pixmaps, store it in ->drawable.class"
This reverts commit 1564c82417.

The drivers used the top bits of the usage_hint to store driver
private flags (intel, radeon, nouveau).

With EXA we need to get at this data so if we migrate the pixmap we
can create the correct type of pixmap in the driver, however this
commit truncates the usage_hint into 8-bit class and loses all the
good stuff.

Signed-off-by: Dave Airlie <airlied@gmail.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
2011-03-17 23:48:52 -07:00
Adam Jackson
1564c82417 dix: Remove usage_hint from pixmaps, store it in ->drawable.class
The class field was unused for pixmaps, and we don't have enough classes
to justify a whole uint32 anyway.

Reviewed-by: Soren Sandmann <ssp@redhat.com>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2011-03-08 13:16:50 -05:00
Michel Dänzer
31704510f4 EXA/mixed: ModifyPixmapHeader pitch fixes. (bug #33929)
If there's a GPU copy and a non-zero devKind was passed in, set the GPU copy
pitch to that instead of to a possibly bogus value derived from the new width.
This is e.g. used by the radeon driver's drmmode_xf86crtc_resize hook, fixes
https://bugs.freedesktop.org/show_bug.cgi?id=33929 .

On the other hand, the system memory copy doesn't need the pitch to be aligned
beyond the PixmapBytePad of the width.

Signed-off-by: Michel Dänzer <daenzer@vmware.com>
Acked-by: Cyril Brulebois <kibi@debian.org>
Tested-by: Cyril Brulebois <kibi@debian.org>
Reported-by: Thierry Vignaud <thierry.vignaud@gmail.com>
Tested-by: Thierry Vignaud <thierry.vignaud@gmail.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2011-02-24 19:38:20 -08:00
Michel Dänzer
6358a60065 EXA: Pad size of system memory copy for 1x1 pixmaps (bug #32803).
Fixes https://bugs.freedesktop.org/show_bug.cgi?id=32803 .

Signed-off-by: Michel Dänzer <daenzer@vmware.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2011-01-06 08:37:27 -08:00
Michel Dänzer
0540c46066 EXA: Finish access to pixmap if it's prepared at destruction time.
Previously we assumed every pixmap destroyed during a software fallback was
also created during a software fallback and had access prepared, but that's
not always true.

Fixes a server abort
Reported-by: 邓逸昕 <bupt.dengyixin@gmail.com>

Signed-off-by: Michel Dänzer <daenzer@vmware.com>
Acked-by: Maarten Maathuis <madman2003@gmail.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-07-13 10:07:04 -07:00
Mikhail Gusarov
0a4d8cbdcd Remove more superfluous if(p) checks around free(p)
This patch has been generated by the following Coccinelle semantic patch:

@@
expression E;
@@

-if(E) { free(E); }
+free(E);

Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Reviewed-by: Fernando Carrijo <fcarrijo@yahoo.com.br>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2010-06-06 20:27:18 +07:00
Keith Packard
2dc138922b Rename region macros to eliminate screen argument
This is a combination of a huge mechanical patch and a few small
fixups required to finish the job. They were reviewed separately, but
because the server does not build without both pieces, I've merged
them together at this time.

The mechanical changes were performed by running the included
'fix-region' script over the whole tree:

$ git ls-files | grep -v '^fix-' | xargs ./fix-region

And then, the white space errors in the resulting patch were fixed
using the provided fix-patch-whitespace script.

$ sh ./fix-patch-whitespace

Thanks to Jamey Sharp for the mighty fine sed-generating sed script.

The hand-done changes involve removing functions from dix/region.c
that duplicate inline functions in include/regionstr.h, along with
their declarations in regionstr.h, mi.h and mispans.h.

Reviewed-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-06-05 18:59:00 -07:00
Tiago Vignatti
49835eec0c exa: check for NULL pointer before dereferences it
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Acked-by: Michel Dänzer <michel@daenzer.net>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
2010-04-21 18:06:59 +03:00
Michel Dänzer
0c1f43c0f3 EXA/mixed: Handle results of software fallbacks in DamageReport hook.
This is more elegant and probably also slightly more correct than doing it
at FinishAccess time.

Signed-off-by: Michel Dänzer <daenzer@vmware.com>
Acked-by: Maarten Maathuis <madman2003@gmail.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2009-12-29 11:04:51 -08:00
Michel Dänzer
08bf26c28f EXA: Fix migration avoidance for 1x1 pixmaps.
Signed-off-by: Michel Dänzer <daenzer@vmware.com>
Acked-by: Maarten Maathuis <madman2003@gmail.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2009-12-29 11:04:40 -08:00
Michel Dänzer
df2635d464 EXA/mixed: Don't consider devKind for detecting dimension change.
Fixes http://bugs.freedesktop.org/show_bug.cgi?id=25536 .

There should be no reason for the pitch to actually change when none of the
other dimensions do, and this could lead to incorrectly freeing the system
memory copy when allocating a GPU copy, resulting in loss of valid pixmap
contents.

Signed-off-by: Michel Dänzer <daenzer@vmware.com>
Acked-by: Maarten Maathuis <madman2003@gmail.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2009-12-10 09:11:14 -08:00
Michel Dänzer
955b9f23a3 EXA: ModifyPixmapHeader_mixed fixes.
* Better detection of dimension changes.
* Make sure to re-create the system memory copy when the pixmap dimensions
  change (e.g. the screen pixmap on screen resize).
* Clear the valid regions.

Signed-off-by: Michel Dänzer <daenzer@vmware.com>
Acked-by: Maarten Maathuis <madman2003@gmail.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2009-12-08 13:06:42 -08:00
Maarten Maathuis
a54c23fe64 exa: s/PixmapIsOffscreen/PixmapHasGpuCopy and s/pExaPixmap->offscreen/pExaPixmap->use_gpu_copy
- Fixup some variable names as well.

Signed-off-by: Maarten Maathuis <madman2003@gmail.com>
Acked-by: Michel Dänzer <michel@daenzer.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2009-11-28 12:44:58 -08:00
Maarten Maathuis
342f3689d1 exa: handle pixmap create/destroy in lower layers
- Pixmaps that are created during a fallback are automatically prepared access.
- During the fallback accelerated ops are blocked to prevent new/scratch gc's
  from triggering accelerated ops on mapped pixmaps.
- A few cases of incorrect wrapping (on the top level pointer instead of
  between damage and (w)fb) have been removed.

Signed-off-by: Maarten Maathuis <madman2003@gmail.com>
Acked-by: Michel Dänzer <michel@daenzer.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2009-11-28 12:44:21 -08:00
Maarten Maathuis
412c56ef33 exa: remove some outdated comment
- This comment is still in exa_driver.c and there it makes sense.

Signed-off-by: Maarten Maathuis <madman2003@gmail.com>
Acked-by: Michel Dänzer <michel@daenzer.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2009-11-02 08:11:27 -08:00
Michel Dänzer
0369eeeb6b EXA: Try to minimize UploadToScreen calls for mixed pixmaps.
If there are several software fallbacks affecting the system memory copy of the
same pixmap, only copy the results back to the driver pixmap when it's used for
acceleration again, or in the BlockHandler, whichever happens first.
2009-09-26 02:04:48 +02:00
Michel Dänzer
1818cbd70f EXA: Extend mixed pixmaps scheme to allow driver PrepareAccess hook to fail.
If the PrepareAccess hook fails, use the DownloadFromScreen hook to retrieve
driver pixmap contents to a system RAM copy, perform software rendering on that
and copy the results back using the UploadToScreen hook. Use the classic
migration logic to minimize transfers (which as a bonus allows slightly
cleaning up some of the existing mixed pixmap code).

This enables things that weren't possible before with driver-allocated pixmap
storage: If some (or all) GPU pixmap storage can't be mapped directly by the
CPU, this can be handled between the PrepareAccess and
DownloadFrom/UploadToScreen hooks, e.g.:

* Radeon KMS on big endian machines can fail PrepareAccess if the pixmap
  requires byte-swapping and swap bytes in DownloadFrom/UploadToScreen.
* Environments where GPU and CPU don't have a shared address space at all.
  Here the driver PrepareAccess hook will always fail and leave all transfers
  between GPU / CPU storage to the Download/From/UploadToScreen hooks.

Drivers which can handle all pixmaps in the PrepareAccess hook should notice
little if any difference.
2009-09-26 01:59:39 +02:00
Michel Dänzer
096f21bb7a EXA: Fix some issues pointed out by clang.
Remove dead variables, fix use of uninitialized values, that kind of thing.
2009-09-23 08:24:06 +02:00
Michel Dänzer
8e873185f4 EXA: Preserve pPixmap->devPrivate.ptr in exaPixmapIsOffscreen_mixed.
Otherwise we may incorrectly clobber it to NULL on repeated PrepareAccess
calls.
2009-09-03 19:11:02 +02:00
Maarten Maathuis
d573cc46d3 exa: more safety 2009-08-08 11:38:51 +02:00
Maarten Maathuis
8b652435cd exa: minor cleanup 2009-08-08 11:38:51 +02:00
Maarten Maathuis
1548e8ae5d exa: fix a potential loophole in "mixed"
- Always free sys_ptr before setting the pixmap to pinned.
2009-08-07 20:38:14 +02:00
Maarten Maathuis
3047bd0674 exa: delay malloc for "mixed" 2009-08-06 23:48:14 +02:00
Maarten Maathuis
9d2a7128d3 exa: Use damage to optimise away useless copies. 2009-08-06 23:48:14 +02:00
Maarten Maathuis
03ecb164f2 exa: A simple 3rd backend implementation.
- Based on driver pixmaps with some changes (completely transparent to driver).
- It helps with the problem of known software fallbacks, such as trapezoids.
- exaDoMigration is now called for all cases that provide a do_migration hook.
- exa_migration.c is renamed to exa_migration_classic.c
2009-08-06 23:48:14 +02:00