Skip to contentSkip to conversation

glamor: Use glamor_egl_create_textured_pixmap_from_gbm_bo when possible

PATCH In review Michel Dänzer 2 participants 2 messages Aug 2, 2018 1 message 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.

(Ported from radeon commit db28d35ce9fd07a2a4703f3df0633d4c8291ff9b)

---
 src/amdgpu_glamor.c | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)
src/amdgpu_glamor.c +18 -14
index 8b839105e..ea49f822f 100644
@@ -53,9 +53,9 @@ void amdgpu_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst)
 
 Bool amdgpu_glamor_create_screen_resources(ScreenPtr screen)
 {
+	PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	AMDGPUInfoPtr info = AMDGPUPTR(scrn);
-	uint32_t bo_handle;
 
 	if (!info->use_glamor)
 		return TRUE;
@@ -65,14 +65,8 @@ Bool amdgpu_glamor_create_screen_resources(ScreenPtr screen)
 		return FALSE;
 #endif
 
-	if (!amdgpu_bo_get_handle(info->front_buffer, &bo_handle) ||
-	    !glamor_egl_create_textured_screen(screen, bo_handle,
-					       scrn->displayWidth *
-					       info->pixel_bytes)) {
-		return FALSE;
-	}
-
-	return TRUE;
+	return amdgpu_glamor_create_textured_pixmap(screen_pixmap,
+						    info->front_buffer);
 }
 
 Bool amdgpu_glamor_pre_init(ScrnInfoPtr scrn)
@@ -129,16 +123,26 @@ amdgpu_glamor_create_textured_pixmap(PixmapPtr pixmap, struct amdgpu_buffer *bo)
 {
 	ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
 	AMDGPUInfoPtr info = AMDGPUPTR(scrn);
-	uint32_t bo_handle;
 
 	if ((info->use_glamor) == 0)
 		return TRUE;
 
-	if (!amdgpu_bo_get_handle(bo, &bo_handle))
-		return FALSE;
+	if (bo->flags & AMDGPU_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 {
+		uint32_t bo_handle;
 
-	return glamor_egl_create_textured_pixmap(pixmap, bo_handle,
-						 pixmap->devKind);
+		if (!amdgpu_bo_get_handle(bo, &bo_handle))
+			return FALSE;
+
+		return glamor_egl_create_textured_pixmap(pixmap, bo_handle,
+							 pixmap->devKind);
+	}
 }
 
 static Bool amdgpu_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): 20180802164713.23060-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org

Reviewed-by
#2 lore raw
Quoted 7 lines · Michel Dänzer

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

Inspired by the modesetting driver.

(Ported from radeon commit db28d35ce9fd07a2a4703f3df0633d4c8291ff9b)

Quoted 71 lines
---
 src/amdgpu_glamor.c | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)
src/amdgpu_glamor.c +18 -15
index 8b839105e..ea49f822f 100644
@@ -53,9 +53,9 @@ void amdgpu_glamor_exchange_buffers(PixmapPtr src, PixmapPtr dst)
 
 Bool amdgpu_glamor_create_screen_resources(ScreenPtr screen)
 {
+       PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
        ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
        AMDGPUInfoPtr info = AMDGPUPTR(scrn);
-       uint32_t bo_handle;
 
        if (!info->use_glamor)
                return TRUE;
@@ -65,14 +65,8 @@ Bool amdgpu_glamor_create_screen_resources(ScreenPtr screen)
                return FALSE;
 #endif
 
-       if (!amdgpu_bo_get_handle(info->front_buffer, &bo_handle) ||
-           !glamor_egl_create_textured_screen(screen, bo_handle,
-                                              scrn->displayWidth *
-                                              info->pixel_bytes)) {
-               return FALSE;
-       }
-
-       return TRUE;
+       return amdgpu_glamor_create_textured_pixmap(screen_pixmap,
+                                                   info->front_buffer);
 }
 
 Bool amdgpu_glamor_pre_init(ScrnInfoPtr scrn)
@@ -129,16 +123,26 @@ amdgpu_glamor_create_textured_pixmap(PixmapPtr pixmap, struct amdgpu_buffer *bo)
 {
        ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
        AMDGPUInfoPtr info = AMDGPUPTR(scrn);
-       uint32_t bo_handle;
 
        if ((info->use_glamor) == 0)
                return TRUE;
 
-       if (!amdgpu_bo_get_handle(bo, &bo_handle))
-               return FALSE;
+       if (bo->flags & AMDGPU_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 {
+               uint32_t bo_handle;
 
-       return glamor_egl_create_textured_pixmap(pixmap, bo_handle,
-                                                pixmap->devKind);
+               if (!amdgpu_bo_get_handle(bo, &bo_handle))
+                       return FALSE;
+
+               return glamor_egl_create_textured_pixmap(pixmap, bo_handle,
+                                                        pixmap->devKind);
+       }
 }
 
 static Bool amdgpu_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