diff options
author | Thierry Reding <[email protected]> | 2018-03-15 21:59:02 +0100 |
---|---|---|
committer | Dylan Baker <[email protected]> | 2018-05-30 16:56:47 -0700 |
commit | 92c633881e0560fd9862423aa55691eb049b19c7 (patch) | |
tree | 30ee32a90d82765f78d8aff419f8c82608c3e4c8 | |
parent | 2b8f87cefe72174af67a18c063494f70120e3bf4 (diff) |
tegra: Fix scanout resources without modifiers
Resources created for scanout but without modifiers need to be treated
as pitch-linear. This is because applications that don't use modifiers
to create resources must be assumed to not understand modifiers and in
turn won't be able to create a DRM framebuffer and passing along which
modifiers were picked by the implementation.
Tested-by: Daniel Kolesa <[email protected]>
Cc: [email protected]
Signed-off-by: Thierry Reding <[email protected]>
(cherry picked from commit 9603d81df05105857b676f20dff964ef3ab0ecff)
-rw-r--r-- | src/gallium/drivers/tegra/tegra_screen.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/gallium/drivers/tegra/tegra_screen.c b/src/gallium/drivers/tegra/tegra_screen.c index 85c8312dd12..99bd9139bb5 100644 --- a/src/gallium/drivers/tegra/tegra_screen.c +++ b/src/gallium/drivers/tegra/tegra_screen.c @@ -323,6 +323,7 @@ tegra_screen_resource_create(struct pipe_screen *pscreen, 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; @@ -330,7 +331,23 @@ tegra_screen_resource_create(struct pipe_screen *pscreen, 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; |