venus: initial AHB support for multi-planar format
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org> Reviewed-by: Chia-I Wu <olvaffe@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11150>
This commit is contained in:
parent
380ac28891
commit
5054f74ce1
|
@ -165,6 +165,10 @@ vn_android_ahb_format_to_vk_format(uint32_t format)
|
||||||
case AHARDWAREBUFFER_FORMAT_S8_UINT:
|
case AHARDWAREBUFFER_FORMAT_S8_UINT:
|
||||||
return VK_FORMAT_S8_UINT;
|
return VK_FORMAT_S8_UINT;
|
||||||
case AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420:
|
case AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420:
|
||||||
|
/* XXX Add a gralloc query for the resolved drm format and then map to a
|
||||||
|
* compatiable VkFormat.
|
||||||
|
*/
|
||||||
|
case AHARDWAREBUFFER_FORMAT_IMPLEMENTATION_DEFINED:
|
||||||
return VK_FORMAT_G8_B8R8_2PLANE_420_UNORM;
|
return VK_FORMAT_G8_B8R8_2PLANE_420_UNORM;
|
||||||
default:
|
default:
|
||||||
return VK_FORMAT_UNDEFINED;
|
return VK_FORMAT_UNDEFINED;
|
||||||
|
@ -303,8 +307,19 @@ vn_android_get_modifier_properties(VkPhysicalDevice physical_device,
|
||||||
vn_GetPhysicalDeviceFormatProperties2(physical_device, format,
|
vn_GetPhysicalDeviceFormatProperties2(physical_device, format,
|
||||||
&format_prop);
|
&format_prop);
|
||||||
|
|
||||||
if (!mod_prop_list.drmFormatModifierCount)
|
if (!mod_prop_list.drmFormatModifierCount) {
|
||||||
return VK_ERROR_INVALID_EXTERNAL_HANDLE;
|
/* XXX Remove this fallback after host VK_EXT_image_drm_format_modifier
|
||||||
|
* can properly support VK_FORMAT_G8_B8R8_2PLANE_420_UNORM.
|
||||||
|
*/
|
||||||
|
if (format != VK_FORMAT_G8_B8R8_2PLANE_420_UNORM)
|
||||||
|
return VK_ERROR_INVALID_EXTERNAL_HANDLE;
|
||||||
|
|
||||||
|
out_props->drmFormatModifier = modifier;
|
||||||
|
out_props->drmFormatModifierPlaneCount = 2;
|
||||||
|
out_props->drmFormatModifierTilingFeatures =
|
||||||
|
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT;
|
||||||
|
return VK_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
VkDrmFormatModifierPropertiesEXT *mod_props =
|
VkDrmFormatModifierPropertiesEXT *mod_props =
|
||||||
vk_zalloc(alloc,
|
vk_zalloc(alloc,
|
||||||
|
@ -378,7 +393,7 @@ vn_android_image_from_anb(struct vn_device *dev,
|
||||||
if (result != VK_SUCCESS)
|
if (result != VK_SUCCESS)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* TODO support multi-planar format */
|
/* WSI image must be single-planar */
|
||||||
if (mod_props.drmFormatModifierPlaneCount != 1) {
|
if (mod_props.drmFormatModifierPlaneCount != 1) {
|
||||||
if (VN_DEBUG(WSI))
|
if (VN_DEBUG(WSI))
|
||||||
vn_log(dev->instance, "plane count is %d, expected 1",
|
vn_log(dev->instance, "plane count is %d, expected 1",
|
||||||
|
@ -831,6 +846,7 @@ vn_android_device_import_ahb(struct vn_device *dev,
|
||||||
const VkAllocationCallbacks *alloc = &dev->base.base.alloc;
|
const VkAllocationCallbacks *alloc = &dev->base.base.alloc;
|
||||||
struct vn_image *img = vn_image_from_handle(dedicated_info->image);
|
struct vn_image *img = vn_image_from_handle(dedicated_info->image);
|
||||||
VkImageCreateInfo *image_info = &img->deferred_info->create;
|
VkImageCreateInfo *image_info = &img->deferred_info->create;
|
||||||
|
VkSubresourceLayout layouts[4];
|
||||||
uint32_t strides[4] = { 0, 0, 0, 0 };
|
uint32_t strides[4] = { 0, 0, 0, 0 };
|
||||||
uint32_t offsets[4] = { 0, 0, 0, 0 };
|
uint32_t offsets[4] = { 0, 0, 0, 0 };
|
||||||
uint64_t format_modifier = 0;
|
uint64_t format_modifier = 0;
|
||||||
|
@ -846,27 +862,18 @@ vn_android_device_import_ahb(struct vn_device *dev,
|
||||||
if (result != VK_SUCCESS)
|
if (result != VK_SUCCESS)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
/* XXX fix plane count > 1 case for external memory */
|
memset(layouts, 0, sizeof(layouts));
|
||||||
if (mod_props.drmFormatModifierPlaneCount != 1) {
|
for (uint32_t i = 0; i < mod_props.drmFormatModifierPlaneCount; i++) {
|
||||||
vn_log(dev->instance, "plane count is %d, expected 1",
|
layouts[i].offset = offsets[i];
|
||||||
mod_props.drmFormatModifierPlaneCount);
|
layouts[i].rowPitch = strides[i];
|
||||||
return VK_ERROR_INVALID_EXTERNAL_HANDLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const VkSubresourceLayout layout = {
|
|
||||||
.offset = offsets[0],
|
|
||||||
.size = 0,
|
|
||||||
.rowPitch = strides[0],
|
|
||||||
.arrayPitch = 0,
|
|
||||||
.depthPitch = 0,
|
|
||||||
};
|
|
||||||
const VkImageDrmFormatModifierExplicitCreateInfoEXT drm_mod_info = {
|
const VkImageDrmFormatModifierExplicitCreateInfoEXT drm_mod_info = {
|
||||||
.sType =
|
.sType =
|
||||||
VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT,
|
VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT,
|
||||||
.pNext = image_info->pNext,
|
.pNext = image_info->pNext,
|
||||||
.drmFormatModifier = format_modifier,
|
.drmFormatModifier = format_modifier,
|
||||||
.drmFormatModifierPlaneCount = 1,
|
.drmFormatModifierPlaneCount = mod_props.drmFormatModifierPlaneCount,
|
||||||
.pPlaneLayouts = &layout,
|
.pPlaneLayouts = layouts,
|
||||||
};
|
};
|
||||||
const VkExternalMemoryImageCreateInfo external_img_info = {
|
const VkExternalMemoryImageCreateInfo external_img_info = {
|
||||||
.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO,
|
||||||
|
|
|
@ -81,6 +81,12 @@ vn_image_init_memory_requirements(struct vn_image *img,
|
||||||
.image = img_handle,
|
.image = img_handle,
|
||||||
},
|
},
|
||||||
&img->memory_requirements[0]);
|
&img->memory_requirements[0]);
|
||||||
|
|
||||||
|
/* AHB backed image requires dedicated allocation */
|
||||||
|
if (img->deferred_info) {
|
||||||
|
img->dedicated_requirements[0].prefersDedicatedAllocation = VK_TRUE;
|
||||||
|
img->dedicated_requirements[0].requiresDedicatedAllocation = VK_TRUE;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for (uint32_t i = 0; i < plane_count; i++) {
|
for (uint32_t i = 0; i < plane_count; i++) {
|
||||||
vn_call_vkGetImageMemoryRequirements2(
|
vn_call_vkGetImageMemoryRequirements2(
|
||||||
|
|
Loading…
Reference in New Issue