gallium: move loader_dri_create_image to dri frontend

this is another case of bad dependencies leaving dri the only place to
move something, which then exposes some other snags to be resolved later

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30450>
This commit is contained in:
Mike Blumenkrantz
2024-07-25 13:57:44 -04:00
committed by Marge Bot
parent 10a80782e0
commit 2b042cb9c2
9 changed files with 55 additions and 47 deletions
+4 -3
View File
@@ -50,6 +50,7 @@
#include "kopper_interface.h"
#include "loader.h"
#include "loader_dri_helper.h"
#include "dri_util.h"
#include <loader_wayland_helper.h>
#include "linux-dmabuf-unstable-v1-client-protocol.h"
@@ -1068,7 +1069,7 @@ create_dri_image(struct dri2_egl_surface *dri2_surf,
modifiers = NULL;
}
dri2_surf->back->dri_image = loader_dri_create_image(
dri2_surf->back->dri_image = dri_create_image_with_modifiers(
dri2_dpy->dri_screen_render_gpu, dri2_dpy->image, dri2_surf->base.Width,
dri2_surf->base.Height, pipe_format,
(dri2_dpy->fd_render_gpu != dri2_dpy->fd_display_gpu) ? 0 : use_flags,
@@ -1209,7 +1210,7 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
__DRIimage *linear_copy_display_gpu_image = NULL;
if (dri2_dpy->dri_screen_display_gpu) {
linear_copy_display_gpu_image = loader_dri_create_image(
linear_copy_display_gpu_image = dri_create_image_with_modifiers(
dri2_dpy->dri_screen_display_gpu, dri2_dpy->image,
dri2_surf->base.Width, dri2_surf->base.Height,
linear_pipe_format, use_flags | __DRI_IMAGE_USE_LINEAR,
@@ -1294,7 +1295,7 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
}
if (!dri2_surf->back->linear_copy) {
dri2_surf->back->linear_copy = loader_dri_create_image(
dri2_surf->back->linear_copy = dri_create_image_with_modifiers(
dri2_dpy->dri_screen_render_gpu, dri2_dpy->image,
dri2_surf->base.Width, dri2_surf->base.Height,
linear_pipe_format, use_flags | __DRI_IMAGE_USE_LINEAR,
+34
View File
@@ -732,4 +732,38 @@ dri_query_dma_buf_formats(__DRIscreen *_screen, int max, int *formats,
return true;
}
__DRIimage *
dri_create_image_with_modifiers(__DRIscreen *screen,
const __DRIimageExtension *image,
uint32_t width, uint32_t height,
uint32_t dri_format, uint32_t dri_usage,
const uint64_t *modifiers,
unsigned int modifiers_count,
void *loaderPrivate)
{
if (modifiers && modifiers_count > 0) {
bool has_valid_modifier = false;
int i;
/* It's acceptable to create an image with INVALID modifier in the list,
* but it cannot be on the only modifier (since it will certainly fail
* later). While we could easily catch this after modifier creation, doing
* the check here is a convenient debug check likely pointing at whatever
* interface the client is using to build its modifier list.
*/
for (i = 0; i < modifiers_count; i++) {
if (modifiers[i] != DRM_FORMAT_MOD_INVALID) {
has_valid_modifier = true;
break;
}
}
if (!has_valid_modifier)
return NULL;
}
return image->createImage(screen, width, height, dri_format,
modifiers, modifiers_count, dri_usage,
loaderPrivate);
}
/* vim: set sw=3 ts=8 sts=3 expandtab: */
+8
View File
@@ -282,4 +282,12 @@ PUBLIC bool
dri2_query_dma_buf_format_modifier_attribs(__DRIscreen *_screen,
uint32_t fourcc, uint64_t modifier,
int attrib, uint64_t *value);
PUBLIC __DRIimage *
dri_create_image_with_modifiers(__DRIscreen *screen,
const __DRIimageExtension *image,
uint32_t width, uint32_t height,
uint32_t dri_format, uint32_t dri_usage,
const uint64_t *modifiers,
unsigned int modifiers_count,
void *loaderPrivate);
#endif /* _DRI_UTIL_H_ */
+2 -1
View File
@@ -24,10 +24,11 @@
dri_interop_export_object;
dri_interop_flush_objects;
dri_loader_get_extensions;
dri_create_image_with_modifiers;
dri_create_image_from_renderbuffer;
dri2_destroy_image;
dri2_create_from_texture;
dri2_create_image;
dri_create_image;
dri2_query_image;
dri2_dup_image;
dri2_validate_usage;
+2 -1
View File
@@ -49,6 +49,7 @@
#include "loader.h"
#include "util/u_debug.h"
#include "util/macros.h"
#include "dri_util.h"
/* For importing wl_buffer */
#if HAVE_WAYLAND_PLATFORM
@@ -1044,7 +1045,7 @@ gbm_dri_bo_create(struct gbm_device *gbm,
mods_comp = NULL;
}
bo->image = loader_dri_create_image(dri->screen, dri->image, width, height,
bo->image = dri_create_image_with_modifiers(dri->screen, dri->image, width, height,
dri_format, dri_use,
mods_filtered ? mods_filtered : modifiers,
mods_filtered ? count_filtered : count,
+4 -1
View File
@@ -16,9 +16,12 @@ args_gbm = [
]
deps_gbm = []
incs_gbm = [
include_directories('main'), inc_include, inc_src, inc_loader, inc_gallium
include_directories('main'), inc_include, inc_src, inc_loader, inc_gallium, inc_st_dri
]
# TODO: fix includes to delete this
incs_gbm += inc_mesa
if with_dri2
files_gbm += files('backends/dri/gbm_dri.c', 'backends/dri/gbm_driint.h')
deps_gbm += dep_libdrm # TODO: pthread-stubs
-32
View File
@@ -30,38 +30,6 @@
#include "loader_dri_helper.h"
#include "util/driconf.h"
__DRIimage *loader_dri_create_image(__DRIscreen *screen,
const __DRIimageExtension *image,
uint32_t width, uint32_t height,
uint32_t dri_format, uint32_t dri_usage,
const uint64_t *modifiers,
unsigned int modifiers_count,
void *loaderPrivate)
{
if (modifiers && modifiers_count > 0) {
bool has_valid_modifier = false;
int i;
/* It's acceptable to create an image with INVALID modifier in the list,
* but it cannot be on the only modifier (since it will certainly fail
* later). While we could easily catch this after modifier creation, doing
* the check here is a convenient debug check likely pointing at whatever
* interface the client is using to build its modifier list.
*/
for (i = 0; i < modifiers_count; i++) {
if (modifiers[i] != DRM_FORMAT_MOD_INVALID) {
has_valid_modifier = true;
break;
}
}
if (!has_valid_modifier)
return NULL;
}
return image->createImage(screen, width, height, dri_format,
modifiers, modifiers_count, dri_usage,
loaderPrivate);
}
/* the DRIimage createImage function takes __DRI_IMAGE_FORMAT codes, while
* the createImageFromDmaBufs call takes DRM_FORMAT codes. To avoid
-8
View File
@@ -104,14 +104,6 @@ struct loader_screen_resources {
#define __DRI_IMAGE_FORMAT_ABGR1555 PIPE_FORMAT_R5G5B5A1_UNORM
#define __DRI_IMAGE_FORMAT_XBGR1555 PIPE_FORMAT_R5G5B5X1_UNORM
__DRIimage *loader_dri_create_image(__DRIscreen *screen,
const __DRIimageExtension *image,
uint32_t width, uint32_t height,
uint32_t dri_format, uint32_t dri_usage,
const uint64_t *modifiers,
unsigned int modifiers_count,
void *loaderPrivate);
int
loader_image_format_to_fourcc(int format);
+1 -1
View File
@@ -1467,7 +1467,7 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int fourcc,
free(mod_reply);
}
#endif
buffer->image = loader_dri_create_image(draw->dri_screen_render_gpu, draw->ext->image,
buffer->image = dri_create_image_with_modifiers(draw->dri_screen_render_gpu, draw->ext->image,
width, height, format,
__DRI_IMAGE_USE_SHARE |
__DRI_IMAGE_USE_SCANOUT |