mirror of
https://github.com/X11Libre/xf86-video-amdgpu.git
synced 2026-03-24 01:24:31 +00:00
dri3: implement get_drawable_modifiers - per-drawable modifiers
Takes a DrawablePtr, format, and returns modifiers via num_modifiers and modifiers parameters Returns TRUE on success, FALSE on allocation failure Selects modifiers based on GPU family (GC 12.0.0+, GFX10+, GFX9+, or older) Returns AMD-specific tiled modifiers (64K_S, 64K_D, 64K_2D) plus LINEAR (cherry picked from commit 69becd71c29c98d97aa69a66246ca6bf6eeaf74f)
This commit is contained in:
@@ -566,17 +566,28 @@ amdgpu_dri3_get_modifiers(ScreenPtr screen, uint32_t format,
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static Bool
|
||||||
amdgpu_dri3_get_drawable_modifiers(DrawablePtr draw, uint32_t format,
|
amdgpu_dri3_get_drawable_modifiers(DrawablePtr draw, uint32_t format,
|
||||||
uint32_t *num_modifiers, uint64_t **modifiers)
|
uint32_t *num_modifiers, uint64_t **modifiers)
|
||||||
{
|
{
|
||||||
ScrnInfoPtr scrn = xf86ScreenToScrn(draw->pScreen);
|
ScrnInfoPtr scrn;
|
||||||
AMDGPUInfoPtr info = AMDGPUPTR(scrn);
|
AMDGPUInfoPtr info;
|
||||||
uint64_t *mods;
|
uint64_t *mods;
|
||||||
uint32_t count;
|
uint32_t count;
|
||||||
int asic_family;
|
int asic_family;
|
||||||
|
|
||||||
/* Get the ASIC family to determine which modifiers to advertise */
|
/* Validate input parameters */
|
||||||
|
if (!draw || !draw->pScreen || !num_modifiers || !modifiers)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
scrn = xf86ScreenToScrn(draw->pScreen);
|
||||||
|
if (!scrn)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
info = AMDGPUPTR(scrn);
|
||||||
|
if (!info)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
asic_family = info->family;
|
asic_family = info->family;
|
||||||
|
|
||||||
/* Determine which set of modifiers to return based on ASIC family.
|
/* Determine which set of modifiers to return based on ASIC family.
|
||||||
@@ -636,15 +647,14 @@ static dri3_screen_info_rec amdgpu_dri3_screen_info = {
|
|||||||
.version = 2,
|
.version = 2,
|
||||||
.open = amdgpu_dri3_open,
|
.open = amdgpu_dri3_open,
|
||||||
.pixmap_from_fd = amdgpu_dri3_pixmap_from_fd,
|
.pixmap_from_fd = amdgpu_dri3_pixmap_from_fd,
|
||||||
// Version 1.1
|
/* Version 1.1 */
|
||||||
.fd_from_pixmap = amdgpu_dri3_fd_from_pixmap,
|
.fd_from_pixmap = amdgpu_dri3_fd_from_pixmap,
|
||||||
// Version 1.2
|
/* Version 1.2 */
|
||||||
.pixmap_from_fds = amdgpu_dri3_pixmap_from_fds,
|
.pixmap_from_fds = amdgpu_dri3_pixmap_from_fds,
|
||||||
.fds_from_pixmap = amdgpu_dri3_fds_from_pixmap,
|
.fds_from_pixmap = amdgpu_dri3_fds_from_pixmap,
|
||||||
.get_formats = amdgpu_dri3_get_formats,
|
.get_formats = amdgpu_dri3_get_formats,
|
||||||
.get_modifiers = amdgpu_dri3_get_modifiers,
|
.get_modifiers = amdgpu_dri3_get_modifiers
|
||||||
.get_drawable_modifiers = amdgpu_dri3_get_drawable_modifiers
|
/* Version 1.4 - get_drawable_modifiers set via glamor callback */
|
||||||
// Version 1.4
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
|
|||||||
@@ -80,4 +80,12 @@ extern int glamor_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds,
|
|||||||
uint64_t *modifier);
|
uint64_t *modifier);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* DRI3 drawable modifiers callback */
|
||||||
|
#ifdef GBM_BO_WITH_MODIFIERS
|
||||||
|
extern Bool amdgpu_dri3_get_drawable_modifiers(DrawablePtr draw,
|
||||||
|
uint32_t format,
|
||||||
|
uint32_t *num_modifiers,
|
||||||
|
uint64_t **modifiers);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* AMDGPU_GLAMOR_H */
|
#endif /* AMDGPU_GLAMOR_H */
|
||||||
|
|||||||
@@ -2038,6 +2038,10 @@ Bool AMDGPUScreenInit_KMS(ScreenPtr pScreen, int argc, char **argv)
|
|||||||
if (amdgpu_glamor_init(pScreen)) {
|
if (amdgpu_glamor_init(pScreen)) {
|
||||||
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
|
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
|
||||||
"Acceleration enabled\n");
|
"Acceleration enabled\n");
|
||||||
|
#ifdef GBM_BO_WITH_MODIFIERS
|
||||||
|
glamor_set_drawable_modifiers_func(pScreen,
|
||||||
|
amdgpu_dri3_get_drawable_modifiers);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
|
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
|
||||||
"Acceleration initialization failed\n");
|
"Acceleration initialization failed\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user