Re: [xf86-video-ati] dri2: Enable BufferAge support
On 19.01.2015 20:00, Chris Wilson wrote: For BufferAge support, we just have to guarrantee that we were not using the DRI2Buffer-flags field for anything else (i.e. it is always 0) and then to make sure that we exchange the flags field after buffer exchanges. radeon does not support TripleBuffering so we do not have to worry about perserving the flags when injecting the third buffer. Signed-off-by: Chris Wilson ch...@chris-wilson.co.uk Cc: Dave Airlie airl...@redhat.com Cc: Jerome Glisse jgli...@redhat.com Cc: Alex Deucher alexander.deuc...@amd.com Cc: Michel Dänzer michel.daen...@amd.com Reviewed-by: Michel Dänzer michel.daen...@amd.com -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
Re: High CPU usage with radeon driver.
On 20.01.2015 10:46, Ken Moffat wrote: Anyway, I'd rather have a lower power usage, or more CPU devoted to what I want to run, but it would be _nice_ to have the correct driver using less CPU ;) Any suggestions, please ? Depending on what you're doing, using glamor instead of EXA might make a difference. Other than that, it's hard to say much without seeing profiles from sysprof / perf / oprofile corresponding to specific activities. -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
Re: High CPU usage with radeon driver.
On 21.01.2015 08:49, Ken Moffat wrote: Now, I've tried Glamor - on the plus side, no 'red' in icewm's CPU window. But on the negative, Xorg.bin CPU% remained at around 52% - not the initial high value, but not dropping down later, CPU frequencies remained quite high / full power, and alt-tabbing between windows, or autorepeat on e.g. cursor when typing, was very slow. What version of xserver and glamor are you using? -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
Re: Radeon HD 6530D crashing Xorg with a CentOS 6.6 kernel
On 06.01.2015 12:03, Darby Vicker wrote: On Sat, Jan 3, 2015 at 11:10 PM, Darby Vicker darby.vic...@gmail.com wrote: On Wed, Dec 24, 2014 at 7:58 PM, Michel Dänzer mic...@daenzer.net wrote: On 24.12.2014 22:26, Darby Vicker wrote: On Wed, Dec 24, 2014 at 12:50 AM, Michel Dänzer mic...@daenzer.net wrote: On 24.12.2014 14:18, Darby Vicker wrote: On Tue, Dec 23, 2014 at 9:02 PM, Michel Dänzer mic...@daenzer.net wrote: On 23.12.2014 14:11, Darby Vicker wrote: Hello, Sorry for the cross post but I figure this is a better place to get help. With the Xorg ABI update in CentOS/RHEL 6.6 [1] I can't get X to come up properly. More info in this thread on the CentOS list: http://lists.centos.org/pipermail/centos/2014-December/148341.html To summarize: * Stock ATI drivers shipped with CentOS crash X with a 6.6 kernel * fglrx drivers also crash X with a 6.6 kernel[2] * a centos 6.6 livecd still exibits the problem (trying to rule out an issue with my specific installation) I have Xorg.0.log files for boots from the 4 combinations of boots from a CentOS 6.5 and 6.6 kernel and the stock and fglrx drivers. Nothing obvious stands out to me but I could definitely be missing something. What's the best way to send the logs - just inline? Please attach the *.stock log files. Sure - attached. I can't see any graphics driver related problem in Xorg.0.log.centos6.6.stock.gz; the X server seems to start up and shut down cleanly. Why do you think the graphics drivers crash? Maybe the problem is on the client side, e.g. related to gdm or the login manager you're using. I should be more specific about the problem. The problem occurs at the point where the boot splash screen transitions to when (I assume) X starts and the login screen comes up. When I boot the CentOS 6.6 kernel, the screen just goes black and shortly after that the monitor goes to sleep with a No signal message. The virtual terminals (e.g. cntl-alt-F2) don't work at that point either. I was assuming that since the Xorg ABI has changed between the CentOS 6.5 and 6.6 release, it was very likely that the problem was related to Xorg. If there was a Xorg ABI issue, you could see in the Xorg log file that the driver fails to load. Do you have any suggestions for isolating the problem? I'm not sure what else to try. I did also try a boot to single user mode with the 6.6 kernel and then did a startx. My thought was to try to start X with minimal other services started to see if something else was interfering with X. But the same thing happens - the screen goes blank and the monitor goes to sleep. Any other suggestions are welcomed. If you boot the 6.5 kernel, does it still work with the same userspace that shows the problem with the 6.6 kernel? If so, it sounds like there's just some regression in the 6.6 kernel. Maybe there's something in dmesg, or maybe you can try isolating the change between the 6.5 and 6.6 kernels which caused the regression. [...] Do you know if there is a way to bypass gdm to see if that is the problem? For example, is there an alternative to GDM or some way to try to start the X-session directly? You can log into console and start X via startx or xinit. However, it sounds like a kernel change at least triggers the problem. You should probably get in touch with the people maintaining the CentOS kernel, they should be able to help you isolate which change that is. -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 07/14] DRI2: Use helper functions for DRM event queue management v3
From: Michel Dänzer michel.daen...@amd.com This is mostly in preparation for Present support, but it also simplifies the DRI2 specific code a little. v2: Fix up for struct radeon_drm_queue - radeon_drm_queue_entry. v3: Removed excess 0s from conversion from microseconds to seconds, thanks to Richard Wilbur richard.wil...@gmail.com for the catch! Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 86 ++-- src/drmmode_display.h | 12 ++- src/radeon_dri2.c | 267 +++--- src/radeon_dri2.h | 37 --- 4 files changed, 166 insertions(+), 236 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index cebd206..5ea2344 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -1799,45 +1799,52 @@ static const xf86CrtcConfigFuncsRec drmmode_xf86crtc_config_funcs = { }; static void -drmmode_vblank_handler(int fd, unsigned int frame, unsigned int tv_sec, - unsigned int tv_usec, void *event_data) +drmmode_flip_free(drmmode_flipevtcarrier_ptr flipcarrier) { - radeon_dri2_frame_event_handler(frame, tv_sec, tv_usec, event_data); + drmmode_flipdata_ptr flipdata = flipcarrier-flipdata; + + free(flipcarrier); + + if (--flipdata-flip_count 0) + return; + + /* Release framebuffer */ + drmModeRmFB(flipdata-drmmode-fd, flipdata-old_fb_id); + + free(flipdata); } static void -drmmode_flip_handler(int fd, unsigned int frame, unsigned int tv_sec, -unsigned int tv_usec, void *event_data) +drmmode_flip_abort(ScrnInfoPtr scrn, void *event_data) +{ + drmmode_flipevtcarrier_ptr flipcarrier = event_data; + drmmode_flipdata_ptr flipdata = flipcarrier-flipdata; + + if (flipdata-flip_count == 1) + flipcarrier-abort(scrn, flipdata-event_data); + + drmmode_flip_free(flipcarrier); +} + +static void +drmmode_flip_handler(ScrnInfoPtr scrn, uint32_t frame, uint64_t usec, void *event_data) { drmmode_flipevtcarrier_ptr flipcarrier = event_data; drmmode_flipdata_ptr flipdata = flipcarrier-flipdata; - drmmode_ptr drmmode = flipdata-drmmode; /* Is this the event whose info shall be delivered to higher level? */ if (flipcarrier-dispatch_me) { /* Yes: Cache msc, ust for later delivery. */ flipdata-fe_frame = frame; - flipdata-fe_tv_sec = tv_sec; - flipdata-fe_tv_usec = tv_usec; + flipdata-fe_usec = usec; } - free(flipcarrier); - - /* Last crtc completed flip? */ - flipdata-flip_count--; - if (flipdata-flip_count 0) - return; - - /* Release framebuffer */ - drmModeRmFB(drmmode-fd, flipdata-old_fb_id); - - if (flipdata-event_data == NULL) - return; /* Deliver cached msc, ust from reference crtc to flip event handler */ - radeon_dri2_flip_event_handler(flipdata-fe_frame, flipdata-fe_tv_sec, - flipdata-fe_tv_usec, flipdata-event_data); + if (flipdata-event_data flipdata-flip_count == 1) + flipcarrier-handler(scrn, flipdata-fe_frame, flipdata-fe_usec, +flipdata-event_data); - free(flipdata); + drmmode_flip_free(flipcarrier); } @@ -1884,8 +1891,8 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp) xf86InitialConfiguration(pScrn, TRUE); drmmode-event_context.version = DRM_EVENT_CONTEXT_VERSION; - drmmode-event_context.vblank_handler = drmmode_vblank_handler; - drmmode-event_context.page_flip_handler = drmmode_flip_handler; + drmmode-event_context.vblank_handler = radeon_drm_queue_handler; + drmmode-event_context.page_flip_handler = radeon_drm_queue_handler; drmModeFreeResources(mode_res); return TRUE; @@ -2229,7 +2236,10 @@ void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode) #endif } -Bool radeon_do_pageflip(ScrnInfoPtr scrn, struct radeon_bo *new_front, void *data, int ref_crtc_hw_id) +Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, + struct radeon_bo *new_front, uint64_t id, void *data, + int ref_crtc_hw_id, radeon_drm_handler_proc handler, + radeon_drm_abort_proc abort) { RADEONInfoPtr info = RADEONPTR(scrn); xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); @@ -2240,7 +2250,8 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, struct radeon_bo *new_front, void *dat uint32_t tiling_flags = 0; int height, emitted = 0; drmmode_flipdata_ptr flipdata; - drmmode_flipevtcarrier_ptr flipcarrier; + drmmode_flipevtcarrier_ptr flipcarrier = NULL; + struct radeon_drm_queue_entry *drm_queue = 0; if (info-allowColorTiling
Re: [PATCH 07/14] DRI2: Use helper functions for DRM event queue management
On 17.03.2015 00:38, Richard Wilbur wrote: On Thu, Mar 12, 2015 at 12:10 AM, Michel Dänzer mic...@daenzer.net wrote: [...] diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c index a3f0776..97164b6 100644 --- a/src/radeon_dri2.c +++ b/src/radeon_dri2.c [...] @@ -613,36 +553,41 @@ xf86CrtcPtr radeon_dri2_drawable_crtc(DrawablePtr pDraw, Bool consider_disabled) return NULL; } -void radeon_dri2_flip_event_handler(unsigned int frame, unsigned int tv_sec, - unsigned int tv_usec, void *event_data) +static void +radeon_dri2_flip_event_abort(ScrnInfoPtr scrn, void *event_data) +{ +free(event_data); +} + +static void +radeon_dri2_flip_event_handler(ScrnInfoPtr scrn, uint32_t frame, uint64_t usec, + void *event_data) { DRI2FrameEventPtr flip = event_data; +unsigned tv_sec, tv_usec; DrawablePtr drawable; ScreenPtr screen; -ScrnInfoPtr scrn; int status; PixmapPtr pixmap; status = dixLookupDrawable(drawable, flip-drawable_id, serverClient, M_ANY, DixWriteAccess); -if (status != Success) { - free(flip); - return; -} -if (!flip-crtc) { - free(flip); - return; -} -frame += radeon_get_interpolated_vblanks(flip-crtc); +if (status != Success) + goto abort; -screen = drawable-pScreen; -scrn = xf86ScreenToScrn(screen); +if (!flip-crtc) + goto abort; +frame += radeon_get_interpolated_vblanks(flip-crtc); +screen = scrn-pScreen; pixmap = screen-GetScreenPixmap(screen); xf86DrvMsgVerb(scrn-scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG, %s:%d fevent[%p] width %d pitch %d (/4 %d)\n, __func__, __LINE__, flip, pixmap-drawable.width, pixmap-devKind, pixmap-devKind/4); +tv_sec = usec / 1000; +tv_usec = usec % 1000; Looks like an extra '0' crept into these calculations. Here we are dividing by 10^7 while everywhere else in this patch we use 10^6. Indeed, thanks for the catch! Fixed in v3. -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 3/3] glamor: Avoid generating GEM flink names for BOs shared via DRI3
From: Michel Dänzer michel.daen...@amd.com We can't create our own struct radeon_bo representation in this case because destroying that would make the GEM handle inaccessible to glamor as well. So just get the handle directly via dma-buf. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/radeon.h | 4 src/radeon_dri3.c| 10 ++ src/radeon_glamor.h | 1 + src/radeon_present.c | 34 ++ 4 files changed, 49 insertions(+) diff --git a/src/radeon.h b/src/radeon.h index 6084cfe..6a60bd3 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -252,6 +252,10 @@ struct radeon_pixmap { uint32_t tiling_flags; int stride; + + /* GEM handle for glamor-only pixmaps shared via DRI3 */ + Bool handle_valid; + uint32_t handle; }; #if HAS_DEVPRIVATEKEYREC diff --git a/src/radeon_dri3.c b/src/radeon_dri3.c index 993c7a7..3a7322e 100644 --- a/src/radeon_dri3.c +++ b/src/radeon_dri3.c @@ -96,6 +96,16 @@ static PixmapPtr radeon_dri3_pixmap_from_fd(ScreenPtr screen, { PixmapPtr pixmap; +#ifdef USE_GLAMOR + /* Avoid generating a GEM flink name if possible */ + if (RADEONPTR(xf86ScreenToScrn(screen))-use_glamor) { + pixmap = glamor_pixmap_from_fd(screen, fd, width, height, + stride, depth, bpp); + if (pixmap) + return pixmap; + } +#endif + if (depth 8) return NULL; diff --git a/src/radeon_glamor.h b/src/radeon_glamor.h index f450f0e..7cef1a9 100644 --- a/src/radeon_glamor.h +++ b/src/radeon_glamor.h @@ -37,6 +37,7 @@ #ifndef GLAMOR_NO_DRI3 #define glamor_fd_from_pixmap glamor_dri3_fd_from_pixmap +#define glamor_pixmap_from_fd glamor_egl_dri3_pixmap_from_fd #endif Bool radeon_glamor_pre_init(ScrnInfoPtr scrn); diff --git a/src/radeon_present.c b/src/radeon_present.c index 85f1bfc..6782513 100644 --- a/src/radeon_present.c +++ b/src/radeon_present.c @@ -42,6 +42,7 @@ #include time.h #include errno.h +#include radeon_glamor.h #include radeon_video.h #include present.h @@ -220,12 +221,45 @@ static Bool radeon_present_get_pixmap_handle(PixmapPtr pixmap, uint32_t *handle) { struct radeon_bo *bo = radeon_get_pixmap_bo(pixmap); +#ifdef USE_GLAMOR +ScreenPtr screen = pixmap-drawable.pScreen; +RADEONInfoPtr info = RADEONPTR(xf86ScreenToScrn(screen)); +#endif if (bo) { *handle = bo-handle; return TRUE; } +#ifdef USE_GLAMOR +if (info-use_glamor) { + struct radeon_pixmap *priv = radeon_get_pixmap_private(pixmap); + CARD16 stride; + CARD32 size; + int fd; + + if (!priv) { + priv = calloc(1, sizeof(*priv)); + radeon_set_pixmap_private(pixmap, priv); + } + + if (priv-handle_valid) { + *handle = priv-handle; + return TRUE; + } + + fd = glamor_fd_from_pixmap(screen, pixmap, stride, size); + if (fd 0) + return FALSE; + + if (drmPrimeFDToHandle(info-dri2.drm_fd, fd, priv-handle) == 0) { + priv-handle_valid = TRUE; + *handle = priv-handle; + return TRUE; + } +} +#endif + return FALSE; } -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 2/3] Present: Add radeon_present_get_pixmap_handle helper
From: Michel Dänzer michel.daen...@amd.com Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/radeon_present.c | 27 +++ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/radeon_present.c b/src/radeon_present.c index 9d774ab..85f1bfc 100644 --- a/src/radeon_present.c +++ b/src/radeon_present.c @@ -216,6 +216,19 @@ get_drmmode_crtc(ScrnInfoPtr scrn, RRCrtcPtr crtc) return NULL; } +static Bool +radeon_present_get_pixmap_handle(PixmapPtr pixmap, uint32_t *handle) +{ +struct radeon_bo *bo = radeon_get_pixmap_bo(pixmap); + +if (bo) { + *handle = bo-handle; + return TRUE; +} + +return FALSE; +} + /* * Test to see if page flipping is possible on the target crtc */ @@ -282,7 +295,7 @@ radeon_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc, struct radeon_present_vblank_event *event; drmmode_crtc_private_ptr drmmode_crtc = get_drmmode_crtc(scrn, crtc); int crtc_id = drmmode_crtc-mode_crtc-crtc_id; -struct radeon_bo *bo; +uint32_t handle; Bool ret; if (!sync_flip) @@ -291,8 +304,7 @@ radeon_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc, if (!radeon_present_check_flip(crtc, screen-root, pixmap, sync_flip)) return FALSE; -bo = radeon_get_pixmap_bo(pixmap); -if (!bo) +if (!radeon_present_get_pixmap_handle(pixmap, handle)) return FALSE; event = calloc(1, sizeof(struct radeon_present_vblank_event)); @@ -301,7 +313,7 @@ radeon_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc, event-event_id = event_id; -ret = radeon_do_pageflip(scrn, RADEON_DRM_QUEUE_CLIENT_DEFAULT, bo-handle, +ret = radeon_do_pageflip(scrn, RADEON_DRM_QUEUE_CLIENT_DEFAULT, handle, event_id, event, crtc_id, radeon_present_flip_event, radeon_present_flip_abort); @@ -320,14 +332,13 @@ radeon_present_unflip(ScreenPtr screen, uint64_t event_id) ScrnInfoPtr scrn = xf86ScreenToScrn(screen); struct radeon_present_vblank_event *event; PixmapPtr pixmap = screen-GetScreenPixmap(screen); -struct radeon_bo *bo; +uint32_t handle; Bool ret; if (!radeon_present_check_flip(NULL, screen-root, pixmap, TRUE)) return; -bo = radeon_get_pixmap_bo(pixmap); -if (!bo) +if (!radeon_present_get_pixmap_handle(pixmap, handle)) return; event = calloc(1, sizeof(struct radeon_present_vblank_event)); @@ -336,7 +347,7 @@ radeon_present_unflip(ScreenPtr screen, uint64_t event_id) event-event_id = event_id; -ret = radeon_do_pageflip(scrn, RADEON_DRM_QUEUE_CLIENT_DEFAULT, bo-handle, +ret = radeon_do_pageflip(scrn, RADEON_DRM_QUEUE_CLIENT_DEFAULT, handle, event_id, event, -1, radeon_present_flip_event, radeon_present_flip_abort); if (!ret) -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 1/3] Make radeon_do_pageflip take a BO handle directly
From: Michel Dänzer michel.daen...@amd.com Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 4 ++-- src/drmmode_display.h | 2 +- src/radeon_dri2.c | 5 +++-- src/radeon_present.c | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 86bc446..f719f0c 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -2265,7 +2265,7 @@ void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode) } Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, - struct radeon_bo *new_front, uint64_t id, void *data, + uint32_t new_front_handle, uint64_t id, void *data, int ref_crtc_hw_id, radeon_drm_handler_proc handler, radeon_drm_abort_proc abort) { @@ -2301,7 +2301,7 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, old_fb_id = drmmode-fb_id; if (drmModeAddFB(drmmode-fd, scrn-virtualX, height, scrn-depth, scrn-bitsPerPixel, pitch, -new_front-handle, drmmode-fb_id)) +new_front_handle, drmmode-fb_id)) goto error_out; flipdata = calloc(1, sizeof(drmmode_flipdata_rec)); diff --git a/src/drmmode_display.h b/src/drmmode_display.h index 6f883c0..b3804ba 100644 --- a/src/drmmode_display.h +++ b/src/drmmode_display.h @@ -129,7 +129,7 @@ extern int drmmode_get_pitch_align(ScrnInfoPtr scrn, int bpe, uint32_t tiling); extern int drmmode_get_base_align(ScrnInfoPtr scrn, int bpe, uint32_t tiling); Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, - struct radeon_bo *new_front, uint64_t id, void *data, + uint32_t new_front_handle, uint64_t id, void *data, int ref_crtc_hw_id, radeon_drm_handler_proc handler, radeon_drm_abort_proc abort); int drmmode_crtc_get_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc); diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c index 02e8e8f..2636456 100644 --- a/src/radeon_dri2.c +++ b/src/radeon_dri2.c @@ -647,8 +647,9 @@ radeon_dri2_schedule_flip(ScrnInfoPtr scrn, ClientPtr client, back_priv = back-driverPrivate; bo = radeon_get_pixmap_bo(back_priv-pixmap); -return radeon_do_pageflip(scrn, client, bo, RADEON_DRM_QUEUE_ID_DEFAULT, - flip_info, ref_crtc_hw_id, +return radeon_do_pageflip(scrn, client, bo-handle, + RADEON_DRM_QUEUE_ID_DEFAULT, flip_info, + ref_crtc_hw_id, radeon_dri2_flip_event_handler, radeon_dri2_flip_event_abort); } diff --git a/src/radeon_present.c b/src/radeon_present.c index 0aa96cf..9d774ab 100644 --- a/src/radeon_present.c +++ b/src/radeon_present.c @@ -301,7 +301,7 @@ radeon_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc, event-event_id = event_id; -ret = radeon_do_pageflip(scrn, RADEON_DRM_QUEUE_CLIENT_DEFAULT, bo, +ret = radeon_do_pageflip(scrn, RADEON_DRM_QUEUE_CLIENT_DEFAULT, bo-handle, event_id, event, crtc_id, radeon_present_flip_event, radeon_present_flip_abort); @@ -336,7 +336,7 @@ radeon_present_unflip(ScreenPtr screen, uint64_t event_id) event-event_id = event_id; -ret = radeon_do_pageflip(scrn, RADEON_DRM_QUEUE_CLIENT_DEFAULT, bo, +ret = radeon_do_pageflip(scrn, RADEON_DRM_QUEUE_CLIENT_DEFAULT, bo-handle, event_id, event, -1, radeon_present_flip_event, radeon_present_flip_abort); if (!ret) -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 3/3] glamor: Avoid generating GEM flink names for BOs shared via DRI3 v2
From: Michel Dänzer michel.daen...@amd.com We can't create our own struct radeon_bo representation in this case because destroying that would make the GEM handle inaccessible to glamor as well. So just get the handle directly via dma-buf. v2: Close dma-buf file descriptor, pointed out by Axel Davy. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/radeon.h | 4 src/radeon_dri3.c| 10 ++ src/radeon_glamor.h | 1 + src/radeon_present.c | 34 ++ 4 files changed, 49 insertions(+) diff --git a/src/radeon.h b/src/radeon.h index 6084cfe..6a60bd3 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -252,6 +252,10 @@ struct radeon_pixmap { uint32_t tiling_flags; int stride; + + /* GEM handle for glamor-only pixmaps shared via DRI3 */ + Bool handle_valid; + uint32_t handle; }; #if HAS_DEVPRIVATEKEYREC diff --git a/src/radeon_dri3.c b/src/radeon_dri3.c index 993c7a7..3a7322e 100644 --- a/src/radeon_dri3.c +++ b/src/radeon_dri3.c @@ -96,6 +96,16 @@ static PixmapPtr radeon_dri3_pixmap_from_fd(ScreenPtr screen, { PixmapPtr pixmap; +#ifdef USE_GLAMOR + /* Avoid generating a GEM flink name if possible */ + if (RADEONPTR(xf86ScreenToScrn(screen))-use_glamor) { + pixmap = glamor_pixmap_from_fd(screen, fd, width, height, + stride, depth, bpp); + if (pixmap) + return pixmap; + } +#endif + if (depth 8) return NULL; diff --git a/src/radeon_glamor.h b/src/radeon_glamor.h index f450f0e..7cef1a9 100644 --- a/src/radeon_glamor.h +++ b/src/radeon_glamor.h @@ -37,6 +37,7 @@ #ifndef GLAMOR_NO_DRI3 #define glamor_fd_from_pixmap glamor_dri3_fd_from_pixmap +#define glamor_pixmap_from_fd glamor_egl_dri3_pixmap_from_fd #endif Bool radeon_glamor_pre_init(ScrnInfoPtr scrn); diff --git a/src/radeon_present.c b/src/radeon_present.c index 85f1bfc..6782513 100644 --- a/src/radeon_present.c +++ b/src/radeon_present.c @@ -42,6 +42,7 @@ #include time.h #include errno.h +#include radeon_glamor.h #include radeon_video.h #include present.h @@ -220,12 +221,45 @@ static Bool radeon_present_get_pixmap_handle(PixmapPtr pixmap, uint32_t *handle) { struct radeon_bo *bo = radeon_get_pixmap_bo(pixmap); +#ifdef USE_GLAMOR +ScreenPtr screen = pixmap-drawable.pScreen; +RADEONInfoPtr info = RADEONPTR(xf86ScreenToScrn(screen)); +#endif if (bo) { *handle = bo-handle; return TRUE; } +#ifdef USE_GLAMOR +if (info-use_glamor) { + struct radeon_pixmap *priv = radeon_get_pixmap_private(pixmap); + CARD16 stride; + CARD32 size; + int fd; + + if (!priv) { + priv = calloc(1, sizeof(*priv)); + radeon_set_pixmap_private(pixmap, priv); + } + + if (priv-handle_valid) { + *handle = priv-handle; + return TRUE; + } + + fd = glamor_fd_from_pixmap(screen, pixmap, stride, size); + if (fd 0) + return FALSE; + + if (drmPrimeFDToHandle(info-dri2.drm_fd, fd, priv-handle) == 0) { + priv-handle_valid = TRUE; + *handle = priv-handle; + return TRUE; + } +} +#endif + return FALSE; } -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 3/3] glamor: Avoid generating GEM flink names for BOs shared via DRI3 v2
From: Michel Dänzer michel.daen...@amd.com We can't create our own struct radeon_bo representation in this case because destroying that would make the GEM handle inaccessible to glamor as well. So just get the handle directly via dma-buf. v2: Close dma-buf file descriptor, pointed out by Axel Davy. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/radeon.h | 4 src/radeon_dri3.c| 10 ++ src/radeon_glamor.h | 1 + src/radeon_present.c | 36 4 files changed, 51 insertions(+) diff --git a/src/radeon.h b/src/radeon.h index 6084cfe..6a60bd3 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -252,6 +252,10 @@ struct radeon_pixmap { uint32_t tiling_flags; int stride; + + /* GEM handle for glamor-only pixmaps shared via DRI3 */ + Bool handle_valid; + uint32_t handle; }; #if HAS_DEVPRIVATEKEYREC diff --git a/src/radeon_dri3.c b/src/radeon_dri3.c index 993c7a7..3a7322e 100644 --- a/src/radeon_dri3.c +++ b/src/radeon_dri3.c @@ -96,6 +96,16 @@ static PixmapPtr radeon_dri3_pixmap_from_fd(ScreenPtr screen, { PixmapPtr pixmap; +#ifdef USE_GLAMOR + /* Avoid generating a GEM flink name if possible */ + if (RADEONPTR(xf86ScreenToScrn(screen))-use_glamor) { + pixmap = glamor_pixmap_from_fd(screen, fd, width, height, + stride, depth, bpp); + if (pixmap) + return pixmap; + } +#endif + if (depth 8) return NULL; diff --git a/src/radeon_glamor.h b/src/radeon_glamor.h index f450f0e..7cef1a9 100644 --- a/src/radeon_glamor.h +++ b/src/radeon_glamor.h @@ -37,6 +37,7 @@ #ifndef GLAMOR_NO_DRI3 #define glamor_fd_from_pixmap glamor_dri3_fd_from_pixmap +#define glamor_pixmap_from_fd glamor_egl_dri3_pixmap_from_fd #endif Bool radeon_glamor_pre_init(ScrnInfoPtr scrn); diff --git a/src/radeon_present.c b/src/radeon_present.c index 85f1bfc..711b45d 100644 --- a/src/radeon_present.c +++ b/src/radeon_present.c @@ -42,6 +42,7 @@ #include time.h #include errno.h +#include radeon_glamor.h #include radeon_video.h #include present.h @@ -220,12 +221,47 @@ static Bool radeon_present_get_pixmap_handle(PixmapPtr pixmap, uint32_t *handle) { struct radeon_bo *bo = radeon_get_pixmap_bo(pixmap); +#ifdef USE_GLAMOR +ScreenPtr screen = pixmap-drawable.pScreen; +RADEONInfoPtr info = RADEONPTR(xf86ScreenToScrn(screen)); +#endif if (bo) { *handle = bo-handle; return TRUE; } +#ifdef USE_GLAMOR +if (info-use_glamor) { + struct radeon_pixmap *priv = radeon_get_pixmap_private(pixmap); + CARD16 stride; + CARD32 size; + int fd, r; + + if (!priv) { + priv = calloc(1, sizeof(*priv)); + radeon_set_pixmap_private(pixmap, priv); + } + + if (priv-handle_valid) { + *handle = priv-handle; + return TRUE; + } + + fd = glamor_fd_from_pixmap(screen, pixmap, stride, size); + if (fd 0) + return FALSE; + + r = drmPrimeFDToHandle(info-dri2.drm_fd, fd, priv-handle); + close(fd); + if (r == 0) { + priv-handle_valid = TRUE; + *handle = priv-handle; + return TRUE; + } +} +#endif + return FALSE; } -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 14/14] Add DRI3 support v2
From: Michel Dänzer michel.daen...@amd.com Must be enabled with Option DRI3 in xorg.conf. v2: Adapt to v2 of patches 11/12. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- configure.ac | 4 ++ man/radeon.man| 4 ++ src/Makefile.am | 5 +- src/radeon.h | 4 ++ src/radeon_dri3.c | 201 ++ src/radeon_kms.c | 21 +- 6 files changed, 236 insertions(+), 3 deletions(-) create mode 100644 src/radeon_dri3.c diff --git a/configure.ac b/configure.ac index 71d8ff0..acd9fe0 100644 --- a/configure.ac +++ b/configure.ac @@ -143,6 +143,10 @@ AC_CHECK_HEADERS([present.h], [], [], #include X11/X.h #include xorg-server.h]) +AC_CHECK_HEADERS([dri3.h], [], [], +[#include X11/Xmd.h +#include xorg-server.h]) + CPPFLAGS=$SAVE_CPPFLAGS PKG_CHECK_MODULES([PCIACCESS], [pciaccess = 0.8.0]) diff --git a/man/radeon.man b/man/radeon.man index 7dde040..6e46f89 100644 --- a/man/radeon.man +++ b/man/radeon.man @@ -267,6 +267,10 @@ The default value is for R/RV6XX, R/RV7XX, RS780, RS880, EVERGREEN, CAYMAN, ARUBA, Southern Islands, and Sea Islands. .TP +.BI Option \*qDRI3\*q \*q boolean \*q +Enable the DRI3 extension. The default is +.B off. +.TP .BI Option \*qEnablePageFlip\*q \*q boolean \*q Enable DRI2 page flipping. The default is .B on. diff --git a/src/Makefile.am b/src/Makefile.am index a3d732a..697c08c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,8 +29,9 @@ ati_drv_la_LIBADD = $(PCIACCESS_LIBS) radeon_drv_la_LIBADD = $(LIBDRM_RADEON_LIBS) $(PCIACCESS_LIBS) -RADEON_KMS_SRCS=radeon_dri2.c radeon_drm_queue.c radeon_kms.c radeon_present.c \ - radeon_sync.c radeon_vbo.c radeon_bo_helper.c drmmode_display.c +RADEON_KMS_SRCS=radeon_dri2.c radeon_dri3.c radeon_drm_queue.c radeon_kms.c \ + radeon_present.c radeon_sync.c radeon_vbo.c radeon_bo_helper.c \ + drmmode_display.c RADEON_EXA_SOURCES = radeon_exa.c r600_exa.c r6xx_accel.c r600_textured_videofuncs.c r600_shader.c radeon_exa_shared.c \ evergreen_exa.c evergreen_accel.c evergreen_shader.c evergreen_textured_videofuncs.c cayman_accel.c cayman_shader.c diff --git a/src/radeon.h b/src/radeon.h index 9346fbd..6084cfe 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -150,6 +150,7 @@ typedef enum { OPTION_ZAPHOD_HEADS, OPTION_SWAPBUFFERS_WAIT, OPTION_DELETE_DP12, +OPTION_DRI3, } RADEONOpts; @@ -549,6 +550,9 @@ extern Bool RADEONGetDatatypeBpp(int bpp, uint32_t *type); extern Bool RADEONGetPixmapOffsetPitch(PixmapPtr pPix, uint32_t *pitch_offset); +/* radeon_dri3.c */ +Bool radeon_dri3_screen_init(ScreenPtr screen); + /* radeon_present.c */ Bool radeon_present_screen_init(ScreenPtr screen); diff --git a/src/radeon_dri3.c b/src/radeon_dri3.c new file mode 100644 index 000..83bffae --- /dev/null +++ b/src/radeon_dri3.c @@ -0,0 +1,201 @@ +/* + * Copyright © 2013-2014 Intel Corporation + * Copyright © 2015 Advanced Micro Devices, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided as + * is without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + + +#ifdef HAVE_CONFIG_H +#include config.h +#endif + +#include xorg-server.h +#include xf86.h +#include fb.h + +#ifdef HAVE_DRI3_H + +#include radeon.h +#include radeon_bo_gem.h +#include radeon_glamor.h +#include dri3.h + +#include sys/types.h +#include sys/stat.h +#include fcntl.h +#include errno.h + + +static int +radeon_dri3_open_client(ClientPtr client, + ScreenPtr screen, + RRProviderPtr provider, + int *out) +{ + ScrnInfoPtr scrn = xf86ScreenToScrn(screen); + RADEONInfoPtr info = RADEONPTR(scrn); + drm_magic_t magic; + int fd; + + fd = open(info-dri2.device_name, O_RDWR | O_CLOEXEC); + if (fd 0
Re: [PATCH 03/14] Add DRM event queue helpers
On 12.03.2015 15:55, Richard Wilbur wrote: On Thu, Mar 12, 2015 at 12:10 AM, Michel Dänzer mic...@daenzer.net wrote: diff --git a/src/radeon_drm_queue.c b/src/radeon_drm_queue.c new file mode 100644 index 000..7b7fd06 --- /dev/null +++ b/src/radeon_drm_queue.c [...] +struct radeon_drm_queue { +struct xorg_list list; +uint64_t id; +void *data; +ClientPtr client; +ScrnInfoPtr scrn; +radeon_drm_handler_proc handler; +radeon_drm_abort_proc abort; +}; + +static int radeon_drm_queue_refcnt; +static struct xorg_list radeon_drm_queue; Seems this would be clearer if the type 'struct radeon_drm_queue' wasn't the same name as a subsequent variable in the same scope. Maybe change the type name to something like 'struct radeon_drm_queue_entry'? Good suggestion, thanks! Changed for v2. -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
Bug#738521: xserver-xorg-video-ati: Persistant system lockup with ATI Radeon X300 GPU running firmware-linux-nonfree
On 07.03.2015 21:36, Magnus Holmgren wrote: Monday 10 February 2014 00.22.05, Paul wrote: Running Debian Wheezy, by installing the package firmware-linux-nonfree which contains the firmware to enable 3D acceleration for the ATI card (Radeon X300), when the system starts and user logins, the system locks. 2. Symptoms The input devices are inoperative, the screen image is undistorted but unresponsive, the eth0 connection breaks (ssh is unavailable.) The REISUB keys are ineffective. The only recourse is to do a hard reset by holding the power button. Lockup occurs any where within seconds to within minutes of bootup. Lockup most often occurs when in the graphical desktop environment; rarely when in a virtual terminal (ALT F1-F6). I've experienced very similar symptoms on jessie ever since 3D acceleration via Glamor became possible with my Southern Island card (Bonaire XTX [Radeon R7 260X]) about six months ago, The symptoms may be similar, but it's very unlikely to be one and the same problem. Please file your own report. although not immediately after logging in but rather after several hours, and never when using the computer but when I leave it unattended. I *think* it's locked up once while switched to a text console, but otherwise only while the graphical console has been active. Whenever it happens, the system starts spewing out _something_ on the ethernet interface, making it impossible to connect to my server connected to the same switch/AP (the LEDs of both ports flash furiously), but I haven't been able to see anything with tcpdump. No clues can be found in any logs, except sometimes a few eth0: link up in the server syslog, and just one time the affected system managed to get off a message about a GPU fault via netconsole: Feb 8 01:49:59 johansson [108159.201208] radeon :01:00.0: GPU fault detected: 146 0x08075014 Feb 8 01:49:59 johansson [108159.201215] radeon :01:00.0: VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x0007B6C0 Feb 8 01:49:59 johansson [108159.201217] radeon :01:00.0: VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x07050014 Once, a couple of weeks ago, I came back to the computer and found it unresponsive; the screen had gone black but not into sleep mode and I could still ssh in. chvt would just hang and when I tried restarting X (kdm), the system stopped responding completely as before. So it seems that the system might not lock up completely right away, but that it's a two-step process. Which version of libgl1-mesa-dri and the kernel are you using? -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer signature.asc Description: OpenPGP digital signature ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 03/14] Add DRM event queue helpers v2
From: Michel Dänzer michel.daen...@amd.com v2: Rename struct radeon_drm_queue to struct radeon_drm_queue_event, thanks to Richard Wilbur richard.wil...@gmail.com for the suggestion. Also changed the corresponding parameter and local variable names from 'q' to 'e'. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/Makefile.am| 5 +- src/radeon_drm_queue.c | 181 + src/radeon_drm_queue.h | 56 +++ src/radeon_kms.c | 4 ++ 4 files changed, 244 insertions(+), 2 deletions(-) create mode 100644 src/radeon_drm_queue.c create mode 100644 src/radeon_drm_queue.h diff --git a/src/Makefile.am b/src/Makefile.am index 708f2ad..9cc8a2d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,8 +29,8 @@ ati_drv_la_LIBADD = $(PCIACCESS_LIBS) radeon_drv_la_LIBADD = $(LIBDRM_RADEON_LIBS) $(PCIACCESS_LIBS) -RADEON_KMS_SRCS=radeon_dri2.c radeon_kms.c drmmode_display.c radeon_vbo.c \ - radeon_bo_helper.c +RADEON_KMS_SRCS=radeon_dri2.c radeon_drm_queue.c radeon_kms.c drmmode_display.c \ + radeon_vbo.c radeon_bo_helper.c RADEON_EXA_SOURCES = radeon_exa.c r600_exa.c r6xx_accel.c r600_textured_videofuncs.c r600_shader.c radeon_exa_shared.c \ evergreen_exa.c evergreen_accel.c evergreen_shader.c evergreen_textured_videofuncs.c cayman_accel.c cayman_shader.c @@ -88,6 +88,7 @@ EXTRA_DIST = \ bicubic_table.h \ bicubic_table.py \ radeon_bo_helper.h \ + radeon_drm_queue.h \ radeon_exa_render.c \ radeon_exa_funcs.c \ radeon_exa_shared.h \ diff --git a/src/radeon_drm_queue.c b/src/radeon_drm_queue.c new file mode 100644 index 000..5e54ef8 --- /dev/null +++ b/src/radeon_drm_queue.c @@ -0,0 +1,181 @@ +/* + * Copyright © 2007 Red Hat, Inc. + * Copyright © 2015 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the Software), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Authors: + *Dave Airlie airl...@redhat.com + * + */ + +#ifdef HAVE_CONFIG_H +#include config.h +#endif + +#include xorg-server.h + +#include radeon.h +#include radeon_drm_queue.h +#include radeon_list.h + + +struct radeon_drm_queue_entry { +struct xorg_list list; +uint64_t id; +void *data; +ClientPtr client; +ScrnInfoPtr scrn; +radeon_drm_handler_proc handler; +radeon_drm_abort_proc abort; +}; + +static int radeon_drm_queue_refcnt; +static struct xorg_list radeon_drm_queue; + + +/* + * Handle a DRM event + */ +void +radeon_drm_queue_handler(int fd, unsigned int frame, unsigned int sec, +unsigned int usec, void *user_ptr) +{ + struct radeon_drm_queue_entry *user_data = user_ptr; + struct radeon_drm_queue_entry *e, *tmp; + + xorg_list_for_each_entry_safe(e, tmp, radeon_drm_queue, list) { + if (e == user_data) { + xorg_list_del(e-list); + e-handler(e-scrn, frame, + (uint64_t)sec * 100 + usec, e-data); + free(e); + break; + } + } +} + +/* + * Enqueue a potential drm response; when the associated response + * appears, we've got data to pass to the handler from here + */ +struct radeon_drm_queue_entry * +radeon_drm_queue_alloc(ScrnInfoPtr scrn, ClientPtr client, + uint64_t id, void *data, + radeon_drm_handler_proc handler, + radeon_drm_abort_proc abort) +{ +struct radeon_drm_queue_entry *e; + +e = calloc(1, sizeof(struct radeon_drm_queue_entry)); +if (!e) + return NULL; + +e-client = client; +e-scrn = scrn; +e-id = id; +e-data = data; +e-handler = handler; +e-abort = abort; + +xorg_list_add(e-list, radeon_drm_queue); + +return e; +} + +/* + * Abort one queued DRM entry, removing it + * from the list, calling the abort function
[PATCH 11/14] Add support for SYNC extension fences v2
From: Michel Dänzer michel.daen...@amd.com v2: Swapped order of patches 11 12 because the Present extension uses SYNC fences. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- configure.ac | 6 +++ src/Makefile.am | 4 +- src/radeon.h | 9 src/radeon_kms.c | 4 ++ src/radeon_sync.c | 144 ++ 5 files changed, 165 insertions(+), 2 deletions(-) create mode 100644 src/radeon_sync.c diff --git a/configure.ac b/configure.ac index 891da03..c2e5a20 100644 --- a/configure.ac +++ b/configure.ac @@ -131,6 +131,12 @@ AC_CHECK_DECL(xorg_list_init, #include xorg-server.h #include list.h]) +AC_CHECK_HEADERS([misyncshm.h], [], [], + [#include X11/Xdefs.h + #include X11/Xfuncproto.h + #include screenint.h + #include xorg-server.h]) + CPPFLAGS=$SAVE_CPPFLAGS PKG_CHECK_MODULES([PCIACCESS], [pciaccess = 0.8.0]) diff --git a/src/Makefile.am b/src/Makefile.am index 9cc8a2d..acb83f1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,8 +29,8 @@ ati_drv_la_LIBADD = $(PCIACCESS_LIBS) radeon_drv_la_LIBADD = $(LIBDRM_RADEON_LIBS) $(PCIACCESS_LIBS) -RADEON_KMS_SRCS=radeon_dri2.c radeon_drm_queue.c radeon_kms.c drmmode_display.c \ - radeon_vbo.c radeon_bo_helper.c +RADEON_KMS_SRCS=radeon_dri2.c radeon_drm_queue.c radeon_kms.c radeon_sync.c \ + radeon_vbo.c radeon_bo_helper.c drmmode_display.c RADEON_EXA_SOURCES = radeon_exa.c r600_exa.c r6xx_accel.c r600_textured_videofuncs.c r600_shader.c radeon_exa_shared.c \ evergreen_exa.c evergreen_accel.c evergreen_shader.c evergreen_textured_videofuncs.c cayman_accel.c cayman_shader.c diff --git a/src/radeon.h b/src/radeon.h index e503cbb..cc52bd9 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -90,6 +90,8 @@ #include simple_list.h #include atipcirename.h +typedef struct _SyncFence SyncFence; + #ifndef MAX #define MAX(a,b) ((a)(b)?(a):(b)) #endif @@ -445,6 +447,9 @@ typedef struct { void (*BlockHandler)(BLOCKHANDLER_ARGS_DECL); +void (*CreateFence) (ScreenPtr pScreen, SyncFence *pFence, + Bool initially_triggered); + int pix24bpp; /* Depth of pixmap for 24bpp fb */ Bool dac6bits; /* Use 6 bit DAC?*/ @@ -544,6 +549,10 @@ extern Bool RADEONGetDatatypeBpp(int bpp, uint32_t *type); extern Bool RADEONGetPixmapOffsetPitch(PixmapPtr pPix, uint32_t *pitch_offset); +/* radeon_sync.c */ +extern Bool radeon_sync_init(ScreenPtr screen); +extern void radeon_sync_close(ScreenPtr screen); + /* radeon_video.c */ extern void RADEONInitVideo(ScreenPtr pScreen); extern void RADEONResetVideo(ScrnInfoPtr pScrn); diff --git a/src/radeon_kms.c b/src/radeon_kms.c index d25d7f5..521f3b9 100644 --- a/src/radeon_kms.c +++ b/src/radeon_kms.c @@ -1192,6 +1192,8 @@ static Bool RADEONCloseScreen_KMS(CLOSE_SCREEN_ARGS_DECL) info-accel_state-exa = NULL; } +radeon_sync_close(pScreen); + if (info-accel_state-use_vbos) radeon_vbo_free_lists(pScrn); @@ -1338,6 +1340,8 @@ Bool RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL) } #endif +radeon_sync_init(pScreen); + pScrn-vtSema = TRUE; xf86SetBackingStore(pScreen); diff --git a/src/radeon_sync.c b/src/radeon_sync.c new file mode 100644 index 000..d8ab5bc --- /dev/null +++ b/src/radeon_sync.c @@ -0,0 +1,144 @@ +/* + * Copyright © 2013-2014 Intel Corporation + * Copyright © 2015 Advanced Micro Devices, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided as + * is without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include radeon.h + +#ifdef HAVE_MISYNCSHM_H + +#include misyncshm.h +#include misyncstr.h + +/* + * This whole file exists to wrap a sync fence
[PATCH 12/14] Add support for the Present extension v2
From: Michel Dänzer michel.daen...@amd.com v2: Fix up for struct radeon_drm_queue - radeon_drm_queue_entry. Swapped order of patches 11 12 because the Present extension uses SYNC fences. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- configure.ac | 6 + src/Makefile.am | 4 +- src/radeon.h | 3 + src/radeon_kms.c | 3 +- src/radeon_present.c | 418 +++ 5 files changed, 431 insertions(+), 3 deletions(-) create mode 100644 src/radeon_present.c diff --git a/configure.ac b/configure.ac index c2e5a20..71d8ff0 100644 --- a/configure.ac +++ b/configure.ac @@ -137,6 +137,12 @@ AC_CHECK_HEADERS([misyncshm.h], [], [], #include screenint.h #include xorg-server.h]) +AC_CHECK_HEADERS([present.h], [], [], +[#include X11/Xmd.h +#include X11/Xproto.h +#include X11/X.h +#include xorg-server.h]) + CPPFLAGS=$SAVE_CPPFLAGS PKG_CHECK_MODULES([PCIACCESS], [pciaccess = 0.8.0]) diff --git a/src/Makefile.am b/src/Makefile.am index acb83f1..a3d732a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,8 +29,8 @@ ati_drv_la_LIBADD = $(PCIACCESS_LIBS) radeon_drv_la_LIBADD = $(LIBDRM_RADEON_LIBS) $(PCIACCESS_LIBS) -RADEON_KMS_SRCS=radeon_dri2.c radeon_drm_queue.c radeon_kms.c radeon_sync.c \ - radeon_vbo.c radeon_bo_helper.c drmmode_display.c +RADEON_KMS_SRCS=radeon_dri2.c radeon_drm_queue.c radeon_kms.c radeon_present.c \ + radeon_sync.c radeon_vbo.c radeon_bo_helper.c drmmode_display.c RADEON_EXA_SOURCES = radeon_exa.c r600_exa.c r6xx_accel.c r600_textured_videofuncs.c r600_shader.c radeon_exa_shared.c \ evergreen_exa.c evergreen_accel.c evergreen_shader.c evergreen_textured_videofuncs.c cayman_accel.c cayman_shader.c diff --git a/src/radeon.h b/src/radeon.h index cc52bd9..9346fbd 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -549,6 +549,9 @@ extern Bool RADEONGetDatatypeBpp(int bpp, uint32_t *type); extern Bool RADEONGetPixmapOffsetPitch(PixmapPtr pPix, uint32_t *pitch_offset); +/* radeon_present.c */ +Bool radeon_present_screen_init(ScreenPtr screen); + /* radeon_sync.c */ extern Bool radeon_sync_init(ScreenPtr screen); extern void radeon_sync_close(ScreenPtr screen); diff --git a/src/radeon_kms.c b/src/radeon_kms.c index 521f3b9..f4452bc 100644 --- a/src/radeon_kms.c +++ b/src/radeon_kms.c @@ -1340,7 +1340,8 @@ Bool RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL) } #endif -radeon_sync_init(pScreen); +if (radeon_sync_init(pScreen)) + radeon_present_screen_init(pScreen); pScrn-vtSema = TRUE; xf86SetBackingStore(pScreen); diff --git a/src/radeon_present.c b/src/radeon_present.c new file mode 100644 index 000..d884548 --- /dev/null +++ b/src/radeon_present.c @@ -0,0 +1,418 @@ +/* + * Copyright © 2014 Intel Corporation + * Copyright © 2015 Advanced Micro Devices, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided as + * is without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include config.h +#endif + +#include xorg-server.h +#include xf86.h + +#ifdef HAVE_PRESENT_H + +#include stdio.h +#include string.h +#include assert.h +#include sys/types.h +#include sys/stat.h +#include sys/ioctl.h +#include unistd.h +#include fcntl.h +#include poll.h +#include sys/time.h +#include time.h +#include errno.h + +#include xf86_OSproc.h + +#include xf86Pci.h +#include xf86drm.h + +#include windowstr.h +#include shadow.h +#include fb.h + +#include radeon.h +#include radeon_video.h + +#include present.h + +struct radeon_present_vblank_event { +uint64_t event_id; +}; + +static uint32_t crtc_select(int crtc_id) +{ +if (crtc_id 1) + return crtc_id DRM_VBLANK_HIGH_CRTC_SHIFT; +else if (crtc_id 0) + return DRM_VBLANK_SECONDARY; +else
[PATCH 14/14] Add DRI3 support
From: Michel Dänzer michel.daen...@amd.com Must be enabled with Option DRI3 in xorg.conf. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- configure.ac | 4 ++ man/radeon.man| 4 ++ src/Makefile.am | 5 +- src/radeon.h | 4 ++ src/radeon_dri3.c | 201 ++ src/radeon_kms.c | 23 ++- 6 files changed, 237 insertions(+), 4 deletions(-) create mode 100644 src/radeon_dri3.c diff --git a/configure.ac b/configure.ac index 71d8ff0..acd9fe0 100644 --- a/configure.ac +++ b/configure.ac @@ -143,6 +143,10 @@ AC_CHECK_HEADERS([present.h], [], [], #include X11/X.h #include xorg-server.h]) +AC_CHECK_HEADERS([dri3.h], [], [], +[#include X11/Xmd.h +#include xorg-server.h]) + CPPFLAGS=$SAVE_CPPFLAGS PKG_CHECK_MODULES([PCIACCESS], [pciaccess = 0.8.0]) diff --git a/man/radeon.man b/man/radeon.man index 7dde040..6e46f89 100644 --- a/man/radeon.man +++ b/man/radeon.man @@ -267,6 +267,10 @@ The default value is for R/RV6XX, R/RV7XX, RS780, RS880, EVERGREEN, CAYMAN, ARUBA, Southern Islands, and Sea Islands. .TP +.BI Option \*qDRI3\*q \*q boolean \*q +Enable the DRI3 extension. The default is +.B off. +.TP .BI Option \*qEnablePageFlip\*q \*q boolean \*q Enable DRI2 page flipping. The default is .B on. diff --git a/src/Makefile.am b/src/Makefile.am index a3d732a..697c08c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,8 +29,9 @@ ati_drv_la_LIBADD = $(PCIACCESS_LIBS) radeon_drv_la_LIBADD = $(LIBDRM_RADEON_LIBS) $(PCIACCESS_LIBS) -RADEON_KMS_SRCS=radeon_dri2.c radeon_drm_queue.c radeon_kms.c radeon_present.c \ - radeon_sync.c radeon_vbo.c radeon_bo_helper.c drmmode_display.c +RADEON_KMS_SRCS=radeon_dri2.c radeon_dri3.c radeon_drm_queue.c radeon_kms.c \ + radeon_present.c radeon_sync.c radeon_vbo.c radeon_bo_helper.c \ + drmmode_display.c RADEON_EXA_SOURCES = radeon_exa.c r600_exa.c r6xx_accel.c r600_textured_videofuncs.c r600_shader.c radeon_exa_shared.c \ evergreen_exa.c evergreen_accel.c evergreen_shader.c evergreen_textured_videofuncs.c cayman_accel.c cayman_shader.c diff --git a/src/radeon.h b/src/radeon.h index 9346fbd..6084cfe 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -150,6 +150,7 @@ typedef enum { OPTION_ZAPHOD_HEADS, OPTION_SWAPBUFFERS_WAIT, OPTION_DELETE_DP12, +OPTION_DRI3, } RADEONOpts; @@ -549,6 +550,9 @@ extern Bool RADEONGetDatatypeBpp(int bpp, uint32_t *type); extern Bool RADEONGetPixmapOffsetPitch(PixmapPtr pPix, uint32_t *pitch_offset); +/* radeon_dri3.c */ +Bool radeon_dri3_screen_init(ScreenPtr screen); + /* radeon_present.c */ Bool radeon_present_screen_init(ScreenPtr screen); diff --git a/src/radeon_dri3.c b/src/radeon_dri3.c new file mode 100644 index 000..83bffae --- /dev/null +++ b/src/radeon_dri3.c @@ -0,0 +1,201 @@ +/* + * Copyright © 2013-2014 Intel Corporation + * Copyright © 2015 Advanced Micro Devices, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided as + * is without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + + +#ifdef HAVE_CONFIG_H +#include config.h +#endif + +#include xorg-server.h +#include xf86.h +#include fb.h + +#ifdef HAVE_DRI3_H + +#include radeon.h +#include radeon_bo_gem.h +#include radeon_glamor.h +#include dri3.h + +#include sys/types.h +#include sys/stat.h +#include fcntl.h +#include errno.h + + +static int +radeon_dri3_open_client(ClientPtr client, + ScreenPtr screen, + RRProviderPtr provider, + int *out) +{ + ScrnInfoPtr scrn = xf86ScreenToScrn(screen); + RADEONInfoPtr info = RADEONPTR(scrn); + drm_magic_t magic; + int fd; + + fd = open(info-dri2.device_name, O_RDWR | O_CLOEXEC); + if (fd 0) + return BadAlloc
[PATCH 05/14] DRI2: Remove superfluous assignments to *_info-frame
From: Michel Dänzer michel.daen...@amd.com That field is only used for page flipping. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/radeon_dri2.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c index 31bd73c..a0eecac 100644 --- a/src/radeon_dri2.c +++ b/src/radeon_dri2.c @@ -1133,7 +1133,6 @@ static int radeon_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw, CARD32 delay; delay = radeon_dri2_extrapolate_msc_delay(crtc, target_msc, divisor, remainder); - wait_info-frame = target_msc; radeon_dri2_schedule_event(delay, wait_info); DRI2BlockClient(client, draw); return TRUE; @@ -1179,8 +1178,6 @@ static int radeon_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw, goto out_complete; } -wait_info-frame = vbl.reply.sequence; - wait_info-frame += radeon_get_interpolated_vblanks(crtc); DRI2BlockClient(client, draw); return TRUE; } @@ -1213,8 +1210,6 @@ static int radeon_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw, goto out_complete; } -wait_info-frame = vbl.reply.sequence; -wait_info-frame += radeon_get_interpolated_vblanks(crtc); DRI2BlockClient(client, draw); return TRUE; @@ -1370,7 +1365,6 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, CARD32 delay; delay = radeon_dri2_extrapolate_msc_delay(crtc, target_msc, divisor, remainder); - swap_info-frame = *target_msc; radeon_dri2_schedule_event(delay, swap_info); return TRUE; } -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 13/14] Handle tiling in radeon_set_shared_pixmap_backing
From: David Heidelberger david.heidelber...@ixit.cz [ Michel Dänzer: Fixups for glamor ] Signed-off-by: David Heidelberger david.heidelber...@ixit.cz Signed-off-by: Axel Davy axel.d...@ens.fr Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/radeon_bo_helper.c | 43 +-- src/radeon_exa.c | 1 - src/radeon_glamor.c| 1 - 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/radeon_bo_helper.c b/src/radeon_bo_helper.c index ed964d7..c3a2d63 100644 --- a/src/radeon_bo_helper.c +++ b/src/radeon_bo_helper.c @@ -200,6 +200,21 @@ Bool radeon_share_pixmap_backing(struct radeon_bo *bo, void **handle_p) return TRUE; } +static unsigned eg_tile_split_opp(unsigned tile_split) +{ +switch (tile_split) { +case 0: tile_split = 64;break; +case 1: tile_split = 128; break; +case 2: tile_split = 256; break; +case 3: tile_split = 512; break; +default: +case 4: tile_split = 1024; break; +case 5: tile_split = 2048; break; +case 6: tile_split = 4096; break; +} +return tile_split; +} + Bool radeon_set_shared_pixmap_backing(PixmapPtr ppix, void *fd_handle, struct radeon_surface *surface) { @@ -215,7 +230,22 @@ Bool radeon_set_shared_pixmap_backing(PixmapPtr ppix, void *fd_handle, memset(surface, 0, sizeof(struct radeon_surface)); +radeon_set_pixmap_bo(ppix, bo); + if (info-ChipFamily = CHIP_FAMILY_R600 info-surf_man) { + uint32_t tiling_flags; + +#ifdef USE_GLAMOR + if (info-use_glamor) { + tiling_flags = radeon_get_pixmap_private(ppix)-tiling_flags; + } else +#endif + { + struct radeon_exa_pixmap_priv *driver_priv; + + driver_priv = exaGetPixmapDriverPrivate(ppix); + tiling_flags = driver_priv-tiling_flags; + } surface-npix_x = ppix-drawable.width; surface-npix_y = ppix-drawable.height; @@ -229,7 +259,17 @@ Bool radeon_set_shared_pixmap_backing(PixmapPtr ppix, void *fd_handle, /* we are requiring a recent enough libdrm version */ surface-flags |= RADEON_SURF_HAS_TILE_MODE_INDEX; surface-flags |= RADEON_SURF_SET(RADEON_SURF_TYPE_2D, TYPE); - surface-flags |= RADEON_SURF_SET(RADEON_SURF_MODE_LINEAR, MODE); + if (tiling_flags RADEON_TILING_MACRO) + surface-flags |= RADEON_SURF_SET(RADEON_SURF_MODE_2D, MODE); + else if (tiling_flags RADEON_TILING_MICRO) + surface-flags |= RADEON_SURF_SET(RADEON_SURF_MODE_1D, MODE); + else + surface-flags |= RADEON_SURF_SET(RADEON_SURF_MODE_LINEAR_ALIGNED, MODE); + surface-bankw = (tiling_flags RADEON_TILING_EG_BANKW_SHIFT) RADEON_TILING_EG_BANKW_MASK; + surface-bankh = (tiling_flags RADEON_TILING_EG_BANKH_SHIFT) RADEON_TILING_EG_BANKH_MASK; + surface-tile_split = eg_tile_split_opp((tiling_flags RADEON_TILING_EG_TILE_SPLIT_SHIFT) RADEON_TILING_EG_TILE_SPLIT_MASK); + surface-stencil_tile_split = (tiling_flags RADEON_TILING_EG_STENCIL_TILE_SPLIT_SHIFT) RADEON_TILING_EG_STENCIL_TILE_SPLIT_MASK; + surface-mtilea = (tiling_flags RADEON_TILING_EG_MACRO_TILE_ASPECT_SHIFT) RADEON_TILING_EG_MACRO_TILE_ASPECT_MASK; if (radeon_surface_best(info-surf_man, surface)) { return FALSE; } @@ -241,7 +281,6 @@ Bool radeon_set_shared_pixmap_backing(PixmapPtr ppix, void *fd_handle, surface-level[0].pitch_bytes = ppix-devKind; surface-level[0].nblk_x = ppix-devKind / surface-bpe; } -radeon_set_pixmap_bo(ppix, bo); close(ihandle); /* we have a reference from the alloc and one from set pixmap bo, diff --git a/src/radeon_exa.c b/src/radeon_exa.c index 0d6cd24..1e457a8 100644 --- a/src/radeon_exa.c +++ b/src/radeon_exa.c @@ -330,7 +330,6 @@ Bool RADEONEXASetSharedPixmapBacking(PixmapPtr ppix, void *fd_handle) return FALSE; driver_priv-shared = TRUE; -driver_priv-tiling_flags = 0; return TRUE; } #endif diff --git a/src/radeon_glamor.c b/src/radeon_glamor.c index f0996fe..c49c7f6 100644 --- a/src/radeon_glamor.c +++ b/src/radeon_glamor.c @@ -303,7 +303,6 @@ radeon_glamor_set_shared_pixmap_backing(PixmapPtr pixmap, void *handle) priv = radeon_get_pixmap_private(pixmap); priv-stride = pixmap-devKind; priv-surface = surface; - priv-tiling_flags = 0; if (!radeon_glamor_create_textured_pixmap(pixmap)) { xf86DrvMsg(scrn-scrnIndex, X_ERROR, -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 12/14] Add support for SYNC extension fences
From: Michel Dänzer michel.daen...@amd.com Signed-off-by: Michel Dänzer michel.daen...@amd.com --- configure.ac | 6 +++ src/Makefile.am | 2 +- src/radeon.h | 9 src/radeon_kms.c | 4 ++ src/radeon_sync.c | 144 ++ 5 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 src/radeon_sync.c diff --git a/configure.ac b/configure.ac index 7042a1e..71d8ff0 100644 --- a/configure.ac +++ b/configure.ac @@ -131,6 +131,12 @@ AC_CHECK_DECL(xorg_list_init, #include xorg-server.h #include list.h]) +AC_CHECK_HEADERS([misyncshm.h], [], [], + [#include X11/Xdefs.h + #include X11/Xfuncproto.h + #include screenint.h + #include xorg-server.h]) + AC_CHECK_HEADERS([present.h], [], [], [#include X11/Xmd.h #include X11/Xproto.h diff --git a/src/Makefile.am b/src/Makefile.am index 629b6bf..a3d732a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -30,7 +30,7 @@ ati_drv_la_LIBADD = $(PCIACCESS_LIBS) radeon_drv_la_LIBADD = $(LIBDRM_RADEON_LIBS) $(PCIACCESS_LIBS) RADEON_KMS_SRCS=radeon_dri2.c radeon_drm_queue.c radeon_kms.c radeon_present.c \ - radeon_vbo.c radeon_bo_helper.c drmmode_display.c + radeon_sync.c radeon_vbo.c radeon_bo_helper.c drmmode_display.c RADEON_EXA_SOURCES = radeon_exa.c r600_exa.c r6xx_accel.c r600_textured_videofuncs.c r600_shader.c radeon_exa_shared.c \ evergreen_exa.c evergreen_accel.c evergreen_shader.c evergreen_textured_videofuncs.c cayman_accel.c cayman_shader.c diff --git a/src/radeon.h b/src/radeon.h index 913adf2..9346fbd 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -90,6 +90,8 @@ #include simple_list.h #include atipcirename.h +typedef struct _SyncFence SyncFence; + #ifndef MAX #define MAX(a,b) ((a)(b)?(a):(b)) #endif @@ -445,6 +447,9 @@ typedef struct { void (*BlockHandler)(BLOCKHANDLER_ARGS_DECL); +void (*CreateFence) (ScreenPtr pScreen, SyncFence *pFence, + Bool initially_triggered); + int pix24bpp; /* Depth of pixmap for 24bpp fb */ Bool dac6bits; /* Use 6 bit DAC?*/ @@ -547,6 +552,10 @@ extern Bool RADEONGetPixmapOffsetPitch(PixmapPtr pPix, /* radeon_present.c */ Bool radeon_present_screen_init(ScreenPtr screen); +/* radeon_sync.c */ +extern Bool radeon_sync_init(ScreenPtr screen); +extern void radeon_sync_close(ScreenPtr screen); + /* radeon_video.c */ extern void RADEONInitVideo(ScreenPtr pScreen); extern void RADEONResetVideo(ScrnInfoPtr pScrn); diff --git a/src/radeon_kms.c b/src/radeon_kms.c index 055d22b..8162f44 100644 --- a/src/radeon_kms.c +++ b/src/radeon_kms.c @@ -1192,6 +1192,8 @@ static Bool RADEONCloseScreen_KMS(CLOSE_SCREEN_ARGS_DECL) info-accel_state-exa = NULL; } +radeon_sync_close(pScreen); + if (info-accel_state-use_vbos) radeon_vbo_free_lists(pScrn); @@ -1340,6 +1342,8 @@ Bool RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL) radeon_present_screen_init(pScreen); +radeon_sync_init(pScreen); + pScrn-vtSema = TRUE; xf86SetBackingStore(pScreen); diff --git a/src/radeon_sync.c b/src/radeon_sync.c new file mode 100644 index 000..d8ab5bc --- /dev/null +++ b/src/radeon_sync.c @@ -0,0 +1,144 @@ +/* + * Copyright © 2013-2014 Intel Corporation + * Copyright © 2015 Advanced Micro Devices, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided as + * is without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include radeon.h + +#ifdef HAVE_MISYNCSHM_H + +#include misyncshm.h +#include misyncstr.h + +/* + * This whole file exists to wrap a sync fence trigger operation + * so that we can flush the batch buffer to provide serialization + * between the server and the shm fence
[PATCH 07/14] DRI2: Use helper functions for DRM event queue management
From: Michel Dänzer michel.daen...@amd.com This is mostly in preparation for Present support, but it also simplifies the DRI2 specific code a little. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 86 ++-- src/drmmode_display.h | 12 ++- src/radeon_dri2.c | 267 +++--- src/radeon_dri2.h | 37 --- 4 files changed, 166 insertions(+), 236 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index cebd206..fc9d8a0 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -1799,45 +1799,52 @@ static const xf86CrtcConfigFuncsRec drmmode_xf86crtc_config_funcs = { }; static void -drmmode_vblank_handler(int fd, unsigned int frame, unsigned int tv_sec, - unsigned int tv_usec, void *event_data) +drmmode_flip_free(drmmode_flipevtcarrier_ptr flipcarrier) { - radeon_dri2_frame_event_handler(frame, tv_sec, tv_usec, event_data); + drmmode_flipdata_ptr flipdata = flipcarrier-flipdata; + + free(flipcarrier); + + if (--flipdata-flip_count 0) + return; + + /* Release framebuffer */ + drmModeRmFB(flipdata-drmmode-fd, flipdata-old_fb_id); + + free(flipdata); } static void -drmmode_flip_handler(int fd, unsigned int frame, unsigned int tv_sec, -unsigned int tv_usec, void *event_data) +drmmode_flip_abort(ScrnInfoPtr scrn, void *event_data) +{ + drmmode_flipevtcarrier_ptr flipcarrier = event_data; + drmmode_flipdata_ptr flipdata = flipcarrier-flipdata; + + if (flipdata-flip_count == 1) + flipcarrier-abort(scrn, flipdata-event_data); + + drmmode_flip_free(flipcarrier); +} + +static void +drmmode_flip_handler(ScrnInfoPtr scrn, uint32_t frame, uint64_t usec, void *event_data) { drmmode_flipevtcarrier_ptr flipcarrier = event_data; drmmode_flipdata_ptr flipdata = flipcarrier-flipdata; - drmmode_ptr drmmode = flipdata-drmmode; /* Is this the event whose info shall be delivered to higher level? */ if (flipcarrier-dispatch_me) { /* Yes: Cache msc, ust for later delivery. */ flipdata-fe_frame = frame; - flipdata-fe_tv_sec = tv_sec; - flipdata-fe_tv_usec = tv_usec; + flipdata-fe_usec = usec; } - free(flipcarrier); - - /* Last crtc completed flip? */ - flipdata-flip_count--; - if (flipdata-flip_count 0) - return; - - /* Release framebuffer */ - drmModeRmFB(drmmode-fd, flipdata-old_fb_id); - - if (flipdata-event_data == NULL) - return; /* Deliver cached msc, ust from reference crtc to flip event handler */ - radeon_dri2_flip_event_handler(flipdata-fe_frame, flipdata-fe_tv_sec, - flipdata-fe_tv_usec, flipdata-event_data); + if (flipdata-event_data flipdata-flip_count == 1) + flipcarrier-handler(scrn, flipdata-fe_frame, flipdata-fe_usec, +flipdata-event_data); - free(flipdata); + drmmode_flip_free(flipcarrier); } @@ -1884,8 +1891,8 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp) xf86InitialConfiguration(pScrn, TRUE); drmmode-event_context.version = DRM_EVENT_CONTEXT_VERSION; - drmmode-event_context.vblank_handler = drmmode_vblank_handler; - drmmode-event_context.page_flip_handler = drmmode_flip_handler; + drmmode-event_context.vblank_handler = radeon_drm_queue_handler; + drmmode-event_context.page_flip_handler = radeon_drm_queue_handler; drmModeFreeResources(mode_res); return TRUE; @@ -2229,7 +2236,10 @@ void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode) #endif } -Bool radeon_do_pageflip(ScrnInfoPtr scrn, struct radeon_bo *new_front, void *data, int ref_crtc_hw_id) +Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, + struct radeon_bo *new_front, uint64_t id, void *data, + int ref_crtc_hw_id, radeon_drm_handler_proc handler, + radeon_drm_abort_proc abort) { RADEONInfoPtr info = RADEONPTR(scrn); xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); @@ -2240,7 +2250,8 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, struct radeon_bo *new_front, void *dat uint32_t tiling_flags = 0; int height, emitted = 0; drmmode_flipdata_ptr flipdata; - drmmode_flipevtcarrier_ptr flipcarrier; + drmmode_flipevtcarrier_ptr flipcarrier = NULL; + struct radeon_drm_queue *drm_queue = 0; if (info-allowColorTiling) { if (info-ChipFamily = CHIP_FAMILY_R600) @@ -2305,9 +2316,22 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, struct radeon_bo *new_front, void *dat */ flipcarrier
[PATCH 01/14] Require at least xserver 1.8
From: Michel Dänzer michel.daen...@amd.com So we can rely on the list.h header. xserver 1.8 was released in April 2010. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- configure.ac | 19 ++- src/radeon_dri2.c | 17 - 2 files changed, 6 insertions(+), 30 deletions(-) diff --git a/configure.ac b/configure.ac index c471ff5..891da03 100644 --- a/configure.ac +++ b/configure.ac @@ -75,7 +75,7 @@ PKG_CHECK_MODULES(LIBDRM, [libdrm = 2.4.58]) PKG_CHECK_MODULES(LIBDRM_RADEON, [libdrm_radeon]) # Obtain compiler/linker options for the driver dependencies -PKG_CHECK_MODULES(XORG, [xorg-server = 1.7 xproto fontsproto xf86driproto $REQUIRED_MODULES]) +PKG_CHECK_MODULES(XORG, [xorg-server = 1.8 xproto fontsproto xf86driproto $REQUIRED_MODULES]) PKG_CHECK_MODULES(XEXT, [xextproto = 7.0.99.1], HAVE_XEXTPROTO_71=yes; AC_DEFINE(HAVE_XEXTPROTO_71, 1, [xextproto 7.1 available]), HAVE_XEXTPROTO_71=no) @@ -125,18 +125,11 @@ else fi AM_CONDITIONAL(GLAMOR, test x$GLAMOR != xno) -AC_CHECK_HEADERS([list.h], -[have_list_h=yes], [have_list_h=no], -[#include X11/Xdefs.h - #include xorg-server.h]) - -if test x$have_list_h = xyes; then -AC_CHECK_DECL(xorg_list_init, - [AC_DEFINE(HAVE_XORG_LIST, 1, [Have xorg_list API])], [], - [#include X11/Xdefs.h - #include xorg-server.h - #include list.h]) -fi +AC_CHECK_DECL(xorg_list_init, + [AC_DEFINE(HAVE_XORG_LIST, 1, [Have xorg_list API])], [], + [#include X11/Xdefs.h + #include xorg-server.h + #include list.h]) CPPFLAGS=$SAVE_CPPFLAGS diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c index 56beeec..8cc7e56 100644 --- a/src/radeon_dri2.c +++ b/src/radeon_dri2.c @@ -42,7 +42,6 @@ #include radeon_version.h -#if HAVE_LIST_H #include list.h #if !HAVE_XORG_LIST #define xorg_list list @@ -51,15 +50,9 @@ #define xorg_list_del list_del #define xorg_list_for_each_entry list_for_each_entry #endif -#endif - #include radeon_bo_gem.h -#if DRI2INFOREC_VERSION = 4 HAVE_LIST_H -#define USE_DRI2_SCHEDULING -#endif - #if DRI2INFOREC_VERSION = 9 #define USE_DRI2_PRIME #endif @@ -490,8 +483,6 @@ radeon_dri2_copy_region(DrawablePtr pDraw, RegionPtr pRegion, pDstBuffer, pSrcBuffer); } -#ifdef USE_DRI2_SCHEDULING - enum DRI2FrameEventType { DRI2_SWAP, DRI2_FLIP, @@ -1537,8 +1528,6 @@ blit_fallback: return TRUE; } -#endif /* USE_DRI2_SCHEDULING */ - Bool radeon_dri2_screen_init(ScreenPtr pScreen) @@ -1546,10 +1535,8 @@ radeon_dri2_screen_init(ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); RADEONInfoPtr info = RADEONPTR(pScrn); DRI2InfoRec dri2_info = { 0 }; -#ifdef USE_DRI2_SCHEDULING const char *driverNames[2]; Bool scheduling_works = TRUE; -#endif if (!info-dri2.available) return FALSE; @@ -1574,7 +1561,6 @@ radeon_dri2_screen_init(ScreenPtr pScreen) dri2_info.DestroyBuffer = radeon_dri2_destroy_buffer; dri2_info.CopyRegion = radeon_dri2_copy_region; -#ifdef USE_DRI2_SCHEDULING if (info-dri2.pKernelDRMVersion-version_minor 4) { xf86DrvMsg(pScrn-scrnIndex, X_WARNING, You need a newer kernel for sync extension\n); @@ -1637,7 +1623,6 @@ radeon_dri2_screen_init(ScreenPtr pScreen) DRI2InfoCnt++; } -#endif #if DRI2INFOREC_VERSION = 9 dri2_info.version = 9; @@ -1655,10 +1640,8 @@ void radeon_dri2_close_screen(ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); RADEONInfoPtr info = RADEONPTR(pScrn); -#ifdef USE_DRI2_SCHEDULING if (--DRI2InfoCnt == 0) DeleteCallback(ClientStateCallback, radeon_dri2_client_state_changed, 0); -#endif DRI2CloseScreen(pScreen); drmFree(info-dri2.device_name); -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 0/14] DRI3 and Present support
Patches 1-10 and 13 are various cleanups and preparatory changes to make the main patches 11, 12 and 14 clearer. Because enabling DRI3 still causes some regressions on the client side (e.g. it breaks some piglit tests, probably due to bugs in the Gallium DRI state tracker code), it's guarded by Option DRI3 for now. It should work with EXA as well, but I've only tested glamor. Any testing with EXA appreciated. [PATCH 01/14] Require at least xserver 1.8 [PATCH 02/14] Move xorg_list backwards compatibility to new [PATCH 03/14] Add DRM event queue helpers [PATCH 04/14] DRI2: Simplify blit fallback handling for scheduled [PATCH 05/14] DRI2: Remove superfluous assignments to *_info-frame [PATCH 06/14] DRI2: Move radeon_dri2_flip_event_handler [PATCH 07/14] DRI2: Use helper functions for DRM event queue [PATCH 08/14] DRI2: Split out helper for getting UST and MSC of a [PATCH 09/14] Move #include radeon_glamor.h from radeon.h to where [PATCH 10/14] Fold radeon_glamor_flush into radeon_cs_flush_indirect [PATCH 11/14] Add support for the Present extension [PATCH 12/14] Add support for SYNC extension fences [PATCH 13/14] Handle tiling in radeon_set_shared_pixmap_backing [PATCH 14/14] Add DRI3 support ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 10/14] Fold radeon_glamor_flush into radeon_cs_flush_indirect
From: Michel Dänzer michel.daen...@amd.com Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/radeon_glamor.c | 9 - src/radeon_glamor.h | 4 src/radeon_kms.c| 18 +++--- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/radeon_glamor.c b/src/radeon_glamor.c index 950f891..f0996fe 100644 --- a/src/radeon_glamor.c +++ b/src/radeon_glamor.c @@ -363,15 +363,6 @@ radeon_glamor_init(ScreenPtr screen) return TRUE; } -void -radeon_glamor_flush(ScrnInfoPtr pScrn) -{ - RADEONInfoPtr info = RADEONPTR(pScrn); - - if (info-use_glamor) - glamor_block_handler(pScrn-pScreen); -} - XF86VideoAdaptorPtr radeon_glamor_xv_init(ScreenPtr pScreen, int num_adapt) { return glamor_xv_init(pScreen, num_adapt); diff --git a/src/radeon_glamor.h b/src/radeon_glamor.h index 548ea98..c402a10 100644 --- a/src/radeon_glamor.h +++ b/src/radeon_glamor.h @@ -40,8 +40,6 @@ Bool radeon_glamor_init(ScreenPtr screen); Bool radeon_glamor_create_screen_resources(ScreenPtr screen); void radeon_glamor_free_screen(int scrnIndex, int flags); -void radeon_glamor_flush(ScrnInfoPtr pScrn); - Bool radeon_glamor_create_textured_pixmap(PixmapPtr pixmap); void radeon_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst); @@ -56,8 +54,6 @@ static inline Bool radeon_glamor_init(ScreenPtr screen) { return FALSE; } static inline Bool radeon_glamor_create_screen_resources(ScreenPtr screen) { return FALSE; } static inline void radeon_glamor_free_screen(int scrnIndex, int flags) { } -static inline void radeon_glamor_flush(ScrnInfoPtr pScrn) { } - static inline Bool radeon_glamor_create_textured_pixmap(PixmapPtr pixmap) { return TRUE; } static inline void radeon_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst) {} diff --git a/src/radeon_kms.c b/src/radeon_kms.c index 23c0694..d25d7f5 100644 --- a/src/radeon_kms.c +++ b/src/radeon_kms.c @@ -84,12 +84,21 @@ const OptionInfoRec *RADEONOptionsWeak(void) { return RADEONOptions_KMS; } void radeon_cs_flush_indirect(ScrnInfoPtr pScrn) { RADEONInfoPtr info = RADEONPTR(pScrn); -struct radeon_accel_state *accel_state = info-accel_state; +struct radeon_accel_state *accel_state; int ret; +#ifdef USE_GLAMOR +if (info-use_glamor) { + glamor_block_handler(pScrn-pScreen); + return; +} +#endif + if (!info-cs-cdw) return; +accel_state = info-accel_state; + /* release the current VBO so we don't block on mapping it later */ if (info-accel_state-vbo.vb_offset info-accel_state-vbo.vb_bo) { radeon_vbo_put(pScrn, info-accel_state-vbo); @@ -307,9 +316,6 @@ static void RADEONBlockHandler_KMS(BLOCKHANDLER_ARGS_DECL) (*pScreen-BlockHandler) (BLOCKHANDLER_ARGS); pScreen-BlockHandler = RADEONBlockHandler_KMS; -if (info-use_glamor) - radeon_glamor_flush(pScrn); - radeon_cs_flush_indirect(pScrn); #ifdef RADEON_PIXMAP_SHARING radeon_dirty_update(pScreen); @@ -322,10 +328,8 @@ radeon_flush_callback(CallbackListPtr *list, { ScrnInfoPtr pScrn = user_data; -if (pScrn-vtSema) { +if (pScrn-vtSema) radeon_cs_flush_indirect(pScrn); - radeon_glamor_flush(pScrn); -} } static Bool RADEONIsFastFBWorking(ScrnInfoPtr pScrn) -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 04/14] DRI2: Simplify blit fallback handling for scheduled swaps
From: Michel Dänzer michel.daen...@amd.com Also use radeon_dri2_schedule_event when possible. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/radeon_dri2.c | 47 --- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c index 36ab4d0..31bd73c 100644 --- a/src/radeon_dri2.c +++ b/src/radeon_dri2.c @@ -1319,7 +1319,6 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, drmVBlank vbl; int ret, flip = 0; DRI2FrameEventPtr swap_info = NULL; -enum DRI2FrameEventType swap_type = DRI2_SWAP; CARD64 current_msc; BoxRec box; RegionRec region; @@ -1345,6 +1344,7 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, if (!swap_info) goto blit_fallback; +swap_info-type = DRI2_SWAP; swap_info-drawable_id = draw-id; swap_info-client = client; swap_info-event_complete = func; @@ -1384,9 +1384,7 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, xf86DrvMsg(scrn-scrnIndex, X_WARNING, first get vblank counter failed: %s\n, strerror(errno)); - *target_msc = 0; - radeon_dri2_schedule_event(FALLBACK_SWAP_DELAY, swap_info); - return TRUE; + goto blit_fallback; } current_msc = vbl.reply.sequence + radeon_get_interpolated_vblanks(crtc); @@ -1394,13 +1392,11 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, /* Flips need to be submitted one frame before */ if (can_flip(scrn, draw, front, back)) { - swap_type = DRI2_FLIP; + swap_info-type = DRI2_FLIP; flip = 1; } -swap_info-type = swap_type; - -/* Correct target_msc by 'flip' if swap_type == DRI2_FLIP. +/* Correct target_msc by 'flip' if swap_info-type == DRI2_FLIP. * Do it early, so handling of different timing constraints * for divisor, remainder and msc vs. target_msc works. */ @@ -1437,9 +1433,7 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, xf86DrvMsg(scrn-scrnIndex, X_WARNING, divisor 0 get vblank counter failed: %s\n, strerror(errno)); - *target_msc = 0; - radeon_dri2_schedule_event(FALLBACK_SWAP_DELAY, swap_info); -return TRUE; + goto blit_fallback; } *target_msc = vbl.reply.sequence + flip; @@ -1486,9 +1480,7 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, xf86DrvMsg(scrn-scrnIndex, X_WARNING, final get vblank counter failed: %s\n, strerror(errno)); - *target_msc = 0; - radeon_dri2_schedule_event(FALLBACK_SWAP_DELAY, swap_info); - return TRUE; + goto blit_fallback; } /* Adjust returned value for 1 fame pageflip offset of flip 0 */ @@ -1499,22 +1491,23 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, return TRUE; blit_fallback: -box.x1 = 0; -box.y1 = 0; -box.x2 = draw-width; -box.y2 = draw-height; -REGION_INIT(pScreen, region, box, 0); +if (swap_info) { + swap_info-type = DRI2_SWAP; + radeon_dri2_schedule_event(FALLBACK_SWAP_DELAY, swap_info); +} else { + box.x1 = 0; + box.y1 = 0; + box.x2 = draw-width; + box.y2 = draw-height; + REGION_INIT(pScreen, region, box, 0); -radeon_dri2_copy_region(draw, region, front, back); + radeon_dri2_copy_region(draw, region, front, back); -DRI2SwapComplete(client, draw, 0, 0, 0, DRI2_BLIT_COMPLETE, func, data); -if (swap_info) { -ListDelDRI2ClientEvents(swap_info-client, swap_info-link); -free(swap_info); -} + DRI2SwapComplete(client, draw, 0, 0, 0, DRI2_BLIT_COMPLETE, func, data); -radeon_dri2_unref_buffer(front); -radeon_dri2_unref_buffer(back); + radeon_dri2_unref_buffer(front); + radeon_dri2_unref_buffer(back); +} *target_msc = 0; /* offscreen, so zero out target vblank count */ return TRUE; -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 02/14] Move xorg_list backwards compatibility to new radeon_list.h header
From: Michel Dänzer michel.daen...@amd.com Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/Makefile.am | 1 + src/radeon_dri2.c | 10 +- src/radeon_list.h | 38 ++ 3 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 src/radeon_list.h diff --git a/src/Makefile.am b/src/Makefile.am index 9ff1ffb..708f2ad 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -93,6 +93,7 @@ EXTRA_DIST = \ radeon_exa_shared.h \ radeon_glamor.h \ radeon.h \ + radeon_list.h \ radeon_probe.h \ radeon_reg.h \ radeon_version.h \ diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c index 8cc7e56..36ab4d0 100644 --- a/src/radeon_dri2.c +++ b/src/radeon_dri2.c @@ -41,15 +41,7 @@ #include errno.h #include radeon_version.h - -#include list.h -#if !HAVE_XORG_LIST -#define xorg_list list -#define xorg_list_init list_init -#define xorg_list_add list_add -#define xorg_list_del list_del -#define xorg_list_for_each_entry list_for_each_entry -#endif +#include radeon_list.h #include radeon_bo_gem.h diff --git a/src/radeon_list.h b/src/radeon_list.h new file mode 100644 index 000..4002013 --- /dev/null +++ b/src/radeon_list.h @@ -0,0 +1,38 @@ +/* + * Copyright © 2015 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the Software), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef _RADEON_LIST_H_ +#define _RADEON_LIST_H_ + +#include xorg-server.h +#include list.h + +#if !HAVE_XORG_LIST +#define xorg_list list +#define xorg_list_init list_init +#define xorg_list_add list_add +#define xorg_list_del list_del +#define xorg_list_for_each_entry list_for_each_entry +#endif + +#endif /* _RADEON_LIST_H_ */ -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 03/14] Add DRM event queue helpers
From: Michel Dänzer michel.daen...@amd.com Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/Makefile.am| 5 +- src/radeon_drm_queue.c | 181 + src/radeon_drm_queue.h | 55 +++ src/radeon_kms.c | 4 ++ 4 files changed, 243 insertions(+), 2 deletions(-) create mode 100644 src/radeon_drm_queue.c create mode 100644 src/radeon_drm_queue.h diff --git a/src/Makefile.am b/src/Makefile.am index 708f2ad..9cc8a2d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,8 +29,8 @@ ati_drv_la_LIBADD = $(PCIACCESS_LIBS) radeon_drv_la_LIBADD = $(LIBDRM_RADEON_LIBS) $(PCIACCESS_LIBS) -RADEON_KMS_SRCS=radeon_dri2.c radeon_kms.c drmmode_display.c radeon_vbo.c \ - radeon_bo_helper.c +RADEON_KMS_SRCS=radeon_dri2.c radeon_drm_queue.c radeon_kms.c drmmode_display.c \ + radeon_vbo.c radeon_bo_helper.c RADEON_EXA_SOURCES = radeon_exa.c r600_exa.c r6xx_accel.c r600_textured_videofuncs.c r600_shader.c radeon_exa_shared.c \ evergreen_exa.c evergreen_accel.c evergreen_shader.c evergreen_textured_videofuncs.c cayman_accel.c cayman_shader.c @@ -88,6 +88,7 @@ EXTRA_DIST = \ bicubic_table.h \ bicubic_table.py \ radeon_bo_helper.h \ + radeon_drm_queue.h \ radeon_exa_render.c \ radeon_exa_funcs.c \ radeon_exa_shared.h \ diff --git a/src/radeon_drm_queue.c b/src/radeon_drm_queue.c new file mode 100644 index 000..7b7fd06 --- /dev/null +++ b/src/radeon_drm_queue.c @@ -0,0 +1,181 @@ +/* + * Copyright © 2007 Red Hat, Inc. + * Copyright © 2015 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the Software), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Authors: + *Dave Airlie airl...@redhat.com + * + */ + +#ifdef HAVE_CONFIG_H +#include config.h +#endif + +#include xorg-server.h + +#include radeon.h +#include radeon_drm_queue.h +#include radeon_list.h + + +struct radeon_drm_queue { +struct xorg_list list; +uint64_t id; +void *data; +ClientPtr client; +ScrnInfoPtr scrn; +radeon_drm_handler_proc handler; +radeon_drm_abort_proc abort; +}; + +static int radeon_drm_queue_refcnt; +static struct xorg_list radeon_drm_queue; + + +/* + * Handle a DRM event + */ +void +radeon_drm_queue_handler(int fd, unsigned int frame, unsigned int sec, +unsigned int usec, void *user_ptr) +{ + struct radeon_drm_queue *user_data = user_ptr; + struct radeon_drm_queue *q, *tmp; + + xorg_list_for_each_entry_safe(q, tmp, radeon_drm_queue, list) { + if (q == user_data) { + xorg_list_del(q-list); + q-handler(q-scrn, frame, + (uint64_t)sec * 100 + usec, q-data); + free(q); + break; + } + } +} + +/* + * Enqueue a potential drm response; when the associated response + * appears, we've got data to pass to the handler from here + */ +struct radeon_drm_queue * +radeon_drm_queue_alloc(ScrnInfoPtr scrn, ClientPtr client, + uint64_t id, void *data, + radeon_drm_handler_proc handler, + radeon_drm_abort_proc abort) +{ +struct radeon_drm_queue *q; + +q = calloc(1, sizeof(struct radeon_drm_queue)); +if (!q) + return NULL; + +q-client = client; +q-scrn = scrn; +q-id = id; +q-data = data; +q-handler = handler; +q-abort = abort; + +xorg_list_add(q-list, radeon_drm_queue); + +return q; +} + +/* + * Abort one queued DRM entry, removing it + * from the list, calling the abort function and + * freeing the memory + */ +static void +radeon_drm_abort_one(struct radeon_drm_queue *q) +{ +xorg_list_del(q-list); +q-abort(q-scrn, q-data); +free(q); +} + +/* + * Abort drm queue entries for a client + */ +void +radeon_drm_abort_client
[PATCH 08/14] DRI2: Split out helper for getting UST and MSC of a specific CRTC
From: Michel Dänzer michel.daen...@amd.com Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 27 +++ src/drmmode_display.h | 1 + src/radeon_dri2.c | 32 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index fc9d8a0..e90a33f 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -245,6 +245,33 @@ int drmmode_get_current_ust(int drm_fd, CARD64 *ust) return 0; } +/* + * Get current frame count and frame count timestamp of the crtc. + */ +int drmmode_crtc_get_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc) +{ +ScrnInfoPtr scrn = crtc-scrn; +RADEONInfoPtr info = RADEONPTR(scrn); +drmVBlank vbl; +int ret; + +vbl.request.type = DRM_VBLANK_RELATIVE; +vbl.request.type |= radeon_populate_vbl_request_type(crtc); +vbl.request.sequence = 0; + +ret = drmWaitVBlank(info-dri2.drm_fd, vbl); +if (ret) { + xf86DrvMsg(scrn-scrnIndex, X_WARNING, + get vblank counter failed: %s\n, strerror(errno)); + return ret; +} + +*ust = ((CARD64)vbl.reply.tval_sec * 100) + vbl.reply.tval_usec; +*msc = vbl.reply.sequence; + +return Success; +} + static void drmmode_do_crtc_dpms(xf86CrtcPtr crtc, int mode) { diff --git a/src/drmmode_display.h b/src/drmmode_display.h index b313460..6f883c0 100644 --- a/src/drmmode_display.h +++ b/src/drmmode_display.h @@ -132,6 +132,7 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, struct radeon_bo *new_front, uint64_t id, void *data, int ref_crtc_hw_id, radeon_drm_handler_proc handler, radeon_drm_abort_proc abort); +int drmmode_crtc_get_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc); int drmmode_get_current_ust(int drm_fd, CARD64 *ust); #endif diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c index 97164b6..ee04be8 100644 --- a/src/radeon_dri2.c +++ b/src/radeon_dri2.c @@ -952,17 +952,13 @@ CARD32 radeon_dri2_extrapolate_msc_delay(xf86CrtcPtr crtc, CARD64 *target_msc, } /* - * Get current frame count and frame count timestamp, based on drawable's - * crtc. + * Get current interpolated frame count and frame count timestamp, based on + * drawable's crtc. */ static int radeon_dri2_get_msc(DrawablePtr draw, CARD64 *ust, CARD64 *msc) { -ScreenPtr screen = draw-pScreen; -ScrnInfoPtr scrn = xf86ScreenToScrn(screen); -RADEONInfoPtr info = RADEONPTR(scrn); -drmVBlank vbl; -int ret; xf86CrtcPtr crtc = radeon_dri2_drawable_crtc(draw, TRUE); +int ret; /* Drawable not displayed, make up a value */ if (crtc == NULL) { @@ -970,25 +966,20 @@ static int radeon_dri2_get_msc(DrawablePtr draw, CARD64 *ust, CARD64 *msc) *msc = 0; return TRUE; } + if (radeon_crtc_is_enabled(crtc)) { /* CRTC is running, read vblank counter and timestamp */ - vbl.request.type = DRM_VBLANK_RELATIVE; - vbl.request.type |= radeon_populate_vbl_request_type(crtc); - vbl.request.sequence = 0; + ret = drmmode_crtc_get_ust_msc(crtc, ust, msc); - ret = drmWaitVBlank(info-dri2.drm_fd, vbl); - if (ret) { - xf86DrvMsg(scrn-scrnIndex, X_WARNING, - get vblank counter failed: %s\n, strerror(errno)); - return FALSE; + if (ret != Success) { + *msc += radeon_get_interpolated_vblanks(crtc); + *msc = 0x; } - - *ust = ((CARD64)vbl.reply.tval_sec * 100) + vbl.reply.tval_usec; - *msc = vbl.reply.sequence + radeon_get_interpolated_vblanks(crtc); - *msc = 0x; } else { /* CRTC is not running, extrapolate MSC and timestamp */ drmmode_crtc_private_ptr drmmode_crtc = crtc-driver_private; + ScrnInfoPtr scrn = crtc-scrn; + RADEONInfoPtr info = RADEONPTR(scrn); CARD64 now, delta_t, delta_seq; if (!drmmode_crtc-dpms_last_ust) @@ -1011,7 +1002,8 @@ static int radeon_dri2_get_msc(DrawablePtr draw, CARD64 *ust, CARD64 *msc) *msc += delta_seq; *msc = 0x; } -return TRUE; + +return ret == Success; } static -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 09/14] Move #include radeon_glamor.h from radeon.h to where it's needed
From: Michel Dänzer michel.daen...@amd.com Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 1 + src/radeon.h | 36 ++-- src/radeon_accel.c| 1 + src/radeon_dri2.c | 4 +--- src/radeon_glamor.c | 3 +-- src/radeon_glamor.h | 31 +++ src/radeon_kms.c | 1 + src/radeon_video.c| 1 + 8 files changed, 43 insertions(+), 35 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index e90a33f..d4c0d4d 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -36,6 +36,7 @@ #include micmap.h #include xf86cmap.h #include radeon.h +#include radeon_glamor.h #include radeon_reg.h #include drmmode_display.h diff --git a/src/radeon.h b/src/radeon.h index 88a0bd5..e503cbb 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -51,8 +51,6 @@ #include exa.h -#include radeon_glamor.h - /* Exa and Cursor Support */ #include xf86Cursor.h @@ -242,6 +240,40 @@ typedef enum { #define CURSOR_WIDTH_CIK 128 #define CURSOR_HEIGHT_CIK 128 + +#ifdef USE_GLAMOR + +struct radeon_pixmap { + struct radeon_surface surface; + struct radeon_bo *bo; + + uint32_t tiling_flags; + int stride; +}; + +#if HAS_DEVPRIVATEKEYREC +extern DevPrivateKeyRec glamor_pixmap_index; +#else +extern int glamor_pixmap_index; +#endif + +static inline struct radeon_pixmap *radeon_get_pixmap_private(PixmapPtr pixmap) +{ +#if HAS_DEVPRIVATEKEYREC + return dixGetPrivate(pixmap-devPrivates, glamor_pixmap_index); +#else + return dixLookupPrivate(pixmap-devPrivates, glamor_pixmap_index); +#endif +} + +static inline void radeon_set_pixmap_private(PixmapPtr pixmap, struct radeon_pixmap *priv) +{ + dixSetPrivate(pixmap-devPrivates, glamor_pixmap_index, priv); +} + +#endif /* USE_GLAMOR */ + + struct radeon_exa_pixmap_priv { struct radeon_bo *bo; uint32_t tiling_flags; diff --git a/src/radeon_accel.c b/src/radeon_accel.c index 8eff5c5..1def2a3 100644 --- a/src/radeon_accel.c +++ b/src/radeon_accel.c @@ -78,6 +78,7 @@ #include assert.h /* Driver data structures */ #include radeon.h +#include radeon_glamor.h #include radeon_reg.h #include r600_reg.h #include radeon_probe.h diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c index ee04be8..6adf93f 100644 --- a/src/radeon_dri2.c +++ b/src/radeon_dri2.c @@ -53,9 +53,7 @@ #define FALLBACK_SWAP_DELAY 16 -#ifdef USE_GLAMOR -#include glamor.h -#endif +#include radeon_glamor.h typedef DRI2BufferPtr BufferPtr; diff --git a/src/radeon_glamor.c b/src/radeon_glamor.c index 210ddcf..950f891 100644 --- a/src/radeon_glamor.c +++ b/src/radeon_glamor.c @@ -29,11 +29,10 @@ #endif #include xf86.h -#define GLAMOR_FOR_XORG 1 -#include glamor.h #include radeon.h #include radeon_bo_helper.h +#include radeon_glamor.h #if HAS_DEVPRIVATEKEYREC DevPrivateKeyRec glamor_pixmap_index; diff --git a/src/radeon_glamor.h b/src/radeon_glamor.h index 36addd7..548ea98 100644 --- a/src/radeon_glamor.h +++ b/src/radeon_glamor.h @@ -30,6 +30,9 @@ #include xf86xv.h #ifdef USE_GLAMOR +#define GLAMOR_FOR_XORG 1 +#include glamor.h + #include radeon_surface.h Bool radeon_glamor_pre_init(ScrnInfoPtr scrn); @@ -46,34 +49,6 @@ Bool radeon_glamor_pixmap_is_offscreen(PixmapPtr pixmap); XF86VideoAdaptorPtr radeon_glamor_xv_init(ScreenPtr pScreen, int num_adapt); -struct radeon_pixmap { - struct radeon_surface surface; - struct radeon_bo *bo; - - uint32_t tiling_flags; - int stride; -}; - -#if HAS_DEVPRIVATEKEYREC -extern DevPrivateKeyRec glamor_pixmap_index; -#else -extern int glamor_pixmap_index; -#endif - -static inline struct radeon_pixmap *radeon_get_pixmap_private(PixmapPtr pixmap) -{ -#if HAS_DEVPRIVATEKEYREC - return dixGetPrivate(pixmap-devPrivates, glamor_pixmap_index); -#else - return dixLookupPrivate(pixmap-devPrivates, glamor_pixmap_index); -#endif -} - -static inline void radeon_set_pixmap_private(PixmapPtr pixmap, struct radeon_pixmap *priv) -{ - dixSetPrivate(pixmap-devPrivates, glamor_pixmap_index, priv); -} - #else static inline Bool radeon_glamor_pre_init(ScrnInfoPtr scrn) { return FALSE; } diff --git a/src/radeon_kms.c b/src/radeon_kms.c index ced3594..23c0694 100644 --- a/src/radeon_kms.c +++ b/src/radeon_kms.c @@ -33,6 +33,7 @@ /* Driver data structures */ #include radeon.h #include radeon_drm_queue.h +#include radeon_glamor.h #include radeon_reg.h #include radeon_probe.h #include micmap.h diff --git a/src/radeon_video.c b/src/radeon_video.c index cbfd554..f66ba55 100644 --- a/src/radeon_video.c +++ b/src/radeon_video.c @@ -9,6 +9,7 @@ #include math.h #include radeon.h +#include radeon_glamor.h #include radeon_reg.h #include radeon_probe.h #include radeon_video.h -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati
[PATCH 11/14] Add support for the Present extension
From: Michel Dänzer michel.daen...@amd.com Signed-off-by: Michel Dänzer michel.daen...@amd.com --- configure.ac | 6 + src/Makefile.am | 4 +- src/radeon.h | 3 + src/radeon_kms.c | 2 + src/radeon_present.c | 418 +++ 5 files changed, 431 insertions(+), 2 deletions(-) create mode 100644 src/radeon_present.c diff --git a/configure.ac b/configure.ac index 891da03..7042a1e 100644 --- a/configure.ac +++ b/configure.ac @@ -131,6 +131,12 @@ AC_CHECK_DECL(xorg_list_init, #include xorg-server.h #include list.h]) +AC_CHECK_HEADERS([present.h], [], [], +[#include X11/Xmd.h +#include X11/Xproto.h +#include X11/X.h +#include xorg-server.h]) + CPPFLAGS=$SAVE_CPPFLAGS PKG_CHECK_MODULES([PCIACCESS], [pciaccess = 0.8.0]) diff --git a/src/Makefile.am b/src/Makefile.am index 9cc8a2d..629b6bf 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,8 +29,8 @@ ati_drv_la_LIBADD = $(PCIACCESS_LIBS) radeon_drv_la_LIBADD = $(LIBDRM_RADEON_LIBS) $(PCIACCESS_LIBS) -RADEON_KMS_SRCS=radeon_dri2.c radeon_drm_queue.c radeon_kms.c drmmode_display.c \ - radeon_vbo.c radeon_bo_helper.c +RADEON_KMS_SRCS=radeon_dri2.c radeon_drm_queue.c radeon_kms.c radeon_present.c \ + radeon_vbo.c radeon_bo_helper.c drmmode_display.c RADEON_EXA_SOURCES = radeon_exa.c r600_exa.c r6xx_accel.c r600_textured_videofuncs.c r600_shader.c radeon_exa_shared.c \ evergreen_exa.c evergreen_accel.c evergreen_shader.c evergreen_textured_videofuncs.c cayman_accel.c cayman_shader.c diff --git a/src/radeon.h b/src/radeon.h index e503cbb..913adf2 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -544,6 +544,9 @@ extern Bool RADEONGetDatatypeBpp(int bpp, uint32_t *type); extern Bool RADEONGetPixmapOffsetPitch(PixmapPtr pPix, uint32_t *pitch_offset); +/* radeon_present.c */ +Bool radeon_present_screen_init(ScreenPtr screen); + /* radeon_video.c */ extern void RADEONInitVideo(ScreenPtr pScreen); extern void RADEONResetVideo(ScrnInfoPtr pScrn); diff --git a/src/radeon_kms.c b/src/radeon_kms.c index d25d7f5..055d22b 100644 --- a/src/radeon_kms.c +++ b/src/radeon_kms.c @@ -1338,6 +1338,8 @@ Bool RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL) } #endif +radeon_present_screen_init(pScreen); + pScrn-vtSema = TRUE; xf86SetBackingStore(pScreen); diff --git a/src/radeon_present.c b/src/radeon_present.c new file mode 100644 index 000..148a093 --- /dev/null +++ b/src/radeon_present.c @@ -0,0 +1,418 @@ +/* + * Copyright © 2014 Intel Corporation + * Copyright © 2015 Advanced Micro Devices, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided as + * is without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include config.h +#endif + +#include xorg-server.h +#include xf86.h + +#ifdef HAVE_PRESENT_H + +#include stdio.h +#include string.h +#include assert.h +#include sys/types.h +#include sys/stat.h +#include sys/ioctl.h +#include unistd.h +#include fcntl.h +#include poll.h +#include sys/time.h +#include time.h +#include errno.h + +#include xf86_OSproc.h + +#include xf86Pci.h +#include xf86drm.h + +#include windowstr.h +#include shadow.h +#include fb.h + +#include radeon.h +#include radeon_video.h + +#include present.h + +struct radeon_present_vblank_event { +uint64_t event_id; +}; + +static uint32_t crtc_select(int crtc_id) +{ +if (crtc_id 1) + return crtc_id DRM_VBLANK_HIGH_CRTC_SHIFT; +else if (crtc_id 0) + return DRM_VBLANK_SECONDARY; +else + return 0; +} + +static RRCrtcPtr +radeon_present_get_crtc(WindowPtr window) +{ +ScreenPtr screen = window-drawable.pScreen; +ScrnInfoPtr pScrn = xf86ScreenToScrn(screen); +xf86CrtcPtr crtc; +RRCrtcPtr randr_crtc = NULL; + +crtc = radeon_pick_best_crtc
[PATCH 06/14] DRI2: Move radeon_dri2_flip_event_handler
From: Michel Dänzer michel.daen...@amd.com In preparation for the next change, which will modify it to a static function which needs to be in the new place. No functional change. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/radeon_dri2.c | 116 +++--- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c index a0eecac..a3f0776 100644 --- a/src/radeon_dri2.c +++ b/src/radeon_dri2.c @@ -613,6 +613,64 @@ xf86CrtcPtr radeon_dri2_drawable_crtc(DrawablePtr pDraw, Bool consider_disabled) return NULL; } +void radeon_dri2_flip_event_handler(unsigned int frame, unsigned int tv_sec, + unsigned int tv_usec, void *event_data) +{ +DRI2FrameEventPtr flip = event_data; +DrawablePtr drawable; +ScreenPtr screen; +ScrnInfoPtr scrn; +int status; +PixmapPtr pixmap; + +status = dixLookupDrawable(drawable, flip-drawable_id, serverClient, + M_ANY, DixWriteAccess); +if (status != Success) { + free(flip); + return; +} +if (!flip-crtc) { + free(flip); + return; +} +frame += radeon_get_interpolated_vblanks(flip-crtc); + +screen = drawable-pScreen; +scrn = xf86ScreenToScrn(screen); + +pixmap = screen-GetScreenPixmap(screen); +xf86DrvMsgVerb(scrn-scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG, + %s:%d fevent[%p] width %d pitch %d (/4 %d)\n, + __func__, __LINE__, flip, pixmap-drawable.width, pixmap-devKind, pixmap-devKind/4); + +/* We assume our flips arrive in order, so we don't check the frame */ +switch (flip-type) { +case DRI2_SWAP: + /* Check for too small vblank count of pageflip completion, taking wraparound +* into account. This usually means some defective kms pageflip completion, +* causing wrong (msc, ust) return values and possible visual corruption. +*/ + if ((frame flip-frame) (flip-frame - frame 5)) { + xf86DrvMsg(scrn-scrnIndex, X_WARNING, + %s: Pageflip completion event has impossible msc %d target_msc %d\n, + __func__, frame, flip-frame); + /* All-Zero values signal failure of (msc, ust) timestamping to client. */ + frame = tv_sec = tv_usec = 0; + } + + DRI2SwapComplete(flip-client, drawable, frame, tv_sec, tv_usec, +DRI2_FLIP_COMPLETE, flip-event_complete, +flip-event_data); + break; +default: + xf86DrvMsg(scrn-scrnIndex, X_WARNING, %s: unknown vblank event received\n, __func__); + /* Unknown type */ + break; +} + +free(flip); +} + static Bool radeon_dri2_schedule_flip(ScrnInfoPtr scrn, ClientPtr client, DrawablePtr draw, DRI2BufferPtr front, @@ -1223,64 +1281,6 @@ out_complete: return TRUE; } -void radeon_dri2_flip_event_handler(unsigned int frame, unsigned int tv_sec, - unsigned int tv_usec, void *event_data) -{ -DRI2FrameEventPtr flip = event_data; -DrawablePtr drawable; -ScreenPtr screen; -ScrnInfoPtr scrn; -int status; -PixmapPtr pixmap; - -status = dixLookupDrawable(drawable, flip-drawable_id, serverClient, - M_ANY, DixWriteAccess); -if (status != Success) { - free(flip); - return; -} -if (!flip-crtc) { - free(flip); - return; -} -frame += radeon_get_interpolated_vblanks(flip-crtc); - -screen = drawable-pScreen; -scrn = xf86ScreenToScrn(screen); - -pixmap = screen-GetScreenPixmap(screen); -xf86DrvMsgVerb(scrn-scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG, - %s:%d fevent[%p] width %d pitch %d (/4 %d)\n, - __func__, __LINE__, flip, pixmap-drawable.width, pixmap-devKind, pixmap-devKind/4); - -/* We assume our flips arrive in order, so we don't check the frame */ -switch (flip-type) { -case DRI2_SWAP: - /* Check for too small vblank count of pageflip completion, taking wraparound -* into account. This usually means some defective kms pageflip completion, -* causing wrong (msc, ust) return values and possible visual corruption. -*/ - if ((frame flip-frame) (flip-frame - frame 5)) { - xf86DrvMsg(scrn-scrnIndex, X_WARNING, - %s: Pageflip completion event has impossible msc %d target_msc %d\n, - __func__, frame, flip-frame); - /* All-Zero values signal failure of (msc, ust) timestamping to client. */ - frame = tv_sec = tv_usec = 0; - } - - DRI2SwapComplete(flip-client, drawable, frame, tv_sec, tv_usec, -DRI2_FLIP_COMPLETE, flip-event_complete, -flip-event_data); - break; -default
[PATCH] glamor: Prepare for GLAMOR_* flags being removed from xserver
From: Michel Dänzer michel.daen...@amd.com The behaviour will be the same when the flags are removed. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/radeon_glamor.c | 8 +++- src/radeon_glamor.h | 11 +++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/radeon_glamor.c b/src/radeon_glamor.c index c49c7f6..e3633ce 100644 --- a/src/radeon_glamor.c +++ b/src/radeon_glamor.c @@ -327,11 +327,9 @@ radeon_glamor_init(ScreenPtr screen) { ScrnInfoPtr scrn = xf86ScreenToScrn(screen); - if (!glamor_init(screen, GLAMOR_INVERTED_Y_AXIS | GLAMOR_USE_EGL_SCREEN | -#ifdef GLAMOR_NO_DRI3 -GLAMOR_NO_DRI3 | -#endif -GLAMOR_USE_SCREEN | GLAMOR_USE_PICTURE_SCREEN)) { + if (!glamor_init(screen, GLAMOR_USE_EGL_SCREEN | GLAMOR_USE_SCREEN | +GLAMOR_USE_PICTURE_SCREEN | GLAMOR_INVERTED_Y_AXIS | +GLAMOR_NO_DRI3)) { xf86DrvMsg(scrn-scrnIndex, X_ERROR, Failed to initialize glamor.\n); return FALSE; diff --git a/src/radeon_glamor.h b/src/radeon_glamor.h index 7cef1a9..a504acb 100644 --- a/src/radeon_glamor.h +++ b/src/radeon_glamor.h @@ -36,10 +36,21 @@ #include radeon_surface.h #ifndef GLAMOR_NO_DRI3 +#define GLAMOR_NO_DRI3 0 #define glamor_fd_from_pixmap glamor_dri3_fd_from_pixmap #define glamor_pixmap_from_fd glamor_egl_dri3_pixmap_from_fd #endif +#ifndef GLAMOR_INVERTED_Y_AXIS +#define GLAMOR_INVERTED_Y_AXIS 0 +#endif +#ifndef GLAMOR_USE_SCREEN +#define GLAMOR_USE_SCREEN 0 +#endif +#ifndef GLAMOR_USE_PICTURE_SCREEN +#define GLAMOR_USE_PICTURE_SCREEN 0 +#endif + Bool radeon_glamor_pre_init(ScrnInfoPtr scrn); Bool radeon_glamor_init(ScreenPtr screen); Bool radeon_glamor_create_screen_resources(ScreenPtr screen); -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 3/3] Move radeon_drm_handler/abort_proc fields to drmmode_flipdata_rec v2
From: Michel Dänzer michel.daen...@amd.com Their values are the same for all DRM flip ioctl calls. v2: Adapt to v2 of patch 1 Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 12 ++-- src/drmmode_display.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 74c5d1d..fd49805 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -1846,7 +1846,7 @@ drmmode_flip_abort(ScrnInfoPtr scrn, void *event_data) drmmode_flipdata_ptr flipdata = flipcarrier-flipdata; if (flipdata-flip_count == 1) - flipcarrier-abort(scrn, flipdata-event_data); + flipdata-abort(scrn, flipdata-event_data); drmmode_flip_free(flipcarrier); } @@ -1867,9 +1867,9 @@ drmmode_flip_handler(ScrnInfoPtr scrn, uint32_t frame, uint64_t usec, void *even if (flipdata-flip_count == 1) { /* Deliver cached msc, ust from reference crtc to flip event handler */ if (flipdata-event_data) - flipcarrier-handler(scrn, flipdata-fe_frame, -flipdata-fe_usec, -flipdata-event_data); + flipdata-handler(scrn, flipdata-fe_frame, + flipdata-fe_usec, + flipdata-event_data); /* Release framebuffer */ drmModeRmFB(flipdata-drmmode-fd, flipdata-old_fb_id); @@ -2326,6 +2326,8 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, flipdata-event_data = data; flipdata-drmmode = drmmode; +flipdata-handler = handler; +flipdata-abort = abort; for (i = 0; i config-num_crtc; i++) { if (!config-crtc[i]-enabled) @@ -2346,8 +2348,6 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, */ flipcarrier-dispatch_me = (drmmode_crtc-hw_id == ref_crtc_hw_id); flipcarrier-flipdata = flipdata; - flipcarrier-handler = handler; - flipcarrier-abort = abort; drm_queue = radeon_drm_queue_alloc(scrn, client, id, flipcarrier, diff --git a/src/drmmode_display.h b/src/drmmode_display.h index b3804ba..c6c076c 100644 --- a/src/drmmode_display.h +++ b/src/drmmode_display.h @@ -63,13 +63,13 @@ typedef struct { void *event_data; unsigned int fe_frame; uint64_t fe_usec; + radeon_drm_handler_proc handler; + radeon_drm_abort_proc abort; } drmmode_flipdata_rec, *drmmode_flipdata_ptr; typedef struct { drmmode_flipdata_ptr flipdata; Bool dispatch_me; - radeon_drm_handler_proc handler; - radeon_drm_abort_proc abort; } drmmode_flipevtcarrier_rec, *drmmode_flipevtcarrier_ptr; typedef struct { -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 1/3] Increase robustness against DRM page flip ioctl failures v2
From: Michel Dänzer michel.daen...@amd.com Centralize cleanup, only clean up things that have been allocated for the failed ioctl call. Fixes double-free after a flip ioctl failure. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89681 v2: Only call drmModeRmFB for flipdata-old_fb_id on receipt of last DRM page flip event. Fixes Black screen on making glxgears fullscreen with DRI3 enabled. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 46 +- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index f719f0c..35bbd9e 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -1836,9 +1836,6 @@ drmmode_flip_free(drmmode_flipevtcarrier_ptr flipcarrier) if (--flipdata-flip_count 0) return; - /* Release framebuffer */ - drmModeRmFB(flipdata-drmmode-fd, flipdata-old_fb_id); - free(flipdata); } @@ -1867,10 +1864,16 @@ drmmode_flip_handler(ScrnInfoPtr scrn, uint32_t frame, uint64_t usec, void *even flipdata-fe_usec = usec; } - /* Deliver cached msc, ust from reference crtc to flip event handler */ - if (flipdata-event_data flipdata-flip_count == 1) - flipcarrier-handler(scrn, flipdata-fe_frame, flipdata-fe_usec, -flipdata-event_data); + if (flipdata-flip_count == 1) { + /* Deliver cached msc, ust from reference crtc to flip event handler */ + if (flipdata-event_data) + flipcarrier-handler(scrn, flipdata-fe_frame, +flipdata-fe_usec, +flipdata-event_data); + + /* Release framebuffer */ + drmModeRmFB(flipdata-drmmode-fd, flipdata-old_fb_id); + } drmmode_flip_free(flipcarrier); } @@ -2276,10 +2279,10 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, unsigned int pitch; int i, old_fb_id; uint32_t tiling_flags = 0; - int height, emitted = 0; + int height; drmmode_flipdata_ptr flipdata; drmmode_flipevtcarrier_ptr flipcarrier = NULL; - struct radeon_drm_queue_entry *drm_queue = 0; + struct radeon_drm_queue_entry *drm_queue = NULL; if (info-allowColorTiling) { if (info-ChipFamily = CHIP_FAMILY_R600) @@ -2322,6 +2325,7 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, flipdata-event_data = data; flipdata-drmmode = drmmode; +flipdata-old_fb_id = old_fb_id; for (i = 0; i config-num_crtc; i++) { if (!config-crtc[i]-enabled) @@ -2334,8 +2338,6 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, if (!flipcarrier) { xf86DrvMsg(scrn-scrnIndex, X_WARNING, flip queue: carrier alloc failed.\n); - if (emitted == 0) - free(flipdata); goto error_undo; } @@ -2362,25 +2364,27 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, drm_queue)) { xf86DrvMsg(scrn-scrnIndex, X_WARNING, flip queue failed: %s\n, strerror(errno)); - free(flipcarrier); - if (emitted == 0) - free(flipdata); goto error_undo; } - emitted++; + flipcarrier = NULL; + drm_queue = NULL; } - flipdata-old_fb_id = old_fb_id; - return TRUE; + if (flipdata-flip_count 0) + return TRUE; error_undo: + if (!flipdata || flipdata-flip_count = 1) { + drmModeRmFB(drmmode-fd, drmmode-fb_id); + drmmode-fb_id = old_fb_id; + } + if (drm_queue) radeon_drm_abort_entry(drm_queue); - else + else if (flipcarrier) drmmode_flip_abort(scrn, flipcarrier); - - drmModeRmFB(drmmode-fd, drmmode-fb_id); - drmmode-fb_id = old_fb_id; + else + free(flipdata); error_out: xf86DrvMsg(scrn-scrnIndex, X_WARNING, Page flip failed: %s\n, -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 1/7] Rename scanout_pixmap_x field to prime_pixmap_x
From: Michel Dänzer michel.daen...@amd.com To avoid confusion with upcoming changes. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 6 +++--- src/drmmode_display.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index e81c6d4..db7ef95 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -560,7 +560,7 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, fb_id = drmmode-fb_id; #ifdef RADEON_PIXMAP_SHARING if (crtc-randr_crtc crtc-randr_crtc-scanout_pixmap) { - x = drmmode_crtc-scanout_pixmap_x; + x = drmmode_crtc-prime_pixmap_x; y = 0; } else #endif @@ -799,7 +799,7 @@ drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix) if (!ppix) { if (crtc-randr_crtc-scanout_pixmap) PixmapStopDirtyTracking(crtc-randr_crtc-scanout_pixmap, screenpix); - drmmode_crtc-scanout_pixmap_x = 0; + drmmode_crtc-prime_pixmap_x = 0; return TRUE; } @@ -838,7 +838,7 @@ drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix) screen-width = screenpix-drawable.width = total_width; screen-height = screenpix-drawable.height = max_height; } - drmmode_crtc-scanout_pixmap_x = this_x; + drmmode_crtc-prime_pixmap_x = this_x; #ifdef HAS_DIRTYTRACKING2 PixmapStartDirtyTracking2(ppix, screenpix, 0, 0, this_x, 0); #else diff --git a/src/drmmode_display.h b/src/drmmode_display.h index c6c076c..245588c 100644 --- a/src/drmmode_display.h +++ b/src/drmmode_display.h @@ -85,7 +85,7 @@ typedef struct { int dpms_last_fps; uint32_t interpolated_vblanks; uint16_t lut_r[256], lut_g[256], lut_b[256]; -int scanout_pixmap_x; +int prime_pixmap_x; } drmmode_crtc_private_rec, *drmmode_crtc_private_ptr; typedef struct { -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 4/7] glamor: Remove unused function radeon_glamor_pixmap_is_offscreen
From: Michel Dänzer michel.daen...@amd.com Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/radeon_glamor.c | 6 -- src/radeon_glamor.h | 4 2 files changed, 10 deletions(-) diff --git a/src/radeon_glamor.c b/src/radeon_glamor.c index e3633ce..46148ad 100644 --- a/src/radeon_glamor.c +++ b/src/radeon_glamor.c @@ -170,12 +170,6 @@ radeon_glamor_create_textured_pixmap(PixmapPtr pixmap) return FALSE; } -Bool radeon_glamor_pixmap_is_offscreen(PixmapPtr pixmap) -{ - struct radeon_pixmap *priv = radeon_get_pixmap_private(pixmap); - return priv priv-bo; -} - #ifndef CREATE_PIXMAP_USAGE_SHARED #define CREATE_PIXMAP_USAGE_SHARED RADEON_CREATE_PIXMAP_DRI2 #endif diff --git a/src/radeon_glamor.h b/src/radeon_glamor.h index a504acb..e766bcc 100644 --- a/src/radeon_glamor.h +++ b/src/radeon_glamor.h @@ -59,8 +59,6 @@ void radeon_glamor_free_screen(int scrnIndex, int flags); Bool radeon_glamor_create_textured_pixmap(PixmapPtr pixmap); void radeon_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst); -Bool radeon_glamor_pixmap_is_offscreen(PixmapPtr pixmap); - XF86VideoAdaptorPtr radeon_glamor_xv_init(ScreenPtr pScreen, int num_adapt); #else @@ -74,8 +72,6 @@ static inline Bool radeon_glamor_create_textured_pixmap(PixmapPtr pixmap) { retu static inline void radeon_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst) {} -static inline Bool radeon_glamor_pixmap_is_offscreen(PixmapPtr pixmap) { return FALSE; } - static inline struct radeon_pixmap *radeon_get_pixmap_private(PixmapPtr pixmap) { return NULL; } static inline XF86VideoAdaptorPtr radeon_glamor_xv_init(ScreenPtr pScreen, int num_adapt) { return NULL; } -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 2/7] Split out struct drmmode_scanout for rotation shadow buffer information
From: Michel Dänzer michel.daen...@amd.com Will be used for other kinds of dedicated scanout buffers as well. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 170 +- src/drmmode_display.h | 9 ++- src/radeon_present.c | 2 +- 3 files changed, 107 insertions(+), 74 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index db7ef95..e8ae58d 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -468,6 +468,98 @@ fallback: radeon_bo_unmap(info-front_bo); } +static void +drmmode_crtc_scanout_destroy(drmmode_ptr drmmode, +struct drmmode_scanout *scanout) +{ + if (scanout-pixmap) { + drmmode_destroy_bo_pixmap(scanout-pixmap); + scanout-pixmap = NULL; + } + + if (scanout-bo) { + drmModeRmFB(drmmode-fd, scanout-fb_id); + scanout-fb_id = 0; + radeon_bo_unmap(scanout-bo); + radeon_bo_unref(scanout-bo); + scanout-bo = NULL; + } + +} + +static void * +drmmode_crtc_scanout_allocate(xf86CrtcPtr crtc, + struct drmmode_scanout *scanout, + int width, int height) +{ + ScrnInfoPtr pScrn = crtc-scrn; + RADEONInfoPtr info = RADEONPTR(pScrn); + drmmode_crtc_private_ptr drmmode_crtc = crtc-driver_private; + drmmode_ptr drmmode = drmmode_crtc-drmmode; + int size; + int ret; + unsigned long rotate_pitch; + int base_align; + + /* rotation requires acceleration */ + if (info-r600_shadow_fb) { + xf86DrvMsg(pScrn-scrnIndex, X_ERROR, + Rotation requires acceleration!\n); + return NULL; + } + + rotate_pitch = + RADEON_ALIGN(width, drmmode_get_pitch_align(pScrn, drmmode-cpp, 0)) + * drmmode-cpp; + height = RADEON_ALIGN(height, drmmode_get_height_align(pScrn, 0)); + base_align = drmmode_get_base_align(pScrn, drmmode-cpp, 0); + size = RADEON_ALIGN(rotate_pitch * height, RADEON_GPU_PAGE_SIZE); + + scanout-bo = radeon_bo_open(drmmode-bufmgr, 0, size, base_align, +RADEON_GEM_DOMAIN_VRAM, 0); + if (scanout-bo == NULL) + return NULL; + + radeon_bo_map(scanout-bo, 1); + + ret = drmModeAddFB(drmmode-fd, width, height, pScrn-depth, + pScrn-bitsPerPixel, rotate_pitch, + scanout-bo-handle, + scanout-fb_id); + if (ret) + ErrorF(failed to add scanout fb\n); + + return scanout-bo-ptr; +} + +static PixmapPtr +drmmode_crtc_scanout_create(xf86CrtcPtr crtc, struct drmmode_scanout *scanout, + void *data, int width, int height) +{ + ScrnInfoPtr pScrn = crtc-scrn; + drmmode_crtc_private_ptr drmmode_crtc = crtc-driver_private; + drmmode_ptr drmmode = drmmode_crtc-drmmode; + unsigned long rotate_pitch; + + if (!data) + data = drmmode_crtc_scanout_allocate(crtc, scanout, width, height); + + rotate_pitch = RADEON_ALIGN(width, drmmode_get_pitch_align(pScrn, drmmode-cpp, 0)) + * drmmode-cpp; + + scanout-pixmap = drmmode_create_bo_pixmap(pScrn, +width, height, +pScrn-depth, +pScrn-bitsPerPixel, +rotate_pitch, +0, scanout-bo, NULL); + if (scanout-pixmap == NULL) + xf86DrvMsg(pScrn-scrnIndex, X_ERROR, + Couldn't allocate scanout pixmap for CRTC\n); + + return scanout-pixmap; +} + static Bool drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, Rotation rotation, int x, int y) @@ -564,8 +656,8 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, y = 0; } else #endif - if (drmmode_crtc-rotate_fb_id) { - fb_id = drmmode_crtc-rotate_fb_id; + if (drmmode_crtc-rotate.fb_id) { + fb_id = drmmode_crtc-rotate.fb_id; x = y = 0; } ret = drmModeSetCrtc(drmmode-fd, drmmode_crtc-mode_crtc-crtc_id, @@ -687,73 +779,19 @@ drmmode_show_cursor (xf86CrtcPtr crtc) static void * drmmode_crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height) { - ScrnInfoPtr pScrn = crtc-scrn; - RADEONInfoPtr info = RADEONPTR(pScrn); drmmode_crtc_private_ptr drmmode_crtc = crtc-driver_private; - drmmode_ptr drmmode = drmmode_crtc-drmmode; - int size; - struct radeon_bo *rotate_bo; - int ret
[PATCH 3/7] Add RADEON_CREATE_PIXMAP_SCANOUT flag
From: Michel Dänzer michel.daen...@amd.com It means that the pixmap is used for scanout exclusively. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 3 ++- src/radeon.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index e8ae58d..e68f17e 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -98,7 +98,8 @@ static PixmapPtr drmmode_create_bo_pixmap(ScrnInfoPtr pScrn, PixmapPtr pixmap; struct radeon_surface *surface; - pixmap = (*pScreen-CreatePixmap)(pScreen, 0, 0, depth, 0); + pixmap = (*pScreen-CreatePixmap)(pScreen, 0, 0, depth, + RADEON_CREATE_PIXMAP_SCANOUT); if (!pixmap) return NULL; diff --git a/src/radeon.h b/src/radeon.h index 00d0495..83b462b 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -838,6 +838,7 @@ static __inline__ void RADEON_SYNC(RADEONInfoPtr info, ScrnInfoPtr pScrn) } enum { +RADEON_CREATE_PIXMAP_SCANOUT = 0x0200, RADEON_CREATE_PIXMAP_DRI2 = 0x0400, RADEON_CREATE_PIXMAP_TILING_MICRO_SQUARE = 0x0800, RADEON_CREATE_PIXMAP_TILING_MACRO = 0x1000, -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 7/7] glamor: Add Option ShadowPrimary
From: Michel Dänzer michel.daen...@amd.com When this option is enabled, most pixmaps (including the screen pixmap) are allocated in system RAM and mostly accessed by the CPU. Changed areas of the screen pixmap are copied to dedicated per-CRTC scanout pixmaps regularly, triggered by the vblank interrupt. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- configure.ac | 10 +++ man/radeon.man | 16 + src/drmmode_display.c | 86 +++- src/drmmode_display.h | 6 ++ src/radeon.h | 2 + src/radeon_bo_helper.c | 7 +- src/radeon_dri3.c | 15 - src/radeon_glamor.c| 60 ++--- src/radeon_glamor.h| 10 +++ src/radeon_kms.c | 179 +++-- 10 files changed, 369 insertions(+), 22 deletions(-) diff --git a/configure.ac b/configure.ac index 57b4c1c..4ca5352 100644 --- a/configure.ac +++ b/configure.ac @@ -125,6 +125,16 @@ else fi AM_CONDITIONAL(GLAMOR, test x$GLAMOR != xno) +AC_CHECK_DECL(fbGlyphs, + [AC_DEFINE(HAVE_FBGLYPHS, 1, [Have fbGlyphs API])], [], + [#include X11/Xmd.h + #include X11/Xfuncproto.h + #include X11/extensions/renderproto.h + #include xorg-server.h + #include picture.h + #include glyphstr.h + #include fbpict.h]) + AC_CHECK_DECL(xorg_list_init, [AC_DEFINE(HAVE_XORG_LIST, 1, [Have xorg_list API])], [], [#include X11/Xdefs.h diff --git a/man/radeon.man b/man/radeon.man index 6e46f89..2703773 100644 --- a/man/radeon.man +++ b/man/radeon.man @@ -290,6 +290,22 @@ as of TAHITI, otherwise The following driver .B Options are supported for +.B glamor +: +.TP +.BI Option \*qShadowPrimary\*q \*q boolean \*q +This option enables a so-called shadow primary buffer for fast CPU access to +pixel data, and separate scanout buffers for each display controller (CRTC). +This may improve performance for some 2D workloads, potentially at the expense +of other (e.g. 3D, video) workloads. +Note in particular that enabling this option currently disables page flipping. +The default is +.B off. + +.PP +The following driver +.B Options +are supported for .B EXA : .TP diff --git a/src/drmmode_display.c b/src/drmmode_display.c index d8d3ca3..efe82bd 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -33,6 +33,7 @@ #include sys/ioctl.h #include time.h #include cursorstr.h +#include damagestr.h #include micmap.h #include xf86cmap.h #include radeon.h @@ -489,6 +490,26 @@ drmmode_crtc_scanout_destroy(drmmode_ptr drmmode, } +void +drmmode_scanout_free(ScrnInfoPtr scrn) +{ + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); + int c; + + for (c = 0; c xf86_config-num_crtc; c++) { + drmmode_crtc_private_ptr drmmode_crtc = + xf86_config-crtc[c]-driver_private; + + drmmode_crtc_scanout_destroy(drmmode_crtc-drmmode, +drmmode_crtc-scanout); + + if (drmmode_crtc-scanout_damage) { + DamageDestroy(drmmode_crtc-scanout_damage); + drmmode_crtc-scanout_damage = NULL; + } + } +} + static void * drmmode_crtc_scanout_allocate(xf86CrtcPtr crtc, struct drmmode_scanout *scanout, @@ -510,6 +531,13 @@ drmmode_crtc_scanout_allocate(xf86CrtcPtr crtc, return NULL; } + if (scanout-bo) { + if (scanout-width == width scanout-height == height) + return scanout-bo-ptr; + + drmmode_crtc_scanout_destroy(drmmode, scanout); + } + rotate_pitch = RADEON_ALIGN(width, drmmode_get_pitch_align(pScrn, drmmode-cpp, 0)) * drmmode-cpp; @@ -531,6 +559,8 @@ drmmode_crtc_scanout_allocate(xf86CrtcPtr crtc, if (ret) ErrorF(failed to add scanout fb\n); + scanout-width = width; + scanout-height = height; return scanout-bo-ptr; } @@ -543,6 +573,13 @@ drmmode_crtc_scanout_create(xf86CrtcPtr crtc, struct drmmode_scanout *scanout, drmmode_ptr drmmode = drmmode_crtc-drmmode; unsigned long rotate_pitch; + if (scanout-pixmap) { + if (scanout-width == width scanout-height == height) + return scanout-pixmap; + + drmmode_crtc_scanout_destroy(drmmode, scanout); + } + if (!data) data = drmmode_crtc_scanout_allocate(crtc, scanout, width, height); @@ -562,6 +599,13 @@ drmmode_crtc_scanout_create(xf86CrtcPtr crtc, struct drmmode_scanout *scanout, return scanout-pixmap; } +static void +radeon_screen_damage_report(DamagePtr damage, RegionPtr region, void *closure) +{ + /* Only keep track of the extents */ + RegionUninit(damage-damage); +} + static Bool
[PATCH 0/7] glamor: Option ShadowPrimary
The first six patches are in preparation for the last patch which adds the new xorg.conf option. It's intended to give better 2D performance in some cases, but currently has some drawbacks, which I'm hoping to address in the future: * Doesn't support page flipping. Enabling ShadowPrimary disables page flipping. * While there should be less tearing in general than without the option, there is still some tearing (which may be more noticeable, because it's more constant), in particular in the upper right corner of each monitor. These changes are also available on the master branch of git://people.freedesktop.org/~daenzer/xf86-video-ati . [PATCH 1/7] Rename scanout_pixmap_x field to prime_pixmap_x [PATCH 2/7] Split out struct drmmode_scanout for rotation shadow [PATCH 3/7] Add RADEON_CREATE_PIXMAP_SCANOUT flag [PATCH 4/7] glamor: Remove unused function [PATCH 5/7] glamor: Add radeon_pixmap parameter to [PATCH 6/7] glamor: Add wrappers for the X server rendering hooks [PATCH 7/7] glamor: Add Option ShadowPrimary ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 5/7] glamor: Add radeon_pixmap parameter to radeon_glamor_create_textured_pixmap
From: Michel Dänzer michel.daen...@amd.com Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 3 ++- src/radeon_glamor.c | 16 ++-- src/radeon_glamor.h | 6 -- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index e68f17e..d8d3ca3 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -149,7 +149,8 @@ static PixmapPtr drmmode_create_bo_pixmap(ScrnInfoPtr pScrn, } } - if (!radeon_glamor_create_textured_pixmap(pixmap)) { + if (!radeon_glamor_create_textured_pixmap(pixmap, + radeon_get_pixmap_private(pixmap))) { pScreen-DestroyPixmap(pixmap); return NULL; } diff --git a/src/radeon_glamor.c b/src/radeon_glamor.c index 46148ad..74d9584 100644 --- a/src/radeon_glamor.c +++ b/src/radeon_glamor.c @@ -151,23 +151,19 @@ radeon_glamor_pre_init(ScrnInfoPtr scrn) } Bool -radeon_glamor_create_textured_pixmap(PixmapPtr pixmap) +radeon_glamor_create_textured_pixmap(PixmapPtr pixmap, struct radeon_pixmap *priv) { ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap-drawable.pScreen); RADEONInfoPtr info = RADEONPTR(scrn); - struct radeon_pixmap *priv; if ((info-use_glamor) == 0) return TRUE; - priv = radeon_get_pixmap_private(pixmap); if (!priv-stride) priv-stride = pixmap-devKind; - if (glamor_egl_create_textured_pixmap(pixmap, priv-bo-handle, - priv-stride)) - return TRUE; - else - return FALSE; + + return glamor_egl_create_textured_pixmap(pixmap, priv-bo-handle, +priv-stride); } #ifndef CREATE_PIXMAP_USAGE_SHARED @@ -222,7 +218,7 @@ radeon_glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth, screen-ModifyPixmapHeader(pixmap, w, h, 0, 0, priv-stride, NULL); - if (!radeon_glamor_create_textured_pixmap(pixmap)) + if (!radeon_glamor_create_textured_pixmap(pixmap, priv)) goto fallback_glamor; } @@ -298,7 +294,7 @@ radeon_glamor_set_shared_pixmap_backing(PixmapPtr pixmap, void *handle) priv-stride = pixmap-devKind; priv-surface = surface; - if (!radeon_glamor_create_textured_pixmap(pixmap)) { + if (!radeon_glamor_create_textured_pixmap(pixmap, priv)) { xf86DrvMsg(scrn-scrnIndex, X_ERROR, Failed to get PRIME drawable for glamor pixmap.\n); return FALSE; diff --git a/src/radeon_glamor.h b/src/radeon_glamor.h index e766bcc..8010b4a 100644 --- a/src/radeon_glamor.h +++ b/src/radeon_glamor.h @@ -51,12 +51,14 @@ #define GLAMOR_USE_PICTURE_SCREEN 0 #endif +struct radeon_pixmap; + Bool radeon_glamor_pre_init(ScrnInfoPtr scrn); Bool radeon_glamor_init(ScreenPtr screen); Bool radeon_glamor_create_screen_resources(ScreenPtr screen); void radeon_glamor_free_screen(int scrnIndex, int flags); -Bool radeon_glamor_create_textured_pixmap(PixmapPtr pixmap); +Bool radeon_glamor_create_textured_pixmap(PixmapPtr pixmap, struct radeon_pixmap *priv); void radeon_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst); XF86VideoAdaptorPtr radeon_glamor_xv_init(ScreenPtr pScreen, int num_adapt); @@ -68,7 +70,7 @@ static inline Bool radeon_glamor_init(ScreenPtr screen) { return FALSE; } static inline Bool radeon_glamor_create_screen_resources(ScreenPtr screen) { return FALSE; } static inline void radeon_glamor_free_screen(int scrnIndex, int flags) { } -static inline Bool radeon_glamor_create_textured_pixmap(PixmapPtr pixmap) { return TRUE; } +static inline Bool radeon_glamor_create_textured_pixmap(PixmapPtr pixmap, struct radeon_pixmap *priv) { return TRUE; } static inline void radeon_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst) {} -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 6/7] glamor: Add wrappers for the X server rendering hooks
From: Michel Dänzer michel.daen...@amd.com They can choose between using the GPU or CPU for the operation. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/Makefile.am | 1 + src/radeon.h | 30 ++ src/radeon_glamor.h | 1 + src/radeon_glamor_wrappers.c | 985 +++ src/radeon_kms.c | 1 + 5 files changed, 1018 insertions(+) create mode 100644 src/radeon_glamor_wrappers.c diff --git a/src/Makefile.am b/src/Makefile.am index 697c08c..a5c4bc2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -65,6 +65,7 @@ if GLAMOR AM_CFLAGS += @LIBGLAMOR_CFLAGS@ radeon_drv_la_LIBADD += @LIBGLAMOR_LIBS@ radeon_drv_la_SOURCES += \ +radeon_glamor_wrappers.c \ radeon_glamor.c endif diff --git a/src/radeon.h b/src/radeon.h index 83b462b..80adc5d 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -248,6 +248,10 @@ typedef enum { struct radeon_pixmap { struct radeon_surface surface; + + uint_fast32_t gpu_read; + uint_fast32_t gpu_write; + struct radeon_bo *bo; uint32_t tiling_flags; @@ -467,6 +471,8 @@ typedef struct { Bool RenderAccel; /* Render */ Bool allowColorTiling; Bool allowColorTiling2D; +uint_fast32_t gpu_flushed; +uint_fast32_t gpu_synced; struct radeon_accel_state *accel_state; Bool accelOn; Bool use_glamor; @@ -525,6 +531,30 @@ typedef struct { /* cursor size */ int cursor_w; int cursor_h; + +#ifdef USE_GLAMOR +struct { + CreateGCProcPtr SavedCreateGC; + RegionPtr (*SavedCopyArea)(DrawablePtr, DrawablePtr, GCPtr, int, int, + int, int, int, int); + CloseScreenProcPtr SavedCloseScreen; + GetImageProcPtr SavedGetImage; + GetSpansProcPtr SavedGetSpans; + CreatePixmapProcPtr SavedCreatePixmap; + DestroyPixmapProcPtr SavedDestroyPixmap; + CopyWindowProcPtr SavedCopyWindow; + ChangeWindowAttributesProcPtr SavedChangeWindowAttributes; + BitmapToRegionProcPtr SavedBitmapToRegion; +#ifdef RENDER + CompositeProcPtr SavedComposite; + TrianglesProcPtr SavedTriangles; + GlyphsProcPtr SavedGlyphs; + TrapezoidsProcPtr SavedTrapezoids; + AddTrapsProcPtr SavedAddTraps; + UnrealizeGlyphProcPtr SavedUnrealizeGlyph; +#endif +} glamor; +#endif /* USE_GLAMOR */ } RADEONInfoRec, *RADEONInfoPtr; /* radeon_accel.c */ diff --git a/src/radeon_glamor.h b/src/radeon_glamor.h index 8010b4a..ea385c7 100644 --- a/src/radeon_glamor.h +++ b/src/radeon_glamor.h @@ -55,6 +55,7 @@ struct radeon_pixmap; Bool radeon_glamor_pre_init(ScrnInfoPtr scrn); Bool radeon_glamor_init(ScreenPtr screen); +void radeon_glamor_screen_init(ScreenPtr screen); Bool radeon_glamor_create_screen_resources(ScreenPtr screen); void radeon_glamor_free_screen(int scrnIndex, int flags); diff --git a/src/radeon_glamor_wrappers.c b/src/radeon_glamor_wrappers.c new file mode 100644 index 000..db2e85f --- /dev/null +++ b/src/radeon_glamor_wrappers.c @@ -0,0 +1,985 @@ +/* + * Copyright � 2001 Keith Packard + * 2010 Intel Corporation + * 2012,2015 Advanced Micro Devices, Inc. + * + * Partly based on code Copyright � 2008 Red Hat, Inc. + * Partly based on code Copyright � 2000 SuSE, Inc. + * + * Partly based on code that is Copyright � The XFree86 Project Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the opyright holders not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The copyright holders make no + * representations about the suitability of this software for any purpose. It + * is provided as is without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifdef HAVE_CONFIG_H +#include config.h +#endif + +#ifdef USE_GLAMOR + +#include radeon.h +#include radeon_glamor.h + + +/** + * get_drawable_pixmap() returns the backing pixmap for a given drawable. + * + * @param pDrawable the drawable being requested. + * + * This function returns the backing pixmap
[PATCH 1/2] Move get_pixmap_handle helper to radeon_bo_helper.c
From: Michel Dänzer michel.daen...@amd.com No functional change. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/radeon_bo_helper.c | 49 ++ src/radeon_bo_helper.h | 3 +++ src/radeon_present.c | 53 +++--- 3 files changed, 55 insertions(+), 50 deletions(-) diff --git a/src/radeon_bo_helper.c b/src/radeon_bo_helper.c index c3a2d63..f45aa76 100644 --- a/src/radeon_bo_helper.c +++ b/src/radeon_bo_helper.c @@ -25,6 +25,7 @@ #endif #include radeon.h +#include radeon_glamor.h #ifdef RADEON_PIXMAP_SHARING #include radeon_bo_gem.h @@ -187,6 +188,54 @@ radeon_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width, int height, int depth, return bo; } +/* Get GEM handle for the pixmap */ +Bool radeon_get_pixmap_handle(PixmapPtr pixmap, uint32_t *handle) +{ +struct radeon_bo *bo = radeon_get_pixmap_bo(pixmap); +#ifdef USE_GLAMOR +ScreenPtr screen = pixmap-drawable.pScreen; +RADEONInfoPtr info = RADEONPTR(xf86ScreenToScrn(screen)); +#endif + +if (bo) { + *handle = bo-handle; + return TRUE; +} + +#ifdef USE_GLAMOR +if (info-use_glamor) { + struct radeon_pixmap *priv = radeon_get_pixmap_private(pixmap); + CARD16 stride; + CARD32 size; + int fd, r; + + if (!priv) { + priv = calloc(1, sizeof(*priv)); + radeon_set_pixmap_private(pixmap, priv); + } + + if (priv-handle_valid) { + *handle = priv-handle; + return TRUE; + } + + fd = glamor_fd_from_pixmap(screen, pixmap, stride, size); + if (fd 0) + return FALSE; + + r = drmPrimeFDToHandle(info-dri2.drm_fd, fd, priv-handle); + close(fd); + if (r == 0) { + priv-handle_valid = TRUE; + *handle = priv-handle; + return TRUE; + } +} +#endif + +return FALSE; +} + #ifdef RADEON_PIXMAP_SHARING Bool radeon_share_pixmap_backing(struct radeon_bo *bo, void **handle_p) diff --git a/src/radeon_bo_helper.h b/src/radeon_bo_helper.h index 9c3d73f..89ad4be 100644 --- a/src/radeon_bo_helper.h +++ b/src/radeon_bo_helper.h @@ -29,6 +29,9 @@ radeon_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width, int height, int depth, struct radeon_surface *new_surface, uint32_t *new_tiling); extern Bool +radeon_get_pixmap_handle(PixmapPtr pixmap, uint32_t *handle); + +extern Bool radeon_share_pixmap_backing(struct radeon_bo *bo, void **handle_p); extern Bool diff --git a/src/radeon_present.c b/src/radeon_present.c index 711b45d..b402110 100644 --- a/src/radeon_present.c +++ b/src/radeon_present.c @@ -42,6 +42,7 @@ #include time.h #include errno.h +#include radeon_bo_helper.h #include radeon_glamor.h #include radeon_video.h @@ -217,54 +218,6 @@ get_drmmode_crtc(ScrnInfoPtr scrn, RRCrtcPtr crtc) return NULL; } -static Bool -radeon_present_get_pixmap_handle(PixmapPtr pixmap, uint32_t *handle) -{ -struct radeon_bo *bo = radeon_get_pixmap_bo(pixmap); -#ifdef USE_GLAMOR -ScreenPtr screen = pixmap-drawable.pScreen; -RADEONInfoPtr info = RADEONPTR(xf86ScreenToScrn(screen)); -#endif - -if (bo) { - *handle = bo-handle; - return TRUE; -} - -#ifdef USE_GLAMOR -if (info-use_glamor) { - struct radeon_pixmap *priv = radeon_get_pixmap_private(pixmap); - CARD16 stride; - CARD32 size; - int fd, r; - - if (!priv) { - priv = calloc(1, sizeof(*priv)); - radeon_set_pixmap_private(pixmap, priv); - } - - if (priv-handle_valid) { - *handle = priv-handle; - return TRUE; - } - - fd = glamor_fd_from_pixmap(screen, pixmap, stride, size); - if (fd 0) - return FALSE; - - r = drmPrimeFDToHandle(info-dri2.drm_fd, fd, priv-handle); - close(fd); - if (r == 0) { - priv-handle_valid = TRUE; - *handle = priv-handle; - return TRUE; - } -} -#endif - -return FALSE; -} - /* * Test to see if page flipping is possible on the target crtc */ @@ -340,7 +293,7 @@ radeon_present_flip(RRCrtcPtr crtc, uint64_t event_id, uint64_t target_msc, if (!radeon_present_check_flip(crtc, screen-root, pixmap, sync_flip)) return FALSE; -if (!radeon_present_get_pixmap_handle(pixmap, handle)) +if (!radeon_get_pixmap_handle(pixmap, handle)) return FALSE; event = calloc(1, sizeof(struct radeon_present_vblank_event)); @@ -374,7 +327,7 @@ radeon_present_unflip(ScreenPtr screen, uint64_t event_id) if (!radeon_present_check_flip(NULL, screen-root, pixmap, TRUE)) return; -if (!radeon_present_get_pixmap_handle(pixmap, handle)) +if (!radeon_get_pixmap_handle(pixmap, handle)) return; event = calloc(1, sizeof(struct radeon_present_vblank_event)); -- 2.1.4 ___ xorg-driver-ati mailing list xorg
[PATCH 2/2] DRI2: Use radeon_get_pixmap_handle
From: Michel Dänzer michel.daen...@amd.com Now we can share pixmaps with no struct radeon_bo via DRI2. Fixes VDPAU video playback freezing when using an OpenGL compositor with DRI3 enabled. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89755 Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/radeon_dri2.c | 35 ++- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c index 2636456..edf643d 100644 --- a/src/radeon_dri2.c +++ b/src/radeon_dri2.c @@ -40,6 +40,7 @@ #include fcntl.h #include errno.h +#include radeon_bo_helper.h #include radeon_version.h #include radeon_list.h @@ -125,6 +126,26 @@ static PixmapPtr fixup_glamor(DrawablePtr drawable, PixmapPtr pixmap) return old; } +/* Get GEM flink name for a pixmap */ +static Bool +radeon_get_flink_name(RADEONInfoPtr info, PixmapPtr pixmap, uint32_t *name) +{ +struct radeon_bo *bo = radeon_get_pixmap_bo(pixmap); +struct drm_gem_flink flink; + +if (bo) + return radeon_gem_get_kernel_name(bo, name) == 0; + +if (radeon_get_pixmap_handle(pixmap, flink.handle)) { + if (drmIoctl(info-dri2.drm_fd, DRM_IOCTL_GEM_FLINK, flink) != 0) + return FALSE; + + *name = flink.name; + return TRUE; +} + +return FALSE; +} static BufferPtr radeon_dri2_create_buffer2(ScreenPtr pScreen, @@ -137,7 +158,6 @@ radeon_dri2_create_buffer2(ScreenPtr pScreen, BufferPtr buffers; struct dri2_buffer_priv *privates; PixmapPtr pixmap, depth_pixmap; -struct radeon_bo *bo; int flags; unsigned front_width; uint32_t tiling = 0; @@ -171,10 +191,12 @@ radeon_dri2_create_buffer2(ScreenPtr pScreen, pixmap = depth_pixmap = NULL; if (attachment == DRI2BufferFrontLeft) { + uint32_t handle; + pixmap = get_drawable_pixmap(drawable); if (pScreen != pixmap-drawable.pScreen) pixmap = NULL; - else if (info-use_glamor !radeon_get_pixmap_bo(pixmap)) { + else if (info-use_glamor !radeon_get_pixmap_handle(pixmap, handle)) { is_glamor_pixmap = TRUE; aligned_width = pixmap-drawable.width; height = pixmap-drawable.height; @@ -285,8 +307,7 @@ radeon_dri2_create_buffer2(ScreenPtr pScreen, if (is_glamor_pixmap) pixmap = fixup_glamor(drawable, pixmap); - bo = radeon_get_pixmap_bo(pixmap); - if (!bo || radeon_gem_get_kernel_name(bo, buffers-name) != 0) + if (!radeon_get_flink_name(info, pixmap, buffers-name)) goto error; } @@ -657,20 +678,16 @@ radeon_dri2_schedule_flip(ScrnInfoPtr scrn, ClientPtr client, static Bool update_front(DrawablePtr draw, DRI2BufferPtr front) { -int r; PixmapPtr pixmap; RADEONInfoPtr info = RADEONPTR(xf86ScreenToScrn(draw-pScreen)); struct dri2_buffer_priv *priv = front-driverPrivate; -struct radeon_bo *bo; pixmap = get_drawable_pixmap(draw); pixmap-refcnt++; if (!info-use_glamor) exaMoveInPixmap(pixmap); -bo = radeon_get_pixmap_bo(pixmap); -r = radeon_gem_get_kernel_name(bo, front-name); -if (r) { +if (!radeon_get_flink_name(info, pixmap, front-name)) { (*draw-pScreen-DestroyPixmap)(pixmap); return FALSE; } -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
Bug#766922: xserver-xorg-video-radeon: resume from suspend/hibernate results in blank screen kernel 3.16
On 21.02.2015 05:53, Jonas Smedegaard wrote: Hi, Should this perhaps be reassigned to the linux kernel, since it seems tied to changes in kernel rather than in Xorg code? Indeed. -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
Bug#779262: xserver-xorg-video-radeon: Low performance and stuck system reproducing videos with Flash in Iceweasel using EXA Accel mode
On 26.02.2015 11:58, Jose Maldonado wrote: Package: xserver-xorg-video-radeon Version: 1:7.5.0-1 Severity: important Tags: upstream Dear Maintainer, Well, I have two little and strange problems with xserver-xorg-video-radeon, in this case using EXA Accel mode and Iceweasel and flashplugin. Chromium and pepperflashplugin without problem. The first case is this: 1.- Open Iceweasel and go to watch any video using Flash player (YouTube, Nowvideo, Vk, Crunchyroll) 2.- Reproduce any video in windows mode. Results: Low performance reproducing video, the frame drops in video is awesome. In HTML5 the videos go without issues. The second case is this: 1.- Open Iceweasel and go to watch any video using Flash (YouTube, Nowvideo, Vk, Crunchyroll) 2.- Reproduce the video in fullscreen mode. 3.- Wait a 5 minutes and Kabooom! Do you have the mesa-vdpau-drivers package installed and video decoding acceleration enabled in flashplugin? If so, does disabling that avoid the problems? -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 3/3] Move radeon_drm_handler/abort_proc fields to drmmode_flipdata_rec
From: Michel Dänzer michel.daen...@amd.com Their values are the same for all DRM flip ioctl calls. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 10 +- src/drmmode_display.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index bd1ab76..be02a8b 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -1846,7 +1846,7 @@ drmmode_flip_abort(ScrnInfoPtr scrn, void *event_data) drmmode_flipdata_ptr flipdata = flipcarrier-flipdata; if (flipdata-flip_count == 1) - flipcarrier-abort(scrn, flipdata-event_data); + flipdata-abort(scrn, flipdata-event_data); drmmode_flip_free(flipcarrier); } @@ -1866,8 +1866,8 @@ drmmode_flip_handler(ScrnInfoPtr scrn, uint32_t frame, uint64_t usec, void *even /* Deliver cached msc, ust from reference crtc to flip event handler */ if (flipdata-event_data flipdata-flip_count == 1) - flipcarrier-handler(scrn, flipdata-fe_frame, flipdata-fe_usec, -flipdata-event_data); + flipdata-handler(scrn, flipdata-fe_frame, flipdata-fe_usec, + flipdata-event_data); /* Release framebuffer */ drmModeRmFB(flipdata-drmmode-fd, flipdata-old_fb_id); @@ -2323,6 +2323,8 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, flipdata-event_data = data; flipdata-drmmode = drmmode; +flipdata-handler = handler; +flipdata-abort = abort; for (i = 0; i config-num_crtc; i++) { if (!config-crtc[i]-enabled) @@ -2343,8 +2345,6 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, */ flipcarrier-dispatch_me = (drmmode_crtc-hw_id == ref_crtc_hw_id); flipcarrier-flipdata = flipdata; - flipcarrier-handler = handler; - flipcarrier-abort = abort; drm_queue = radeon_drm_queue_alloc(scrn, client, id, flipcarrier, diff --git a/src/drmmode_display.h b/src/drmmode_display.h index b3804ba..c6c076c 100644 --- a/src/drmmode_display.h +++ b/src/drmmode_display.h @@ -63,13 +63,13 @@ typedef struct { void *event_data; unsigned int fe_frame; uint64_t fe_usec; + radeon_drm_handler_proc handler; + radeon_drm_abort_proc abort; } drmmode_flipdata_rec, *drmmode_flipdata_ptr; typedef struct { drmmode_flipdata_ptr flipdata; Bool dispatch_me; - radeon_drm_handler_proc handler; - radeon_drm_abort_proc abort; } drmmode_flipevtcarrier_rec, *drmmode_flipevtcarrier_ptr; typedef struct { -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 1/3] Increase robustness against DRM page flip ioctl failures
From: Michel Dänzer michel.daen...@amd.com Centralize cleanup, only clean up things that have been allocated for the failed ioctl call. Fixes double-free after a flip ioctl failure. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89681 Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 35 ++- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index f719f0c..b8aaf64 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -1836,9 +1836,6 @@ drmmode_flip_free(drmmode_flipevtcarrier_ptr flipcarrier) if (--flipdata-flip_count 0) return; - /* Release framebuffer */ - drmModeRmFB(flipdata-drmmode-fd, flipdata-old_fb_id); - free(flipdata); } @@ -1872,6 +1869,9 @@ drmmode_flip_handler(ScrnInfoPtr scrn, uint32_t frame, uint64_t usec, void *even flipcarrier-handler(scrn, flipdata-fe_frame, flipdata-fe_usec, flipdata-event_data); + /* Release framebuffer */ + drmModeRmFB(flipdata-drmmode-fd, flipdata-old_fb_id); + drmmode_flip_free(flipcarrier); } @@ -2276,10 +2276,10 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, unsigned int pitch; int i, old_fb_id; uint32_t tiling_flags = 0; - int height, emitted = 0; + int height; drmmode_flipdata_ptr flipdata; drmmode_flipevtcarrier_ptr flipcarrier = NULL; - struct radeon_drm_queue_entry *drm_queue = 0; + struct radeon_drm_queue_entry *drm_queue = NULL; if (info-allowColorTiling) { if (info-ChipFamily = CHIP_FAMILY_R600) @@ -2322,6 +2322,7 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, flipdata-event_data = data; flipdata-drmmode = drmmode; +flipdata-old_fb_id = old_fb_id; for (i = 0; i config-num_crtc; i++) { if (!config-crtc[i]-enabled) @@ -2334,8 +2335,6 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, if (!flipcarrier) { xf86DrvMsg(scrn-scrnIndex, X_WARNING, flip queue: carrier alloc failed.\n); - if (emitted == 0) - free(flipdata); goto error_undo; } @@ -2362,25 +2361,27 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, drm_queue)) { xf86DrvMsg(scrn-scrnIndex, X_WARNING, flip queue failed: %s\n, strerror(errno)); - free(flipcarrier); - if (emitted == 0) - free(flipdata); goto error_undo; } - emitted++; + flipcarrier = NULL; + drm_queue = NULL; } - flipdata-old_fb_id = old_fb_id; - return TRUE; + if (flipdata-flip_count 0) + return TRUE; error_undo: + if (!flipdata || flipdata-flip_count = 1) { + drmModeRmFB(drmmode-fd, drmmode-fb_id); + drmmode-fb_id = old_fb_id; + } + if (drm_queue) radeon_drm_abort_entry(drm_queue); - else + else if (flipcarrier) drmmode_flip_abort(scrn, flipcarrier); - - drmModeRmFB(drmmode-fd, drmmode-fb_id); - drmmode-fb_id = old_fb_id; + else + free(flipdata); error_out: xf86DrvMsg(scrn-scrnIndex, X_WARNING, Page flip failed: %s\n, -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 2/3] Simplify radeon_do_pageflip() error handling slightly more
From: Michel Dänzer michel.daen...@amd.com We don't need the local variable old_fb_id. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 33 - 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index b8aaf64..bd1ab76 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -2274,7 +2274,7 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, drmmode_crtc_private_ptr drmmode_crtc = config-crtc[0]-driver_private; drmmode_ptr drmmode = drmmode_crtc-drmmode; unsigned int pitch; - int i, old_fb_id; + int i; uint32_t tiling_flags = 0; int height; drmmode_flipdata_ptr flipdata; @@ -2295,21 +2295,22 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, pitch = info-front_surface.level[0].pitch_bytes; } +flipdata = calloc(1, sizeof(drmmode_flipdata_rec)); +if (!flipdata) { + xf86DrvMsg(scrn-scrnIndex, X_WARNING, +flip queue: data alloc failed.\n); + goto error; +} + /* * Create a new handle for the back buffer */ - old_fb_id = drmmode-fb_id; + flipdata-old_fb_id = drmmode-fb_id; if (drmModeAddFB(drmmode-fd, scrn-virtualX, height, scrn-depth, scrn-bitsPerPixel, pitch, new_front_handle, drmmode-fb_id)) - goto error_out; + goto error; -flipdata = calloc(1, sizeof(drmmode_flipdata_rec)); -if (!flipdata) { - xf86DrvMsg(scrn-scrnIndex, X_WARNING, -flip queue: data alloc failed.\n); - goto error_undo; -} /* * Queue flips on all enabled CRTCs * Note that if/when we get per-CRTC buffers, we'll have to update this. @@ -2322,7 +2323,6 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, flipdata-event_data = data; flipdata-drmmode = drmmode; -flipdata-old_fb_id = old_fb_id; for (i = 0; i config-num_crtc; i++) { if (!config-crtc[i]-enabled) @@ -2335,7 +2335,7 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, if (!flipcarrier) { xf86DrvMsg(scrn-scrnIndex, X_WARNING, flip queue: carrier alloc failed.\n); - goto error_undo; + goto error; } /* Only the reference crtc will finally deliver its page flip @@ -2353,7 +2353,7 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, if (!drm_queue) { xf86DrvMsg(scrn-scrnIndex, X_WARNING, Allocating DRM queue event entry failed.\n); - goto error_undo; + goto error; } if (drmModePageFlip(drmmode-fd, drmmode_crtc-mode_crtc-crtc_id, @@ -2361,7 +2361,7 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, drm_queue)) { xf86DrvMsg(scrn-scrnIndex, X_WARNING, flip queue failed: %s\n, strerror(errno)); - goto error_undo; + goto error; } flipcarrier = NULL; drm_queue = NULL; @@ -2370,10 +2370,10 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, if (flipdata-flip_count 0) return TRUE; -error_undo: - if (!flipdata || flipdata-flip_count = 1) { +error: + if (flipdata flipdata-flip_count = 1) { drmModeRmFB(drmmode-fd, drmmode-fb_id); - drmmode-fb_id = old_fb_id; + drmmode-fb_id = flipdata-old_fb_id; } if (drm_queue) @@ -2383,7 +2383,6 @@ error_undo: else free(flipdata); -error_out: xf86DrvMsg(scrn-scrnIndex, X_WARNING, Page flip failed: %s\n, strerror(errno)); return FALSE; -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 1/2] Add radeon_get_pixmap_tiling_flags helper
From: Michel Dänzer michel.daen...@amd.com Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/radeon_bo_helper.c | 33 + src/radeon_bo_helper.h | 3 +++ 2 files changed, 36 insertions(+) diff --git a/src/radeon_bo_helper.c b/src/radeon_bo_helper.c index adf6599..ebbb192 100644 --- a/src/radeon_bo_helper.c +++ b/src/radeon_bo_helper.c @@ -229,8 +229,16 @@ Bool radeon_get_pixmap_handle(PixmapPtr pixmap, uint32_t *handle) r = drmPrimeFDToHandle(info-dri2.drm_fd, fd, priv-handle); close(fd); if (r == 0) { + struct drm_radeon_gem_set_tiling args = { .handle = priv-handle }; + priv-handle_valid = TRUE; *handle = priv-handle; + + if (drmCommandWriteRead(info-dri2.drm_fd, + DRM_RADEON_GEM_GET_TILING, args, + sizeof(args)) == 0) + priv-tiling_flags = args.tiling_flags; + return TRUE; } } @@ -239,6 +247,31 @@ Bool radeon_get_pixmap_handle(PixmapPtr pixmap, uint32_t *handle) return FALSE; } +uint32_t radeon_get_pixmap_tiling_flags(PixmapPtr pPix) +{ +#ifdef USE_GLAMOR +RADEONInfoPtr info = RADEONPTR(xf86ScreenToScrn(pPix-drawable.pScreen)); + +if (info-use_glamor) { + struct radeon_pixmap *priv = radeon_get_pixmap_private(pPix); + + if (!priv || (!priv-bo !priv-handle_valid)) { + uint32_t handle; + + radeon_get_pixmap_handle(pPix, handle); + priv = radeon_get_pixmap_private(pPix); + } + + return priv ? priv-tiling_flags : 0; +} else +#endif +{ + struct radeon_exa_pixmap_priv *driver_priv; + driver_priv = exaGetPixmapDriverPrivate(pPix); + return driver_priv ? driver_priv-tiling_flags : 0; +} +} + #ifdef RADEON_PIXMAP_SHARING Bool radeon_share_pixmap_backing(struct radeon_bo *bo, void **handle_p) diff --git a/src/radeon_bo_helper.h b/src/radeon_bo_helper.h index 89ad4be..d4a4ee0 100644 --- a/src/radeon_bo_helper.h +++ b/src/radeon_bo_helper.h @@ -31,6 +31,9 @@ radeon_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width, int height, int depth, extern Bool radeon_get_pixmap_handle(PixmapPtr pixmap, uint32_t *handle); +extern uint32_t +radeon_get_pixmap_tiling_flags(PixmapPtr pPix); + extern Bool radeon_share_pixmap_backing(struct radeon_bo *bo, void **handle_p); -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 2/2] present: Don't flip between BOs with different tiling parameters
From: Michel Dänzer michel.daen...@amd.com The kernel driver doesn't handle that correctly yet. Fixes or at least avoids issues with PRIME and DRI3 enabled. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89720 Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/radeon_present.c | 24 1 file changed, 24 insertions(+) diff --git a/src/radeon_present.c b/src/radeon_present.c index 1cdc995..5b1d5ab 100644 --- a/src/radeon_present.c +++ b/src/radeon_present.c @@ -218,6 +218,21 @@ get_drmmode_crtc(ScrnInfoPtr scrn, RRCrtcPtr crtc) return NULL; } +static uint32_t +radeon_present_get_pixmap_tiling_flags(RADEONInfoPtr info, PixmapPtr pixmap) +{ +uint32_t tiling_flags = radeon_get_pixmap_tiling_flags(pixmap); + +/* Micro tiling is always enabled with macro tiling on = R600, so we + * can ignore the micro tiling bit in that case + */ +if ((tiling_flags RADEON_TILING_MACRO) + info-ChipFamily = CHIP_FAMILY_R600) + tiling_flags = ~RADEON_TILING_MICRO; + +return tiling_flags; +} + /* * Test to see if page flipping is possible on the target crtc */ @@ -228,6 +243,7 @@ radeon_present_check_flip(RRCrtcPtr crtc, WindowPtr window, PixmapPtr pixmap, ScreenPtr screen = window-drawable.pScreen; ScrnInfoPtr scrn = xf86ScreenToScrn(screen); RADEONInfoPtr info = RADEONPTR(scrn); +PixmapPtr screen_pixmap; if (!scrn-vtSema) return FALSE; @@ -235,6 +251,14 @@ radeon_present_check_flip(RRCrtcPtr crtc, WindowPtr window, PixmapPtr pixmap, if (!info-allowPageFlip) return FALSE; +/* The kernel driver doesn't handle flipping between BOs with different + * tiling parameters correctly yet + */ +screen_pixmap = screen-GetScreenPixmap(screen); +if (radeon_present_get_pixmap_tiling_flags(info, pixmap) != + radeon_present_get_pixmap_tiling_flags(info, screen_pixmap)) + return FALSE; + if (crtc) { drmmode_crtc_private_ptr drmmode_crtc = get_drmmode_crtc(scrn, crtc); -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH] Only enable SYNC extension fences and the Present extension along with DRI3
From: Michel Dänzer michel.daen...@amd.com This avoids some trouble with the Gallium nine state tracker, which uses the Present extension even when DRI3 is disabled. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89772 Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/radeon_kms.c | 12 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/radeon_kms.c b/src/radeon_kms.c index 29275cc..64593ab 100644 --- a/src/radeon_kms.c +++ b/src/radeon_kms.c @@ -1400,7 +1400,7 @@ Bool RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL) RADEONInfoPtr info = RADEONPTR(pScrn); intsubPixelOrder = SubPixelUnknown; MessageType from; -Bool have_present = FALSE, value; +Bool value; const char *s; void *front_ptr; @@ -1511,9 +1511,6 @@ Bool RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL) } #endif -if (radeon_sync_init(pScreen)) - have_present = radeon_present_screen_init(pScreen); - value = FALSE; if (xf86GetOptValBool(info-Options, OPTION_DRI3, value)) from = X_CONFIG; @@ -1521,10 +1518,9 @@ Bool RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL) from = X_DEFAULT; if (value) { - if (have_present) - value = radeon_dri3_screen_init(pScreen); - else - value = FALSE; + value = radeon_sync_init(pScreen) + radeon_present_screen_init(pScreen) + radeon_dri3_screen_init(pScreen); if (!value) from = X_WARNING; -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH] Add Option TearFree v2
From: Michel Dänzer michel.daen...@amd.com Avoids tearing by flipping between two scanout BOs per (non-rotated) CRTC v2: * Fix condition for TearFree log message (Richard Wilbur) * Log warning message about DRI page flipping being enabled because of TearFree (or ShadowPrimary) also when building without glamor support Signed-off-by: Michel Dänzer michel.daen...@amd.com --- man/radeon.man| 7 +++ src/drmmode_display.c | 78 ++- src/drmmode_display.h | 5 +- src/radeon.h | 2 + src/radeon_kms.c | 142 +- 5 files changed, 160 insertions(+), 74 deletions(-) diff --git a/man/radeon.man b/man/radeon.man index 2703773..f0a6be1 100644 --- a/man/radeon.man +++ b/man/radeon.man @@ -276,6 +276,13 @@ Enable DRI2 page flipping. The default is .B on. Pageflipping is supported on all radeon hardware. .TP +.BI Option \*qTearFree\*q \*q boolean \*q +Enable tearing prevention using the hardware page flipping mechanism. This +option currently doesn't have any effect for rotated CRTCs. It requires +allocating two separate scanout buffers for each non-rotated CRTC. Enabling +this option currently disables Option \*qEnablePageFlip\*q. The default is +.B off. +.TP .BI Option \*qAccelMethod\*q \*q string \*q Chooses between available acceleration architectures. Valid values are .B EXA diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 1f22869..ce6cd80 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -488,6 +488,10 @@ drmmode_crtc_scanout_destroy(drmmode_ptr drmmode, scanout-bo = NULL; } + if (scanout-damage) { + DamageDestroy(scanout-damage); + scanout-damage = NULL; + } } void @@ -501,12 +505,9 @@ drmmode_scanout_free(ScrnInfoPtr scrn) xf86_config-crtc[c]-driver_private; drmmode_crtc_scanout_destroy(drmmode_crtc-drmmode, -drmmode_crtc-scanout); - - if (drmmode_crtc-scanout_damage) { - DamageDestroy(drmmode_crtc-scanout_damage); - drmmode_crtc-scanout_damage = NULL; - } +drmmode_crtc-scanout[0]); + drmmode_crtc_scanout_destroy(drmmode_crtc-drmmode, +drmmode_crtc-scanout[1]); } } @@ -704,44 +705,49 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, x = drmmode_crtc-prime_pixmap_x; y = 0; - drmmode_crtc_scanout_destroy(drmmode, drmmode_crtc-scanout); + drmmode_crtc_scanout_destroy(drmmode, drmmode_crtc-scanout[0]); + drmmode_crtc_scanout_destroy(drmmode, drmmode_crtc-scanout[1]); } else #endif if (drmmode_crtc-rotate.fb_id) { fb_id = drmmode_crtc-rotate.fb_id; x = y = 0; - drmmode_crtc_scanout_destroy(drmmode, drmmode_crtc-scanout); - } else if (info-shadow_primary) { - drmmode_crtc_scanout_create(crtc, - drmmode_crtc-scanout, - NULL, mode-HDisplay, - mode-VDisplay); - - if (drmmode_crtc-scanout.pixmap) { - RegionPtr pRegion; - BoxPtr pBox; - - if (!drmmode_crtc-scanout_damage) { - drmmode_crtc-scanout_damage = - DamageCreate(radeon_screen_damage_report, -NULL, DamageReportRawRegion, -TRUE, pScreen, NULL); - DamageRegister(pScreen-GetScreenPixmap(pScreen)-drawable, - drmmode_crtc-scanout_damage); + drmmode_crtc_scanout_destroy(drmmode, drmmode_crtc-scanout[0]); + drmmode_crtc_scanout_destroy(drmmode, drmmode_crtc-scanout[1]); + } else if (info-tear_free || info-shadow_primary) { + for (i = 0; i (info-tear_free ? 2 : 1); i++) { + drmmode_crtc_scanout_create(crtc, + drmmode_crtc-scanout[i], + NULL, mode-HDisplay, + mode-VDisplay); + + if (drmmode_crtc-scanout[i].pixmap
Re: [PATCH] Add Option TearFree
On 21.04.2015 06:08, Richard Wilbur wrote: On Mon, Apr 20, 2015 at 3:54 AM, Michel Dänzer mic...@daenzer.net wrote: [...] diff --git a/src/radeon_kms.c b/src/radeon_kms.c index 64593ab..e18f85a 100644 --- a/src/radeon_kms.c +++ b/src/radeon_kms.c @@ -1092,15 +1157,22 @@ Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn, int flags) } #endif +info-tear_free = xf86ReturnOptValBool(info-Options, OPTION_TEAR_FREE, + FALSE); + +if (info-shadow_primary) + xf86DrvMsg(pScrn-scrnIndex, X_CONFIG, TearFree enabled\n); + It seems likely that I don't understand the full implications of info-tear_free and info-shadow_primary. I would have expected the message about TearFree enabled to be predicated on info-tear_free, since that is what we are adding with this patch, as opposed to info-shadow_primary, which doesn't seem to be touched by the new option. You're absolutely right, thanks for the catch. Copy'n'paste accident. :) Fixed in v2. -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH] Add Option TearFree
From: Michel Dänzer michel.daen...@amd.com Avoids tearing by flipping between two scanout BOs per (non-rotated) CRTC Signed-off-by: Michel Dänzer michel.daen...@amd.com --- man/radeon.man| 7 +++ src/drmmode_display.c | 78 - src/drmmode_display.h | 5 +- src/radeon.h | 2 + src/radeon_kms.c | 136 ++ 5 files changed, 158 insertions(+), 70 deletions(-) diff --git a/man/radeon.man b/man/radeon.man index 2703773..f0a6be1 100644 --- a/man/radeon.man +++ b/man/radeon.man @@ -276,6 +276,13 @@ Enable DRI2 page flipping. The default is .B on. Pageflipping is supported on all radeon hardware. .TP +.BI Option \*qTearFree\*q \*q boolean \*q +Enable tearing prevention using the hardware page flipping mechanism. This +option currently doesn't have any effect for rotated CRTCs. It requires +allocating two separate scanout buffers for each non-rotated CRTC. Enabling +this option currently disables Option \*qEnablePageFlip\*q. The default is +.B off. +.TP .BI Option \*qAccelMethod\*q \*q string \*q Chooses between available acceleration architectures. Valid values are .B EXA diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 1f22869..ce6cd80 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -488,6 +488,10 @@ drmmode_crtc_scanout_destroy(drmmode_ptr drmmode, scanout-bo = NULL; } + if (scanout-damage) { + DamageDestroy(scanout-damage); + scanout-damage = NULL; + } } void @@ -501,12 +505,9 @@ drmmode_scanout_free(ScrnInfoPtr scrn) xf86_config-crtc[c]-driver_private; drmmode_crtc_scanout_destroy(drmmode_crtc-drmmode, -drmmode_crtc-scanout); - - if (drmmode_crtc-scanout_damage) { - DamageDestroy(drmmode_crtc-scanout_damage); - drmmode_crtc-scanout_damage = NULL; - } +drmmode_crtc-scanout[0]); + drmmode_crtc_scanout_destroy(drmmode_crtc-drmmode, +drmmode_crtc-scanout[1]); } } @@ -704,44 +705,49 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, x = drmmode_crtc-prime_pixmap_x; y = 0; - drmmode_crtc_scanout_destroy(drmmode, drmmode_crtc-scanout); + drmmode_crtc_scanout_destroy(drmmode, drmmode_crtc-scanout[0]); + drmmode_crtc_scanout_destroy(drmmode, drmmode_crtc-scanout[1]); } else #endif if (drmmode_crtc-rotate.fb_id) { fb_id = drmmode_crtc-rotate.fb_id; x = y = 0; - drmmode_crtc_scanout_destroy(drmmode, drmmode_crtc-scanout); - } else if (info-shadow_primary) { - drmmode_crtc_scanout_create(crtc, - drmmode_crtc-scanout, - NULL, mode-HDisplay, - mode-VDisplay); - - if (drmmode_crtc-scanout.pixmap) { - RegionPtr pRegion; - BoxPtr pBox; - - if (!drmmode_crtc-scanout_damage) { - drmmode_crtc-scanout_damage = - DamageCreate(radeon_screen_damage_report, -NULL, DamageReportRawRegion, -TRUE, pScreen, NULL); - DamageRegister(pScreen-GetScreenPixmap(pScreen)-drawable, - drmmode_crtc-scanout_damage); + drmmode_crtc_scanout_destroy(drmmode, drmmode_crtc-scanout[0]); + drmmode_crtc_scanout_destroy(drmmode, drmmode_crtc-scanout[1]); + } else if (info-tear_free || info-shadow_primary) { + for (i = 0; i (info-tear_free ? 2 : 1); i++) { + drmmode_crtc_scanout_create(crtc, + drmmode_crtc-scanout[i], + NULL, mode-HDisplay, + mode-VDisplay); + + if (drmmode_crtc-scanout[i].pixmap) { + RegionPtr pRegion; + BoxPtr pBox; + + if (!drmmode_crtc-scanout[i].damage
[PATCH 1/5] Only copy fbcon BO contents if bgNoneRoot is TRUE
From: Michel Dänzer michel.daen...@amd.com Otherwise, the X server will initialize the screen pixmap contents anyway. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 27 +++ src/drmmode_display.h | 2 ++ 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 21a5937..edeba47 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -385,6 +385,8 @@ out_free_fb: return pixmap; } +#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) = 10 + void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode) { xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); @@ -397,9 +399,6 @@ void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode) uint32_t tiling_flags = 0; Bool ret; - if (info-accelOn == FALSE || info-use_glamor) - goto fallback; - for (i = 0; i xf86_config-num_crtc; i++) { drmmode_crtc_private_ptr drmmode_crtc = xf86_config-crtc[i]-driver_private; @@ -408,7 +407,7 @@ void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode) } if (!fbcon_id) - goto fallback; + return; if (fbcon_id == drmmode-fb_id) { /* in some rare case there might be no fbcon and we might already @@ -421,7 +420,7 @@ void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode) src = create_pixmap_for_fbcon(drmmode, pScrn, fbcon_id); if (!src) - goto fallback; + return; if (info-allowColorTiling) { if (info-ChipFamily = CHIP_FAMILY_R600) { @@ -454,23 +453,15 @@ void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode) info-accel_state-exa-DoneCopy (dst); radeon_cs_flush_indirect(pScrn); -#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) = 10 pScreen-canDoBGNoneRoot = TRUE; -#endif drmmode_destroy_bo_pixmap(dst); out_free_src: drmmode_destroy_bo_pixmap(src); return; - -fallback: - /* map and memset the bo */ - if (radeon_bo_map(info-front_bo, 1)) - return; - - memset(info-front_bo-ptr, 0x00, info-front_bo-size); - radeon_bo_unmap(info-front_bo); } +#endif /* GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) = 10 */ + static void drmmode_crtc_scanout_destroy(drmmode_ptr drmmode, struct drmmode_scanout *scanout) @@ -2122,8 +2113,12 @@ Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode) { xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); int c; +#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) = 10 + RADEONInfoPtr info = RADEONPTR(pScrn); - drmmode_copy_fb(pScrn, drmmode); + if (bgNoneRoot info-accelOn !info-use_glamor) + drmmode_copy_fb(pScrn, drmmode); +#endif for (c = 0; c config-num_crtc; c++) { xf86CrtcPtr crtc = config-crtc[c]; diff --git a/src/drmmode_display.h b/src/drmmode_display.h index 1908b46..49b02d6 100644 --- a/src/drmmode_display.h +++ b/src/drmmode_display.h @@ -127,7 +127,9 @@ extern Bool drmmode_set_bufmgr(ScrnInfoPtr pScrn, drmmode_ptr drmmode, struct ra extern void drmmode_set_cursor(ScrnInfoPtr scrn, drmmode_ptr drmmode, int id, struct radeon_bo *bo); void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y); extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode); +#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) = 10 extern void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode); +#endif extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn); extern void drmmode_scanout_free(ScrnInfoPtr scrn); -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 3/5] Defer initial modeset until the first BlockHandler invocation
From: Michel Dänzer michel.daen...@amd.com This ensures that the screen pixmap contents have been initialized when the initial modes are set. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=27757 Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 44 ++-- src/drmmode_display.h | 3 ++- src/radeon_kms.c | 17 ++--- 3 files changed, 30 insertions(+), 34 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 76b2577..064a64c 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -395,8 +395,6 @@ void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode) ScreenPtr pScreen = pScrn-pScreen; int fbcon_id = 0; int i; - int pitch; - uint32_t tiling_flags = 0; Bool ret; for (i = 0; i xf86_config-num_crtc; i++) { @@ -422,28 +420,7 @@ void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode) if (!src) return; - if (info-allowColorTiling) { - if (info-ChipFamily = CHIP_FAMILY_R600) { - if (info-allowColorTiling2D) { - tiling_flags |= RADEON_TILING_MACRO; - } else { - tiling_flags |= RADEON_TILING_MICRO; - } - } else - tiling_flags |= RADEON_TILING_MACRO; - } - - pitch = RADEON_ALIGN(pScrn-displayWidth, -drmmode_get_pitch_align(pScrn, info-pixel_bytes, tiling_flags)) * - info-pixel_bytes; - - dst = drmmode_create_bo_pixmap(pScrn, pScrn-virtualX, - pScrn-virtualY, pScrn-depth, - pScrn-bitsPerPixel, pitch, - tiling_flags, info-front_bo, info-front_surface); - if (!dst) - goto out_free_src; - + dst = pScreen-GetScreenPixmap(pScreen); ret = info-accel_state-exa-PrepareCopy (src, dst, -1, -1, GXcopy, FB_ALLONES); if (!ret) @@ -454,7 +431,6 @@ void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode) radeon_cs_flush_indirect(pScrn); pScreen-canDoBGNoneRoot = TRUE; - drmmode_destroy_bo_pixmap(dst); out_free_src: drmmode_destroy_bo_pixmap(src); return; @@ -2109,7 +2085,8 @@ void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y) } } -Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode) +Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode, + Bool set_hw) { xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); int c; @@ -2121,7 +2098,7 @@ Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode) int o; /* Skip disabled CRTCs */ - if (!crtc-enabled) { + if (set_hw !crtc-enabled) { drmmode_do_crtc_dpms(crtc, DPMSModeOff); drmModeSetCrtc(drmmode-fd, drmmode_crtc-mode_crtc-crtc_id, 0, 0, 0, NULL, 0, NULL); @@ -2157,9 +2134,16 @@ Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode) crtc-desiredY = 0; } - if (!crtc-funcs-set_mode_major(crtc, crtc-desiredMode, crtc-desiredRotation, -crtc-desiredX, crtc-desiredY)) - return FALSE; + if (set_hw) { + if (!crtc-funcs-set_mode_major(crtc, crtc-desiredMode, crtc-desiredRotation, +crtc-desiredX, crtc-desiredY)) + return FALSE; + } else { + crtc-mode = crtc-desiredMode; + crtc-rotation = crtc-desiredRotation; + crtc-x = crtc-desiredX; + crtc-y = crtc-desiredY; + } } return TRUE; } diff --git a/src/drmmode_display.h b/src/drmmode_display.h index 49b02d6..2fdd3e0 100644 --- a/src/drmmode_display.h +++ b/src/drmmode_display.h @@ -126,7 +126,8 @@ extern void drmmode_fini(ScrnInfoPtr pScrn, drmmode_ptr drmmode); extern Bool drmmode_set_bufmgr(ScrnInfoPtr pScrn, drmmode_ptr drmmode, struct radeon_bo_manager *bufmgr); extern void drmmode_set_cursor(ScrnInfoPtr scrn, drmmode_ptr drmmode, int id, struct radeon_bo *bo); void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y); -extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode); +extern Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode, + Bool set_hw
[PATCH 0/5] Smoother startup
These patches make the Xorg startup smoother in two ways: * Make sure the contents of the buffers being scanned out have been initialized when the initial modes are set * Make the -background none command line option work as intended with glamor as well The patches apply on top of the 'Add Option TearFree' patch and are also available on the master branch of git://people.freedesktop.org/~daenzer/xf86-video-ati . [PATCH 1/5] Only copy fbcon BO contents if bgNoneRoot is TRUE [PATCH 2/5] Defer initial drmmode_copy_fb call until root window [PATCH 3/5] Defer initial modeset until the first BlockHandler [PATCH 4/5] Update scanout pixmap contents before setting a mode with [PATCH 5/5] Make drmmode_copy_fb() work with glamor as well ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 2/5] Defer initial drmmode_copy_fb call until root window creation
From: Michel Dänzer michel.daen...@amd.com That's late enough for acceleration to be fully initialized, but still early enough to set pScreen-canDoBGNoneRoot. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 6 -- src/radeon.h | 3 +++ src/radeon_kms.c | 40 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index edeba47..76b2577 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -2113,12 +2113,6 @@ Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode) { xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); int c; -#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) = 10 - RADEONInfoPtr info = RADEONPTR(pScrn); - - if (bgNoneRoot info-accelOn !info-use_glamor) - drmmode_copy_fb(pScrn, drmmode); -#endif for (c = 0; c config-num_crtc; c++) { xf86CrtcPtr crtc = config-crtc[c]; diff --git a/src/radeon.h b/src/radeon.h index 1c794ce..962a68d 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -493,6 +493,9 @@ typedef struct { DisplayModePtr currentMode; CreateScreenResourcesProcPtr CreateScreenResources; +#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) = 10 +CreateWindowProcPtr CreateWindow; +#endif Bool IsSecondary; Bool IsPrimary; diff --git a/src/radeon_kms.c b/src/radeon_kms.c index a85e890..2a84ff6 100644 --- a/src/radeon_kms.c +++ b/src/radeon_kms.c @@ -1012,6 +1012,34 @@ static void RADEONSetupCapabilities(ScrnInfoPtr pScrn) #endif } +#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) = 10 + +/* When the root window is created, initialize the screen contents from + * console if -background none was specified on the command line + */ +static Bool RADEONCreateWindow(WindowPtr pWin) +{ +ScreenPtr pScreen = pWin-drawable.pScreen; +ScrnInfoPtr pScrn; +RADEONInfoPtr info; +Bool ret; + +if (pWin != pScreen-root) + ErrorF(%s called for non-root window %p\n, __func__, pWin); + +pScrn = xf86ScreenToScrn(pScreen); +info = RADEONPTR(pScrn); +pScreen-CreateWindow = info-CreateWindow; +ret = pScreen-CreateWindow(pWin); + +if (ret) + drmmode_copy_fb(pScrn, info-drmmode); + +return ret; +} + +#endif + Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn, int flags) { RADEONInfoPtr info; @@ -1666,6 +1694,13 @@ Bool RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL) } pScrn-pScreen = pScreen; +#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) = 10 +if (bgNoneRoot info-accelOn !info-use_glamor) { + info-CreateWindow = pScreen-CreateWindow; + pScreen-CreateWindow = RADEONCreateWindow; +} +#endif + /* Provide SaveScreen wrap BlockHandler and CloseScreen */ /* Wrap CloseScreen */ info-CloseScreen= pScreen-CloseScreen; @@ -1725,6 +1760,11 @@ Bool RADEONEnterVT_KMS(VT_FUNC_ARGS_DECL) pScrn-vtSema = TRUE; +#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) = 10 +if (bgNoneRoot info-accelOn !info-use_glamor) + drmmode_copy_fb(pScrn, info-drmmode); +#endif + if (!drmmode_set_desired_modes(pScrn, info-drmmode)) return FALSE; -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 4/5] Update scanout pixmap contents before setting a mode with it
From: Michel Dänzer michel.daen...@amd.com This ensures the scanout pixmaps used for Option TearFree and Option ShadowPrimary have been initialized when their initial mode is set. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 2 ++ src/radeon.h | 4 src/radeon_kms.c | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 064a64c..8caad70 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -718,6 +718,8 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, drmmode_crtc-scanout_id = 0; fb_id = drmmode_crtc-scanout[0].fb_id; x = y = 0; + + radeon_scanout_update_handler(pScrn, 0, 0, crtc); } } ret = drmModeSetCrtc(drmmode-fd, drmmode_crtc-mode_crtc-crtc_id, diff --git a/src/radeon.h b/src/radeon.h index 962a68d..8220da7 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -593,6 +593,10 @@ extern Bool RADEONGetPixmapOffsetPitch(PixmapPtr pPix, /* radeon_dri3.c */ Bool radeon_dri3_screen_init(ScreenPtr screen); +/* radeon_kms.c */ +void radeon_scanout_update_handler(ScrnInfoPtr scrn, uint32_t frame, + uint64_t usec, void *event_data); + /* radeon_present.c */ Bool radeon_present_screen_init(ScreenPtr screen); diff --git a/src/radeon_kms.c b/src/radeon_kms.c index eda3f33..082c5b6 100644 --- a/src/radeon_kms.c +++ b/src/radeon_kms.c @@ -385,7 +385,7 @@ radeon_scanout_update_abort(ScrnInfoPtr scrn, void *event_data) drmmode_crtc-scanout_update_pending = FALSE; } -static void +void radeon_scanout_update_handler(ScrnInfoPtr scrn, uint32_t frame, uint64_t usec, void *event_data) { -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH 5/5] Make drmmode_copy_fb() work with glamor as well
From: Michel Dänzer michel.daen...@amd.com Needed for Xorg -background none. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 49 ++--- src/radeon.h | 1 + src/radeon_kms.c | 7 +-- 3 files changed, 44 insertions(+), 13 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 8caad70..326d863 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -348,11 +348,15 @@ static PixmapPtr create_pixmap_for_fbcon(drmmode_ptr drmmode, ScrnInfoPtr pScrn, int fbcon_id) { - PixmapPtr pixmap = NULL; + RADEONInfoPtr info = RADEONPTR(pScrn); + PixmapPtr pixmap = info-fbcon_pixmap; struct radeon_bo *bo; drmModeFBPtr fbcon; struct drm_gem_flink flink; + if (pixmap) + return pixmap; + fbcon = drmModeGetFB(drmmode-fd, fbcon_id); if (fbcon == NULL) return NULL; @@ -379,12 +383,30 @@ create_pixmap_for_fbcon(drmmode_ptr drmmode, pixmap = drmmode_create_bo_pixmap(pScrn, fbcon-width, fbcon-height, fbcon-depth, fbcon-bpp, fbcon-pitch, 0, bo, NULL); + info-fbcon_pixmap = pixmap; radeon_bo_unref(bo); out_free_fb: drmModeFreeFB(fbcon); return pixmap; } +static void +destroy_pixmap_for_fbcon(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + + /* XXX: The current GPUVM support in the kernel doesn't allow removing +* the virtual address range for this BO, so we need to keep around +* the pixmap to avoid breaking glamor with GPUVM +*/ + if (info-use_glamor info-ChipFamily = CHIP_FAMILY_CAYMAN) + return; + + if (info-fbcon_pixmap) + pScrn-pScreen-DestroyPixmap(info-fbcon_pixmap); + info-fbcon_pixmap = NULL; +} + #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) = 10 void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode) @@ -394,8 +416,9 @@ void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode) PixmapPtr src, dst; ScreenPtr pScreen = pScrn-pScreen; int fbcon_id = 0; + Bool force; + GCPtr gc; int i; - Bool ret; for (i = 0; i xf86_config-num_crtc; i++) { drmmode_crtc_private_ptr drmmode_crtc = xf86_config-crtc[i]-driver_private; @@ -421,18 +444,22 @@ void drmmode_copy_fb(ScrnInfoPtr pScrn, drmmode_ptr drmmode) return; dst = pScreen-GetScreenPixmap(pScreen); - ret = info-accel_state-exa-PrepareCopy (src, dst, - -1, -1, GXcopy, FB_ALLONES); - if (!ret) - goto out_free_src; - info-accel_state-exa-Copy (dst, 0, 0, 0, 0, - pScrn-virtualX, pScrn-virtualY); - info-accel_state-exa-DoneCopy (dst); + + gc = GetScratchGC(pScrn-depth, pScreen); + ValidateGC(dst-drawable, gc); + + force = info-accel_state-force; + info-accel_state-force = TRUE; + (*gc-ops-CopyArea)(src-drawable, dst-drawable, gc, 0, 0, +pScrn-virtualX, pScrn-virtualY, 0, 0); + info-accel_state-force = force; + + FreeScratchGC(gc); + radeon_cs_flush_indirect(pScrn); pScreen-canDoBGNoneRoot = TRUE; - out_free_src: - drmmode_destroy_bo_pixmap(src); + destroy_pixmap_for_fbcon(pScrn); return; } diff --git a/src/radeon.h b/src/radeon.h index 8220da7..cd03d53 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -475,6 +475,7 @@ typedef struct { uint_fast32_t gpu_flushed; uint_fast32_t gpu_synced; struct radeon_accel_state *accel_state; +PixmapPtr fbcon_pixmap; Bool accelOn; Bool use_glamor; Bool shadow_primary; diff --git a/src/radeon_kms.c b/src/radeon_kms.c index 082c5b6..fa40776 100644 --- a/src/radeon_kms.c +++ b/src/radeon_kms.c @@ -186,6 +186,9 @@ static void RADEONFreeRec(ScrnInfoPtr pScrn) info = RADEONPTR(pScrn); +if (info-fbcon_pixmap) + pScrn-pScreen-DestroyPixmap(info-fbcon_pixmap); + if (info-dri2.drm_fd 0) { DevUnion *pPriv; RADEONEntPtr pRADEONEnt; @@ -1706,7 +1709,7 @@ Bool RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL) pScrn-pScreen = pScreen; #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) = 10 -if (bgNoneRoot info-accelOn !info-use_glamor) { +if (bgNoneRoot info-accelOn) { info-CreateWindow = pScreen-CreateWindow; pScreen-CreateWindow = RADEONCreateWindow; } @@ -1772,7 +1775,7 @@ Bool RADEONEnterVT_KMS(VT_FUNC_ARGS_DECL) pScrn-vtSema = TRUE; #if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) = 10 -if (bgNoneRoot info-accelOn !info-use_glamor) +if (bgNoneRoot info-accelOn) drmmode_copy_fb(pScrn, info-drmmode
[PATCH] Add Option TearFree v3
From: Michel Dänzer michel.daen...@amd.com Avoids tearing by flipping between two scanout BOs per (non-rotated) CRTC v2: * Fix condition for TearFree log message (Richard Wilbur) * Log warning message about DRI page flipping being enabled because of TearFree (or ShadowPrimary) also when building without glamor support v3: * Only override fb_id/x/y if all scanout pixmaps have been successfully allocated Signed-off-by: Michel Dänzer michel.daen...@amd.com --- man/radeon.man| 7 +++ src/drmmode_display.c | 79 +++- src/drmmode_display.h | 5 +- src/radeon.h | 2 + src/radeon_kms.c | 142 +- 5 files changed, 162 insertions(+), 73 deletions(-) diff --git a/man/radeon.man b/man/radeon.man index 2703773..f0a6be1 100644 --- a/man/radeon.man +++ b/man/radeon.man @@ -276,6 +276,13 @@ Enable DRI2 page flipping. The default is .B on. Pageflipping is supported on all radeon hardware. .TP +.BI Option \*qTearFree\*q \*q boolean \*q +Enable tearing prevention using the hardware page flipping mechanism. This +option currently doesn't have any effect for rotated CRTCs. It requires +allocating two separate scanout buffers for each non-rotated CRTC. Enabling +this option currently disables Option \*qEnablePageFlip\*q. The default is +.B off. +.TP .BI Option \*qAccelMethod\*q \*q string \*q Chooses between available acceleration architectures. Valid values are .B EXA diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 1f22869..21a5937 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -488,6 +488,10 @@ drmmode_crtc_scanout_destroy(drmmode_ptr drmmode, scanout-bo = NULL; } + if (scanout-damage) { + DamageDestroy(scanout-damage); + scanout-damage = NULL; + } } void @@ -501,12 +505,9 @@ drmmode_scanout_free(ScrnInfoPtr scrn) xf86_config-crtc[c]-driver_private; drmmode_crtc_scanout_destroy(drmmode_crtc-drmmode, -drmmode_crtc-scanout); - - if (drmmode_crtc-scanout_damage) { - DamageDestroy(drmmode_crtc-scanout_damage); - drmmode_crtc-scanout_damage = NULL; - } +drmmode_crtc-scanout[0]); + drmmode_crtc_scanout_destroy(drmmode_crtc-drmmode, +drmmode_crtc-scanout[1]); } } @@ -704,43 +705,51 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, x = drmmode_crtc-prime_pixmap_x; y = 0; - drmmode_crtc_scanout_destroy(drmmode, drmmode_crtc-scanout); + drmmode_crtc_scanout_destroy(drmmode, drmmode_crtc-scanout[0]); + drmmode_crtc_scanout_destroy(drmmode, drmmode_crtc-scanout[1]); } else #endif if (drmmode_crtc-rotate.fb_id) { fb_id = drmmode_crtc-rotate.fb_id; x = y = 0; - drmmode_crtc_scanout_destroy(drmmode, drmmode_crtc-scanout); - } else if (info-shadow_primary) { - drmmode_crtc_scanout_create(crtc, - drmmode_crtc-scanout, - NULL, mode-HDisplay, - mode-VDisplay); - - if (drmmode_crtc-scanout.pixmap) { - RegionPtr pRegion; - BoxPtr pBox; - - if (!drmmode_crtc-scanout_damage) { - drmmode_crtc-scanout_damage = - DamageCreate(radeon_screen_damage_report, -NULL, DamageReportRawRegion, -TRUE, pScreen, NULL); - DamageRegister(pScreen-GetScreenPixmap(pScreen)-drawable, - drmmode_crtc-scanout_damage); + drmmode_crtc_scanout_destroy(drmmode, drmmode_crtc-scanout[0]); + drmmode_crtc_scanout_destroy(drmmode, drmmode_crtc-scanout[1]); + } else if (info-tear_free || info-shadow_primary) { + for (i = 0; i (info-tear_free ? 2 : 1); i++) { + drmmode_crtc_scanout_create(crtc, + drmmode_crtc-scanout[i], + NULL, mode-HDisplay, + mode-VDisplay
[PATCH] DRI2: Clear old-devPrivate.ptr in fixup_glamor
From: Michel Dänzer michel.daen...@amd.com It doesn't point to the memory of the newly allocated BO. Fixes crash running piglit with Option ShadowPrimary enabled. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/radeon_dri2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c index 31a1ce7..6bb3dc6 100644 --- a/src/radeon_dri2.c +++ b/src/radeon_dri2.c @@ -119,6 +119,7 @@ static PixmapPtr fixup_glamor(DrawablePtr drawable, PixmapPtr pixmap) 0, 0, pixmap-devKind, NULL); + old-devPrivate.ptr = NULL; screen-DestroyPixmap(pixmap); -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH xf86-video-amdgpu] Add 10-amdgpu.conf xorg.conf.d snippet
From: Michel Dänzer michel.daen...@amd.com This instructs Xorg = 1.16 to try loading the amdgpu driver for devices managed by the amdgpu kernel driver. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- Makefile.am | 2 +- conf/10-amdgpu.conf | 5 + conf/Makefile.am| 24 configure.ac| 14 ++ 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 conf/10-amdgpu.conf create mode 100644 conf/Makefile.am diff --git a/Makefile.am b/Makefile.am index f4f4233..f0e2c3c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,7 +18,7 @@ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -SUBDIRS = src man +SUBDIRS = src man conf MAINTAINERCLEANFILES = ChangeLog INSTALL .PHONY: ChangeLog INSTALL diff --git a/conf/10-amdgpu.conf b/conf/10-amdgpu.conf new file mode 100644 index 000..338e898 --- /dev/null +++ b/conf/10-amdgpu.conf @@ -0,0 +1,5 @@ +Section OutputClass + Identifier AMDgpu + MatchDriver amdgpu + Driver amdgpu +EndSection \ No newline at end of file diff --git a/conf/Makefile.am b/conf/Makefile.am new file mode 100644 index 000..7ab1586 --- /dev/null +++ b/conf/Makefile.am @@ -0,0 +1,24 @@ +# Copyright 2015 Advanced Micro Devices, Inc. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the Software), +# to deal in the Software without restriction, including without limitation +# on the rights to use, copy, modify, merge, publish, distribute, sub +# license, and/or sell copies of the Software, and to permit persons to whom +# the Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL +# ADAM JACKSON BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +if HAS_XORG_CONF_DIR +dist_config_DATA = 10-amdgpu.conf +endif diff --git a/configure.ac b/configure.ac index 1766d9c..ead206e 100644 --- a/configure.ac +++ b/configure.ac @@ -81,6 +81,19 @@ PKG_CHECK_MODULES(XEXT, [xextproto = 7.0.99.1], HAVE_XEXTPROTO_71=no) AM_CONDITIONAL(HAVE_XEXTPROTO_71, [ test $HAVE_XEXTPROTO_71 = yes ]) +# Define a configure option for an alternate X Server configuration directory +# Section OutputClass is only supported as of xserver 1.16 +PKG_CHECK_EXISTS([xorg-server = 1.16], +[sysconfigdir=`$PKG_CONFIG --variable=sysconfigdir xorg-server`], +[sysconfigdir=]) +AC_ARG_WITH(xorg-conf-dir, +AS_HELP_STRING([--with-xorg-conf-dir=DIR], + [Default xorg.conf.d directory [[default=from $PKG_CONFIG xorg-server]]]), +[configdir=$withval], +[configdir=$sysconfigdir]) +AC_SUBST(configdir) +AM_CONDITIONAL(HAS_XORG_CONF_DIR, [test x$sysconfigdir != x]) + AC_ARG_ENABLE([udev], AS_HELP_STRING([--disable-udev], [Disable libudev support [default=auto]]), [enable_udev=$enableval], @@ -212,6 +225,7 @@ AC_CONFIG_FILES([ Makefile src/Makefile man/Makefile +conf/Makefile ]) AC_OUTPUT -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH] Skip disabled CRTCs in drmmode_set_desired_modes() even if set_hw == FALSE
From: Michel Dänzer michel.daen...@amd.com Not skipping a disabled CRTC results in a crash. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90187 Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 06d1ec0..c12bf51 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -2145,10 +2145,13 @@ Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int o; /* Skip disabled CRTCs */ - if (set_hw !crtc-enabled) { - drmmode_do_crtc_dpms(crtc, DPMSModeOff); - drmModeSetCrtc(drmmode-fd, drmmode_crtc-mode_crtc-crtc_id, - 0, 0, 0, NULL, 0, NULL); + if (!crtc-enabled) { + if (set_hw) { + drmmode_do_crtc_dpms(crtc, DPMSModeOff); + drmModeSetCrtc(drmmode-fd, + drmmode_crtc-mode_crtc-crtc_id, + 0, 0, 0, NULL, 0, NULL); + } continue; } -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH xf86-video-amdgpu] Link against libgbm
From: Michel Dänzer michel.daen...@amd.com Fixes unresolved symbol gbm_create_device. Reported-and-Tested-by: Brian Paterni bpate...@gmail.com Signed-off-by: Michel Dänzer michel.daen...@amd.com --- configure.ac| 1 + src/Makefile.am | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index ead206e..946c70e 100644 --- a/configure.ac +++ b/configure.ac @@ -73,6 +73,7 @@ XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto) # Checks for libraries. PKG_CHECK_MODULES(LIBDRM, [libdrm = 2.4.46]) PKG_CHECK_MODULES(LIBDRM_AMDGPU, [libdrm_amdgpu]) +PKG_CHECK_MODULES(GBM, [gbm]) # Obtain compiler/linker options for the driver dependencies PKG_CHECK_MODULES(XORG, [xorg-server = 1.7 xproto fontsproto xf86driproto $REQUIRED_MODULES]) diff --git a/src/Makefile.am b/src/Makefile.am index 817da2d..8715eb3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,11 +26,12 @@ # _ladir passes a dummy rpath to libtool so the thing will actually link # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc. -amdgpu_drv_la_LIBADD = $(PCIACCESS_LIBS) $(LIBDRM_AMDGPU_LIBS) +amdgpu_drv_la_LIBADD = $(PCIACCESS_LIBS) $(LIBDRM_AMDGPU_LIBS) $(GBM_LIBS) AMDGPU_KMS_SRCS=amdgpu_dri2.c amdgpu_kms.c drmmode_display.c amdgpu_bo_helper.c AM_CFLAGS = \ +@GBM_CFLAGS@ \ @LIBDRM_AMDGPU_CFLAGS@ \ @XORG_CFLAGS@ \ @LIBUDEV_CFLAGS@ -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
Re: [PATCH 3/3] present: Disable check for compatible tiling flags.
[ Adding the xorg-driver-ati mailing list, please post DDX driver patches there ] On 09.05.2015 14:24, Mario Kleiner wrote: Commit 5921ba4ca705a0d919515626088f3948cc4848c1 Don't flip between BOs with different tiling parameters breaks page flipping completely, even on a simple non-prime configuration, at least on the tested Radeon HD 4670, due to incompatible tiling flags between pixmap and screen pixmap. This is just a hack which fixes pageflipping on that gpu, not intended for merging, just to illustrate that something is missing here. Signed-off-by: Mario Kleiner mario.kleiner...@gmail.com --- src/radeon_present.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/radeon_present.c b/src/radeon_present.c index 53819e0..53634ad 100644 --- a/src/radeon_present.c +++ b/src/radeon_present.c @@ -257,11 +257,12 @@ radeon_present_check_flip(RRCrtcPtr crtc, WindowPtr window, PixmapPtr pixmap, /* The kernel driver doesn't handle flipping between BOs with different * tiling parameters correctly yet */ +/* screen_pixmap = screen-GetScreenPixmap(screen); if (radeon_present_get_pixmap_tiling_flags(info, pixmap) != radeon_present_get_pixmap_tiling_flags(info, screen_pixmap)) return FALSE; - +*/ if (crtc) { drmmode_crtc_private_ptr drmmode_crtc = get_drmmode_crtc(scrn, crtc); We probably need to ignore more bits in radeon_present_get_pixmap_tiling_flags(). What does it currently return for each pixmap for you in the failing case? Patches 1 and 2 look good, I'm planning to push them soon, thanks! -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH] glamor: Deal with glamor_glyphs_init being removed from xserver
From: Michel Dänzer michel.daen...@amd.com Signed-off-by: Michel Dänzer michel.daen...@amd.com --- glamor_glyphs_init would be removed by http://lists.freedesktop.org/archives/xorg-devel/2015-May/046328.html . configure.ac| 6 ++ src/radeon_glamor.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/configure.ac b/configure.ac index 4ca5352..c371829 100644 --- a/configure.ac +++ b/configure.ac @@ -113,6 +113,12 @@ if test x$GLAMOR != xno; then [GLAMOR_XSERVER=yes], [GLAMOR_XSERVER=no], [#include xorg-server.h #include glamor.h]) + + AC_CHECK_DECL(glamor_glyphs_init, + [AC_DEFINE(HAVE_GLAMOR_GLYPHS_INIT, 1, +[Have glamor_glyphs_init API])], [], + [#include xorg-server.h + #include glamor.h]) fi if test x$GLAMOR_XSERVER != xyes; then diff --git a/src/radeon_glamor.c b/src/radeon_glamor.c index 4b6b024..fdd5aea 100644 --- a/src/radeon_glamor.c +++ b/src/radeon_glamor.c @@ -60,8 +60,10 @@ radeon_glamor_create_screen_resources(ScreenPtr screen) if (!info-use_glamor) return TRUE; +#ifdef HAVE_GLAMOR_GLYPHS_INIT if (!glamor_glyphs_init(screen)) return FALSE; +#endif if (!glamor_egl_create_textured_screen_ext(screen, info-front_bo-handle, -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
Re: [PATCH 1/2] add new bonaire pci id
On 13.05.2015 02:31, Alex Deucher wrote: Signed-off-by: Alex Deucher alexander.deuc...@amd.com Both patches are Reviewed-by: Michel Dänzer michel.daen...@amd.com P.S. Please add this to .git/config in your xf86-video-amdgpu repositories: [format] subjectprefix = PATCH xf86-video-amdgpu -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
Re: [PATCH] add new bonaire pci id
On 13.05.2015 02:32, Alex Deucher wrote: Signed-off-by: Alex Deucher alexander.deuc...@amd.com Reviewed-by: Michel Dänzer michel.daen...@amd.com -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
Re: [PATCH xf86-video-amdgpu] extend conditional group GBM_BO_USE_LINEAR over both usages
On 17.05.2015 05:00, Brian Paterni wrote: Fixes 'GBM_BO_USE_LINEAR' undeclared error when compiling against older libgbm Signed-off-by: Brian Paterni bpate...@gmail.com --- src/amdgpu_bo_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/amdgpu_bo_helper.c b/src/amdgpu_bo_helper.c index e4f30f1..1de2a0a 100644 --- a/src/amdgpu_bo_helper.c +++ b/src/amdgpu_bo_helper.c @@ -75,13 +75,13 @@ struct amdgpu_buffer *amdgpu_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width, if ( bitsPerPixel == pScrn-bitsPerPixel) bo_use |= GBM_BO_USE_SCANOUT; +#ifdef GBM_BO_USE_LINEAR #ifdef CREATE_PIXMAP_USAGE_SHARED if (usage_hint == CREATE_PIXMAP_USAGE_SHARED) { bo_use |= GBM_BO_USE_LINEAR; } #endif -#ifdef GBM_BO_USE_LINEAR if (usage_hint AMDGPU_CREATE_PIXMAP_LINEAR) { bo_use |= GBM_BO_USE_LINEAR; } Reviewed and applied, thanks! -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
Bug#785448: xserver-xorg-video-ati: Screen is badly tinged with green when using the open source driver
On 16.05.2015 21:21, Owen Riddy wrote: Package: xserver-xorg-video-ati Version: 1:7.5.0-1+b1 Severity: important Dear Maintainer, I'm using the open source ati graphics with a 3-screen setup. After upgrading to unstable after the release of Jessie everything ran without issue. I booted into a seperate install of Jessie on the same computer that had flgrx installed, and after rebooting into unstable one of the screens (connected by a HDMI cable) has acquired a distinct green tinge that obscures whatever the screen is trying to show. It is a sort of neon green. This image is a graphical corruption bug - I took a screenshot using ksnapshot and on my other two screens the image dispaled withouth the green tinge. The tinge is not present: * In the BIOS * When GRUB is active * Early in the boot process when the kernel is still printing text * On a separate Debian install on the same hardware, using fglrx I tried changing the gamma settings of the screen and poking at the backlight settings but this did not help. Changing the gamma made a very slight difference but the tinge does nto seem to be caused by a rogue gamma setting. At some points during, eg, shutdown my screens go blank - usually this is black but at present the green tinged screen goes straight green. It sounds like there might be a problem with the physical display connection. Have you checked the connector seating at both ends, maybe unplugging and re-plugging them, or even using a different cable? -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
Bug#785448: xserver-xorg-video-ati: Screen is badly tinged with green when using the open source driver
On 18.05.2015 16:28, Owen Riddy wrote: I have not, but if I reboot the computer to an install of Jessie using fglrx the tinge is not present; and it appeared shortly after updating to Jessie + unstable. I'll try a few things with the cable report back if any of them have an impact, but the fglrx test suggests this problem is 100% fixable in software. I guess I misunderstood the comments about fglrx in your original report. I agree it's probably a software bug then, though it's more likely in the kernel driver than in the Xorg driver. -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH] glamor: Remove the stride member of struct radeon_pixmap
From: Michel Dänzer michel.daen...@amd.com Its value was always the same as that of the PixmapRec devKind member. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/radeon.h| 1 - src/radeon_dri2.c | 5 +++-- src/radeon_glamor.c | 16 ++-- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/radeon.h b/src/radeon.h index afb66b2..dbc1660 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -256,7 +256,6 @@ struct radeon_pixmap { struct radeon_bo *bo; uint32_t tiling_flags; - int stride; /* GEM handle for glamor-only pixmaps shared via DRI3 */ Bool handle_valid; diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c index edf643d..31a1ce7 100644 --- a/src/radeon_dri2.c +++ b/src/radeon_dri2.c @@ -111,16 +111,17 @@ static PixmapPtr fixup_glamor(DrawablePtr drawable, PixmapPtr pixmap) /* And redirect the pixmap to the new bo (for 3D). */ glamor_egl_exchange_buffers(old, pixmap); radeon_set_pixmap_private(old, priv); - screen-DestroyPixmap(pixmap); old-refcnt++; screen-ModifyPixmapHeader(old, old-drawable.width, old-drawable.height, 0, 0, - priv-stride, + pixmap-devKind, NULL); + screen-DestroyPixmap(pixmap); + #endif /* USE_GLAMOR*/ return old; diff --git a/src/radeon_glamor.c b/src/radeon_glamor.c index eccb8f7..f00967f 100644 --- a/src/radeon_glamor.c +++ b/src/radeon_glamor.c @@ -159,11 +159,8 @@ radeon_glamor_create_textured_pixmap(PixmapPtr pixmap, struct radeon_pixmap *pri if ((info-use_glamor) == 0) return TRUE; - if (!priv-stride) - priv-stride = pixmap-devKind; - return glamor_egl_create_textured_pixmap(pixmap, priv-bo-handle, -priv-stride); +pixmap-devKind); } static PixmapPtr @@ -200,13 +197,15 @@ radeon_glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth, return pixmap; if (w h) { + int stride; + priv = calloc(1, sizeof (struct radeon_pixmap)); if (priv == NULL) goto fallback_pixmap; priv-bo = radeon_alloc_pixmap_bo(scrn, w, h, depth, usage, pixmap-drawable.bitsPerPixel, - priv-stride, + stride, priv-surface, priv-tiling_flags); if (!priv-bo) @@ -214,7 +213,7 @@ radeon_glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth, radeon_set_pixmap_private(pixmap, priv); - screen-ModifyPixmapHeader(pixmap, w, h, 0, 0, priv-stride, NULL); + screen-ModifyPixmapHeader(pixmap, w, h, 0, 0, stride, NULL); if (!radeon_glamor_create_textured_pixmap(pixmap, priv)) goto fallback_glamor; @@ -298,7 +297,6 @@ radeon_glamor_set_shared_pixmap_backing(PixmapPtr pixmap, void *handle) return FALSE; priv = radeon_get_pixmap_private(pixmap); - priv-stride = pixmap-devKind; priv-surface = surface; if (!radeon_glamor_create_textured_pixmap(pixmap, priv)) { @@ -310,9 +308,7 @@ radeon_glamor_set_shared_pixmap_backing(PixmapPtr pixmap, void *handle) screen-ModifyPixmapHeader(pixmap, pixmap-drawable.width, pixmap-drawable.height, - 0, 0, - priv-stride, - NULL); + 0, 0, 0, NULL); return TRUE; } -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH] present: Remove get_drmmode_crtc helper
From: Michel Dänzer michel.daen...@amd.com It was getting the drmmode_crtc_private_ptr in a roundabout way. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/radeon_present.c | 19 ++- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/radeon_present.c b/src/radeon_present.c index 53819e0..2626044 100644 --- a/src/radeon_present.c +++ b/src/radeon_present.c @@ -202,22 +202,6 @@ radeon_present_flush(WindowPtr window) radeon_cs_flush_indirect(xf86ScreenToScrn(window-drawable.pScreen)); } -static drmmode_crtc_private_ptr -get_drmmode_crtc(ScrnInfoPtr scrn, RRCrtcPtr crtc) -{ -xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); -int i; - -for (i = 0; i config-num_crtc; i++) { - xf86CrtcPtr xf86crtc = config-crtc[i]; - - if (xf86crtc-randr_crtc == crtc) - return xf86crtc-driver_private; -} - -return NULL; -} - static uint32_t radeon_present_get_pixmap_tiling_flags(RADEONInfoPtr info, PixmapPtr pixmap) { @@ -263,7 +247,8 @@ radeon_present_check_flip(RRCrtcPtr crtc, WindowPtr window, PixmapPtr pixmap, return FALSE; if (crtc) { - drmmode_crtc_private_ptr drmmode_crtc = get_drmmode_crtc(scrn, crtc); + xf86CrtcPtr xf86_crtc = crtc-devPrivate; + drmmode_crtc_private_ptr drmmode_crtc = xf86_crtc-driver_private; if (!drmmode_crtc || drmmode_crtc-rotate.bo != NULL || -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH xf86-video-amdgpu 01/13] Require at least xserver 1.8
From: Michel Dänzer michel.daen...@amd.com So we can rely on the list.h header. xserver 1.8 was released in April 2010. (Cherry picked from radeon commit 7388d0b6c54b9d536fdb161e3aa61b326627b939) Signed-off-by: Michel Dänzer michel.daen...@amd.com --- configure.ac | 19 ++- src/amdgpu_dri2.c | 16 2 files changed, 6 insertions(+), 29 deletions(-) diff --git a/configure.ac b/configure.ac index b26eebb..ff0979e 100644 --- a/configure.ac +++ b/configure.ac @@ -76,7 +76,7 @@ PKG_CHECK_MODULES(LIBDRM_AMDGPU, [libdrm_amdgpu]) PKG_CHECK_MODULES(GBM, [gbm]) # Obtain compiler/linker options for the driver dependencies -PKG_CHECK_MODULES(XORG, [xorg-server = 1.7 xproto fontsproto xf86driproto $REQUIRED_MODULES]) +PKG_CHECK_MODULES(XORG, [xorg-server = 1.8 xproto fontsproto xf86driproto $REQUIRED_MODULES]) PKG_CHECK_MODULES(XEXT, [xextproto = 7.0.99.1], HAVE_XEXTPROTO_71=yes; AC_DEFINE(HAVE_XEXTPROTO_71, 1, [xextproto 7.1 available]), HAVE_XEXTPROTO_71=no) @@ -145,18 +145,11 @@ else fi AM_CONDITIONAL(GLAMOR, test x$GLAMOR != xno) -AC_CHECK_HEADERS([list.h], -[have_list_h=yes], [have_list_h=no], -[#include X11/Xdefs.h - #include xorg-server.h]) - -if test x$have_list_h = xyes; then -AC_CHECK_DECL(xorg_list_init, - [AC_DEFINE(HAVE_XORG_LIST, 1, [Have xorg_list API])], [], - [#include X11/Xdefs.h - #include xorg-server.h - #include list.h]) -fi +AC_CHECK_DECL(xorg_list_init, + [AC_DEFINE(HAVE_XORG_LIST, 1, [Have xorg_list API])], [], + [#include X11/Xdefs.h + #include xorg-server.h + #include list.h]) AC_CHECK_DECL(GBM_BO_USE_LINEAR, [AC_DEFINE(HAVE_GBM_BO_USE_LINEAR, 1, [Have GBM_BO_USE_LINEAR])], [], diff --git a/src/amdgpu_dri2.c b/src/amdgpu_dri2.c index 15bb497..32f6171 100644 --- a/src/amdgpu_dri2.c +++ b/src/amdgpu_dri2.c @@ -47,7 +47,6 @@ #include amdgpu_version.h -#if HAVE_LIST_H #include list.h #if !HAVE_XORG_LIST #define xorg_list list @@ -56,11 +55,6 @@ #define xorg_list_del list_del #define xorg_list_for_each_entry list_for_each_entry #endif -#endif - -#if DRI2INFOREC_VERSION = 4 HAVE_LIST_H -#define USE_DRI2_SCHEDULING -#endif #if DRI2INFOREC_VERSION = 9 #define USE_DRI2_PRIME @@ -373,8 +367,6 @@ amdgpu_dri2_copy_region(DrawablePtr pDraw, RegionPtr pRegion, pDstBuffer, pSrcBuffer); } -#ifdef USE_DRI2_SCHEDULING - enum DRI2FrameEventType { DRI2_SWAP, DRI2_FLIP, @@ -1446,17 +1438,13 @@ blit_fallback: return TRUE; } -#endif /* USE_DRI2_SCHEDULING */ - Bool amdgpu_dri2_screen_init(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); AMDGPUInfoPtr info = AMDGPUPTR(pScrn); DRI2InfoRec dri2_info = { 0 }; -#ifdef USE_DRI2_SCHEDULING const char *driverNames[2]; Bool scheduling_works = TRUE; -#endif if (!info-dri2.available) return FALSE; @@ -1471,7 +1459,6 @@ Bool amdgpu_dri2_screen_init(ScreenPtr pScreen) dri2_info.DestroyBuffer = amdgpu_dri2_destroy_buffer; dri2_info.CopyRegion = amdgpu_dri2_copy_region; -#ifdef USE_DRI2_SCHEDULING if (info-drmmode.mode_res-count_crtcs 2) { #ifdef DRM_CAP_VBLANK_HIGH_CRTC uint64_t cap_value; @@ -1532,7 +1519,6 @@ Bool amdgpu_dri2_screen_init(ScreenPtr pScreen) DRI2InfoCnt++; } -#endif #if DRI2INFOREC_VERSION = 9 dri2_info.version = 9; @@ -1550,11 +1536,9 @@ void amdgpu_dri2_close_screen(ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); AMDGPUInfoPtr info = AMDGPUPTR(pScrn); -#ifdef USE_DRI2_SCHEDULING if (--DRI2InfoCnt == 0) DeleteCallback(ClientStateCallback, amdgpu_dri2_client_state_changed, 0); -#endif DRI2CloseScreen(pScreen); drmFree(info-dri2.device_name); -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH xf86-video-amdgpu 11/13] glamor: Add radeon_pixmap parameter to radeon_glamor_create_textured_pixmap
From: Michel Dänzer michel.daen...@amd.com (cherry picked from radeon commit 051d46382656ffc3e6cac1aab3aee7efdf5b623a) Reviewed-by: Michel Dänzer michel.daen...@amd.com Signed-off-by: Darren Powell darren.pow...@amd.com Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/amdgpu_glamor.c | 20 +++- src/amdgpu_glamor.h | 5 - src/drmmode_display.c | 3 ++- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/amdgpu_glamor.c b/src/amdgpu_glamor.c index 36241ce..79b3d01 100644 --- a/src/amdgpu_glamor.c +++ b/src/amdgpu_glamor.c @@ -126,28 +126,22 @@ Bool amdgpu_glamor_pre_init(ScrnInfoPtr scrn) return TRUE; } -Bool amdgpu_glamor_create_textured_pixmap(PixmapPtr pixmap) +Bool +amdgpu_glamor_create_textured_pixmap(PixmapPtr pixmap, struct amdgpu_pixmap *priv) { ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap-drawable.pScreen); AMDGPUInfoPtr info = AMDGPUPTR(scrn); - struct amdgpu_pixmap *priv; union gbm_bo_handle bo_handle; if ((info-use_glamor) == 0) return TRUE; - priv = amdgpu_get_pixmap_private(pixmap); - if (!priv-stride) { + if (!priv-stride) priv-stride = pixmap-devKind; - } bo_handle = gbm_bo_get_handle(priv-bo-bo.gbm); - if (glamor_egl_create_textured_pixmap(pixmap, bo_handle.u32, - priv-stride)) { - return TRUE; - } else { - return FALSE; - } + return glamor_egl_create_textured_pixmap(pixmap, bo_handle.u32, +priv-stride); } Bool amdgpu_glamor_pixmap_is_offscreen(PixmapPtr pixmap) @@ -206,7 +200,7 @@ amdgpu_glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth, screen-ModifyPixmapHeader(pixmap, w, h, 0, 0, priv-stride, NULL); - if (!amdgpu_glamor_create_textured_pixmap(pixmap)) + if (!amdgpu_glamor_create_textured_pixmap(pixmap, priv)) goto fallback_glamor; } @@ -280,7 +274,7 @@ amdgpu_glamor_set_shared_pixmap_backing(PixmapPtr pixmap, void *handle) priv = amdgpu_get_pixmap_private(pixmap); priv-stride = pixmap-devKind; - if (!amdgpu_glamor_create_textured_pixmap(pixmap)) { + if (!amdgpu_glamor_create_textured_pixmap(pixmap, priv)) { xf86DrvMsg(scrn-scrnIndex, X_ERROR, Failed to get PRIME drawable for glamor pixmap.\n); return FALSE; diff --git a/src/amdgpu_glamor.h b/src/amdgpu_glamor.h index 01b5ce1..f2414da 100644 --- a/src/amdgpu_glamor.h +++ b/src/amdgpu_glamor.h @@ -48,6 +48,8 @@ #define GLAMOR_USE_PICTURE_SCREEN 0 #endif +struct amdgpu_pixmap; + Bool amdgpu_glamor_pre_init(ScrnInfoPtr scrn); Bool amdgpu_glamor_init(ScreenPtr screen); Bool amdgpu_glamor_create_screen_resources(ScreenPtr screen); @@ -55,7 +57,8 @@ void amdgpu_glamor_free_screen(int scrnIndex, int flags); void amdgpu_glamor_flush(ScrnInfoPtr pScrn); -Bool amdgpu_glamor_create_textured_pixmap(PixmapPtr pixmap); +Bool +amdgpu_glamor_create_textured_pixmap(PixmapPtr pixmap, struct amdgpu_pixmap *priv); void amdgpu_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst); Bool amdgpu_glamor_pixmap_is_offscreen(PixmapPtr pixmap); diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 01fe860..870ced6 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -108,7 +108,8 @@ static PixmapPtr drmmode_create_bo_pixmap(ScrnInfoPtr pScrn, amdgpu_set_pixmap_bo(pixmap, bo); - if (!amdgpu_glamor_create_textured_pixmap(pixmap)) { + if (!amdgpu_glamor_create_textured_pixmap(pixmap, + amdgpu_get_pixmap_private(pixmap))) { pScreen-DestroyPixmap(pixmap); return NULL; } -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH xf86-video-amdgpu 09/13] Add support for SYNC extension fences
From: Michel Dänzer michel.daen...@amd.com (Cherry picked from radeon commits 8fc9a241ab59ffbcdc178d6415332c88a54e85fe, af1862a37570fa512a525ab47d72b30400d2e2d6, aa7825eb29cdf6ac9d7b28ad18186807ff384687, af6076241c0d322b295a4e898407ae2472bd8eb4 and d64a13ebe0ecd241ee3260dbffd8f4a01e254183) Signed-off-by: Michel Dänzer michel.daen...@amd.com --- configure.ac | 6 +++ src/Makefile.am | 2 +- src/amdgpu_drv.h | 9 src/amdgpu_kms.c | 4 ++ src/amdgpu_sync.c | 147 ++ 5 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 src/amdgpu_sync.c diff --git a/configure.ac b/configure.ac index ff0979e..2d6d4c7 100644 --- a/configure.ac +++ b/configure.ac @@ -156,6 +156,12 @@ AC_CHECK_DECL(GBM_BO_USE_LINEAR, [#include stdlib.h #include gbm.h]) +AC_CHECK_HEADERS([misyncshm.h], [], [], + [#include X11/Xdefs.h + #include X11/Xfuncproto.h + #include xorg-server.h + #include screenint.h]) + CPPFLAGS=$SAVE_CPPFLAGS PKG_CHECK_MODULES([PCIACCESS], [pciaccess = 0.8.0]) diff --git a/src/Makefile.am b/src/Makefile.am index 8e91472..fa3be5c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,7 +29,7 @@ amdgpu_drv_la_LIBADD = $(PCIACCESS_LIBS) $(LIBDRM_AMDGPU_LIBS) $(GBM_LIBS) AMDGPU_KMS_SRCS=amdgpu_bo_helper.c amdgpu_dri2.c amdgpu_drm_queue.c amdgpu_kms.c \ - drmmode_display.c + amdgpu_sync.c drmmode_display.c AM_CFLAGS = \ @GBM_CFLAGS@ \ diff --git a/src/amdgpu_drv.h b/src/amdgpu_drv.h index 4b87e6e..ad51c86 100644 --- a/src/amdgpu_drv.h +++ b/src/amdgpu_drv.h @@ -88,6 +88,8 @@ #include simple_list.h #include amdpciids.h +struct _SyncFence; + #ifndef MAX #define MAX(a,b) ((a)(b)?(a):(b)) #endif @@ -185,6 +187,9 @@ typedef struct { void (*BlockHandler) (BLOCKHANDLER_ARGS_DECL); + void (*CreateFence) (ScreenPtr pScreen, struct _SyncFence *pFence, +Bool initially_triggered); + int pix24bpp; /* Depth of pixmap for 24bpp fb */ Bool dac6bits; /* Use 6 bit DAC?*/ @@ -228,6 +233,10 @@ typedef struct { } AMDGPUInfoRec, *AMDGPUInfoPtr; +/* amdgpu_sync.c */ +extern Bool amdgpu_sync_init(ScreenPtr screen); +extern void amdgpu_sync_close(ScreenPtr screen); + /* amdgpu_video.c */ extern void AMDGPUInitVideo(ScreenPtr pScreen); extern void AMDGPUResetVideo(ScrnInfoPtr pScrn); diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c index 71a4aa7..28d9305 100644 --- a/src/amdgpu_kms.c +++ b/src/amdgpu_kms.c @@ -703,6 +703,8 @@ static Bool AMDGPUCloseScreen_KMS(CLOSE_SCREEN_ARGS_DECL) DeleteCallback(FlushCallback, amdgpu_flush_callback, pScrn); + amdgpu_sync_close(pScreen); + drmDropMaster(info-dri2.drm_fd); drmmode_fini(pScrn, info-drmmode); @@ -825,6 +827,8 @@ Bool AMDGPUScreenInit_KMS(SCREEN_INIT_ARGS_DECL) } #endif + amdgpu_sync_init(pScreen); + pScrn-vtSema = TRUE; xf86SetBackingStore(pScreen); diff --git a/src/amdgpu_sync.c b/src/amdgpu_sync.c new file mode 100644 index 000..baade0e --- /dev/null +++ b/src/amdgpu_sync.c @@ -0,0 +1,147 @@ +/* + * Copyright © 2013-2014 Intel Corporation + * Copyright © 2015 Advanced Micro Devices, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided as + * is without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include amdgpu_drv.h + +#ifdef HAVE_MISYNCSHM_H + +#include misync.h +#include misyncshm.h +#include misyncstr.h + +#include amdgpu_glamor.h + +/* + * This whole file exists to wrap a sync fence trigger operation + * so that we can flush the batch buffer to provide serialization + * between the server and the shm fence client + */ + +static DevPrivateKeyRec amdgpu_sync_fence_private_key; + +typedef struct _amdgpu_sync_fence_private
[PATCH xf86-video-amdgpu 04/13] DRI2: Simplify blit fallback handling for scheduled swaps
From: Michel Dänzer michel.daen...@amd.com Also use amdgpu_dri2_schedule_event when possible. (Cherry picked from radeon commit ad27f16f308079d06a2b1c788b3cb0947531253a) Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/amdgpu_dri2.c | 48 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/src/amdgpu_dri2.c b/src/amdgpu_dri2.c index f05b742..895abcd 100644 --- a/src/amdgpu_dri2.c +++ b/src/amdgpu_dri2.c @@ -1228,7 +1228,6 @@ static int amdgpu_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, drmVBlank vbl; int ret, flip = 0; DRI2FrameEventPtr swap_info = NULL; - enum DRI2FrameEventType swap_type = DRI2_SWAP; CARD64 current_msc; BoxRec box; RegionRec region; @@ -1254,6 +1253,7 @@ static int amdgpu_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, if (!swap_info) goto blit_fallback; + swap_info-type = DRI2_SWAP; swap_info-drawable_id = draw-id; swap_info-client = client; swap_info-event_complete = func; @@ -1293,9 +1293,7 @@ static int amdgpu_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, xf86DrvMsg(scrn-scrnIndex, X_WARNING, first get vblank counter failed: %s\n, strerror(errno)); - *target_msc = 0; - amdgpu_dri2_schedule_event(FALLBACK_SWAP_DELAY, swap_info); - return TRUE; + goto blit_fallback; } current_msc = @@ -1304,13 +1302,11 @@ static int amdgpu_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, /* Flips need to be submitted one frame before */ if (can_flip(scrn, draw, front, back)) { - swap_type = DRI2_FLIP; + swap_info-type = DRI2_FLIP; flip = 1; } - swap_info-type = swap_type; - - /* Correct target_msc by 'flip' if swap_type == DRI2_FLIP. + /* Correct target_msc by 'flip' if swap_info-type == DRI2_FLIP. * Do it early, so handling of different timing constraints * for divisor, remainder and msc vs. target_msc works. */ @@ -1347,10 +1343,7 @@ static int amdgpu_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, xf86DrvMsg(scrn-scrnIndex, X_WARNING, divisor 0 get vblank counter failed: %s\n, strerror(errno)); - *target_msc = 0; - amdgpu_dri2_schedule_event(FALLBACK_SWAP_DELAY, - swap_info); - return TRUE; + goto blit_fallback; } *target_msc = vbl.reply.sequence + flip; @@ -1397,9 +1390,7 @@ static int amdgpu_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, xf86DrvMsg(scrn-scrnIndex, X_WARNING, final get vblank counter failed: %s\n, strerror(errno)); - *target_msc = 0; - amdgpu_dri2_schedule_event(FALLBACK_SWAP_DELAY, swap_info); - return TRUE; + goto blit_fallback; } /* Adjust returned value for 1 fame pageflip offset of flip 0 */ @@ -1410,22 +1401,23 @@ static int amdgpu_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, return TRUE; blit_fallback: - box.x1 = 0; - box.y1 = 0; - box.x2 = draw-width; - box.y2 = draw-height; - REGION_INIT(pScreen, region, box, 0); + if (swap_info) { + swap_info-type = DRI2_SWAP; + amdgpu_dri2_schedule_event(FALLBACK_SWAP_DELAY, swap_info); + } else { + box.x1 = 0; + box.y1 = 0; + box.x2 = draw-width; + box.y2 = draw-height; + REGION_INIT(pScreen, region, box, 0); - amdgpu_dri2_copy_region(draw, region, front, back); + amdgpu_dri2_copy_region(draw, region, front, back); - DRI2SwapComplete(client, draw, 0, 0, 0, DRI2_BLIT_COMPLETE, func, data); - if (swap_info) { - ListDelDRI2ClientEvents(swap_info-client, swap_info-link); - free(swap_info); - } + DRI2SwapComplete(client, draw, 0, 0, 0, DRI2_BLIT_COMPLETE, func, data); - amdgpu_dri2_unref_buffer(front); - amdgpu_dri2_unref_buffer(back); + amdgpu_dri2_unref_buffer(front); + amdgpu_dri2_unref_buffer(back); + } *target_msc = 0;/* offscreen, so zero out target vblank count */ return TRUE; -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH xf86-video-amdgpu 10/13] Add support for the Present extension
From: Michel Dänzer michel.daen...@amd.com (Cherry picked from radeon commits 3c65fb849e1ba9fb6454bcaa55b696548902f3fc, 694e04720b886060fe3eefdce59741f218c8269f, e3be8b0a8cf484ff16597413a6172788178e80c8, 80eede245d1eda27eaba108b0761a24bfd69aff6 and 5f82a720374c9c1caebb42bfbeea1f0cf8847d28) Signed-off-by: Michel Dänzer michel.daen...@amd.com --- configure.ac | 6 + src/Makefile.am | 2 +- src/amdgpu_drv.h | 3 + src/amdgpu_kms.c | 3 +- src/amdgpu_present.c | 394 +++ 5 files changed, 406 insertions(+), 2 deletions(-) create mode 100644 src/amdgpu_present.c diff --git a/configure.ac b/configure.ac index 2d6d4c7..b91ce17 100644 --- a/configure.ac +++ b/configure.ac @@ -162,6 +162,12 @@ AC_CHECK_HEADERS([misyncshm.h], [], [], #include xorg-server.h #include screenint.h]) +AC_CHECK_HEADERS([present.h], [], [], +[#include X11/Xmd.h +#include X11/Xproto.h +#include X11/X.h +#include xorg-server.h]) + CPPFLAGS=$SAVE_CPPFLAGS PKG_CHECK_MODULES([PCIACCESS], [pciaccess = 0.8.0]) diff --git a/src/Makefile.am b/src/Makefile.am index fa3be5c..fc8b77a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,7 +29,7 @@ amdgpu_drv_la_LIBADD = $(PCIACCESS_LIBS) $(LIBDRM_AMDGPU_LIBS) $(GBM_LIBS) AMDGPU_KMS_SRCS=amdgpu_bo_helper.c amdgpu_dri2.c amdgpu_drm_queue.c amdgpu_kms.c \ - amdgpu_sync.c drmmode_display.c + amdgpu_present.c amdgpu_sync.c drmmode_display.c AM_CFLAGS = \ @GBM_CFLAGS@ \ diff --git a/src/amdgpu_drv.h b/src/amdgpu_drv.h index ad51c86..c6c968f 100644 --- a/src/amdgpu_drv.h +++ b/src/amdgpu_drv.h @@ -233,6 +233,9 @@ typedef struct { } AMDGPUInfoRec, *AMDGPUInfoPtr; +/* amdgpu_present.c */ +Bool amdgpu_present_screen_init(ScreenPtr screen); + /* amdgpu_sync.c */ extern Bool amdgpu_sync_init(ScreenPtr screen); extern void amdgpu_sync_close(ScreenPtr screen); diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c index 28d9305..05e9adf 100644 --- a/src/amdgpu_kms.c +++ b/src/amdgpu_kms.c @@ -827,7 +827,8 @@ Bool AMDGPUScreenInit_KMS(SCREEN_INIT_ARGS_DECL) } #endif - amdgpu_sync_init(pScreen); + if (amdgpu_sync_init(pScreen)) + amdgpu_present_screen_init(pScreen); pScrn-vtSema = TRUE; xf86SetBackingStore(pScreen); diff --git a/src/amdgpu_present.c b/src/amdgpu_present.c new file mode 100644 index 000..c0a5a32 --- /dev/null +++ b/src/amdgpu_present.c @@ -0,0 +1,394 @@ +/* + * Copyright © 2014 Intel Corporation + * Copyright © 2015 Advanced Micro Devices, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided as + * is without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include config.h +#endif + +#include amdgpu_drv.h + +#ifdef HAVE_PRESENT_H + +#include stdio.h +#include string.h +#include assert.h +#include sys/types.h +#include sys/stat.h +#include sys/ioctl.h +#include unistd.h +#include fcntl.h +#include poll.h +#include sys/time.h +#include time.h +#include errno.h + +#include amdgpu_glamor.h +#include amdgpu_pixmap.h +#include amdgpu_video.h + +#include present.h + +struct amdgpu_present_vblank_event { + uint64_t event_id; +}; + +static uint32_t crtc_select(int crtc_id) +{ + if (crtc_id 1) + return crtc_id DRM_VBLANK_HIGH_CRTC_SHIFT; + else if (crtc_id 0) + return DRM_VBLANK_SECONDARY; + else + return 0; +} + +static RRCrtcPtr +amdgpu_present_get_crtc(WindowPtr window) +{ + ScreenPtr screen = window-drawable.pScreen; + ScrnInfoPtr pScrn = xf86ScreenToScrn(screen); + xf86CrtcPtr crtc; + RRCrtcPtr randr_crtc = NULL; + + crtc = amdgpu_pick_best_crtc(pScrn, FALSE, +window-drawable.x, +window-drawable.x
[PATCH xf86-video-amdgpu 08/13] DRI2: Split out helper for getting UST and MSC of a specific CRTC
From: Michel Dänzer michel.daen...@amd.com (Cherry picked from radeon commits 76c2923ac5c7230a8b2f9f8329c308d28b44d9c0 and d7c82731a8bf3d381bc571b94d80d9bb2dd6e40d) Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/amdgpu_dri2.c | 34 +++--- src/drmmode_display.c | 27 +++ src/drmmode_display.h | 1 + 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/src/amdgpu_dri2.c b/src/amdgpu_dri2.c index 95db216..28c56e7 100644 --- a/src/amdgpu_dri2.c +++ b/src/amdgpu_dri2.c @@ -851,17 +851,13 @@ CARD32 amdgpu_dri2_extrapolate_msc_delay(xf86CrtcPtr crtc, CARD64 * target_msc, } /* - * Get current frame count and frame count timestamp, based on drawable's - * crtc. + * Get current interpolated frame count and frame count timestamp, based on + * drawable's crtc. */ static int amdgpu_dri2_get_msc(DrawablePtr draw, CARD64 * ust, CARD64 * msc) { - ScreenPtr screen = draw-pScreen; - ScrnInfoPtr scrn = xf86ScreenToScrn(screen); - AMDGPUInfoPtr info = AMDGPUPTR(scrn); - drmVBlank vbl; - int ret; xf86CrtcPtr crtc = amdgpu_dri2_drawable_crtc(draw, TRUE); + int ret; /* Drawable not displayed, make up a value */ if (crtc == NULL) { @@ -869,29 +865,20 @@ static int amdgpu_dri2_get_msc(DrawablePtr draw, CARD64 * ust, CARD64 * msc) *msc = 0; return TRUE; } + if (amdgpu_crtc_is_enabled(crtc)) { /* CRTC is running, read vblank counter and timestamp */ - vbl.request.type = DRM_VBLANK_RELATIVE; - vbl.request.type |= amdgpu_populate_vbl_request_type(crtc); - vbl.request.sequence = 0; - - ret = drmWaitVBlank(info-dri2.drm_fd, vbl); - if (ret) { - xf86DrvMsg(scrn-scrnIndex, X_WARNING, - get vblank counter failed: %s\n, - strerror(errno)); + ret = drmmode_crtc_get_ust_msc(crtc, ust, msc); + if (ret != Success) return FALSE; - } - *ust = - ((CARD64) vbl.reply.tval_sec * 100) + - vbl.reply.tval_usec; - *msc = - vbl.reply.sequence + amdgpu_get_interpolated_vblanks(crtc); + *msc += amdgpu_get_interpolated_vblanks(crtc); *msc = 0x; } else { /* CRTC is not running, extrapolate MSC and timestamp */ drmmode_crtc_private_ptr drmmode_crtc = crtc-driver_private; + ScrnInfoPtr scrn = crtc-scrn; + AMDGPUInfoPtr info = AMDGPUPTR(scrn); CARD64 now, delta_t, delta_seq; if (!drmmode_crtc-dpms_last_ust) @@ -914,7 +901,8 @@ static int amdgpu_dri2_get_msc(DrawablePtr draw, CARD64 * ust, CARD64 * msc) *msc += delta_seq; *msc = 0x; } - return TRUE; + + return ret == Success; } static diff --git a/src/drmmode_display.c b/src/drmmode_display.c index aa7c8c4..01fe860 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -204,6 +204,33 @@ int drmmode_get_current_ust(int drm_fd, CARD64 * ust) return 0; } +/* + * Get current frame count and frame count timestamp of the crtc. + */ +int drmmode_crtc_get_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc) +{ + ScrnInfoPtr scrn = crtc-scrn; + AMDGPUInfoPtr info = AMDGPUPTR(scrn); + drmVBlank vbl; + int ret; + + vbl.request.type = DRM_VBLANK_RELATIVE; + vbl.request.type |= amdgpu_populate_vbl_request_type(crtc); + vbl.request.sequence = 0; + + ret = drmWaitVBlank(info-dri2.drm_fd, vbl); + if (ret) { + xf86DrvMsg(scrn-scrnIndex, X_WARNING, + get vblank counter failed: %s\n, strerror(errno)); + return ret; + } + + *ust = ((CARD64)vbl.reply.tval_sec * 100) + vbl.reply.tval_usec; + *msc = vbl.reply.sequence; + + return Success; +} + static void drmmode_crtc_dpms(xf86CrtcPtr crtc, int mode) { drmmode_crtc_private_ptr drmmode_crtc = crtc-driver_private; diff --git a/src/drmmode_display.h b/src/drmmode_display.h index 9cf6932..90ab537 100644 --- a/src/drmmode_display.h +++ b/src/drmmode_display.h @@ -125,6 +125,7 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, struct amdgpu_buffer *new_front, uint64_t id, void *data, int ref_crtc_hw_id, amdgpu_drm_handler_proc handler, amdgpu_drm_abort_proc abort); +int drmmode_crtc_get_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc); int drmmode_get_current_ust(int drm_fd, CARD64 * ust); #endif -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org
[PATCH xf86-video-amdgpu 03/13] Add DRM event queue helpers
From: Michel Dänzer michel.daen...@amd.com (Cherry picked from radeon commit b4af8a327ed8420f0ff4ea0f113f4a59406ed4d3) Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/Makefile.am| 4 +- src/amdgpu_drm_queue.c | 181 + src/amdgpu_drm_queue.h | 56 +++ src/amdgpu_kms.c | 4 ++ 4 files changed, 244 insertions(+), 1 deletion(-) create mode 100644 src/amdgpu_drm_queue.c create mode 100644 src/amdgpu_drm_queue.h diff --git a/src/Makefile.am b/src/Makefile.am index 3fe1cd0..8e91472 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,7 +28,8 @@ amdgpu_drv_la_LIBADD = $(PCIACCESS_LIBS) $(LIBDRM_AMDGPU_LIBS) $(GBM_LIBS) -AMDGPU_KMS_SRCS=amdgpu_dri2.c amdgpu_kms.c drmmode_display.c amdgpu_bo_helper.c +AMDGPU_KMS_SRCS=amdgpu_bo_helper.c amdgpu_dri2.c amdgpu_drm_queue.c amdgpu_kms.c \ + drmmode_display.c AM_CFLAGS = \ @GBM_CFLAGS@ \ @@ -57,6 +58,7 @@ amdgpu_drv_la_SOURCES += \ EXTRA_DIST = \ compat-api.h \ amdgpu_bo_helper.h \ + amdgpu_drm_queue.h \ amdgpu_glamor.h \ amdgpu_drv.h \ amdgpu_list.h \ diff --git a/src/amdgpu_drm_queue.c b/src/amdgpu_drm_queue.c new file mode 100644 index 000..9bec658 --- /dev/null +++ b/src/amdgpu_drm_queue.c @@ -0,0 +1,181 @@ +/* + * Copyright © 2007 Red Hat, Inc. + * Copyright © 2015 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the Software), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Authors: + *Dave Airlie airl...@redhat.com + * + */ + +#ifdef HAVE_CONFIG_H +#include config.h +#endif + +#include xorg-server.h + +#include amdgpu_drv.h +#include amdgpu_drm_queue.h +#include amdgpu_list.h + + +struct amdgpu_drm_queue_entry { + struct xorg_list list; + uint64_t id; + void *data; + ClientPtr client; + ScrnInfoPtr scrn; + amdgpu_drm_handler_proc handler; + amdgpu_drm_abort_proc abort; +}; + +static int amdgpu_drm_queue_refcnt; +static struct xorg_list amdgpu_drm_queue; + + +/* + * Handle a DRM event + */ +void +amdgpu_drm_queue_handler(int fd, unsigned int frame, unsigned int sec, +unsigned int usec, void *user_ptr) +{ + struct amdgpu_drm_queue_entry *user_data = user_ptr; + struct amdgpu_drm_queue_entry *e, *tmp; + + xorg_list_for_each_entry_safe(e, tmp, amdgpu_drm_queue, list) { + if (e == user_data) { + xorg_list_del(e-list); + e-handler(e-scrn, frame, + (uint64_t)sec * 100 + usec, e-data); + free(e); + break; + } + } +} + +/* + * Enqueue a potential drm response; when the associated response + * appears, we've got data to pass to the handler from here + */ +struct amdgpu_drm_queue_entry * +amdgpu_drm_queue_alloc(ScrnInfoPtr scrn, ClientPtr client, + uint64_t id, void *data, + amdgpu_drm_handler_proc handler, + amdgpu_drm_abort_proc abort) +{ + struct amdgpu_drm_queue_entry *e; + + e = calloc(1, sizeof(struct amdgpu_drm_queue_entry)); + if (!e) + return NULL; + + e-client = client; + e-scrn = scrn; + e-id = id; + e-data = data; + e-handler = handler; + e-abort = abort; + + xorg_list_add(e-list, amdgpu_drm_queue); + + return e; +} + +/* + * Abort one queued DRM entry, removing it + * from the list, calling the abort function and + * freeing the memory + */ +static void +amdgpu_drm_abort_one(struct amdgpu_drm_queue_entry *e) +{ + xorg_list_del(e-list); + e-abort(e-scrn, e-data); + free(e); +} + +/* + * Abort drm queue entries for a client + */ +void +amdgpu_drm_abort_client(ClientPtr client) +{ + struct amdgpu_drm_queue_entry *e, *tmp
[PATCH xf86-video-amdgpu 05/13] DRI2: Remove superfluous assignments to *_info-frame
From: Michel Dänzer michel.daen...@amd.com That field is only used for page flipping. (Cherry picked from radeon commit 65045112fdc8a9fa36e0e00f46739a6152b775ff) Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/amdgpu_dri2.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/src/amdgpu_dri2.c b/src/amdgpu_dri2.c index 895abcd..fd98fa7 100644 --- a/src/amdgpu_dri2.c +++ b/src/amdgpu_dri2.c @@ -1038,7 +1038,6 @@ static int amdgpu_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw, CARD32 delay; delay = amdgpu_dri2_extrapolate_msc_delay(crtc, target_msc, divisor, remainder); - wait_info-frame = target_msc; amdgpu_dri2_schedule_event(delay, wait_info); DRI2BlockClient(client, draw); return TRUE; @@ -1086,8 +1085,6 @@ static int amdgpu_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw, goto out_complete; } - wait_info-frame = vbl.reply.sequence; - wait_info-frame += amdgpu_get_interpolated_vblanks(crtc); DRI2BlockClient(client, draw); return TRUE; } @@ -1120,8 +1117,6 @@ static int amdgpu_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw, goto out_complete; } - wait_info-frame = vbl.reply.sequence; - wait_info-frame += amdgpu_get_interpolated_vblanks(crtc); DRI2BlockClient(client, draw); return TRUE; @@ -1279,7 +1274,6 @@ static int amdgpu_dri2_schedule_swap(ClientPtr client, DrawablePtr draw, CARD32 delay; delay = amdgpu_dri2_extrapolate_msc_delay(crtc, target_msc, divisor, remainder); - swap_info-frame = *target_msc; amdgpu_dri2_schedule_event(delay, swap_info); return TRUE; } -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH xf86-video-amdgpu 07/13] DRI2: Use helper functions for DRM event queue management
From: Michel Dänzer michel.daen...@amd.com This is mostly in preparation for Present support, but it also simplifies the DRI2 specific code a little. (Cherry picked from radeon commit 6c3a721cde9317233072b573f9502348dcd21b16) Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/amdgpu_dri2.c | 271 ++ src/amdgpu_dri2.h | 37 --- src/drmmode_display.c | 90 +++-- src/drmmode_display.h | 13 ++- 4 files changed, 165 insertions(+), 246 deletions(-) diff --git a/src/amdgpu_dri2.c b/src/amdgpu_dri2.c index c139dec..95db216 100644 --- a/src/amdgpu_dri2.c +++ b/src/amdgpu_dri2.c @@ -49,6 +49,8 @@ #include amdgpu_list.h +#include xf86Priv.h + #if DRI2INFOREC_VERSION = 9 #define USE_DRI2_PRIME #endif @@ -370,65 +372,20 @@ typedef struct _DRI2FrameEvent { XID drawable_id; ClientPtr client; enum DRI2FrameEventType type; - int frame; + unsigned frame; xf86CrtcPtr crtc; + OsTimerPtr timer; + struct amdgpu_drm_queue_entry *drm_queue; /* for swaps flips only */ DRI2SwapEventPtr event_complete; void *event_data; DRI2BufferPtr front; DRI2BufferPtr back; - - Bool valid; - - struct xorg_list link; } DRI2FrameEventRec, *DRI2FrameEventPtr; -typedef struct _DRI2ClientEvents { - struct xorg_list reference_list; -} DRI2ClientEventsRec, *DRI2ClientEventsPtr; - -#if HAS_DEVPRIVATEKEYREC - static int DRI2InfoCnt; -static DevPrivateKeyRec DRI2ClientEventsPrivateKeyRec; -#define DRI2ClientEventsPrivateKey (DRI2ClientEventsPrivateKeyRec) - -#else - -static int DRI2ClientEventsPrivateKeyIndex; -DevPrivateKey DRI2ClientEventsPrivateKey = DRI2ClientEventsPrivateKeyIndex; - -#endif /* HAS_DEVPRIVATEKEYREC */ - -#define GetDRI2ClientEvents(pClient) ((DRI2ClientEventsPtr) \ -dixLookupPrivate((pClient)-devPrivates, DRI2ClientEventsPrivateKey)) - -static int ListAddDRI2ClientEvents(ClientPtr client, struct xorg_list *entry) -{ - DRI2ClientEventsPtr pClientPriv; - pClientPriv = GetDRI2ClientEvents(client); - - if (!pClientPriv) { - return BadAlloc; - } - - xorg_list_add(entry, pClientPriv-reference_list); - return 0; -} - -static void ListDelDRI2ClientEvents(ClientPtr client, struct xorg_list *entry) -{ - DRI2ClientEventsPtr pClientPriv; - pClientPriv = GetDRI2ClientEvents(client); - - if (!pClientPriv) { - return; - } - xorg_list_del(entry); -} - static void amdgpu_dri2_ref_buffer(BufferPtr buffer) { struct dri2_buffer_priv *private = buffer-driverPrivate; @@ -448,30 +405,13 @@ static void amdgpu_dri2_client_state_changed(CallbackListPtr * ClientStateCallback, pointer data, pointer calldata) { - DRI2ClientEventsPtr pClientEventsPriv; - DRI2FrameEventPtr ref; NewClientInfoRec *clientinfo = calldata; ClientPtr pClient = clientinfo-client; - pClientEventsPriv = GetDRI2ClientEvents(pClient); switch (pClient-clientState) { - case ClientStateInitial: - xorg_list_init(pClientEventsPriv-reference_list); - break; - case ClientStateRunning: - break; - case ClientStateRetained: case ClientStateGone: - if (pClientEventsPriv) { - xorg_list_for_each_entry(ref, -pClientEventsPriv- -reference_list, link) { - ref-valid = FALSE; - amdgpu_dri2_unref_buffer(ref-front); - amdgpu_dri2_unref_buffer(ref-back); - } - } + amdgpu_drm_abort_client(pClient); break; default: break; @@ -497,37 +437,42 @@ xf86CrtcPtr amdgpu_dri2_drawable_crtc(DrawablePtr pDraw, Bool consider_disabled) return NULL; } -void amdgpu_dri2_flip_event_handler(unsigned int frame, unsigned int tv_sec, - unsigned int tv_usec, void *event_data) +static void +amdgpu_dri2_flip_event_abort(ScrnInfoPtr scrn, void *event_data) +{ + free(event_data); +} + +static void +amdgpu_dri2_flip_event_handler(ScrnInfoPtr scrn, uint32_t frame, uint64_t usec, + void *event_data) { DRI2FrameEventPtr flip = event_data; + unsigned tv_sec, tv_usec; DrawablePtr drawable; ScreenPtr screen; - ScrnInfoPtr scrn; int status; PixmapPtr pixmap; status = dixLookupDrawable(drawable, flip-drawable_id, serverClient, M_ANY, DixWriteAccess); - if (status != Success) { - free(flip); - return; - } - if (!flip-crtc
[PATCH xf86-video-amdgpu 13/13] Add DRI3 support
From: Michel Dänzer michel.daen...@amd.com Must be enabled with Option DRI3 in xorg.conf. (Cherry picked from radeon commits 64e1e4dbdd3caee6f5d8f6b6c094b4533fa94953, 694e04720b886060fe3eefdce59741f218c8269f, f940fd741b15f03393037c5bb904cd74f012de9d, fcd37f65f485291084c174666bd605e215bf1398, 4b0997e56dec0053cb2cb793e0f4ae35055ff7e6, f68d9b5ba0c91a725b5eec9386c61bea8824c299 and 98fb4199e63fedd4607cddee64bf602d6398df81) Signed-off-by: Michel Dänzer michel.daen...@amd.com --- configure.ac | 4 ++ man/amdgpu.man| 4 ++ src/Makefile.am | 4 +- src/amdgpu_dri3.c | 196 ++ src/amdgpu_drv.h | 6 +- src/amdgpu_kms.c | 20 +- 6 files changed, 229 insertions(+), 5 deletions(-) create mode 100644 src/amdgpu_dri3.c diff --git a/configure.ac b/configure.ac index b91ce17..d9d97ef 100644 --- a/configure.ac +++ b/configure.ac @@ -168,6 +168,10 @@ AC_CHECK_HEADERS([present.h], [], [], #include X11/X.h #include xorg-server.h]) +AC_CHECK_HEADERS([dri3.h], [], [], +[#include X11/Xmd.h +#include xorg-server.h]) + CPPFLAGS=$SAVE_CPPFLAGS PKG_CHECK_MODULES([PCIACCESS], [pciaccess = 0.8.0]) diff --git a/man/amdgpu.man b/man/amdgpu.man index 64633b3..bc7bf30 100644 --- a/man/amdgpu.man +++ b/man/amdgpu.man @@ -70,6 +70,10 @@ For example: Option \*qZaphodHeads\*q \*qLVDS,VGA-0\*q will assign xrandr outputs LVDS and VGA-0 to this instance of the driver. .TP +.BI Option \*qDRI3\*q \*q boolean \*q +Enable the DRI3 extension. The default is +.B off. +.TP .BI Option \*qEnablePageFlip\*q \*q boolean \*q Enable DRI2 page flipping. The default is .B on. diff --git a/src/Makefile.am b/src/Makefile.am index fc8b77a..b953d4c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,8 +28,8 @@ amdgpu_drv_la_LIBADD = $(PCIACCESS_LIBS) $(LIBDRM_AMDGPU_LIBS) $(GBM_LIBS) -AMDGPU_KMS_SRCS=amdgpu_bo_helper.c amdgpu_dri2.c amdgpu_drm_queue.c amdgpu_kms.c \ - amdgpu_present.c amdgpu_sync.c drmmode_display.c +AMDGPU_KMS_SRCS=amdgpu_bo_helper.c amdgpu_dri2.c amdgpu_dri3.c amdgpu_drm_queue.c \ + amdgpu_kms.c amdgpu_present.c amdgpu_sync.c drmmode_display.c AM_CFLAGS = \ @GBM_CFLAGS@ \ diff --git a/src/amdgpu_dri3.c b/src/amdgpu_dri3.c new file mode 100644 index 000..ce0f8e7 --- /dev/null +++ b/src/amdgpu_dri3.c @@ -0,0 +1,196 @@ +/* + * Copyright © 2013-2014 Intel Corporation + * Copyright © 2015 Advanced Micro Devices, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided as + * is without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + + +#ifdef HAVE_CONFIG_H +#include config.h +#endif + +#include amdgpu_drv.h + +#ifdef HAVE_DRI3_H + +#include amdgpu_glamor.h +#include amdgpu_pixmap.h +#include dri3.h + +#include sys/types.h +#include sys/stat.h +#include fcntl.h +#include errno.h + + +static int +amdgpu_dri3_open(ScreenPtr screen, RRProviderPtr provider, int *out) +{ + ScrnInfoPtr scrn = xf86ScreenToScrn(screen); + AMDGPUInfoPtr info = AMDGPUPTR(scrn); + drm_magic_t magic; + int fd; + + fd = open(info-dri2.device_name, O_RDWR | O_CLOEXEC); + if (fd 0) + return BadAlloc; + + /* Before FD passing in the X protocol with DRI3 (and increased +* security of rendering with per-process address spaces on the +* GPU), the kernel had to come up with a way to have the server +* decide which clients got to access the GPU, which was done by +* each client getting a unique (magic) number from the kernel, +* passing it to the server, and the server then telling the +* kernel which clients were authenticated for using the device. +* +* Now that we have FD passing, the server can just set up the +* authentication on its own and hand the prepared FD off to the +* client
[PATCH xf86-video-amdgpu 02/13] Move xorg_list backwards compatibility to new amdgpu_list.h header
From: Michel Dänzer michel.daen...@amd.com (Cherry picked from radeon commits 7c3470f4b659206ed23f761948936ede3a2dba3d and 4a98f60117c387a228d5cbaadb6e298fb4e865df) Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/Makefile.am | 1 + src/amdgpu_dri2.c | 9 + src/amdgpu_list.h | 39 +++ 3 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 src/amdgpu_list.h diff --git a/src/Makefile.am b/src/Makefile.am index 8715eb3..3fe1cd0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -59,6 +59,7 @@ EXTRA_DIST = \ amdgpu_bo_helper.h \ amdgpu_glamor.h \ amdgpu_drv.h \ + amdgpu_list.h \ amdgpu_probe.h \ amdgpu_version.h \ amdgpu_video.h \ diff --git a/src/amdgpu_dri2.c b/src/amdgpu_dri2.c index 32f6171..f05b742 100644 --- a/src/amdgpu_dri2.c +++ b/src/amdgpu_dri2.c @@ -47,14 +47,7 @@ #include amdgpu_version.h -#include list.h -#if !HAVE_XORG_LIST -#define xorg_list list -#define xorg_list_init list_init -#define xorg_list_add list_add -#define xorg_list_del list_del -#define xorg_list_for_each_entry list_for_each_entry -#endif +#include amdgpu_list.h #if DRI2INFOREC_VERSION = 9 #define USE_DRI2_PRIME diff --git a/src/amdgpu_list.h b/src/amdgpu_list.h new file mode 100644 index 000..c1e3516 --- /dev/null +++ b/src/amdgpu_list.h @@ -0,0 +1,39 @@ +/* + * Copyright © 2015 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the Software), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef _AMDGPU_LIST_H_ +#define _AMDGPU_LIST_H_ + +#include xorg-server.h +#include list.h + +#if !HAVE_XORG_LIST +#define xorg_list list +#define xorg_list_init list_init +#define xorg_list_add list_add +#define xorg_list_del list_del +#define xorg_list_for_each_entry list_for_each_entry +#define xorg_list_for_each_entry_safe list_for_each_entry_safe +#endif + +#endif /* _AMDGPU_LIST_H_ */ -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH xf86-video-amdgpu 12/13] amdgpu_set_shared_pixmap_backing: Add support for GBM / glamor
From: Michel Dänzer michel.daen...@amd.com Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/amdgpu_bo_helper.c | 101 ++--- 1 file changed, 78 insertions(+), 23 deletions(-) diff --git a/src/amdgpu_bo_helper.c b/src/amdgpu_bo_helper.c index 0487b46..08e4048 100644 --- a/src/amdgpu_bo_helper.c +++ b/src/amdgpu_bo_helper.c @@ -27,8 +27,32 @@ #include gbm.h #include amdgpu_drv.h #include amdgpu_bo_helper.h +#include amdgpu_glamor.h #include amdgpu_pixmap.h +static uint32_t +amdgpu_get_gbm_format(int depth, int bitsPerPixel) +{ + switch (depth) { +#ifdef GBM_FORMAT_R8 + case 8: + return GBM_FORMAT_R8; +#endif + case 16: + return GBM_FORMAT_RGB565; + case 32: + return GBM_FORMAT_ARGB; + case 24: + if (bitsPerPixel == 32) + return GBM_FORMAT_XRGB; + /* fall through */ + default: + ErrorF(%s: Unsupported depth/bpp %d/%d\n, __func__, + depth, bitsPerPixel); + return ~0U; + } +} + /* Calculate appropriate pitch for a pixmap and allocate a BO that can hold it. */ struct amdgpu_buffer *amdgpu_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width, @@ -40,31 +64,10 @@ struct amdgpu_buffer *amdgpu_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width, if (info-gbm) { uint32_t bo_use = GBM_BO_USE_RENDERING; - uint32_t gbm_format; + uint32_t gbm_format = amdgpu_get_gbm_format(depth, bitsPerPixel); - switch (depth) { -#ifdef GBM_FORMAT_R8 - case 8: - gbm_format = GBM_FORMAT_R8; - break; -#endif - case 16: - gbm_format = GBM_FORMAT_RGB565; - break; - case 32: - gbm_format = GBM_FORMAT_ARGB; - break; - case 24: - if (bitsPerPixel == 32) { - gbm_format = GBM_FORMAT_XRGB; - break; - } - /* fall through */ - default: - ErrorF(%s: Unsupported depth/bpp %d/%d\n, __func__, - depth, bitsPerPixel); + if (gbm_format == ~0U) return NULL; - } pixmap_buffer = (struct amdgpu_buffer *)calloc(1, sizeof(struct amdgpu_buffer)); if (!pixmap_buffer) { @@ -310,11 +313,63 @@ Bool amdgpu_share_pixmap_backing(struct amdgpu_buffer *bo, void **handle_p) Bool amdgpu_set_shared_pixmap_backing(PixmapPtr ppix, void *fd_handle) { ScrnInfoPtr pScrn = xf86ScreenToScrn(ppix-drawable.pScreen); + AMDGPUInfoPtr info = AMDGPUPTR(pScrn); AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(pScrn); struct amdgpu_buffer *pixmap_buffer = NULL; int ihandle = (int)(long)fd_handle; uint32_t size = ppix-devKind * ppix-drawable.height; + if (info-gbm) { + struct amdgpu_pixmap *priv; + struct gbm_import_fd_data data; + uint32_t bo_use = GBM_BO_USE_RENDERING; + + data.format = amdgpu_get_gbm_format(ppix-drawable.depth, + ppix-drawable.bitsPerPixel); + if (data.format == ~0U) + return FALSE; + + priv = calloc(1, sizeof(struct amdgpu_pixmap)); + if (!priv) + return FALSE; + + priv-bo = calloc(1, sizeof(struct amdgpu_buffer)); + if (!priv-bo) { + free(priv); + return FALSE; + } + + data.fd = ihandle; + data.width = ppix-drawable.width; + data.height = ppix-drawable.height; + data.stride = ppix-devKind; + + if (ppix-drawable.bitsPerPixel == pScrn-bitsPerPixel) + bo_use |= GBM_BO_USE_SCANOUT; + + priv-bo-bo.gbm = gbm_bo_import(info-gbm, GBM_BO_IMPORT_FD, +data, bo_use); + if (!priv-bo-bo.gbm) { + free(priv-bo); + free(priv); + return FALSE; + } + + priv-bo-flags |= AMDGPU_BO_FLAGS_GBM; + +#ifdef USE_GLAMOR + if (info-use_glamor + !amdgpu_glamor_create_textured_pixmap(ppix, priv)) { + free(priv-bo); + free(priv); + return FALSE; + } +#endif + + amdgpu_set_pixmap_private(ppix, priv); + return TRUE; + } + pixmap_buffer = amdgpu_gem_bo_open_prime(pAMDGPUEnt-pDev, ihandle, size
[PATCH xf86-video-amdgpu 06/13] DRI2: Move amdgpu_dri2_flip_event_handler
From: Michel Dänzer michel.daen...@amd.com In preparation for the next change, which will modify it to a static function which needs to be in the new place. No functional change. (Cherry picked from radeon commit c3fa22a479e61d1899fa9d327d9c4e2a7f64b0c1) Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/amdgpu_dri2.c | 120 +++--- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/src/amdgpu_dri2.c b/src/amdgpu_dri2.c index fd98fa7..c139dec 100644 --- a/src/amdgpu_dri2.c +++ b/src/amdgpu_dri2.c @@ -497,6 +497,66 @@ xf86CrtcPtr amdgpu_dri2_drawable_crtc(DrawablePtr pDraw, Bool consider_disabled) return NULL; } +void amdgpu_dri2_flip_event_handler(unsigned int frame, unsigned int tv_sec, + unsigned int tv_usec, void *event_data) +{ + DRI2FrameEventPtr flip = event_data; + DrawablePtr drawable; + ScreenPtr screen; + ScrnInfoPtr scrn; + int status; + PixmapPtr pixmap; + + status = dixLookupDrawable(drawable, flip-drawable_id, serverClient, + M_ANY, DixWriteAccess); + if (status != Success) { + free(flip); + return; + } + if (!flip-crtc) { + free(flip); + return; + } + frame += amdgpu_get_interpolated_vblanks(flip-crtc); + + screen = drawable-pScreen; + scrn = xf86ScreenToScrn(screen); + + pixmap = screen-GetScreenPixmap(screen); + xf86DrvMsgVerb(scrn-scrnIndex, X_INFO, AMDGPU_LOGLEVEL_DEBUG, + %s:%d fevent[%p] width %d pitch %d (/4 %d)\n, + __func__, __LINE__, flip, pixmap-drawable.width, + pixmap-devKind, pixmap-devKind / 4); + + /* We assume our flips arrive in order, so we don't check the frame */ + switch (flip-type) { + case DRI2_SWAP: + /* Check for too small vblank count of pageflip completion, taking wraparound +* into account. This usually means some defective kms pageflip completion, +* causing wrong (msc, ust) return values and possible visual corruption. +*/ + if ((frame flip-frame) (flip-frame - frame 5)) { + xf86DrvMsg(scrn-scrnIndex, X_WARNING, + %s: Pageflip completion event has impossible msc %d target_msc %d\n, + __func__, frame, flip-frame); + /* All-Zero values signal failure of (msc, ust) timestamping to client. */ + frame = tv_sec = tv_usec = 0; + } + + DRI2SwapComplete(flip-client, drawable, frame, tv_sec, tv_usec, +DRI2_FLIP_COMPLETE, flip-event_complete, +flip-event_data); + break; + default: + xf86DrvMsg(scrn-scrnIndex, X_WARNING, + %s: unknown vblank event received\n, __func__); + /* Unknown type */ + break; + } + + free(flip); +} + static Bool amdgpu_dri2_schedule_flip(ScrnInfoPtr scrn, ClientPtr client, DrawablePtr draw, DRI2BufferPtr front, @@ -1130,66 +1190,6 @@ out_complete: return TRUE; } -void amdgpu_dri2_flip_event_handler(unsigned int frame, unsigned int tv_sec, - unsigned int tv_usec, void *event_data) -{ - DRI2FrameEventPtr flip = event_data; - DrawablePtr drawable; - ScreenPtr screen; - ScrnInfoPtr scrn; - int status; - PixmapPtr pixmap; - - status = dixLookupDrawable(drawable, flip-drawable_id, serverClient, - M_ANY, DixWriteAccess); - if (status != Success) { - free(flip); - return; - } - if (!flip-crtc) { - free(flip); - return; - } - frame += amdgpu_get_interpolated_vblanks(flip-crtc); - - screen = drawable-pScreen; - scrn = xf86ScreenToScrn(screen); - - pixmap = screen-GetScreenPixmap(screen); - xf86DrvMsgVerb(scrn-scrnIndex, X_INFO, AMDGPU_LOGLEVEL_DEBUG, - %s:%d fevent[%p] width %d pitch %d (/4 %d)\n, - __func__, __LINE__, flip, pixmap-drawable.width, - pixmap-devKind, pixmap-devKind / 4); - - /* We assume our flips arrive in order, so we don't check the frame */ - switch (flip-type) { - case DRI2_SWAP: - /* Check for too small vblank count of pageflip completion, taking wraparound -* into account. This usually means some defective kms pageflip completion, -* causing wrong (msc, ust) return values and possible visual corruption. -*/ - if ((frame flip-frame) (flip
[PATCH xf86-video-amdgpu 0/13] DRI3/Present support ported from radeon
This series ports the changes for DRI3/Present support from the radeon driver, with some followup fixes squashed in. Patch 11 was ported by Darren Powell, so I added my review tag. [PATCH xf86-video-amdgpu 01/13] Require at least xserver 1.8 [PATCH xf86-video-amdgpu 02/13] Move xorg_list backwards [PATCH xf86-video-amdgpu 03/13] Add DRM event queue helpers [PATCH xf86-video-amdgpu 04/13] DRI2: Simplify blit fallback handling [PATCH xf86-video-amdgpu 05/13] DRI2: Remove superfluous assignments [PATCH xf86-video-amdgpu 06/13] DRI2: Move [PATCH xf86-video-amdgpu 07/13] DRI2: Use helper functions for DRM [PATCH xf86-video-amdgpu 08/13] DRI2: Split out helper for getting [PATCH xf86-video-amdgpu 09/13] Add support for SYNC extension fences [PATCH xf86-video-amdgpu 10/13] Add support for the Present extension [PATCH xf86-video-amdgpu 11/13] glamor: Add radeon_pixmap parameter [PATCH xf86-video-amdgpu 12/13] amdgpu_set_shared_pixmap_backing: Add [PATCH xf86-video-amdgpu 13/13] Add DRI3 support ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
Re: [PATCH xf86-video-amdgpu] Check GBM flag for textured pixmap creation
On 08.06.2015 12:12, Zhou, Jammy wrote: How can AMDGPU_BO_FLAGS_GBM not be set when using glamor? It may happen in amdgpu_glamor_set_shared_pixmap_backing for PRIME support. I fixed that in http://lists.x.org/archives/xorg-driver-ati/2015-June/027599.html . P.S. The clock is set incorrectly (in the future) on the system where you generated the patch. -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
Re: [PATCH xf86-video-amdgpu] Check GBM flag for textured pixmap creation
On 08.06.2015 19:32, Jammy Zhou wrote: Signed-off-by: Jammy Zhou jammy.z...@amd.com --- src/amdgpu_glamor.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/amdgpu_glamor.c b/src/amdgpu_glamor.c index d451fa9..434c138 100644 --- a/src/amdgpu_glamor.c +++ b/src/amdgpu_glamor.c @@ -135,6 +135,7 @@ Bool amdgpu_glamor_create_textured_pixmap(PixmapPtr pixmap) AMDGPUInfoPtr info = AMDGPUPTR(scrn); struct amdgpu_pixmap *priv; union gbm_bo_handle bo_handle; + int handle; if ((info-use_glamor) == 0) return TRUE; @@ -144,8 +145,17 @@ Bool amdgpu_glamor_create_textured_pixmap(PixmapPtr pixmap) priv-stride = pixmap-devKind; } - bo_handle = gbm_bo_get_handle(priv-bo-bo.gbm); - if (glamor_egl_create_textured_pixmap(pixmap, bo_handle.u32, + if (priv-bo-flags AMDGPU_BO_FLAGS_GBM) { + bo_handle = gbm_bo_get_handle(priv-bo-bo.gbm); + handle = bo_handle.u32; + } else { + if (amdgpu_bo_export(priv-bo-bo.amdgpu, + amdgpu_bo_handle_type_kms, + handle)) + return FALSE; + } + + if (glamor_egl_create_textured_pixmap(pixmap, handle, priv-stride)) { return TRUE; } else { How can AMDGPU_BO_FLAGS_GBM not be set when using glamor? -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
Re: [PATCH 2/2] Allow/Fix use of multiple ZaphodHead outputs per x-screen.
On 05.06.2015 21:33, Mario Kleiner wrote: Defining multiple ZaphodHead outputs per x-screen in a multiple x-screen's per gpu configuration caused all outputs except one per x-screen to go dark, because there was a fixed mapping x-screen number - crtc number, limiting the number of crtc's per x-screen to one. On a ZaphodHead's setup, be more clever and assign as many crtc's to a given x-screen as there are ZaphodHeads defined for that screen, assuming there are enough unused crtc's available. Tested on a triple display setup with different combos of one, two or three ZaphodHeads per one, two or three x-screens. This is a port of almost identical code from nouveau-ddx. Signed-off-by: Mario Kleiner mario.kleiner...@gmail.com Some questions / suggestions below. Other than that, it looks good to me. + /* Mark num'th crtc as in use on this device. */ + pRADEONEnt-assigned_crtcs |= (1 num); + xf86DrvMsg(pScrn-scrnIndex, X_INFO, +Allocated crtc nr. %d to this screen.\n, num); These log messages seem rather verbose. Maybe they should have a higher log level so they aren't printed by default. + /* All ZaphodHeads outputs provided with matching crtcs? */ + if (xf86IsEntityShared(pScrn-entityList[0]) (crtcs_needed 0)) + xf86DrvMsg(pScrn-scrnIndex, X_WARNING, +%d ZaphodHeads crtcs unavailable. Trouble!\n, crtcs_needed); Can this say something more useful than Trouble!, e.g. what bad thing(s) will likely happen? diff --git a/src/radeon_probe.c b/src/radeon_probe.c index ad1e96e..45a89f3 100644 --- a/src/radeon_probe.c +++ b/src/radeon_probe.c @@ -174,6 +174,13 @@ radeon_get_scrninfo(int entity_num, void *pci_dev) pRADEONEnt = pPriv-ptr; pRADEONEnt-HasSecondary = TRUE; } + +/* Reset settings which must not persist across server regeneration */ +if (pRADEONEnt-reinitGeneration != serverGeneration) { +pRADEONEnt-reinitGeneration = serverGeneration; +/* Clear mask of assigned crtc's in this generation to none */ +pRADEONEnt-assigned_crtcs = 0; +} Is pRADEONEnt-reinitGeneration really necessary? Couldn't we just set pRADEONEnt-assigned_crtcs = 0 in CloseScreen? -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH xf86-video-amdgpu 05/11] glamor: Add wrappers for the X server rendering hooks
From: Michel Dänzer michel.daen...@amd.com They can choose between using the GPU or CPU for the operation. (cherry picked from radeon commits eea79472a84672ee4dc7adc4487cec6a4037048a and e58fc380ccf2a581d28f041fd74b963626ca5404) Signed-off-by: Darren Powell darren.pow...@amd.com Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/Makefile.am | 1 + src/amdgpu_bo_helper.c | 3 - src/amdgpu_drv.h | 26 ++ src/amdgpu_glamor.c | 4 +- src/amdgpu_glamor_wrappers.c | 992 +++ src/amdgpu_pixmap.h | 3 + 6 files changed, 1025 insertions(+), 4 deletions(-) create mode 100644 src/amdgpu_glamor_wrappers.c diff --git a/src/Makefile.am b/src/Makefile.am index b953d4c..6c8d1de 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -53,6 +53,7 @@ AM_CFLAGS += @LIBGLAMOR_CFLAGS@ amdgpu_drv_la_LIBADD += @LIBGLAMOR_LIBS@ amdgpu_drv_la_SOURCES += \ amdgpu_glamor.c \ + amdgpu_glamor_wrappers.c \ amdgpu_pixmap.c EXTRA_DIST = \ diff --git a/src/amdgpu_bo_helper.c b/src/amdgpu_bo_helper.c index c778796..54270c6 100644 --- a/src/amdgpu_bo_helper.c +++ b/src/amdgpu_bo_helper.c @@ -123,9 +123,6 @@ int amdgpu_bo_map(ScrnInfoPtr pScrn, struct amdgpu_buffer *bo) AMDGPUInfoPtr info = AMDGPUPTR(pScrn); int ret = 0; - if (info-use_glamor) - return 0; - if (bo-flags AMDGPU_BO_FLAGS_GBM) { uint32_t handle, stride, height; union drm_amdgpu_gem_mmap args; diff --git a/src/amdgpu_drv.h b/src/amdgpu_drv.h index 5ffbc6a..467c2fb 100644 --- a/src/amdgpu_drv.h +++ b/src/amdgpu_drv.h @@ -200,6 +200,8 @@ typedef struct { struct amdgpu_dri2 dri2; /* accel */ + uint_fast32_t gpu_flushed; + uint_fast32_t gpu_synced; Bool use_glamor; /* general */ @@ -231,6 +233,30 @@ typedef struct { /* cursor size */ int cursor_w; int cursor_h; + + struct { + CreateGCProcPtr SavedCreateGC; + RegionPtr (*SavedCopyArea)(DrawablePtr, DrawablePtr, GCPtr, + int, int, int, int, int, int); + void (*SavedPolyFillRect)(DrawablePtr, GCPtr, int, xRectangle*); + CloseScreenProcPtr SavedCloseScreen; + GetImageProcPtr SavedGetImage; + GetSpansProcPtr SavedGetSpans; + CreatePixmapProcPtr SavedCreatePixmap; + DestroyPixmapProcPtr SavedDestroyPixmap; + CopyWindowProcPtr SavedCopyWindow; + ChangeWindowAttributesProcPtr SavedChangeWindowAttributes; + BitmapToRegionProcPtr SavedBitmapToRegion; +#ifdef RENDER + CompositeProcPtr SavedComposite; + TrianglesProcPtr SavedTriangles; + GlyphsProcPtr SavedGlyphs; + TrapezoidsProcPtr SavedTrapezoids; + AddTrapsProcPtr SavedAddTraps; + UnrealizeGlyphProcPtr SavedUnrealizeGlyph; +#endif + } glamor; + } AMDGPUInfoRec, *AMDGPUInfoPtr; diff --git a/src/amdgpu_glamor.c b/src/amdgpu_glamor.c index 296115e..7c45f34 100644 --- a/src/amdgpu_glamor.c +++ b/src/amdgpu_glamor.c @@ -324,8 +324,10 @@ void amdgpu_glamor_flush(ScrnInfoPtr pScrn) { AMDGPUInfoPtr info = AMDGPUPTR(pScrn); - if (info-use_glamor) + if (info-use_glamor) { glamor_block_handler(pScrn-pScreen); + info-gpu_flushed++; + } } XF86VideoAdaptorPtr amdgpu_glamor_xv_init(ScreenPtr pScreen, int num_adapt) diff --git a/src/amdgpu_glamor_wrappers.c b/src/amdgpu_glamor_wrappers.c new file mode 100644 index 000..8edfde0 --- /dev/null +++ b/src/amdgpu_glamor_wrappers.c @@ -0,0 +1,992 @@ +/* + * Copyright © 2001 Keith Packard + * 2010 Intel Corporation + * 2012,2015 Advanced Micro Devices, Inc. + * + * Partly based on code Copyright © 2008 Red Hat, Inc. + * Partly based on code Copyright © 2000 SuSE, Inc. + * + * Partly based on code that is Copyright © The XFree86 Project Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the opyright holders not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The copyright holders make no + * representations about the suitability of this software for any purpose. It + * is provided as is without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE
[PATCH xf86-video-amdgpu 00/11] ShadowPrimary TearFree support
This series adds support for options ShadowPrimary and TearFree, corresponding to the same options in the radeon driver. Most of the changes are ports from the radeon driver, large parts of which was done by Darren Powell. [PATCH xf86-video-amdgpu 01/11] Rename scanout_pixmap_x field to [PATCH xf86-video-amdgpu 02/11] Split out struct drmmode_scanout for [PATCH xf86-video-amdgpu 03/11] Add RADEON_CREATE_PIXMAP_SCANOUT flag [PATCH xf86-video-amdgpu 04/11] glamor: Remove unused function [PATCH xf86-video-amdgpu 05/11] glamor: Add wrappers for the X server [PATCH xf86-video-amdgpu 06/11] Set AMDGPU_BO_FLAGS_GBM for cursor [PATCH xf86-video-amdgpu 07/11] Factor out amdgpu_bo_get_handle [PATCH xf86-video-amdgpu 08/11] Add AMDGPU_CREATE_PIXMAP_GTT flag [PATCH xf86-video-amdgpu 09/11] glamor: Add Option ShadowPrimary [PATCH xf86-video-amdgpu 10/11] glamor: Remove the stride member of [PATCH xf86-video-amdgpu 11/11] Add Option TearFree ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH xf86-video-amdgpu 07/11] Factor out amdgpu_bo_get_handle helper
From: Michel Dänzer michel.daen...@amd.com The helper transparently handles BOs allocated from GBM and libdrm_amdgpu. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/amdgpu_bo_helper.c | 11 +++ src/amdgpu_bo_helper.h | 2 ++ src/amdgpu_glamor.c| 18 ++ src/drmmode_display.c | 32 ++-- 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/src/amdgpu_bo_helper.c b/src/amdgpu_bo_helper.c index 54270c6..47cd9eb 100644 --- a/src/amdgpu_bo_helper.c +++ b/src/amdgpu_bo_helper.c @@ -118,6 +118,17 @@ struct amdgpu_buffer *amdgpu_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width, return pixmap_buffer; } +Bool amdgpu_bo_get_handle(struct amdgpu_buffer *bo, uint32_t *handle) +{ + if (bo-flags AMDGPU_BO_FLAGS_GBM) { + *handle = gbm_bo_get_handle(bo-bo.gbm).u32; + return TRUE; + } + + return amdgpu_bo_export(bo-bo.amdgpu, amdgpu_bo_handle_type_kms, + handle) == 0; +} + int amdgpu_bo_map(ScrnInfoPtr pScrn, struct amdgpu_buffer *bo) { AMDGPUInfoPtr info = AMDGPUPTR(pScrn); diff --git a/src/amdgpu_bo_helper.h b/src/amdgpu_bo_helper.h index 8270d39..4dae200 100644 --- a/src/amdgpu_bo_helper.h +++ b/src/amdgpu_bo_helper.h @@ -29,6 +29,8 @@ extern struct amdgpu_buffer *amdgpu_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width int height, int depth, int usage_hint, int bitsPerPixel, int *new_pitch); +extern Bool amdgpu_bo_get_handle(struct amdgpu_buffer *bo, uint32_t *handle); + extern int amdgpu_bo_map(ScrnInfoPtr pScrn, struct amdgpu_buffer *bo); extern void amdgpu_bo_unmap(struct amdgpu_buffer *bo); diff --git a/src/amdgpu_glamor.c b/src/amdgpu_glamor.c index 7c45f34..d91effc 100644 --- a/src/amdgpu_glamor.c +++ b/src/amdgpu_glamor.c @@ -55,7 +55,7 @@ Bool amdgpu_glamor_create_screen_resources(ScreenPtr screen) { ScrnInfoPtr scrn = xf86ScreenToScrn(screen); AMDGPUInfoPtr info = AMDGPUPTR(scrn); - union gbm_bo_handle bo_handle; + uint32_t bo_handle; if (!info-use_glamor) return TRUE; @@ -65,9 +65,9 @@ Bool amdgpu_glamor_create_screen_resources(ScreenPtr screen) return FALSE; #endif - bo_handle = gbm_bo_get_handle(info-front_buffer-bo.gbm); - if (!glamor_egl_create_textured_screen_ext(screen, - bo_handle.u32, + if (!amdgpu_bo_get_handle(info-front_buffer, bo_handle) || + !glamor_egl_create_textured_screen_ext(screen, + bo_handle, scrn-displayWidth * info-pixel_bytes, NULL)) { return FALSE; @@ -131,7 +131,7 @@ amdgpu_glamor_create_textured_pixmap(PixmapPtr pixmap, struct amdgpu_pixmap *pri { ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap-drawable.pScreen); AMDGPUInfoPtr info = AMDGPUPTR(scrn); - union gbm_bo_handle bo_handle; + uint32_t bo_handle; if ((info-use_glamor) == 0) return TRUE; @@ -139,9 +139,11 @@ amdgpu_glamor_create_textured_pixmap(PixmapPtr pixmap, struct amdgpu_pixmap *pri if (!priv-stride) priv-stride = pixmap-devKind; - bo_handle = gbm_bo_get_handle(priv-bo-bo.gbm); - return glamor_egl_create_textured_pixmap(pixmap, bo_handle.u32, -priv-stride); + if (!amdgpu_bo_get_handle(priv-bo, bo_handle)) + return FALSE; + + return glamor_egl_create_textured_pixmap(pixmap, bo_handle, +pixmap-devKind); } #ifndef CREATE_PIXMAP_USAGE_SHARED diff --git a/src/drmmode_display.c b/src/drmmode_display.c index d855787..1fcf901 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -420,18 +420,12 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, int i; int fb_id; drmModeModeInfo kmode; - union gbm_bo_handle bo_handle; + uint32_t bo_handle; if (drmmode-fb_id == 0) { - if (info-gbm) { - bo_handle = gbm_bo_get_handle(info-front_buffer-bo.gbm); - } else { - if (amdgpu_bo_export(info-front_buffer-bo.amdgpu, -amdgpu_bo_handle_type_kms, -bo_handle.u32)) { - ErrorF(failed to get BO handle for FB\n); - return FALSE; - } + if (!amdgpu_bo_get_handle(info-front_buffer, bo_handle)) { + ErrorF(failed to get BO handle for FB\n); + return FALSE
[PATCH xf86-video-amdgpu 08/11] Add AMDGPU_CREATE_PIXMAP_GTT flag
From: Michel Dänzer michel.daen...@amd.com When set, the pixmap memory is allocated in GTT instead of in VRAM. Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/amdgpu_bo_helper.c | 6 -- src/amdgpu_pixmap.h| 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/amdgpu_bo_helper.c b/src/amdgpu_bo_helper.c index 47cd9eb..00e8643 100644 --- a/src/amdgpu_bo_helper.c +++ b/src/amdgpu_bo_helper.c @@ -62,7 +62,7 @@ struct amdgpu_buffer *amdgpu_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width, AMDGPUInfoPtr info = AMDGPUPTR(pScrn); struct amdgpu_buffer *pixmap_buffer; - if (info-gbm) { + if (!(usage_hint AMDGPU_CREATE_PIXMAP_GTT) info-gbm) { uint32_t bo_use = GBM_BO_USE_RENDERING; uint32_t gbm_format = amdgpu_get_gbm_format(depth, bitsPerPixel); @@ -107,9 +107,11 @@ struct amdgpu_buffer *amdgpu_alloc_pixmap_bo(ScrnInfoPtr pScrn, int width, unsigned cpp = (bitsPerPixel + 7) / 8; unsigned pitch = cpp * AMDGPU_ALIGN(width, drmmode_get_pitch_align(pScrn, cpp)); + uint32_t domain = (usage_hint AMDGPU_CREATE_PIXMAP_GTT) ? + AMDGPU_GEM_DOMAIN_GTT : AMDGPU_GEM_DOMAIN_VRAM; pixmap_buffer = amdgpu_bo_open(pAMDGPUEnt-pDev, pitch * height, - 4096, AMDGPU_GEM_DOMAIN_VRAM); + 4096, domain); if (new_pitch) *new_pitch = pitch; diff --git a/src/amdgpu_pixmap.h b/src/amdgpu_pixmap.h index a5dc081..b269853 100644 --- a/src/amdgpu_pixmap.h +++ b/src/amdgpu_pixmap.h @@ -107,6 +107,7 @@ enum { AMDGPU_CREATE_PIXMAP_DRI2= 0x0800, AMDGPU_CREATE_PIXMAP_LINEAR = 0x0400, AMDGPU_CREATE_PIXMAP_SCANOUT = 0x0200, + AMDGPU_CREATE_PIXMAP_GTT = 0x0100, }; extern Bool amdgpu_pixmap_init(ScreenPtr screen); -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH xf86-video-amdgpu 09/11] glamor: Add Option ShadowPrimary
From: Michel Dänzer michel.daen...@amd.com When this option is enabled, most pixmaps (including the screen pixmap) are allocated in system RAM and mostly accessed by the CPU. Changed areas of the screen pixmap are copied to dedicated per-CRTC scanout pixmaps regularly, triggered by the vblank interrupt. (Cherry picked from radeon commits ae92d1765fa370a8d94c2856ad6c45d273ec3c69 and 1af044d7eee211fd4b248c236280274a68334da5) [ Michel Dänzer: Additional adjustements for the amdgpu driver ] Signed-off-by: Darren Powell darren.pow...@amd.com Signed-off-by: Michel Dänzer michel.daen...@amd.com --- configure.ac | 10 +++ man/amdgpu.man| 35 --- src/amdgpu_dri2.c | 1 + src/amdgpu_dri3.c | 3 +- src/amdgpu_drv.h | 2 + src/amdgpu_glamor.c | 62 --- src/amdgpu_glamor.h | 9 +++ src/amdgpu_kms.c | 167 -- src/drmmode_display.c | 150 + src/drmmode_display.h | 6 ++ 10 files changed, 381 insertions(+), 64 deletions(-) diff --git a/configure.ac b/configure.ac index d9d97ef..85892fa 100644 --- a/configure.ac +++ b/configure.ac @@ -145,6 +145,16 @@ else fi AM_CONDITIONAL(GLAMOR, test x$GLAMOR != xno) +AC_CHECK_DECL(fbGlyphs, + [AC_DEFINE(HAVE_FBGLYPHS, 1, [Have fbGlyphs API])], [], + [#include X11/Xmd.h + #include X11/Xfuncproto.h + #include X11/extensions/renderproto.h + #include xorg-server.h + #include picture.h + #include glyphstr.h + #include fbpict.h]) + AC_CHECK_DECL(xorg_list_init, [AC_DEFINE(HAVE_XORG_LIST, 1, [Have xorg_list API])], [], [#include X11/Xdefs.h diff --git a/man/amdgpu.man b/man/amdgpu.man index bc7bf30..d280197 100644 --- a/man/amdgpu.man +++ b/man/amdgpu.man @@ -50,15 +50,7 @@ Enables or disables all hardware acceleration. The default is to .B enable hardware acceleration. -.TP -.BI Option \*qAccelMethod\*q \*q string \*q -Setting this option to -.B none -disables use of the glamor acceleration architecture. In that case, all 2D -rendering is done by the CPU, but 3D and video hardware acceleration can still -work. This is mainly useful for OpenGL driver bring-up. -.br -The default is to use glamor. + .TP .BI Option \*qZaphodHeads\*q \*q string \*q Specify the RandR output(s) to use with zaphod mode for a particular driver @@ -77,6 +69,31 @@ Enable the DRI3 extension. The default is .BI Option \*qEnablePageFlip\*q \*q boolean \*q Enable DRI2 page flipping. The default is .B on. +.TP +.BI Option \*qAccelMethod\*q \*q string \*q +Setting this option to +.B none +disables use of the glamor acceleration architecture. In that case, all 2D +rendering is done by the CPU, but 3D and video hardware acceleration can still +work. This is mainly useful for OpenGL driver bring-up. +.br +The default is to use glamor. + +.PP +The following driver +.B Option +is supported for +.B glamor +: +.TP +.BI Option \*qShadowPrimary\*q \*q boolean \*q +This option enables a so-called shadow primary buffer for fast CPU access to +pixel data, and separate scanout buffers for each display controller (CRTC). +This may improve performance for some 2D workloads, potentially at the expense +of other (e.g. 3D, video) workloads. +Note in particular that enabling this option currently disables page flipping. +The default is +.B off. .SH SEE ALSO __xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__) diff --git a/src/amdgpu_dri2.c b/src/amdgpu_dri2.c index 28c56e7..bdb0d37 100644 --- a/src/amdgpu_dri2.c +++ b/src/amdgpu_dri2.c @@ -116,6 +116,7 @@ static PixmapPtr fixup_glamor(DrawablePtr drawable, PixmapPtr pixmap) old-drawable.width, old-drawable.height, 0, 0, priv-stride, NULL); + old-devPrivate.ptr = NULL; return old; } diff --git a/src/amdgpu_dri3.c b/src/amdgpu_dri3.c index ce0f8e7..a89421e 100644 --- a/src/amdgpu_dri3.c +++ b/src/amdgpu_dri3.c @@ -108,7 +108,8 @@ static PixmapPtr amdgpu_dri3_pixmap_from_fd(ScreenPtr screen, return NULL; } - pixmap = screen-CreatePixmap(screen, 0, 0, depth, 0); + pixmap = screen-CreatePixmap(screen, 0, 0, depth, + AMDGPU_CREATE_PIXMAP_DRI2); if (!pixmap) return NULL; diff --git a/src/amdgpu_drv.h b/src/amdgpu_drv.h index 467c2fb..55be626 100644 --- a/src/amdgpu_drv.h +++ b/src/amdgpu_drv.h @@ -142,6 +142,7 @@ typedef enum { OPTION_ZAPHOD_HEADS, OPTION_ACCEL_METHOD, OPTION_DRI3, + OPTION_SHADOW_PRIMARY, } AMDGPUOpts; #define AMDGPU_VSYNC_TIMEOUT 2 /* Maximum wait for VSYNC (in usecs) */ @@ -203,6 +204,7 @@ typedef struct { uint_fast32_t
[PATCH xf86-video-amdgpu 01/11] Rename scanout_pixmap_x field to prime_pixmap_x
From: Michel Dänzer michel.daen...@amd.com To avoid confusion with upcoming changes. (cherry picked from radeon commit c32b0530302739f6512755bccf281c2300617376) Signed-off-by: Darren Powell darren.pow...@amd.com Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/drmmode_display.c | 6 +++--- src/drmmode_display.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 870ced6..c391ab2 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -402,7 +402,7 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, fb_id = drmmode-fb_id; #ifdef AMDGPU_PIXMAP_SHARING if (crtc-randr_crtc crtc-randr_crtc-scanout_pixmap) { - x = drmmode_crtc-scanout_pixmap_x; + x = drmmode_crtc-prime_pixmap_x; y = 0; } else #endif @@ -635,7 +635,7 @@ static Bool drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix) PixmapStopDirtyTracking(crtc- randr_crtc-scanout_pixmap, screenpix); - drmmode_crtc-scanout_pixmap_x = 0; + drmmode_crtc-prime_pixmap_x = 0; return TRUE; } @@ -677,7 +677,7 @@ static Bool drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix) screen-width = screenpix-drawable.width = total_width; screen-height = screenpix-drawable.height = max_height; } - drmmode_crtc-scanout_pixmap_x = this_x; + drmmode_crtc-prime_pixmap_x = this_x; #ifdef HAS_DIRTYTRACKING2 PixmapStartDirtyTracking2(ppix, screenpix, 0, 0, this_x, 0); #else diff --git a/src/drmmode_display.h b/src/drmmode_display.h index 90ab537..df46099 100644 --- a/src/drmmode_display.h +++ b/src/drmmode_display.h @@ -83,7 +83,7 @@ typedef struct { int dpms_last_fps; uint32_t interpolated_vblanks; uint16_t lut_r[256], lut_g[256], lut_b[256]; - int scanout_pixmap_x; + int prime_pixmap_x; } drmmode_crtc_private_rec, *drmmode_crtc_private_ptr; typedef struct { -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati
[PATCH xf86-video-amdgpu 06/11] Set AMDGPU_BO_FLAGS_GBM for cursor buffers allocated from GBM
From: Michel Dänzer michel.daen...@amd.com Signed-off-by: Michel Dänzer michel.daen...@amd.com --- src/amdgpu_kms.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c index 1e256af..cfdf716 100644 --- a/src/amdgpu_kms.c +++ b/src/amdgpu_kms.c @@ -1037,6 +1037,7 @@ static Bool amdgpu_setup_kernel_mem(ScreenPtr pScreen) return FALSE; } info-cursor_buffer[c]-ref_count = 1; + info-cursor_buffer[c]-flags = AMDGPU_BO_FLAGS_GBM; info-cursor_buffer[c]-bo.gbm = gbm_bo_create(info-gbm, info-cursor_w, -- 2.1.4 ___ xorg-driver-ati mailing list xorg-driver-ati@lists.x.org http://lists.x.org/mailman/listinfo/xorg-driver-ati