anv/image: Implement the wsi "extension"
Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Chad Versace <chadversary@chromium.org>
This commit is contained in:
parent
a44744e01d
commit
3dabb4011f
|
@ -1653,8 +1653,17 @@ VkResult anv_AllocateMemory(
|
||||||
if (pdevice->memory.heaps[mem->type->heapIndex].supports_48bit_addresses)
|
if (pdevice->memory.heaps[mem->type->heapIndex].supports_48bit_addresses)
|
||||||
mem->bo->flags |= EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
|
mem->bo->flags |= EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
|
||||||
|
|
||||||
if (pdevice->has_exec_async)
|
const struct wsi_memory_allocate_info *wsi_info =
|
||||||
|
vk_find_struct_const(pAllocateInfo->pNext, WSI_MEMORY_ALLOCATE_INFO_MESA);
|
||||||
|
if (wsi_info && wsi_info->implicit_sync) {
|
||||||
|
/* We need to set the WRITE flag on window system buffers so that GEM
|
||||||
|
* will know we're writing to them and synchronize uses on other rings
|
||||||
|
* (eg if the display server uses the blitter ring).
|
||||||
|
*/
|
||||||
|
mem->bo->flags |= EXEC_OBJECT_WRITE;
|
||||||
|
} else if (pdevice->has_exec_async) {
|
||||||
mem->bo->flags |= EXEC_OBJECT_ASYNC;
|
mem->bo->flags |= EXEC_OBJECT_ASYNC;
|
||||||
|
}
|
||||||
|
|
||||||
*pMem = anv_device_memory_to_handle(mem);
|
*pMem = anv_device_memory_to_handle(mem);
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,8 @@ choose_isl_surf_usage(VkImageCreateFlags vk_create_flags,
|
||||||
}
|
}
|
||||||
|
|
||||||
static isl_tiling_flags_t
|
static isl_tiling_flags_t
|
||||||
choose_isl_tiling_flags(const struct anv_image_create_info *anv_info)
|
choose_isl_tiling_flags(const struct anv_image_create_info *anv_info,
|
||||||
|
const struct isl_drm_modifier_info *isl_mod_info)
|
||||||
{
|
{
|
||||||
const VkImageCreateInfo *base_info = anv_info->vk_info;
|
const VkImageCreateInfo *base_info = anv_info->vk_info;
|
||||||
isl_tiling_flags_t flags = 0;
|
isl_tiling_flags_t flags = 0;
|
||||||
|
@ -111,6 +112,9 @@ choose_isl_tiling_flags(const struct anv_image_create_info *anv_info)
|
||||||
if (anv_info->isl_tiling_flags)
|
if (anv_info->isl_tiling_flags)
|
||||||
flags &= anv_info->isl_tiling_flags;
|
flags &= anv_info->isl_tiling_flags;
|
||||||
|
|
||||||
|
if (isl_mod_info)
|
||||||
|
flags &= 1 << isl_mod_info->tiling;
|
||||||
|
|
||||||
assert(flags);
|
assert(flags);
|
||||||
|
|
||||||
return flags;
|
return flags;
|
||||||
|
@ -493,6 +497,19 @@ make_surface(const struct anv_device *dev,
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct isl_drm_modifier_info *
|
||||||
|
get_legacy_scanout_drm_format_mod(VkImageTiling tiling)
|
||||||
|
{
|
||||||
|
switch (tiling) {
|
||||||
|
case VK_IMAGE_TILING_OPTIMAL:
|
||||||
|
return isl_drm_modifier_get_info(I915_FORMAT_MOD_X_TILED);
|
||||||
|
case VK_IMAGE_TILING_LINEAR:
|
||||||
|
return isl_drm_modifier_get_info(DRM_FORMAT_MOD_LINEAR);
|
||||||
|
default:
|
||||||
|
unreachable("bad VkImageTiling");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
VkResult
|
VkResult
|
||||||
anv_image_create(VkDevice _device,
|
anv_image_create(VkDevice _device,
|
||||||
const struct anv_image_create_info *create_info,
|
const struct anv_image_create_info *create_info,
|
||||||
|
@ -501,11 +518,17 @@ anv_image_create(VkDevice _device,
|
||||||
{
|
{
|
||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
const VkImageCreateInfo *pCreateInfo = create_info->vk_info;
|
const VkImageCreateInfo *pCreateInfo = create_info->vk_info;
|
||||||
|
const struct isl_drm_modifier_info *isl_mod_info = NULL;
|
||||||
struct anv_image *image = NULL;
|
struct anv_image *image = NULL;
|
||||||
VkResult r;
|
VkResult r;
|
||||||
|
|
||||||
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO);
|
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO);
|
||||||
|
|
||||||
|
const struct wsi_image_create_info *wsi_info =
|
||||||
|
vk_find_struct_const(pCreateInfo->pNext, WSI_IMAGE_CREATE_INFO_MESA);
|
||||||
|
if (wsi_info && wsi_info->scanout)
|
||||||
|
isl_mod_info = get_legacy_scanout_drm_format_mod(pCreateInfo->tiling);
|
||||||
|
|
||||||
anv_assert(pCreateInfo->mipLevels > 0);
|
anv_assert(pCreateInfo->mipLevels > 0);
|
||||||
anv_assert(pCreateInfo->arrayLayers > 0);
|
anv_assert(pCreateInfo->arrayLayers > 0);
|
||||||
anv_assert(pCreateInfo->samples > 0);
|
anv_assert(pCreateInfo->samples > 0);
|
||||||
|
@ -528,14 +551,15 @@ anv_image_create(VkDevice _device,
|
||||||
image->samples = pCreateInfo->samples;
|
image->samples = pCreateInfo->samples;
|
||||||
image->usage = pCreateInfo->usage;
|
image->usage = pCreateInfo->usage;
|
||||||
image->tiling = pCreateInfo->tiling;
|
image->tiling = pCreateInfo->tiling;
|
||||||
image->drm_format_mod = DRM_FORMAT_MOD_INVALID;
|
|
||||||
image->disjoint = pCreateInfo->flags & VK_IMAGE_CREATE_DISJOINT_BIT_KHR;
|
image->disjoint = pCreateInfo->flags & VK_IMAGE_CREATE_DISJOINT_BIT_KHR;
|
||||||
|
image->drm_format_mod = isl_mod_info ? isl_mod_info->modifier :
|
||||||
|
DRM_FORMAT_MOD_INVALID;
|
||||||
|
|
||||||
const struct anv_format *format = anv_get_format(image->vk_format);
|
const struct anv_format *format = anv_get_format(image->vk_format);
|
||||||
assert(format != NULL);
|
assert(format != NULL);
|
||||||
|
|
||||||
const isl_tiling_flags_t isl_tiling_flags =
|
const isl_tiling_flags_t isl_tiling_flags =
|
||||||
choose_isl_tiling_flags(create_info);
|
choose_isl_tiling_flags(create_info, isl_mod_info);
|
||||||
|
|
||||||
image->n_planes = format->n_planes;
|
image->n_planes = format->n_planes;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue