Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package kmscube for openSUSE:Factory checked in at 2022-03-17 17:01:41 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/kmscube (Old) and /work/SRC/openSUSE:Factory/.kmscube.new.25692 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "kmscube" Thu Mar 17 17:01:41 2022 rev:5 rq:962354 version:0.0.0.git1612698153.9f63f35 Changes: -------- --- /work/SRC/openSUSE:Factory/kmscube/kmscube.changes 2020-06-09 00:12:48.538927131 +0200 +++ /work/SRC/openSUSE:Factory/.kmscube.new.25692/kmscube.changes 2022-03-17 17:01:54.277704012 +0100 @@ -1,0 +2,10 @@ +Thu Mar 17 08:42:43 UTC 2022 - guillaume.gar...@opensuse.org + +- Update to version 0.0.0.git1612698153.9f63f35: + * Revert "Multiple GL_ TRIANGLE_ STRIP draw merge." + * Multiple GL_ TRIANGLE_ STRIP draw merge. + * drm: grab correct handle for plane != 0 + * surfaceless support + * gbm: split out helper to initialize surface + +------------------------------------------------------------------- Old: ---- kmscube-0.0.0.git1585705428.4660a7d.tar.xz New: ---- kmscube-0.0.0.git1612698153.9f63f35.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ kmscube.spec ++++++ --- /var/tmp/diff_new_pack.jN40it/_old 2022-03-17 17:01:54.781704398 +0100 +++ /var/tmp/diff_new_pack.jN40it/_new 2022-03-17 17:01:54.781704398 +0100 @@ -1,7 +1,7 @@ # # spec file for package kmscube # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2022 SUSE LLC # Copyright (c) 2019, Guillaume GARDET <guilla...@opensuse.org> # # All modifications and additions to the file contributed by third parties @@ -18,16 +18,15 @@ Name: kmscube -Version: 0.0.0.git1585705428.4660a7d +Version: 0.0.0.git1612698153.9f63f35 Release: 0 Summary: Demo for bare metal graphics License: MIT Group: Development/Tools/Other -URL: https://github.com/bastibl/kmscube.git +URL: https://gitlab.freedesktop.org/mesa/kmscube Source: %{name}-%{version}.tar.xz BuildRequires: Mesa-devel BuildRequires: Mesa-libGLESv3-devel -BuildRequires: meson >= 0.47 BuildRequires: gcc BuildRequires: glib2-devel BuildRequires: gstreamer-devel >= 1.6.0 @@ -35,6 +34,7 @@ BuildRequires: libdrm-devel >= 2.4.71 BuildRequires: libgbm-devel >= 13.0 BuildRequires: make +BuildRequires: meson >= 0.47 BuildRequires: pkgconfig >= 0.9.0 BuildRequires: pkgconfig(libpng16) BuildRequires: pkgconfig(x11) ++++++ _service ++++++ --- /var/tmp/diff_new_pack.jN40it/_old 2022-03-17 17:01:54.817704424 +0100 +++ /var/tmp/diff_new_pack.jN40it/_new 2022-03-17 17:01:54.821704428 +0100 @@ -2,7 +2,7 @@ <service name="tar_scm" mode="disabled"> <param name="scm">git</param> <param name="url">https://gitlab.freedesktop.org/mesa/kmscube</param> - <param name="revision">4660a7dc</param> + <param name="revision">9f63f359</param> <param name="exclude">.git</param> <param name="versionformat">git%ct.%h</param> <param name="versionprefix">0.0.0</param> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.jN40it/_old 2022-03-17 17:01:54.841704444 +0100 +++ /var/tmp/diff_new_pack.jN40it/_new 2022-03-17 17:01:54.845704446 +0100 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://gitlab.freedesktop.org/mesa/kmscube</param> - <param name="changesrevision">4660a7dca6512b6e658759d00cff7d4ad2a2059d</param></service></servicedata> + <param name="changesrevision">9f63f359fab1b5d8e862508e4e51c9dfe339ccb0</param></service></servicedata> (No newline at EOF) ++++++ kmscube-0.0.0.git1585705428.4660a7d.tar.xz -> kmscube-0.0.0.git1612698153.9f63f35.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kmscube-0.0.0.git1585705428.4660a7d/common.c new/kmscube-0.0.0.git1612698153.9f63f35/common.c --- old/kmscube-0.0.0.git1585705428.4660a7d/common.c 2020-04-01 03:43:48.000000000 +0200 +++ new/kmscube-0.0.0.git1612698153.9f63f35/common.c 2021-02-07 12:42:33.000000000 +0100 @@ -22,6 +22,7 @@ * DEALINGS IN THE SOFTWARE. */ +#include <assert.h> #include <errno.h> #include <fcntl.h> #include <stdbool.h> @@ -29,6 +30,7 @@ #include <stdlib.h> #include <string.h> #include <time.h> +#include <unistd.h> #include "common.h" @@ -40,15 +42,59 @@ uint32_t format, const uint64_t *modifiers, const unsigned int count); +WEAK struct gbm_bo * +gbm_bo_create_with_modifiers(struct gbm_device *gbm, + uint32_t width, uint32_t height, + uint32_t format, + const uint64_t *modifiers, + const unsigned int count); -const struct gbm * init_gbm(int drm_fd, int w, int h, uint32_t format, uint64_t modifier) +static struct gbm_bo * init_bo(uint64_t modifier) { - gbm.dev = gbm_create_device(drm_fd); - gbm.format = format; - gbm.surface = NULL; + struct gbm_bo *bo = NULL; + + if (gbm_bo_create_with_modifiers) { + bo = gbm_bo_create_with_modifiers(gbm.dev, + gbm.width, gbm.height, + gbm.format, + &modifier, 1); + } + + if (!bo) { + if (modifier != DRM_FORMAT_MOD_LINEAR) { + fprintf(stderr, "Modifiers requested but support isn't available\n"); + return NULL; + } + + bo = gbm_bo_create(gbm.dev, + gbm.width, gbm.height, + gbm.format, + GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); + } + if (!bo) { + printf("failed to create gbm bo\n"); + return NULL; + } + + return bo; +} + +static struct gbm * init_surfaceless(uint64_t modifier) +{ + for (unsigned i = 0; i < ARRAY_SIZE(gbm.bos); i++) { + gbm.bos[i] = init_bo(modifier); + if (!gbm.bos[i]) + return NULL; + } + return &gbm; +} + +static struct gbm * init_surface(uint64_t modifier) +{ if (gbm_surface_create_with_modifiers) { - gbm.surface = gbm_surface_create_with_modifiers(gbm.dev, w, h, + gbm.surface = gbm_surface_create_with_modifiers(gbm.dev, + gbm.width, gbm.height, gbm.format, &modifier, 1); @@ -59,7 +105,8 @@ fprintf(stderr, "Modifiers requested but support isn't available\n"); return NULL; } - gbm.surface = gbm_surface_create(gbm.dev, w, h, + gbm.surface = gbm_surface_create(gbm.dev, + gbm.width, gbm.height, gbm.format, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); @@ -70,10 +117,23 @@ return NULL; } + return &gbm; +} + +const struct gbm * init_gbm(int drm_fd, int w, int h, uint32_t format, + uint64_t modifier, bool surfaceless) +{ + gbm.dev = gbm_create_device(drm_fd); + gbm.format = format; + gbm.surface = NULL; + gbm.width = w; gbm.height = h; - return &gbm; + if (surfaceless) + return init_surfaceless(modifier); + + return init_surface(modifier); } static bool has_ext(const char *extension_list, const char *ext) @@ -162,6 +222,82 @@ return true; } +static bool +create_framebuffer(const struct egl *egl, struct gbm_bo *bo, + struct framebuffer *fb) { + assert(egl->eglCreateImageKHR); + assert(bo); + assert(fb); + + // 1. Create EGLImage. + int fd = gbm_bo_get_fd(bo); + if (fd < 0) { + printf("failed to get fd for bo: %d\n", fd); + return false; + } + + EGLint khr_image_attrs[17] = { + EGL_WIDTH, gbm_bo_get_width(bo), + EGL_HEIGHT, gbm_bo_get_height(bo), + EGL_LINUX_DRM_FOURCC_EXT, (int)gbm_bo_get_format(bo), + EGL_DMA_BUF_PLANE0_FD_EXT, fd, + EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0, + EGL_DMA_BUF_PLANE0_PITCH_EXT, gbm_bo_get_stride(bo), + EGL_NONE, EGL_NONE, /* modifier lo */ + EGL_NONE, EGL_NONE, /* modifier hi */ + EGL_NONE, + }; + + if (egl->modifiers_supported) { + const uint64_t modifier = gbm_bo_get_modifier(bo); + if (modifier != DRM_FORMAT_MOD_LINEAR) { + size_t attrs_index = 12; + khr_image_attrs[attrs_index++] = + EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT; + khr_image_attrs[attrs_index++] = modifier & 0xfffffffful; + khr_image_attrs[attrs_index++] = + EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT; + khr_image_attrs[attrs_index++] = modifier >> 32; + } + } + + fb->image = egl->eglCreateImageKHR(egl->display, EGL_NO_CONTEXT, + EGL_LINUX_DMA_BUF_EXT, NULL /* no client buffer */, + khr_image_attrs); + + if (fb->image == EGL_NO_IMAGE_KHR) { + printf("failed to make image from buffer object\n"); + return false; + } + + // EGLImage takes the fd ownership. + close(fd); + + // 2. Create GL texture and framebuffer. + glGenTextures(1, &fb->tex); + glBindTexture(GL_TEXTURE_2D, fb->tex); + egl->glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, fb->image); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glBindTexture(GL_TEXTURE_2D, 0); + + glGenFramebuffers(1, &fb->fb); + glBindFramebuffer(GL_FRAMEBUFFER, fb->fb); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + fb->tex, 0); + + if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { + printf("failed framebuffer check for created target buffer\n"); + glDeleteFramebuffers(1, &fb->fb); + glDeleteTextures(1, &fb->tex); + return false; + } + + return true; +} + int init_egl(struct egl *egl, const struct gbm *gbm, int samples) { EGLint major, minor; @@ -253,11 +389,15 @@ return -1; } - egl->surface = eglCreateWindowSurface(egl->display, egl->config, - (EGLNativeWindowType)gbm->surface, NULL); - if (egl->surface == EGL_NO_SURFACE) { - printf("failed to create egl surface\n"); - return -1; + if (!gbm->surface) { + egl->surface = EGL_NO_SURFACE; + } else { + egl->surface = eglCreateWindowSurface(egl->display, egl->config, + (EGLNativeWindowType)gbm->surface, NULL); + if (egl->surface == EGL_NO_SURFACE) { + printf("failed to create egl surface\n"); + return -1; + } } /* connect the context to the surface */ @@ -286,6 +426,15 @@ get_proc_gl(GL_AMD_performance_monitor, glEndPerfMonitorAMD); get_proc_gl(GL_AMD_performance_monitor, glGetPerfMonitorCounterDataAMD); + if (!gbm->surface) { + for (unsigned i = 0; i < ARRAY_SIZE(gbm->bos); i++) { + if (!create_framebuffer(egl, gbm->bos[i], &egl->fbs[i])) { + printf("failed to create framebuffer\n"); + return -1; + } + } + } + return 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kmscube-0.0.0.git1585705428.4660a7d/common.h new/kmscube-0.0.0.git1612698153.9f63f35/common.h --- old/kmscube-0.0.0.git1585705428.4660a7d/common.h 2020-04-01 03:43:48.000000000 +0200 +++ new/kmscube-0.0.0.git1612698153.9f63f35/common.h 2021-02-07 12:42:33.000000000 +0100 @@ -96,21 +96,30 @@ #define EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT 0x344A #endif +#define NUM_BUFFERS 2 + struct gbm { struct gbm_device *dev; struct gbm_surface *surface; + struct gbm_bo *bos[NUM_BUFFERS]; /* for the surfaceless case */ uint32_t format; int width, height; }; -const struct gbm * init_gbm(int drm_fd, int w, int h, uint32_t format, uint64_t modifier); +const struct gbm * init_gbm(int drm_fd, int w, int h, uint32_t format, uint64_t modifier, bool surfaceless); +struct framebuffer { + EGLImageKHR image; + GLuint tex; + GLuint fb; +}; struct egl { EGLDisplay display; EGLConfig config; EGLContext context; EGLSurface surface; + struct framebuffer fbs[NUM_BUFFERS]; /* for the surfaceless case */ PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT; PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kmscube-0.0.0.git1585705428.4660a7d/drm-atomic.c new/kmscube-0.0.0.git1612698153.9f63f35/drm-atomic.c --- old/kmscube-0.0.0.git1585705428.4660a7d/drm-atomic.c 2020-04-01 03:43:48.000000000 +0200 +++ new/kmscube-0.0.0.git1612698153.9f63f35/drm-atomic.c 2021-02-07 12:42:33.000000000 +0100 @@ -196,6 +196,7 @@ start_time = report_time = get_time_ns(); while (i < drm.count) { + unsigned frame = i; struct gbm_bo *next_bo; EGLSyncKHR gpu_fence = NULL; /* out-fence from gpu, in-fence to kms */ EGLSyncKHR kms_fence = NULL; /* in-fence to gpu, out-fence from kms */ @@ -222,6 +223,10 @@ start_time = report_time = get_time_ns(); } + if (!gbm->surface) { + glBindFramebuffer(GL_FRAMEBUFFER, egl->fbs[frame % NUM_BUFFERS].fb); + } + egl->draw(i++); /* insert fence to be singled in cmdstream.. this fence will be @@ -230,7 +235,9 @@ gpu_fence = create_fence(egl, EGL_NO_NATIVE_FENCE_FD_ANDROID); assert(gpu_fence); - eglSwapBuffers(egl->display, egl->surface); + if (gbm->surface) { + eglSwapBuffers(egl->display, egl->surface); + } /* after swapbuffers, gpu_fence should be flushed, so safe * to get fd: @@ -239,7 +246,11 @@ egl->eglDestroySyncKHR(egl->display, gpu_fence); assert(drm.kms_in_fence_fd != -1); - next_bo = gbm_surface_lock_front_buffer(gbm->surface); + if (gbm->surface) { + next_bo = gbm_surface_lock_front_buffer(gbm->surface); + } else { + next_bo = gbm->bos[frame % NUM_BUFFERS]; + } if (!next_bo) { printf("Failed to lock frontbuffer\n"); return -1; @@ -300,7 +311,7 @@ } /* release last buffer to render on again: */ - if (bo) + if (bo && gbm->surface) gbm_surface_release_buffer(gbm->surface, bo); bo = next_bo; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kmscube-0.0.0.git1585705428.4660a7d/drm-common.c new/kmscube-0.0.0.git1612698153.9f63f35/drm-common.c --- old/kmscube-0.0.0.git1585705428.4660a7d/drm-common.c 2020-04-01 03:43:48.000000000 +0200 +++ new/kmscube-0.0.0.git1612698153.9f63f35/drm-common.c 2021-02-07 12:42:33.000000000 +0100 @@ -32,6 +32,9 @@ #include "common.h" #include "drm-common.h" +WEAK union gbm_bo_handle +gbm_bo_get_handle_for_plane(struct gbm_bo *bo, int plane); + WEAK uint64_t gbm_bo_get_modifier(struct gbm_bo *bo); @@ -75,15 +78,16 @@ height = gbm_bo_get_height(bo); format = gbm_bo_get_format(bo); - if (gbm_bo_get_modifier && gbm_bo_get_plane_count && - gbm_bo_get_stride_for_plane && gbm_bo_get_offset) { + if (gbm_bo_get_handle_for_plane && gbm_bo_get_modifier && + gbm_bo_get_plane_count && gbm_bo_get_stride_for_plane && + gbm_bo_get_offset) { uint64_t modifiers[4] = {0}; modifiers[0] = gbm_bo_get_modifier(bo); const int num_planes = gbm_bo_get_plane_count(bo); for (int i = 0; i < num_planes; i++) { + handles[i] = gbm_bo_get_handle_for_plane(bo, i).u32; strides[i] = gbm_bo_get_stride_for_plane(bo, i); - handles[i] = gbm_bo_get_handle(bo).u32; offsets[i] = gbm_bo_get_offset(bo, i); modifiers[i] = modifiers[0]; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kmscube-0.0.0.git1585705428.4660a7d/drm-legacy.c new/kmscube-0.0.0.git1612698153.9f63f35/drm-legacy.c --- old/kmscube-0.0.0.git1585705428.4660a7d/drm-legacy.c 2020-04-01 03:43:48.000000000 +0200 +++ new/kmscube-0.0.0.git1612698153.9f63f35/drm-legacy.c 2021-02-07 12:42:33.000000000 +0100 @@ -54,8 +54,12 @@ int64_t start_time, report_time, cur_time; int ret; - eglSwapBuffers(egl->display, egl->surface); - bo = gbm_surface_lock_front_buffer(gbm->surface); + if (gbm->surface) { + eglSwapBuffers(egl->display, egl->surface); + bo = gbm_surface_lock_front_buffer(gbm->surface); + } else { + bo = gbm->bos[0]; + } fb = drm_fb_get_from_bo(bo); if (!fb) { fprintf(stderr, "Failed to get a new framebuffer BO\n"); @@ -73,6 +77,7 @@ start_time = report_time = get_time_ns(); while (i < drm.count) { + unsigned frame = i; struct gbm_bo *next_bo; int waiting_for_flip = 1; @@ -83,10 +88,19 @@ start_time = report_time = get_time_ns(); } + if (!gbm->surface) { + glBindFramebuffer(GL_FRAMEBUFFER, egl->fbs[frame % NUM_BUFFERS].fb); + } + egl->draw(i++); - eglSwapBuffers(egl->display, egl->surface); - next_bo = gbm_surface_lock_front_buffer(gbm->surface); + if (gbm->surface) { + eglSwapBuffers(egl->display, egl->surface); + next_bo = gbm_surface_lock_front_buffer(gbm->surface); + } else { + glFinish(); + next_bo = gbm->bos[frame % NUM_BUFFERS]; + } fb = drm_fb_get_from_bo(next_bo); if (!fb) { fprintf(stderr, "Failed to get a new framebuffer BO\n"); @@ -135,7 +149,9 @@ } /* release last buffer to render on again: */ - gbm_surface_release_buffer(gbm->surface, bo); + if (gbm->surface) { + gbm_surface_release_buffer(gbm->surface, bo); + } bo = next_bo; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kmscube-0.0.0.git1585705428.4660a7d/kmscube.c new/kmscube-0.0.0.git1612698153.9f63f35/kmscube.c --- old/kmscube-0.0.0.git1585705428.4660a7d/kmscube.c 2020-04-01 03:43:48.000000000 +0200 +++ new/kmscube-0.0.0.git1612698153.9f63f35/kmscube.c 2021-02-07 12:42:33.000000000 +0100 @@ -41,7 +41,7 @@ static const struct gbm *gbm; static const struct drm *drm; -static const char *shortopts = "Ac:D:f:M:m:p:S:s:V:v:"; +static const char *shortopts = "Ac:D:f:M:m:p:S:s:V:v:x"; static const struct option longopts[] = { {"atomic", no_argument, 0, 'A'}, @@ -54,12 +54,13 @@ {"samples", required_argument, 0, 's'}, {"video", required_argument, 0, 'V'}, {"vmode", required_argument, 0, 'v'}, + {"surfaceless", no_argument, 0, 'x'}, {0, 0, 0, 0} }; static void usage(const char *name) { - printf("Usage: %s [-ADfMmSsVv]\n" + printf("Usage: %s [-ADfMmSsVvx]\n" "\n" "options:\n" " -A, --atomic use atomic modesetting and fencing\n" @@ -79,7 +80,9 @@ " -s, --samples=N use MSAA\n" " -V, --video=FILE video textured cube (comma separated list)\n" " -v, --vmode=VMODE specify the video mode in the format\n" - " <mode>[-<vrefresh>]\n", + " <mode>[-<vrefresh>]\n" + " -x, --surfaceless use surfaceless mode, instead of gbm surface\n" + , name); } @@ -100,6 +103,7 @@ unsigned int len; unsigned int vrefresh = 0; unsigned int count = ~0; + bool surfaceless = false; #ifdef HAVE_GST gst_init(&argc, &argv); @@ -177,6 +181,9 @@ strncpy(mode_str, optarg, len); mode_str[len] = '\0'; break; + case 'x': + surfaceless = true; + break; default: usage(argv[0]); return -1; @@ -193,7 +200,7 @@ } gbm = init_gbm(drm->fd, drm->mode->hdisplay, drm->mode->vdisplay, - format, modifier); + format, modifier, surfaceless); if (!gbm) { printf("failed to initialize GBM\n"); return -1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kmscube-0.0.0.git1585705428.4660a7d/texturator.c new/kmscube-0.0.0.git1612698153.9f63f35/texturator.c --- old/kmscube-0.0.0.git1585705428.4660a7d/texturator.c 2020-04-01 03:43:48.000000000 +0200 +++ new/kmscube-0.0.0.git1612698153.9f63f35/texturator.c 2021-02-07 12:42:33.000000000 +0100 @@ -957,7 +957,7 @@ } gbm = init_gbm(drm->fd, drm->mode->hdisplay, drm->mode->vdisplay, - DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_LINEAR); + DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_LINEAR, false); if (!gbm) { printf("failed to initialize GBM\n"); return -1;