memset(&handle, 0, sizeof(handle));
handle.modifier = DRM_FORMAT_MOD_INVALID;
- handle.type = DRM_API_HANDLE_TYPE_FD;
+ handle.type = WINSYS_HANDLE_TYPE_FD;
status = screen->gpu->resource_get_handle(screen->gpu, NULL, resource->gpu,
&handle, usage);
const struct pipe_resource *template)
{
struct tegra_screen *screen = to_tegra_screen(pscreen);
+ uint64_t modifier = DRM_FORMAT_MOD_INVALID;
struct tegra_resource *resource;
int err;
if (!resource)
return NULL;
- resource->gpu = screen->gpu->resource_create(screen->gpu, template);
+ /*
+ * Applications that create scanout resources without modifiers are very
+ * unlikely to support modifiers at all. In that case the resources need
+ * to be created with a pitch-linear layout so that they can be properly
+ * shared with scanout hardware.
+ *
+ * Technically it is possible for applications to create resources without
+ * specifying a modifier but still query the modifier associated with the
+ * resource (e.g. using gbm_bo_get_modifier()) before handing it to the
+ * framebuffer creation API (such as the DRM_IOCTL_MODE_ADDFB2 IOCTL).
+ */
+ if (template->bind & PIPE_BIND_SCANOUT)
+ modifier = DRM_FORMAT_MOD_LINEAR;
+
+ resource->gpu = screen->gpu->resource_create_with_modifiers(screen->gpu,
+ template,
+ &modifier, 1);
if (!resource->gpu)
goto free;
* to pass buffers into Tegra DRM for display. In all other cases, return
* the Nouveau handle, assuming they will be used for sharing in DRI2/3.
*/
- if (handle->type == DRM_API_HANDLE_TYPE_KMS &&
+ if (handle->type == WINSYS_HANDLE_TYPE_KMS &&
presource->bind & PIPE_BIND_SCANOUT) {
handle->modifier = resource->modifier;
handle->handle = resource->handle;
int count)
{
struct tegra_screen *screen = to_tegra_screen(pscreen);
+ struct pipe_resource tmpl = *template;
struct tegra_resource *resource;
int err;
if (!resource)
return NULL;
+ /*
+ * Assume that resources created with modifiers will always be used for
+ * scanout. This is necessary because some of the APIs that are used to
+ * create resources with modifiers (e.g. gbm_bo_create_with_modifiers())
+ * can't pass along usage information. Adding that capability might be
+ * worth adding to remove this ambiguity. Not all future use-cases that
+ * involve modifiers may always be targetting scanout hardware.
+ */
+ tmpl.bind |= PIPE_BIND_SCANOUT;
+
resource->gpu = screen->gpu->resource_create_with_modifiers(screen->gpu,
- template,
+ &tmpl,
modifiers,
count);
if (!resource->gpu)