Gurchetan Singh <gurchetansi...@chromium.org> writes: > +static int virtio_gpu_rutabaga_init(VirtIOGPU *g, Error **errp) > +{ > + int result; > + uint64_t capset_mask; > + struct rutabaga_channels channels = { 0 }; > + struct rutabaga_builder builder = { 0 }; > + > + VirtIOGPURutabaga *vr = VIRTIO_GPU_RUTABAGA(g); > + vr->rutabaga = NULL; > + > + if (!vr->capset_names) { > + error_setg(errp, "a capset name from virtio-gpu spec"); > + return -EINVAL; > + } > + > + builder.wsi = RUTABAGA_WSI_SURFACELESS; > + /* > + * Currently, if WSI is specified, the only valid strings are > "surfaceless" > + * or "headless". Surfaceless doesn't create a native window surface, > but > + * does copy from the render target to the Pixman buffer if a virtio-gpu > + * 2D hypercall is issued. Surfacless is the default. > + * > + * Headless is like surfaceless, but doesn't copy to the Pixman buffer. > The > + * use case is automated testing environments where there is no need to > view > + * results. > + * > + * In the future, more performant virtio-gpu 2D UI integration may be > added. > + */ > + if (vr->wsi) { > + if (g_str_equal(vr->wsi, "surfaceless")) { > + vr->headless = false; > + } else if (g_str_equal(vr->wsi, "headless")) { > + vr->headless = true; > + } else { > + error_setg(errp, "invalid wsi option selected"); > + return -EINVAL; > + } > + } > + > + result = rutabaga_calculate_capset_mask(vr->capset_names, &capset_mask); > + if (result) { > + error_setg(errp, "invalid capset names: %s", vr->capset_names); > + return result; > + } > + > + builder.fence_cb = virtio_gpu_rutabaga_fence_cb; > + builder.debug_cb = virtio_gpu_rutabaga_debug_cb; > + builder.capset_mask = capset_mask; > + > + /* > + * Using GPOINTER_TO_UINT(g) below causes segfaults. > + */ > + builder.user_data = (uint64_t)(uintptr_t *)(void *)g; > + > + if (vr->wayland_socket_path) { > + if ((builder.capset_mask & (1 << RUTABAGA_CAPSET_CROSS_DOMAIN)) == > 0) { > + error_setg(errp, "cross-domain required with wayland socket"); > + return -EINVAL; > + } > + > + channels.channels = g_new0(struct rutabaga_channel, 1); > + channels.num_channels = 1; > + channels.channels[0].channel_name = vr->wayland_socket_path; > + channels.channels[0].channel_type = RUTABAGA_CHANNEL_TYPE_WAYLAND; > + builder.channels = &channels; > + } > +
Would it be feasible to identify whether Wayland should be used in some other way, to avoid users having to manually specify the socket path and allow the standard wl_display_connect() logic to be used? > + result = rutabaga_init(&builder, &vr->rutabaga); > + if (builder.capset_mask & (1 << RUTABAGA_CAPSET_CROSS_DOMAIN)) { > + g_free(channels.channels); > + } > + > + return result; > +}
signature.asc
Description: PGP signature