egl: remove is_different_gpu variable from struct dri2_egl_display
v2: fd number is different (Pierre-Eric) v1: remove is_different_gpu (Pierre-Eric) Signed-off-by: Yogesh Mohan Marimuthu <yogesh.mohanmarimuthu@amd.com> Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13422>
This commit is contained in:

committed by
Marge Bot

parent
1a0ec8e8d3
commit
31013f3ce7
@@ -982,7 +982,7 @@ dri2_create_screen(_EGLDisplay *disp)
|
||||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||
char *driver_name_display_gpu;
|
||||
|
||||
if (dri2_dpy->fd_display_gpu >= 0) {
|
||||
if (dri2_dpy->fd_render_gpu != dri2_dpy->fd_display_gpu) {
|
||||
driver_name_display_gpu = loader_get_driver_for_fd(dri2_dpy->fd_display_gpu);
|
||||
if (driver_name_display_gpu) {
|
||||
/* check if driver name is matching so that non mesa drivers
|
||||
@@ -1013,6 +1013,9 @@ dri2_create_screen(_EGLDisplay *disp)
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
if (dri2_dpy->fd_render_gpu == dri2_dpy->fd_display_gpu)
|
||||
dri2_dpy->dri_screen_display_gpu = dri2_dpy->dri_screen_render_gpu;
|
||||
|
||||
dri2_dpy->own_dri_screen = true;
|
||||
return EGL_TRUE;
|
||||
}
|
||||
@@ -1146,13 +1149,14 @@ dri2_display_destroy(_EGLDisplay *disp)
|
||||
|
||||
dri2_dpy->core->destroyScreen(dri2_dpy->dri_screen_render_gpu);
|
||||
|
||||
if (dri2_dpy->dri_screen_display_gpu)
|
||||
if (dri2_dpy->dri_screen_display_gpu &&
|
||||
dri2_dpy->fd_render_gpu != dri2_dpy->fd_display_gpu)
|
||||
dri2_dpy->core->destroyScreen(dri2_dpy->dri_screen_display_gpu);
|
||||
}
|
||||
if (dri2_dpy->fd_display_gpu >= 0 &&dri2_dpy->fd_render_gpu != dri2_dpy->fd_display_gpu)
|
||||
close(dri2_dpy->fd_display_gpu);
|
||||
if (dri2_dpy->fd_render_gpu >= 0)
|
||||
close(dri2_dpy->fd_render_gpu);
|
||||
if (dri2_dpy->fd_display_gpu >= 0)
|
||||
close(dri2_dpy->fd_display_gpu);
|
||||
|
||||
/* Don't dlclose the driver when building with the address sanitizer, so you
|
||||
* get good symbols from the leak reports.
|
||||
|
@@ -223,6 +223,12 @@ struct dri2_egl_display
|
||||
int dri2_major;
|
||||
int dri2_minor;
|
||||
__DRIscreen *dri_screen_render_gpu;
|
||||
/* dri_screen_display_gpu holds display GPU in case of prime gpu offloading else
|
||||
* dri_screen_render_gpu and dri_screen_display_gpu is same.
|
||||
* In case of prime gpu offloading, if display and render driver names are different
|
||||
* (potentially not compatible), dri_screen_display_gpu will be NULL but fd_display_gpu
|
||||
* will still hold fd for display driver.
|
||||
*/
|
||||
__DRIscreen *dri_screen_display_gpu;
|
||||
bool own_dri_screen;
|
||||
const __DRIconfig **driver_configs;
|
||||
@@ -244,7 +250,12 @@ struct dri2_egl_display
|
||||
const __DRI2interopExtension *interop;
|
||||
const __DRIconfigOptionsExtension *configOptions;
|
||||
const __DRImutableRenderBufferDriverExtension *mutable_render_buffer;
|
||||
/* fd of the GPU used for rendering. */
|
||||
int fd_render_gpu;
|
||||
/* fd of the GPU used for display. If the same GPU is used for display
|
||||
* and rendering, then fd_render_gpu == fd_display_gpu (no need to use
|
||||
* os_same_file_description).
|
||||
*/
|
||||
int fd_display_gpu;
|
||||
|
||||
/* dri2_initialize/dri2_terminate increment/decrement this count, so does
|
||||
@@ -304,7 +315,6 @@ struct dri2_egl_display
|
||||
#endif
|
||||
|
||||
bool is_render_node;
|
||||
bool is_different_gpu;
|
||||
};
|
||||
|
||||
struct dri2_egl_context
|
||||
|
@@ -1692,6 +1692,8 @@ dri2_initialize_android(_EGLDisplay *disp)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
dri2_dpy->fd_display_gpu = dri2_dpy->fd_render_gpu;
|
||||
|
||||
dev = _eglAddDevice(dri2_dpy->fd_render_gpu, false);
|
||||
if (!dev) {
|
||||
err = "DRI2: failed to find EGLDevice";
|
||||
|
@@ -351,6 +351,8 @@ dri2_initialize_surfaceless(_EGLDisplay *disp)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
dri2_dpy->fd_display_gpu = dri2_dpy->fd_render_gpu;
|
||||
|
||||
if (!dri2_create_screen(disp)) {
|
||||
err = "DRI2: failed to create screen";
|
||||
goto cleanup;
|
||||
|
@@ -938,7 +938,7 @@ create_dri_image_from_dmabuf_feedback(struct dri2_egl_surface *dri2_surf,
|
||||
dri2_surf->base.Width,
|
||||
dri2_surf->base.Height,
|
||||
dri_image_format,
|
||||
dri2_dpy->is_different_gpu ? 0 : flags,
|
||||
(dri2_dpy->fd_render_gpu != dri2_dpy->fd_display_gpu) ? 0 : flags,
|
||||
modifiers, num_modifiers, NULL);
|
||||
|
||||
if (dri2_surf->back->dri_image)
|
||||
@@ -976,7 +976,7 @@ create_dri_image(struct dri2_egl_surface *dri2_surf,
|
||||
dri2_surf->base.Width,
|
||||
dri2_surf->base.Height,
|
||||
dri_image_format,
|
||||
dri2_dpy->is_different_gpu ? 0 : use_flags,
|
||||
(dri2_dpy->fd_render_gpu != dri2_dpy->fd_display_gpu) ? 0 : use_flags,
|
||||
modifiers, num_modifiers, NULL);
|
||||
}
|
||||
|
||||
@@ -1046,12 +1046,13 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
|
||||
|
||||
if (dri2_surf->base.ProtectedContent) {
|
||||
/* Protected buffers can't be read from another GPU */
|
||||
if (dri2_dpy->is_different_gpu)
|
||||
if (dri2_dpy->fd_render_gpu != dri2_dpy->fd_display_gpu)
|
||||
return -1;
|
||||
use_flags |= __DRI_IMAGE_USE_PROTECTED;
|
||||
}
|
||||
|
||||
if (dri2_dpy->is_different_gpu && dri2_surf->back->linear_copy == NULL) {
|
||||
if (dri2_dpy->fd_render_gpu != dri2_dpy->fd_display_gpu &&
|
||||
dri2_surf->back->linear_copy == NULL) {
|
||||
uint64_t linear_mod = DRM_FORMAT_MOD_LINEAR;
|
||||
__DRIimage *linear_copy_display_gpu_image = NULL;
|
||||
|
||||
@@ -1222,7 +1223,7 @@ update_buffers(struct dri2_egl_surface *dri2_surf)
|
||||
dri2_surf->color_buffers[i].age > BUFFER_TRIM_AGE_HYSTERESIS) {
|
||||
wl_buffer_destroy(dri2_surf->color_buffers[i].wl_buffer);
|
||||
dri2_dpy->image->destroyImage(dri2_surf->color_buffers[i].dri_image);
|
||||
if (dri2_dpy->is_different_gpu)
|
||||
if (dri2_dpy->fd_render_gpu != dri2_dpy->fd_display_gpu)
|
||||
dri2_dpy->image->destroyImage(dri2_surf->color_buffers[i].linear_copy);
|
||||
dri2_surf->color_buffers[i].wl_buffer = NULL;
|
||||
dri2_surf->color_buffers[i].dri_image = NULL;
|
||||
@@ -1625,7 +1626,7 @@ dri2_wl_swap_buffers_with_damage(_EGLDisplay *disp,
|
||||
if (!dri2_surf->current->wl_buffer) {
|
||||
__DRIimage *image;
|
||||
|
||||
if (dri2_dpy->is_different_gpu)
|
||||
if (dri2_dpy->fd_render_gpu != dri2_dpy->fd_display_gpu)
|
||||
image = dri2_surf->current->linear_copy;
|
||||
else
|
||||
image = dri2_surf->current->dri_image;
|
||||
@@ -1656,7 +1657,7 @@ dri2_wl_swap_buffers_with_damage(_EGLDisplay *disp,
|
||||
wl_surface_damage(dri2_surf->wl_surface_wrapper,
|
||||
0, 0, INT32_MAX, INT32_MAX);
|
||||
|
||||
if (dri2_dpy->is_different_gpu) {
|
||||
if (dri2_dpy->fd_render_gpu != dri2_dpy->fd_display_gpu) {
|
||||
_EGLContext *ctx = _eglGetCurrentContext();
|
||||
struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
|
||||
dri2_dpy->image->blitImage(dri2_ctx->dri_context,
|
||||
@@ -2097,7 +2098,7 @@ dri2_wl_add_configs_for_visuals(_EGLDisplay *disp)
|
||||
}
|
||||
}
|
||||
|
||||
if (!assigned && dri2_dpy->is_different_gpu) {
|
||||
if (!assigned && dri2_dpy->fd_render_gpu != dri2_dpy->fd_display_gpu) {
|
||||
struct dri2_egl_config *dri2_conf;
|
||||
int alt_dri_image_format, c, s;
|
||||
|
||||
@@ -2229,8 +2230,7 @@ dri2_initialize_wayland_drm(_EGLDisplay *disp)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
dri2_dpy->is_different_gpu =
|
||||
loader_get_user_preferred_fd(&dri2_dpy->fd_render_gpu, &dri2_dpy->fd_display_gpu);
|
||||
loader_get_user_preferred_fd(&dri2_dpy->fd_render_gpu, &dri2_dpy->fd_display_gpu);
|
||||
|
||||
dev = _eglAddDevice(dri2_dpy->fd_render_gpu, false);
|
||||
if (!dev) {
|
||||
@@ -2240,7 +2240,7 @@ dri2_initialize_wayland_drm(_EGLDisplay *disp)
|
||||
|
||||
disp->Device = dev;
|
||||
|
||||
if (dri2_dpy->is_different_gpu) {
|
||||
if (dri2_dpy->fd_render_gpu != dri2_dpy->fd_display_gpu) {
|
||||
free(dri2_dpy->device_name);
|
||||
dri2_dpy->device_name = loader_get_device_name_for_fd(dri2_dpy->fd_render_gpu);
|
||||
if (!dri2_dpy->device_name) {
|
||||
@@ -2301,7 +2301,7 @@ dri2_initialize_wayland_drm(_EGLDisplay *disp)
|
||||
}
|
||||
}
|
||||
|
||||
if (dri2_dpy->is_different_gpu &&
|
||||
if (dri2_dpy->fd_render_gpu != dri2_dpy->fd_display_gpu &&
|
||||
(dri2_dpy->image->base.version < 9 ||
|
||||
dri2_dpy->image->blitImage == NULL)) {
|
||||
_eglLog(_EGL_WARNING, "wayland-egl: Different GPU selected, but the "
|
||||
@@ -2321,7 +2321,7 @@ dri2_initialize_wayland_drm(_EGLDisplay *disp)
|
||||
* because the buffer of the EGLImage has likely a tiling mode the server
|
||||
* gpu won't support. These is no way to check for now. Thus do not support the
|
||||
* extension */
|
||||
if (!dri2_dpy->is_different_gpu)
|
||||
if (dri2_dpy->fd_render_gpu == dri2_dpy->fd_display_gpu)
|
||||
disp->Extensions.WL_create_wayland_buffer_from_image = EGL_TRUE;
|
||||
|
||||
disp->Extensions.EXT_buffer_age = EGL_TRUE;
|
||||
|
@@ -1489,7 +1489,7 @@ dri2_initialize_x11_swrast(_EGLDisplay *disp)
|
||||
#endif
|
||||
dri2_dpy->swap_available = EGL_TRUE;
|
||||
dri2_x11_setup_swap_interval(disp);
|
||||
if (!dri2_dpy->is_different_gpu)
|
||||
if (dri2_dpy->fd_render_gpu == dri2_dpy->fd_display_gpu)
|
||||
disp->Extensions.KHR_image_pixmap = EGL_TRUE;
|
||||
disp->Extensions.NOK_texture_from_pixmap = EGL_TRUE;
|
||||
disp->Extensions.CHROMIUM_sync_control = EGL_TRUE;
|
||||
@@ -1575,7 +1575,7 @@ dri2_initialize_x11_dri3(_EGLDisplay *disp)
|
||||
|
||||
dri2_x11_setup_swap_interval(disp);
|
||||
|
||||
if (!dri2_dpy->is_different_gpu)
|
||||
if (dri2_dpy->fd_render_gpu == dri2_dpy->fd_display_gpu)
|
||||
disp->Extensions.KHR_image_pixmap = EGL_TRUE;
|
||||
disp->Extensions.NOK_texture_from_pixmap = EGL_TRUE;
|
||||
disp->Extensions.CHROMIUM_sync_control = EGL_TRUE;
|
||||
|
@@ -190,7 +190,7 @@ dri3_create_surface(_EGLDisplay *disp, EGLint type, _EGLConfig *conf,
|
||||
egl_to_loader_dri3_drawable_type(type),
|
||||
dri2_dpy->dri_screen_render_gpu,
|
||||
dri2_dpy->dri_screen_display_gpu,
|
||||
dri2_dpy->is_different_gpu,
|
||||
dri2_dpy->fd_render_gpu != dri2_dpy->fd_display_gpu,
|
||||
dri2_dpy->multibuffers_available,
|
||||
true,
|
||||
dri_config,
|
||||
@@ -202,7 +202,7 @@ dri3_create_surface(_EGLDisplay *disp, EGLint type, _EGLConfig *conf,
|
||||
}
|
||||
|
||||
if (dri3_surf->surf.base.ProtectedContent &&
|
||||
dri2_dpy->is_different_gpu) {
|
||||
dri2_dpy->fd_render_gpu != dri2_dpy->fd_display_gpu) {
|
||||
_eglError(EGL_BAD_ALLOC, "dri3_surface_create");
|
||||
goto cleanup_pixmap;
|
||||
}
|
||||
@@ -635,8 +635,7 @@ dri3_x11_connect(struct dri2_egl_display *dri2_dpy)
|
||||
return EGL_FALSE;
|
||||
}
|
||||
|
||||
dri2_dpy->is_different_gpu =
|
||||
loader_get_user_preferred_fd(&dri2_dpy->fd_render_gpu, &dri2_dpy->fd_display_gpu);
|
||||
loader_get_user_preferred_fd(&dri2_dpy->fd_render_gpu, &dri2_dpy->fd_display_gpu);
|
||||
|
||||
dri2_dpy->driver_name = loader_get_driver_for_fd(dri2_dpy->fd_render_gpu);
|
||||
if (!dri2_dpy->driver_name) {
|
||||
|
Reference in New Issue
Block a user