[waffle] [PATCH v2 3/4] gbm: initial functional gbm support
Jordan Justen
jljusten at gmail.com
Thu Sep 13 10:07:42 PDT 2012
Chad,
I think I've incorporated in changes for each of your suggestions
below in my v3 series.
-Jordan
On Mon, Aug 20, 2012 at 10:05 AM, Chad Versace
<chad.versace at linux.intel.com> wrote:
> On 08/13/2012 05:11 PM, Jordan Justen wrote:
>> src/waffle/gbm is based on src/waffle/wayland, and then heavily
>> modified.
>>
>> Tested as functional with: examples/gl_basic gbm gl|gles2
>>
>> Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
>> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
>> ---
>> CMakeLists.txt | 23 ++++-
>> include/waffle/waffle_config.h | 2 +
>> include/waffle/waffle_enum.h | 1 +
>
> include/waffle/native/waffle_gbm.h is missing.
>
>
>
>
>> diff --git a/CMakeLists.txt b/CMakeLists.txt
>
>> +if(waffle_has_gbm)
>> + waffle_find_library(waffle_GL_library GL)
>> + waffle_find_library(waffle_udev_library udev)
>> +endif()
>
> Is libGL really necessary here?
>
> I expected to find `waffle_find_library(waffle_gbm_library). I haven't tested
> the patches yet, but without that I don't
> expect them to build. Or is it that libEGL pulls in libgbm as a dependency? If
> that is the case, then we should still explicitly link to libgbm because GNU's
> ld and Clang's gold behave differently with respect to transitive shared library
> dependencies.
>
>
>
>
>> --- a/src/waffle/CMakeLists.txt
>> +++ b/src/waffle/CMakeLists.txt
>> @@ -111,6 +111,22 @@ if(waffle_has_x11_egl)
>> )
>> endif()
>>
>> +if(waffle_has_gbm)
>> + list(APPEND waffle_sources
>> + gbm/gbm_config.c
>> + gbm/gbm_context.c
>> + gbm/gbm_display.c
>> + gbm/gbm_platform.c
>> + gbm/gbm_priv_egl.c
>> + gbm/gbm_window.c
>> + )
>> + list(APPEND waffle_libdeps
>> + ${waffle_gbm-client_library}
>> + ${waffle_gbm-egl_library}
>> + ${waffle_udev_library}
>> + )
>> +endif()
>
> I can't find where waffle_gbm-client_library and waffle_gbm-eg_library are
> defined in this patch. Copy-paste error from Wayland?
>
>
>
>
>> +struct wcore_config*
>> +gbm_config_choose(struct wcore_platform *wc_plat,
>> + struct wcore_display *wc_dpy,
>> + const struct wcore_config_attrs *attrs)
>> +{
>> + struct gbm_config *self;
>> + struct gbm_display *dpy = gbm_display(wc_dpy);
>> + bool ok = true;
>
> Here, the config needs to be rejected if there is no corresponding GBM_FORMAT.
> See my comments on gbm_window_create().
>
>> +
>> + self = wcore_calloc(sizeof(*self));
>> + if (self == NULL)
>> + return NULL;
>> +
>> + ok = wcore_config_init(&self->wcore, wc_dpy);
>> + if (!ok)
>> + goto error;
>> +
>> + ok = egl_get_render_buffer_attrib(attrs, &self->egl_render_buffer);
>> + if (!ok)
>> + goto error;
>> +
>> + self->egl = egl_choose_config(wc_plat, dpy->egl, attrs);
>> + if (!self->egl)
>> + goto error;
>> +
>> + self->waffle_context_api = attrs->context_api;
>> + self->wcore.vtbl = &gbm_config_wcore_vtbl;
>> + return &self->wcore;
>> +
>> +error:
>> + gbm_config_destroy(&self->wcore);
>> + return NULL;
>> +}
>
>
>
>
>> +static int
>> +gbm_get_fd(void)
>> +{
>> + struct udev *ud;
>> + struct udev_enumerate *en;
>> + struct udev_list_entry *entry;
>> + const char *path, *filename;
>> + struct udev_device *device;
>> + int fd;
>> +
>> + ud = udev_new();
>> + en = udev_enumerate_new(ud);
>> + udev_enumerate_add_match_subsystem(en, "drm");
>> + udev_enumerate_add_match_sysname(en, "card[0-9]*");
>> + udev_enumerate_scan_devices(en);
>> +
>> + udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(en)) {
>> + path = udev_list_entry_get_name(entry);
>> + device = udev_device_new_from_syspath(ud, path);
>> + filename = udev_device_get_devnode(device);
>> + fd = open(filename, O_RDWR | O_CLOEXEC);
>> + udev_device_unref(device);
>> + if (fd >= 0) {
>> + return fd;
>> + }
>> + }
>> +
>> + return -1;
>> +}
>
> Is the `path` variable a filepath? Is it a udev path, whatever that is? I don't
> know udev, and that little bit confused me.
path: /sys/devices/pci0000:00/0000:00:02.0/drm/card0
filename: /dev/dri/card0
>> +struct wcore_window*
>> +gbm_window_create(struct wcore_platform *wc_plat,
>> + struct wcore_config *wc_config,
>> + int width,
>> + int height)
>> +{
>> + struct gbm_window *self;
>> + struct gbm_config *config = gbm_config(wc_config);
>> + struct gbm_display *dpy = gbm_display(wc_config->display);
>> + bool ok = true;
>> +
>> + self = wcore_calloc(sizeof(*self));
>> + if (self == NULL)
>> + return NULL;
>> +
>> + ok = wcore_window_init(&self->wcore, wc_config);
>> + if (!ok)
>> + goto error;
>> +
>> + self->gbm_surface = gbm_surface_create(dpy->gbm_device, width, height,
>> + GBM_FORMAT_XRGB8888,
>> + GBM_BO_USE_RENDERING);
>
> Here, waffle needs to respect the color bits with which the waffle_config was
> created.
>
> As an aside, GBM has no formats with depth bits. In order to run all Piglit
> tests under GBM, we will need to extend to GBM somehow.
>
>> + if (!self->gbm_surface) {
>> + wcore_errorf(WAFFLE_ERROR_UNKNOWN,
>> + "gbm_surface_create failed");
>> + goto error;
>> + }
>> +
>> + self->egl = gbm_egl_create_window_surface(dpy->egl,
>> + config->egl,
>> + self->gbm_surface,
>> + config->egl_render_buffer);
>> + if (!self->egl)
>> + goto error;
>> +
>> + self->wcore.vtbl = &gbm_window_wcore_vtbl;
>> + return &self->wcore;
>> +
>> +error:
>> + gbm_window_destroy(&self->wcore);
>> + return NULL;
>> +}
>
>
>
>
>> +static union waffle_native_window*
>> +gbm_window_get_native(struct wcore_window *wc_self)
>> +{
>> + struct gbm_window *self = gbm_window(wc_self);
>> + struct gbm_display *dpy = gbm_display(wc_self->display);
>> + struct waffle_gbm_window *n_window;
>> +
>> + n_window = wcore_malloc(sizeof(*n_window));
>> + if (n_window == NULL)
>> + return NULL;
>> +
>> + gbm_display_fill_native(dpy, &n_window->display);
>> + n_window->egl_surface = self->egl;
>
> n_window->gbm_surface = self->gbm_surface?
>
>> +
>> + return (union waffle_native_window*) n_window;
>> +}
> _______________________________________________
> waffle mailing list
> waffle at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/waffle
More information about the waffle
mailing list