summaryrefslogtreecommitdiff
path: root/lib/mesa/src/loader
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2022-09-02 05:47:02 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2022-09-02 05:47:02 +0000
commit0dbbf1e0708df85a357d70e2708c0a11aeb5480e (patch)
tree6656ff8eb8b15a2fc1c02888973caf618388cfd0 /lib/mesa/src/loader
parent5f66494d31f735486b8222ecfa0a0c9046e92543 (diff)
Merge Mesa 22.1.7
Diffstat (limited to 'lib/mesa/src/loader')
-rw-r--r--lib/mesa/src/loader/loader.c69
-rw-r--r--lib/mesa/src/loader/loader.h4
-rw-r--r--lib/mesa/src/loader/loader_dri3_helper.c325
-rw-r--r--lib/mesa/src/loader/loader_dri3_helper.h14
-rw-r--r--lib/mesa/src/loader/pci_id_driver_map.c55
5 files changed, 294 insertions, 173 deletions
diff --git a/lib/mesa/src/loader/loader.c b/lib/mesa/src/loader/loader.c
index f917f8ad2..e391cc93c 100644
--- a/lib/mesa/src/loader/loader.c
+++ b/lib/mesa/src/loader/loader.c
@@ -47,6 +47,7 @@
#include <GL/gl.h>
#include <GL/internal/dri_interface.h>
#include "loader.h"
+#include "util/os_file.h"
#ifdef HAVE_LIBDRM
#include <xf86drm.h>
@@ -177,6 +178,26 @@ loader_open_render_node(const char *name)
return fd;
}
+char *
+loader_get_render_node(dev_t device)
+{
+ char *render_node = NULL;
+ drmDevicePtr dev_ptr;
+
+ if (drmGetDeviceFromDevId(device, 0, &dev_ptr) < 0)
+ return NULL;
+
+ if (dev_ptr->available_nodes & (1 << DRM_NODE_RENDER)) {
+ render_node = strdup(dev_ptr->nodes[DRM_NODE_RENDER]);
+ if (!render_node)
+ log_(_LOADER_DEBUG, "MESA-LOADER: failed to allocate memory for render node\n");
+ }
+
+ drmFreeDevice(&dev_ptr);
+
+ return render_node;
+}
+
#ifdef USE_DRICONF
static const driOptionDescription __driConfigOptionsLoader[] = {
DRI_CONF_SECTION_INITIALIZATION
@@ -375,6 +396,12 @@ loader_open_render_node(const char *name)
return -1;
}
+char *
+loader_get_render_node(dev_t device)
+{
+ return NULL;
+}
+
int loader_get_user_preferred_fd(int default_fd, bool *different_device)
{
*different_device = false;
@@ -407,10 +434,52 @@ drm_get_pci_id_for_fd(int fd, int *vendor_id, int *chip_id)
}
#endif
+#ifdef __linux__
+static int loader_get_linux_pci_field(int maj, int min, const char *field)
+{
+ char path[PATH_MAX + 1];
+ snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device/%s", maj, min, field);
+
+ char *field_str = os_read_file(path, NULL);
+ if (!field_str) {
+ /* Probably non-PCI device. */
+ return 0;
+ }
+
+ int value = (int)strtoll(field_str, NULL, 16);
+ free(field_str);
+
+ return value;
+}
+
+static bool
+loader_get_linux_pci_id_for_fd(int fd, int *vendor_id, int *chip_id)
+{
+ struct stat sbuf;
+ if (fstat(fd, &sbuf) != 0) {
+ log_(_LOADER_DEBUG, "MESA-LOADER: failed to fstat fd\n");
+ return false;
+ }
+
+ int maj = major(sbuf.st_rdev);
+ int min = minor(sbuf.st_rdev);
+
+ *vendor_id = loader_get_linux_pci_field(maj, min, "vendor");
+ *chip_id = loader_get_linux_pci_field(maj, min, "device");
+
+ return *vendor_id && *chip_id;
+}
+#endif /* __linux__ */
bool
loader_get_pci_id_for_fd(int fd, int *vendor_id, int *chip_id)
{
+#ifdef __linux__
+ /* Implementation without causing full enumeration of DRM devices. */
+ if (loader_get_linux_pci_id_for_fd(fd, vendor_id, chip_id))
+ return true;
+#endif
+
#if HAVE_LIBDRM
return drm_get_pci_id_for_fd(fd, vendor_id, chip_id);
#endif
diff --git a/lib/mesa/src/loader/loader.h b/lib/mesa/src/loader/loader.h
index 8ce001cb7..0305e27df 100644
--- a/lib/mesa/src/loader/loader.h
+++ b/lib/mesa/src/loader/loader.h
@@ -28,6 +28,7 @@
#define LOADER_H
#include <stdbool.h>
+#include <sys/stat.h>
#ifdef __cplusplus
extern "C" {
@@ -43,6 +44,9 @@ loader_open_device(const char *);
int
loader_open_render_node(const char *name);
+char *
+loader_get_render_node(dev_t device);
+
bool
loader_get_pci_id_for_fd(int fd, int *vendor_id, int *chip_id);
diff --git a/lib/mesa/src/loader/loader_dri3_helper.c b/lib/mesa/src/loader/loader_dri3_helper.c
index fc043bd05..364695d06 100644
--- a/lib/mesa/src/loader/loader_dri3_helper.c
+++ b/lib/mesa/src/loader/loader_dri3_helper.c
@@ -384,6 +384,7 @@ loader_dri3_drawable_fini(struct loader_dri3_drawable *draw)
int
loader_dri3_drawable_init(xcb_connection_t *conn,
xcb_drawable_t drawable,
+ enum loader_dri3_drawable_type type,
__DRIscreen *dri_screen,
bool is_different_gpu,
bool multiplanes_available,
@@ -403,6 +404,7 @@ loader_dri3_drawable_init(xcb_connection_t *conn,
draw->ext = ext;
draw->vtable = vtable;
draw->drawable = drawable;
+ draw->type = type;
draw->region = 0;
draw->dri_screen = dri_screen;
draw->is_different_gpu = is_different_gpu;
@@ -771,7 +773,7 @@ dri3_back_buffer(struct loader_dri3_drawable *draw)
}
static struct loader_dri3_buffer *
-dri3_fake_front_buffer(struct loader_dri3_drawable *draw)
+dri3_front_buffer(struct loader_dri3_drawable *draw)
{
return draw->buffers[LOADER_DRI3_FRONT_ID];
}
@@ -833,7 +835,7 @@ loader_dri3_copy_sub_buffer(struct loader_dri3_drawable *draw,
unsigned flags = __DRI2_FLUSH_DRAWABLE;
/* Check we have the right attachments */
- if (!draw->have_back || draw->is_pixmap)
+ if (!draw->have_back || draw->type != LOADER_DRI3_DRAWABLE_WINDOW)
return;
if (flush)
@@ -870,19 +872,19 @@ loader_dri3_copy_sub_buffer(struct loader_dri3_drawable *draw,
*/
if (draw->have_fake_front &&
!loader_dri3_blit_image(draw,
- dri3_fake_front_buffer(draw)->image,
+ dri3_front_buffer(draw)->image,
back->image,
x, y, width, height,
x, y, __BLIT_FLAG_FLUSH) &&
!draw->is_different_gpu) {
- dri3_fence_reset(draw->conn, dri3_fake_front_buffer(draw));
+ dri3_fence_reset(draw->conn, dri3_front_buffer(draw));
dri3_copy_area(draw->conn,
back->pixmap,
- dri3_fake_front_buffer(draw)->pixmap,
+ dri3_front_buffer(draw)->pixmap,
dri3_drawable_gc(draw),
x, y, x, y, width, height);
- dri3_fence_trigger(draw->conn, dri3_fake_front_buffer(draw));
- dri3_fence_await(draw->conn, NULL, dri3_fake_front_buffer(draw));
+ dri3_fence_trigger(draw->conn, dri3_front_buffer(draw));
+ dri3_fence_await(draw->conn, NULL, dri3_front_buffer(draw));
}
dri3_fence_await(draw->conn, draw, back);
}
@@ -894,13 +896,19 @@ loader_dri3_copy_drawable(struct loader_dri3_drawable *draw,
{
loader_dri3_flush(draw, __DRI2_FLUSH_DRAWABLE, __DRI2_THROTTLE_COPYSUBBUFFER);
- dri3_fence_reset(draw->conn, dri3_fake_front_buffer(draw));
+ struct loader_dri3_buffer *front = dri3_front_buffer(draw);
+ if (front)
+ dri3_fence_reset(draw->conn, front);
+
dri3_copy_area(draw->conn,
src, dest,
dri3_drawable_gc(draw),
0, 0, 0, 0, draw->width, draw->height);
- dri3_fence_trigger(draw->conn, dri3_fake_front_buffer(draw));
- dri3_fence_await(draw->conn, draw, dri3_fake_front_buffer(draw));
+
+ if (front) {
+ dri3_fence_trigger(draw->conn, front);
+ dri3_fence_await(draw->conn, draw, front);
+ }
}
void
@@ -911,7 +919,7 @@ loader_dri3_wait_x(struct loader_dri3_drawable *draw)
if (draw == NULL || !draw->have_fake_front)
return;
- front = dri3_fake_front_buffer(draw);
+ front = dri3_front_buffer(draw);
loader_dri3_copy_drawable(draw, front->pixmap, draw->drawable);
@@ -936,7 +944,7 @@ loader_dri3_wait_gl(struct loader_dri3_drawable *draw)
if (draw == NULL || !draw->have_fake_front)
return;
- front = dri3_fake_front_buffer(draw);
+ front = dri3_front_buffer(draw);
/* In the psc->is_different_gpu case, we update the linear_buffer
* before updating the real front.
@@ -988,11 +996,41 @@ loader_dri3_swap_buffers_msc(struct loader_dri3_drawable *draw,
{
struct loader_dri3_buffer *back;
int64_t ret = 0;
- uint32_t options = XCB_PRESENT_OPTION_NONE;
+
+ /* GLX spec:
+ * void glXSwapBuffers(Display *dpy, GLXDrawable draw);
+ * This operation is a no-op if draw was created with a non-double-buffered
+ * GLXFBConfig, or if draw is a GLXPixmap.
+ * ...
+ * GLX pixmaps may be created with a config that includes back buffers and
+ * stereoscopic buffers. However, glXSwapBuffers is ignored for these pixmaps.
+ * ...
+ * It is possible to create a pbuffer with back buffers and to swap the
+ * front and back buffers by calling glXSwapBuffers.
+ *
+ * EGL spec:
+ * EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface);
+ * If surface is a back-buffered window surface, then the color buffer is
+ * copied to the native window associated with that surface. If surface is
+ * a single-buffered window, pixmap, or pbuffer surface, eglSwapBuffers has
+ * no effect.
+ *
+ * SwapBuffer effect:
+ * | GLX | EGL |
+ * | window | pixmap | pbuffer | window | pixmap | pbuffer|
+ *-------+--------+--------+---------+--------+--------+--------+
+ * single| nop | nop | nop | nop | nop | nop |
+ * double| swap | nop | swap | swap | NA | NA |
+ */
+ if (!draw->have_back || draw->type == LOADER_DRI3_DRAWABLE_PIXMAP)
+ return ret;
draw->vtable->flush_drawable(draw, flush_flags);
back = dri3_find_back_alloc(draw);
+ /* Could only happen when error case, like display is already closed. */
+ if (!back)
+ return ret;
mtx_lock(&draw->mtx);
@@ -1001,7 +1039,7 @@ loader_dri3_swap_buffers_msc(struct loader_dri3_drawable *draw,
draw->adaptive_sync_active = true;
}
- if (draw->is_different_gpu && back) {
+ if (draw->is_different_gpu) {
/* Update the linear buffer before presenting the pixmap */
(void) loader_dri3_blit_image(draw,
back->linear_buffer,
@@ -1020,10 +1058,10 @@ loader_dri3_swap_buffers_msc(struct loader_dri3_drawable *draw,
/* Exchange the back and fake front. Even though the server knows about these
* buffers, it has no notion of back and fake front.
*/
- if (back && draw->have_fake_front) {
+ if (draw->have_fake_front) {
struct loader_dri3_buffer *tmp;
- tmp = dri3_fake_front_buffer(draw);
+ tmp = dri3_front_buffer(draw);
draw->buffers[LOADER_DRI3_FRONT_ID] = back;
draw->buffers[LOADER_DRI3_BACK_ID(draw->cur_back)] = tmp;
@@ -1033,7 +1071,7 @@ loader_dri3_swap_buffers_msc(struct loader_dri3_drawable *draw,
dri3_flush_present_events(draw);
- if (back && !draw->is_pixmap) {
+ if (draw->type == LOADER_DRI3_DRAWABLE_WINDOW) {
dri3_fence_reset(draw->conn, back);
/* Compute when we want the frame shown by taking the last known
@@ -1075,8 +1113,9 @@ loader_dri3_swap_buffers_msc(struct loader_dri3_drawable *draw,
* behaviour by not using XCB_PRESENT_OPTION_ASYNC, but this should not be
* the default.
*/
+ uint32_t options = XCB_PRESENT_OPTION_NONE;
if (draw->swap_interval <= 0)
- options |= XCB_PRESENT_OPTION_ASYNC;
+ options |= XCB_PRESENT_OPTION_ASYNC;
/* If we need to populate the new back, but need to reuse the back
* buffer slot due to lack of local blit capabilities, make sure
@@ -1127,32 +1166,59 @@ loader_dri3_swap_buffers_msc(struct loader_dri3_drawable *draw,
target_msc,
divisor,
remainder, 0, NULL);
- ret = (int64_t) draw->send_sbc;
-
- /* Schedule a server-side back-preserving blit if necessary.
- * This happens iff all conditions below are satisfied:
- * a) We have a fake front,
- * b) We need to preserve the back buffer,
- * c) We don't have local blit capabilities.
+ } else {
+ /* This can only be reached by double buffered GLXPbuffer. */
+ assert(draw->type == LOADER_DRI3_DRAWABLE_PBUFFER);
+ /* GLX does not have damage regions. */
+ assert(n_rects == 0);
+
+ /* For wait and buffer age usage. */
+ draw->send_sbc++;
+ draw->recv_sbc = back->last_swap = draw->send_sbc;
+
+ /* Pixmap is imported as front buffer image when same GPU case, so just
+ * locally blit back buffer image to it is enough. Otherwise front buffer
+ * is a fake one which needs to be synced with pixmap by xserver remotely.
*/
- if (!loader_dri3_have_image_blit(draw) && draw->cur_blit_source != -1 &&
- draw->cur_blit_source != LOADER_DRI3_BACK_ID(draw->cur_back)) {
- struct loader_dri3_buffer *new_back = dri3_back_buffer(draw);
- struct loader_dri3_buffer *src = draw->buffers[draw->cur_blit_source];
-
- dri3_fence_reset(draw->conn, new_back);
- dri3_copy_area(draw->conn, src->pixmap,
- new_back->pixmap,
+ if (draw->is_different_gpu ||
+ !loader_dri3_blit_image(draw,
+ dri3_front_buffer(draw)->image,
+ back->image,
+ 0, 0, draw->width, draw->height,
+ 0, 0, __BLIT_FLAG_FLUSH)) {
+ dri3_copy_area(draw->conn, back->pixmap,
+ draw->drawable,
dri3_drawable_gc(draw),
0, 0, 0, 0, draw->width, draw->height);
- dri3_fence_trigger(draw->conn, new_back);
- new_back->last_swap = src->last_swap;
}
+ }
+
+ ret = (int64_t) draw->send_sbc;
- xcb_flush(draw->conn);
- if (draw->stamp)
- ++(*draw->stamp);
+ /* Schedule a server-side back-preserving blit if necessary.
+ * This happens iff all conditions below are satisfied:
+ * a) We have a fake front,
+ * b) We need to preserve the back buffer,
+ * c) We don't have local blit capabilities.
+ */
+ if (!loader_dri3_have_image_blit(draw) && draw->cur_blit_source != -1 &&
+ draw->cur_blit_source != LOADER_DRI3_BACK_ID(draw->cur_back)) {
+ struct loader_dri3_buffer *new_back = dri3_back_buffer(draw);
+ struct loader_dri3_buffer *src = draw->buffers[draw->cur_blit_source];
+
+ dri3_fence_reset(draw->conn, new_back);
+ dri3_copy_area(draw->conn, src->pixmap,
+ new_back->pixmap,
+ dri3_drawable_gc(draw),
+ 0, 0, 0, 0, draw->width, draw->height);
+ dri3_fence_trigger(draw->conn, new_back);
+ new_back->last_swap = src->last_swap;
}
+
+ xcb_flush(draw->conn);
+ if (draw->stamp)
+ ++(*draw->stamp);
+
mtx_unlock(&draw->mtx);
draw->ext->flush->invalidate(draw->dri_drawable);
@@ -1491,7 +1557,8 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int format,
__DRI_IMAGE_USE_SHARE |
__DRI_IMAGE_USE_LINEAR |
__DRI_IMAGE_USE_BACKBUFFER |
- __DRI_IMAGE_USE_SCANOUT,
+ __DRI_IMAGE_USE_SCANOUT |
+ __DRI_IMAGE_USE_PRIME_BUFFER,
buffer);
pixmap_buffer = buffer->linear_buffer;
@@ -1545,15 +1612,27 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int format,
/* The linear buffer was created in the display GPU's vram, so we
* need to make it visible to render GPU
*/
- buffer->linear_buffer =
- draw->ext->image->createImageFromFds(draw->dri_screen,
- width,
- height,
- image_format_to_fourcc(format),
- &buffer_fds[0], num_planes,
- &buffer->strides[0],
- &buffer->offsets[0],
- buffer);
+ if (draw->ext->image->base.version >= 20)
+ buffer->linear_buffer =
+ draw->ext->image->createImageFromFds2(draw->dri_screen,
+ width,
+ height,
+ image_format_to_fourcc(format),
+ &buffer_fds[0], num_planes,
+ __DRI_IMAGE_PRIME_LINEAR_BUFFER,
+ &buffer->strides[0],
+ &buffer->offsets[0],
+ buffer);
+ else
+ buffer->linear_buffer =
+ draw->ext->image->createImageFromFds(draw->dri_screen,
+ width,
+ height,
+ image_format_to_fourcc(format),
+ &buffer_fds[0], num_planes,
+ &buffer->strides[0],
+ &buffer->offsets[0],
+ buffer);
if (!buffer->linear_buffer)
goto no_buffer_attrib;
@@ -1625,6 +1704,80 @@ no_shm_fence:
return NULL;
}
+static bool
+dri3_detect_drawable_is_window(struct loader_dri3_drawable *draw)
+{
+ /* Try to select for input on the window.
+ *
+ * If the drawable is a window, this will get our events
+ * delivered.
+ *
+ * Otherwise, we'll get a BadWindow error back from this request which
+ * will let us know that the drawable is a pixmap instead.
+ */
+
+ xcb_void_cookie_t cookie =
+ xcb_present_select_input_checked(draw->conn, draw->eid, draw->drawable,
+ XCB_PRESENT_EVENT_MASK_CONFIGURE_NOTIFY |
+ XCB_PRESENT_EVENT_MASK_COMPLETE_NOTIFY |
+ XCB_PRESENT_EVENT_MASK_IDLE_NOTIFY);
+
+ /* Check to see if our select input call failed. If it failed with a
+ * BadWindow error, then assume the drawable is a pixmap.
+ */
+ xcb_generic_error_t *error = xcb_request_check(draw->conn, cookie);
+
+ if (error) {
+ if (error->error_code != BadWindow) {
+ free(error);
+ return false;
+ }
+ free(error);
+
+ /* pixmap can't get here, see driFetchDrawable(). */
+ draw->type = LOADER_DRI3_DRAWABLE_PBUFFER;
+ return true;
+ }
+
+ draw->type = LOADER_DRI3_DRAWABLE_WINDOW;
+ return true;
+}
+
+static bool
+dri3_setup_present_event(struct loader_dri3_drawable *draw)
+{
+ /* No need to setup for pixmap drawable. */
+ if (draw->type == LOADER_DRI3_DRAWABLE_PIXMAP ||
+ draw->type == LOADER_DRI3_DRAWABLE_PBUFFER)
+ return true;
+
+ draw->eid = xcb_generate_id(draw->conn);
+
+ if (draw->type == LOADER_DRI3_DRAWABLE_WINDOW) {
+ xcb_present_select_input(draw->conn, draw->eid, draw->drawable,
+ XCB_PRESENT_EVENT_MASK_CONFIGURE_NOTIFY |
+ XCB_PRESENT_EVENT_MASK_COMPLETE_NOTIFY |
+ XCB_PRESENT_EVENT_MASK_IDLE_NOTIFY);
+ } else {
+ assert(draw->type == LOADER_DRI3_DRAWABLE_UNKNOWN);
+
+ if (!dri3_detect_drawable_is_window(draw))
+ return false;
+
+ if (draw->type != LOADER_DRI3_DRAWABLE_WINDOW)
+ return true;
+ }
+
+ /* Create an XCB event queue to hold present events outside of the usual
+ * application event queue
+ */
+ draw->special_event = xcb_register_for_special_xge(draw->conn,
+ &xcb_present_id,
+ draw->eid,
+ draw->stamp);
+ return true;
+}
+
/** loader_dri3_update_drawable
*
* Called the first time we use the drawable and then
@@ -1638,40 +1791,15 @@ dri3_update_drawable(struct loader_dri3_drawable *draw)
if (draw->first_init) {
xcb_get_geometry_cookie_t geom_cookie;
xcb_get_geometry_reply_t *geom_reply;
- xcb_void_cookie_t cookie;
- xcb_generic_error_t *error;
- xcb_present_query_capabilities_cookie_t present_capabilities_cookie;
- xcb_present_query_capabilities_reply_t *present_capabilities_reply;
xcb_window_t root_win;
draw->first_init = false;
- /* Try to select for input on the window.
- *
- * If the drawable is a window, this will get our events
- * delivered.
- *
- * Otherwise, we'll get a BadWindow error back from this request which
- * will let us know that the drawable is a pixmap instead.
- */
-
- draw->eid = xcb_generate_id(draw->conn);
- cookie =
- xcb_present_select_input_checked(draw->conn, draw->eid, draw->drawable,
- XCB_PRESENT_EVENT_MASK_CONFIGURE_NOTIFY |
- XCB_PRESENT_EVENT_MASK_COMPLETE_NOTIFY |
- XCB_PRESENT_EVENT_MASK_IDLE_NOTIFY);
-
- present_capabilities_cookie =
- xcb_present_query_capabilities(draw->conn, draw->drawable);
+ if (!dri3_setup_present_event(draw)) {
+ mtx_unlock(&draw->mtx);
+ return false;
+ }
- /* Create an XCB event queue to hold present events outside of the usual
- * application event queue
- */
- draw->special_event = xcb_register_for_special_xge(draw->conn,
- &xcb_present_id,
- draw->eid,
- draw->stamp);
geom_cookie = xcb_get_geometry(draw->conn, draw->drawable);
geom_reply = xcb_get_geometry_reply(draw->conn, geom_cookie, NULL);
@@ -1688,39 +1816,7 @@ dri3_update_drawable(struct loader_dri3_drawable *draw)
free(geom_reply);
- draw->is_pixmap = false;
-
- /* Check to see if our select input call failed. If it failed with a
- * BadWindow error, then assume the drawable is a pixmap. Destroy the
- * special event queue created above and mark the drawable as a pixmap
- */
-
- error = xcb_request_check(draw->conn, cookie);
-
- present_capabilities_reply =
- xcb_present_query_capabilities_reply(draw->conn,
- present_capabilities_cookie,
- NULL);
-
- if (present_capabilities_reply) {
- draw->present_capabilities = present_capabilities_reply->capabilities;
- free(present_capabilities_reply);
- } else
- draw->present_capabilities = 0;
-
- if (error) {
- if (error->error_code != BadWindow) {
- free(error);
- mtx_unlock(&draw->mtx);
- return false;
- }
- free(error);
- draw->is_pixmap = true;
- xcb_unregister_for_special_event(draw->conn, draw->special_event);
- draw->special_event = NULL;
- }
-
- if (draw->is_pixmap)
+ if (draw->type != LOADER_DRI3_DRAWABLE_WINDOW)
draw->window = root_win;
else
draw->window = draw->drawable;
@@ -2141,7 +2237,8 @@ loader_dri3_get_buffers(__DRIdrawable *driDrawable,
/* pixmaps always have front buffers.
* Exchange swaps also mandate fake front buffers.
*/
- if (draw->is_pixmap || draw->swap_method == __DRI_ATTRIB_SWAP_EXCHANGE)
+ if (draw->type != LOADER_DRI3_DRAWABLE_WINDOW ||
+ draw->swap_method == __DRI_ATTRIB_SWAP_EXCHANGE)
buffer_mask |= __DRI_IMAGE_BUFFER_FRONT;
if (buffer_mask & __DRI_IMAGE_BUFFER_FRONT) {
@@ -2153,7 +2250,7 @@ loader_dri3_get_buffers(__DRIdrawable *driDrawable,
* content will get synced with the fake front
* buffer.
*/
- if (draw->is_pixmap && !draw->is_different_gpu)
+ if (draw->type != LOADER_DRI3_DRAWABLE_WINDOW && !draw->is_different_gpu)
front = dri3_get_pixmap_buffer(driDrawable,
format,
loader_dri3_buffer_front,
@@ -2187,7 +2284,9 @@ loader_dri3_get_buffers(__DRIdrawable *driDrawable,
if (front) {
buffers->image_mask |= __DRI_IMAGE_BUFFER_FRONT;
buffers->front = front->image;
- draw->have_fake_front = draw->is_different_gpu || !draw->is_pixmap;
+ draw->have_fake_front =
+ draw->is_different_gpu ||
+ draw->type == LOADER_DRI3_DRAWABLE_WINDOW;
}
if (back) {
diff --git a/lib/mesa/src/loader/loader_dri3_helper.h b/lib/mesa/src/loader/loader_dri3_helper.h
index 615212c33..792f72700 100644
--- a/lib/mesa/src/loader/loader_dri3_helper.h
+++ b/lib/mesa/src/loader/loader_dri3_helper.h
@@ -116,6 +116,13 @@ struct loader_dri3_vtable {
#define LOADER_DRI3_NUM_BUFFERS (1 + LOADER_DRI3_MAX_BACK)
+enum loader_dri3_drawable_type {
+ LOADER_DRI3_DRAWABLE_UNKNOWN,
+ LOADER_DRI3_DRAWABLE_WINDOW,
+ LOADER_DRI3_DRAWABLE_PIXMAP,
+ LOADER_DRI3_DRAWABLE_PBUFFER,
+};
+
struct loader_dri3_drawable {
xcb_connection_t *conn;
xcb_screen_t *screen;
@@ -128,7 +135,7 @@ struct loader_dri3_drawable {
int depth;
uint8_t have_back;
uint8_t have_fake_front;
- uint8_t is_pixmap;
+ enum loader_dri3_drawable_type type;
/* Information about the GPU owning the buffer */
__DRIscreen *dri_screen;
@@ -139,10 +146,6 @@ struct loader_dri3_drawable {
/* DRI screen created for display GPU in case of prime */
__DRIscreen *dri_screen_display_gpu;
- /* Present extension capabilities
- */
- uint32_t present_capabilities;
-
/* SBC numbers are tracked by using the serial numbers
* in the present request and complete events
*/
@@ -202,6 +205,7 @@ loader_dri3_drawable_fini(struct loader_dri3_drawable *draw);
int
loader_dri3_drawable_init(xcb_connection_t *conn,
xcb_drawable_t drawable,
+ enum loader_dri3_drawable_type type,
__DRIscreen *dri_screen,
bool is_different_gpu,
bool is_multiplanes_available,
diff --git a/lib/mesa/src/loader/pci_id_driver_map.c b/lib/mesa/src/loader/pci_id_driver_map.c
deleted file mode 100644
index 3c4657fd0..000000000
--- a/lib/mesa/src/loader/pci_id_driver_map.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2014 Ilia Mirkin
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-int is_nouveau_vieux(int fd);
-
-#ifdef HAVE_LIBDRM
-
-#include <xf86drm.h>
-#include <nouveau_drm.h>
-
-static int
-nouveau_chipset(int fd)
-{
- struct drm_nouveau_getparam gp = { NOUVEAU_GETPARAM_CHIPSET_ID, 0 };
- int ret;
-
- ret = drmCommandWriteRead(fd, DRM_NOUVEAU_GETPARAM, &gp, sizeof(gp));
- if (ret)
- return -1;
-
- return gp.value;
-}
-
-int
-is_nouveau_vieux(int fd)
-{
- int chipset = nouveau_chipset(fd);
- return chipset > 0 && chipset < 0x30;
-}
-
-#else
-
-int is_nouveau_vieux(int fd) { return 0; }
-
-#endif