From 0c6d4cf9a2bb01e08869e6b503e31fe86b461c87 Mon Sep 17 00:00:00 2001 From: Rob Clark Date: Thu, 28 Jul 2022 14:04:27 -0700 Subject: [PATCH] gbm: Add USE_FRONT_RENDERING flag Provide a use flag to let the driver know that the allocated buffer will be used for frontbuffer rendering. For example, bandwidth compressed formats should usually be avoided for frontbuffer rendering to avoid the visual corruption that results from this display racing with the GPU writing header data vs. pixel data. Signed-off-by: Rob Clark Reviewed-by: Emma Anholt Part-of: --- include/GL/internal/dri_interface.h | 1 + src/gallium/frontends/dri/dri2.c | 2 ++ src/gallium/include/pipe/p_defines.h | 1 + src/gbm/backends/dri/gbm_dri.c | 2 ++ src/gbm/main/gbm.h | 8 ++++++++ 5 files changed, 14 insertions(+) diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 74c807c..09ed565 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -1224,6 +1224,7 @@ struct __DRIdri2ExtensionRec { #define __DRI_IMAGE_USE_BACKBUFFER 0x0010 #define __DRI_IMAGE_USE_PROTECTED 0x0020 #define __DRI_IMAGE_USE_PRIME_BUFFER 0x0040 +#define __DRI_IMAGE_USE_FRONT_RENDERING 0x0080 #define __DRI_IMAGE_TRANSFER_READ 0x1 diff --git a/src/gallium/frontends/dri/dri2.c b/src/gallium/frontends/dri/dri2.c index 20724a0..a606ba7 100644 --- a/src/gallium/frontends/dri/dri2.c +++ b/src/gallium/frontends/dri/dri2.c @@ -1146,6 +1146,8 @@ dri2_create_image_common(__DRIscreen *_screen, tex_usage |= PIPE_BIND_PROTECTED; if (use & __DRI_IMAGE_USE_PRIME_BUFFER) tex_usage |= PIPE_BIND_PRIME_BLIT_DST; + if (use & __DRI_IMAGE_USE_FRONT_RENDERING) + tex_usage |= PIPE_BIND_USE_FRONT_RENDERING; img = CALLOC_STRUCT(__DRIimageRec); if (!img) diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index ff85888..3e89595 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -519,6 +519,7 @@ enum pipe_flush_flags #define PIPE_BIND_SAMPLER_REDUCTION_MINMAX (1 << 23) /* PIPE_CAP_SAMPLER_REDUCTION_MINMAX */ /* Resource is the DRI_PRIME blit destination. Only set on on the render GPU. */ #define PIPE_BIND_PRIME_BLIT_DST (1 << 24) +#define PIPE_BIND_USE_FRONT_RENDERING (1 << 25) /* Resource may be used for frontbuffer rendering */ /** diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c index 0f31488..f410da0 100644 --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c @@ -1244,6 +1244,8 @@ gbm_dri_bo_create(struct gbm_device *gbm, dri_use |= __DRI_IMAGE_USE_LINEAR; if (usage & GBM_BO_USE_PROTECTED) dri_use |= __DRI_IMAGE_USE_PROTECTED; + if (usage & GBM_BO_USE_FRONT_RENDERING) + dri_use |= __DRI_IMAGE_USE_FRONT_RENDERING; /* Gallium drivers requires shared in order to get the handle/stride */ dri_use |= __DRI_IMAGE_USE_SHARE; diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h index 829c4cb..1a1e2ca 100644 --- a/src/gbm/main/gbm.h +++ b/src/gbm/main/gbm.h @@ -256,6 +256,14 @@ enum gbm_bo_flags { * OpenCL, and Vulkan applications. */ GBM_BO_USE_PROTECTED = (1 << 5), + + /** + * The buffer will be used for front buffer rendering. On some + * platforms this may (for example) disable framebuffer compression + * to avoid problems with compression flags data being out of sync + * with pixel data. + */ + GBM_BO_USE_FRONT_RENDERING = (1 << 6), }; int -- 2.7.4