From patchwork Wed May 13 15:53:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lynne X-Patchwork-Id: 19674 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id DBAAA44B129 for ; Wed, 13 May 2020 18:53:39 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D0C5768A460; Wed, 13 May 2020 18:53:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7D6D76805B9 for ; Wed, 13 May 2020 18:53:33 +0300 (EEST) Received: from w3.tutanota.de (unknown [192.168.1.164]) by w4.tutanota.de (Postfix) with ESMTP id 1F02C1060154 for ; Wed, 13 May 2020 15:53:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1589385213; s=s1; d=lynne.ee; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Cc:Date:Date:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:Sender; bh=DYC3+2Nw5nS7DQbm59XV9x+WnZ1a5AC1/jUbdhUTOAc=; b=KDUFx6nseGSldZu1ZEz+qkMDWrw7xzNrpG4xWMRrAuSVNC1q5ApqOJxC4CN5EIHI YrIbtQ0eq2av6tNGjEsG11a7m1O+j7IZxqGqeYtd13YwZiJfrhtb3+1taod/p+2Pn29 hHpq7XvyBO7BajPrhES3wMMYlqMr0QhohYIdVr+Da8KrnKEYs5paM/5h/uKK0094K9a OX8kbHOuEX5mPkEUkhG7X6embdsKhknK2/2cvdIsCJPZtQulQmWjvVfzUaXvbHiZbOm W7u7Pdi5ptIuYKZsvSjCy8/FP9PbMT/94pI0mm2P69u0N5gnLCm1wgcqRpxqM/9fkM5 FCjB1jeskQ== Date: Wed, 13 May 2020 17:53:33 +0200 (CEST) From: Lynne To: Ffmpeg Devel Message-ID: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] hwcontext_vulkan: expose the enabled device features X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" With this, the puzze of making libplacebo, ffmpeg and any other Vulkan API users interoperable is complete. Users of both libraries can initialize one another's contexts without having to create a new one. Patch attached. Subject: [PATCH 2/2] hwcontext_vulkan: expose the enabled device features With this, the puzze of making libplacebo, ffmpeg and any other Vulkan API users interoperable is complete. Users of both libraries can initialize one another's contexts without having to create a new one. --- libavutil/hwcontext_vulkan.c | 11 +++++++++++ libavutil/hwcontext_vulkan.h | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index 82ceb7013a..d05dd2cf5d 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -807,6 +807,7 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, AVDictionaryEntry *opt_d; VulkanDevicePriv *p = ctx->internal->priv; AVVulkanDeviceContext *hwctx = ctx->hwctx; + VkPhysicalDeviceFeatures dev_features = { 0 }; VkDeviceQueueCreateInfo queue_create_info[3] = { { .sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, }, { .sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, }, @@ -815,6 +816,7 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, VkDeviceCreateInfo dev_info = { .sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, + .pEnabledFeatures = &hwctx->device_features, .pQueueCreateInfos = queue_create_info, .queueCreateInfoCount = 0, }; @@ -839,6 +841,15 @@ static int vulkan_device_create_internal(AVHWDeviceContext *ctx, av_log(ctx, AV_LOG_VERBOSE, " minMemoryMapAlignment: %li\n", p->props.limits.minMemoryMapAlignment); + vkGetPhysicalDeviceFeatures(hwctx->phys_dev, &dev_features); +#define COPY_FEATURE(DST, NAME) (DST).NAME = dev_features.NAME; + COPY_FEATURE(hwctx->device_features, shaderImageGatherExtended) + COPY_FEATURE(hwctx->device_features, shaderStorageImageExtendedFormats) + COPY_FEATURE(hwctx->device_features, fragmentStoresAndAtomics) + COPY_FEATURE(hwctx->device_features, vertexPipelineStoresAndAtomics) + COPY_FEATURE(hwctx->device_features, shaderInt64) +#undef COPY_FEATURE + /* Search queue family */ if ((err = search_queue_families(ctx, &dev_info))) goto end; diff --git a/libavutil/hwcontext_vulkan.h b/libavutil/hwcontext_vulkan.h index 9fbe8b9dcb..b73097d514 100644 --- a/libavutil/hwcontext_vulkan.h +++ b/libavutil/hwcontext_vulkan.h @@ -94,6 +94,13 @@ typedef struct AVVulkanDeviceContext { */ const char * const *enabled_dev_extensions; int nb_enabled_dev_extensions; + /** + * This structure lists all device features that are present and enabled + * during device creation. By default, if present, shaderImageGatherExtended, + * shaderStorageImageExtendedFormats, fragmentStoresAndAtomics, shaderInt64, + * and vertexPipelineStoresAndAtomics are enabled. + */ + VkPhysicalDeviceFeatures device_features; } AVVulkanDeviceContext; /**