Skip to contentSkip to conversation

glamor: Use glamor_egl_create_textured_pixmap_from_gbm_bo when possible

PATCH Superseded Michel Dänzer 2 participants 4 messages Jul 27, 2018 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 glamor: Use glamor_egl_create_textured_pixmap_from_gbm_bo when possible

From: Michel Dänzer <[email protected]>

Inspired by the modesetting driver.

Fixes screen pixmap corruption with Xorg < 1.20, and as a bonus, simplifies the code slightly.

Bugzilla: https://bugs.freedesktop.org/107385

---
 src/radeon_glamor.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)
src/radeon_glamor.c +12 -16
index b649bd18d..368e433ef 100644
@@ -50,9 +50,9 @@ radeon_glamor_exchange_buffers(PixmapPtr src,
 Bool
 radeon_glamor_create_screen_resources(ScreenPtr screen)
 {
+	PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	RADEONInfoPtr info = RADEONPTR(scrn);
-	uint32_t handle;
 
 	if (!info->use_glamor)
 		return TRUE;
@@ -62,16 +62,11 @@ radeon_glamor_create_screen_resources(ScreenPtr screen)
 		return FALSE;
 #endif
 
-	if (info->front_buffer->flags & RADEON_BO_FLAGS_GBM)
-		handle = gbm_bo_get_handle(info->front_buffer->bo.gbm).u32;
-	else
-		handle = info->front_buffer->bo.radeon->handle;
-
-	if (!glamor_egl_create_textured_screen(screen, handle,
-					       scrn->displayWidth *
-					       info->pixel_bytes))
+	if (!radeon_glamor_create_textured_pixmap(screen_pixmap, info->front_buffer))
 		return FALSE;
 
+	glamor_set_screen_pixmap(screen_pixmap, NULL);
+
 	return TRUE;
 }
 
@@ -180,17 +175,18 @@ radeon_glamor_create_textured_pixmap(PixmapPtr pixmap, struct radeon_buffer *bo)
 {
 	ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
 	RADEONInfoPtr info = RADEONPTR(scrn);
-	uint32_t handle;
 
 	if (!info->use_glamor)
 		return TRUE;
 
-	if (bo->flags & RADEON_BO_FLAGS_GBM)
-		handle = gbm_bo_get_handle(bo->bo.gbm).u32;
-	else
-		handle = bo->bo.radeon->handle;
-
-	return glamor_egl_create_textured_pixmap(pixmap, handle, pixmap->devKind);
+	if (bo->flags & RADEON_BO_FLAGS_GBM) {
+		return glamor_egl_create_textured_pixmap_from_gbm_bo(pixmap,
+								     bo->bo.gbm);
+	} else {
+		return glamor_egl_create_textured_pixmap(pixmap,
+							 bo->bo.radeon->handle,
+							 pixmap->devKind);
+	}
 }
 
 static Bool radeon_glamor_destroy_pixmap(PixmapPtr pixmap)
Signature · 6 lines
2.18.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20180727093309.31736-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org

#2 lore raw
Quoted 6 lines · Michel Dänzer

From: Michel Dänzer <[email protected]>

Inspired by the modesetting driver.

Fixes screen pixmap corruption with Xorg < 1.20, and as a bonus, simplifies the code slightly.

Unfortunately, turns out this patch as is breaks compilation against xserver 1.20. I'll send a v2 patch which works in both cases.

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#3 lore raw

PATCH v2 1/1 glamor: Use glamor_egl_create_textured_pixmap_from_gbm_bo when possible

In reply to a message not in the archive

From: Michel Dänzer <[email protected]>

Inspired by the modesetting driver.

Fixes screen pixmap corruption with Xorg < 1.20, and as a bonus, simplifies the code slightly.

v2:
* Now doesn't break with xserver 1.20

Bugzilla: https://bugs.freedesktop.org/107385

---
 src/radeon_glamor.c | 34 +++++++++++++++-------------------
 1 file changed, 15 insertions(+), 19 deletions(-)
src/radeon_glamor.c +15 -19
index b649bd18d..c733d192d 100644
@@ -50,9 +50,9 @@ radeon_glamor_exchange_buffers(PixmapPtr src,
 Bool
 radeon_glamor_create_screen_resources(ScreenPtr screen)
 {
+	PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	RADEONInfoPtr info = RADEONPTR(scrn);
-	uint32_t handle;
 
 	if (!info->use_glamor)
 		return TRUE;
@@ -62,17 +62,8 @@ radeon_glamor_create_screen_resources(ScreenPtr screen)
 		return FALSE;
 #endif
 
-	if (info->front_buffer->flags & RADEON_BO_FLAGS_GBM)
-		handle = gbm_bo_get_handle(info->front_buffer->bo.gbm).u32;
-	else
-		handle = info->front_buffer->bo.radeon->handle;
-
-	if (!glamor_egl_create_textured_screen(screen, handle,
-					       scrn->displayWidth *
-					       info->pixel_bytes))
-		return FALSE;
-
-	return TRUE;
+	return radeon_glamor_create_textured_pixmap(screen_pixmap,
+						    info->front_buffer);
 }
 
 
@@ -180,17 +171,22 @@ radeon_glamor_create_textured_pixmap(PixmapPtr pixmap, struct radeon_buffer *bo)
 {
 	ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
 	RADEONInfoPtr info = RADEONPTR(scrn);
-	uint32_t handle;
 
 	if (!info->use_glamor)
 		return TRUE;
 
-	if (bo->flags & RADEON_BO_FLAGS_GBM)
-		handle = gbm_bo_get_handle(bo->bo.gbm).u32;
-	else
-		handle = bo->bo.radeon->handle;
-
-	return glamor_egl_create_textured_pixmap(pixmap, handle, pixmap->devKind);
+	if (bo->flags & RADEON_BO_FLAGS_GBM) {
+		return glamor_egl_create_textured_pixmap_from_gbm_bo(pixmap,
+								     bo->bo.gbm
+#if XORG_VERSION_CURRENT > XORG_VERSION_NUMERIC(1,19,99,903,0)
+								     , FALSE
+#endif
+								     );
+	} else {
+		return glamor_egl_create_textured_pixmap(pixmap,
+							 bo->bo.radeon->handle,
+							 pixmap->devKind);
+	}
 }
 
 static Bool radeon_glamor_destroy_pixmap(PixmapPtr pixmap)
Signature · 6 lines
2.18.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20180727145306.18773-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org

Reviewed-by
#5 lore raw
Quoted 4 lines · Michel Dänzer

From: Michel Dänzer <[email protected]>

Inspired by the modesetting driver.

Quoted 8 lines

Fixes screen pixmap corruption with Xorg < 1.20, and as a bonus, simplifies the code slightly.

v2:
* Now doesn't break with xserver 1.20

Bugzilla: https://bugs.freedesktop.org/107385

Quoted 72 lines
---
 src/radeon_glamor.c | 34 +++++++++++++++-------------------
 1 file changed, 15 insertions(+), 19 deletions(-)
src/radeon_glamor.c +15 -20
index b649bd18d..c733d192d 100644
@@ -50,9 +50,9 @@ radeon_glamor_exchange_buffers(PixmapPtr src,
 Bool
 radeon_glamor_create_screen_resources(ScreenPtr screen)
 {
+       PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
        ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
        RADEONInfoPtr info = RADEONPTR(scrn);
-       uint32_t handle;
 
        if (!info->use_glamor)
                return TRUE;
@@ -62,17 +62,8 @@ radeon_glamor_create_screen_resources(ScreenPtr screen)
                return FALSE;
 #endif
 
-       if (info->front_buffer->flags & RADEON_BO_FLAGS_GBM)
-               handle = gbm_bo_get_handle(info->front_buffer->bo.gbm).u32;
-       else
-               handle = info->front_buffer->bo.radeon->handle;
-
-       if (!glamor_egl_create_textured_screen(screen, handle,
-                                              scrn->displayWidth *
-                                              info->pixel_bytes))
-               return FALSE;
-
-       return TRUE;
+       return radeon_glamor_create_textured_pixmap(screen_pixmap,
+                                                   info->front_buffer);
 }
 
 
@@ -180,17 +171,22 @@ radeon_glamor_create_textured_pixmap(PixmapPtr pixmap, struct radeon_buffer *bo)
 {
        ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
        RADEONInfoPtr info = RADEONPTR(scrn);
-       uint32_t handle;
 
        if (!info->use_glamor)
                return TRUE;
 
-       if (bo->flags & RADEON_BO_FLAGS_GBM)
-               handle = gbm_bo_get_handle(bo->bo.gbm).u32;
-       else
-               handle = bo->bo.radeon->handle;
-
-       return glamor_egl_create_textured_pixmap(pixmap, handle, pixmap->devKind);
+       if (bo->flags & RADEON_BO_FLAGS_GBM) {
+               return glamor_egl_create_textured_pixmap_from_gbm_bo(pixmap,
+                                                                    bo->bo.gbm
+#if XORG_VERSION_CURRENT > XORG_VERSION_NUMERIC(1,19,99,903,0)
+                                                                    , FALSE
+#endif
+                                                                    );
+       } else {
+               return glamor_egl_create_textured_pixmap(pixmap,
+                                                        bo->bo.radeon->handle,
+                                                        pixmap->devKind);
+       }
 }
 
 static Bool radeon_glamor_destroy_pixmap(PixmapPtr pixmap)
--

2.18.0

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx