lima: enable tiling
Now that we have tiled format modifier merged into linux we can enable tiling. That should improve overall performance and also workaround broken mipmapping for linear textures since now we prefer tiled textures. Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Reviewed-by: Andreas Baierl <ichgeh@imkreisrum.de> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
This commit is contained in:
parent
272ef5d39a
commit
8c12f4e5f2
|
@ -178,9 +178,13 @@ _lima_resource_create_with_modifiers(struct pipe_screen *pscreen,
|
||||||
int count)
|
int count)
|
||||||
{
|
{
|
||||||
struct lima_screen *screen = lima_screen(pscreen);
|
struct lima_screen *screen = lima_screen(pscreen);
|
||||||
bool should_tile = false;
|
bool should_tile = true;
|
||||||
unsigned width, height;
|
unsigned width, height;
|
||||||
bool should_align_dimensions;
|
bool should_align_dimensions;
|
||||||
|
bool has_user_modifiers = true;
|
||||||
|
|
||||||
|
if (count == 1 && modifiers[0] == DRM_FORMAT_MOD_INVALID)
|
||||||
|
has_user_modifiers = false;
|
||||||
|
|
||||||
/* VBOs/PBOs are untiled (and 1 height). */
|
/* VBOs/PBOs are untiled (and 1 height). */
|
||||||
if (templat->target == PIPE_BUFFER)
|
if (templat->target == PIPE_BUFFER)
|
||||||
|
@ -189,9 +193,13 @@ _lima_resource_create_with_modifiers(struct pipe_screen *pscreen,
|
||||||
if (templat->bind & (PIPE_BIND_LINEAR | PIPE_BIND_SCANOUT))
|
if (templat->bind & (PIPE_BIND_LINEAR | PIPE_BIND_SCANOUT))
|
||||||
should_tile = false;
|
should_tile = false;
|
||||||
|
|
||||||
/* if linear buffer is not allowed, alloc fail */
|
if (drm_find_modifier(DRM_FORMAT_MOD_LINEAR, modifiers, count))
|
||||||
if (!should_tile && !drm_find_modifier(DRM_FORMAT_MOD_LINEAR, modifiers, count))
|
should_tile = false;
|
||||||
return NULL;
|
|
||||||
|
if (has_user_modifiers &&
|
||||||
|
!drm_find_modifier(DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED,
|
||||||
|
modifiers, count))
|
||||||
|
should_tile = false;
|
||||||
|
|
||||||
if (should_tile || (templat->bind & PIPE_BIND_RENDER_TARGET) ||
|
if (should_tile || (templat->bind & PIPE_BIND_RENDER_TARGET) ||
|
||||||
(templat->bind & PIPE_BIND_DEPTH_STENCIL)) {
|
(templat->bind & PIPE_BIND_DEPTH_STENCIL)) {
|
||||||
|
@ -228,10 +236,9 @@ static struct pipe_resource *
|
||||||
lima_resource_create(struct pipe_screen *pscreen,
|
lima_resource_create(struct pipe_screen *pscreen,
|
||||||
const struct pipe_resource *templat)
|
const struct pipe_resource *templat)
|
||||||
{
|
{
|
||||||
static const uint64_t modifiers[] = {
|
const uint64_t mod = DRM_FORMAT_MOD_INVALID;
|
||||||
DRM_FORMAT_MOD_LINEAR,
|
|
||||||
};
|
return _lima_resource_create_with_modifiers(pscreen, templat, &mod, 1);
|
||||||
return _lima_resource_create_with_modifiers(pscreen, templat, modifiers, ARRAY_SIZE(modifiers));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct pipe_resource *
|
static struct pipe_resource *
|
||||||
|
@ -315,8 +322,17 @@ lima_resource_from_handle(struct pipe_screen *pscreen,
|
||||||
else
|
else
|
||||||
res->levels[0].width = pres->width0;
|
res->levels[0].width = pres->width0;
|
||||||
|
|
||||||
handle->modifier = DRM_FORMAT_MOD_LINEAR;
|
switch (handle->modifier) {
|
||||||
res->tiled = false;
|
case DRM_FORMAT_MOD_LINEAR:
|
||||||
|
res->tiled = false;
|
||||||
|
break;
|
||||||
|
case DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED:
|
||||||
|
res->tiled = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "Attempted to import unsupported modifier 0x%llx\n",
|
||||||
|
(long long)handle->modifier);
|
||||||
|
}
|
||||||
|
|
||||||
return pres;
|
return pres;
|
||||||
|
|
||||||
|
@ -334,7 +350,10 @@ lima_resource_get_handle(struct pipe_screen *pscreen,
|
||||||
struct lima_screen *screen = lima_screen(pscreen);
|
struct lima_screen *screen = lima_screen(pscreen);
|
||||||
struct lima_resource *res = lima_resource(pres);
|
struct lima_resource *res = lima_resource(pres);
|
||||||
|
|
||||||
handle->modifier = DRM_FORMAT_MOD_LINEAR;
|
if (res->tiled)
|
||||||
|
handle->modifier = DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED;
|
||||||
|
else
|
||||||
|
handle->modifier = DRM_FORMAT_MOD_LINEAR;
|
||||||
|
|
||||||
if (handle->type == WINSYS_HANDLE_TYPE_KMS && screen->ro &&
|
if (handle->type == WINSYS_HANDLE_TYPE_KMS && screen->ro &&
|
||||||
renderonly_get_handle(res->scanout, handle))
|
renderonly_get_handle(res->scanout, handle))
|
||||||
|
|
Loading…
Reference in New Issue