From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 192BE456AF for ; Wed, 19 Jul 2023 04:20:05 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 43F7868C5A4; Wed, 19 Jul 2023 07:20:03 +0300 (EEST) Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A782A68C318 for ; Wed, 19 Jul 2023 07:19:56 +0300 (EEST) Received: from tutadb.w10.tutanota.de (unknown [192.168.1.10]) by w4.tutanota.de (Postfix) with ESMTP id 0CAB81060140 for ; Wed, 19 Jul 2023 04:19:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1689740396; 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:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender; bh=siCQWSKR69usiMG/DuDtj2k9wPiai4bi5DrJX+IpsSg=; b=mBrpbtDsrnJRYdtSsjngb3LOsVMvU3iPTyrjFzh5Cf6ayFFpp4rdaKDhXEFpXXWq U+Yg9OKcUDbTRHhEV/C3funzlfW9YTgZIXKLdXCTnLb9g+dU60Q3JhD2+YaNdV1tet2 xqaQu4/e1GTbFOoF8uOdrZ+rLLR9AdqbOkKLunKsvTrtfaG4cTvfHc8+M5vg5yfRgd1 F+5odoAYRaC+KLw1pn0hzFqA5SnF1CngeQ48ptOaTcK8Maqp30mChiTsZuAiBpb5iia zwKf6imbmdAQVvwiMsvKC3ePgAwZGmdaheyv84X/A+aMekY/d3ciLiYCMw4vrQDha// tb/w93IyTA== Date: Wed, 19 Jul 2023 06:19:56 +0200 (CEST) From: Lynne To: FFmpeg development discussions and patches Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_142696_987248917.1689740396363" Subject: [FFmpeg-devel] lavu/vulkan: remove threadsafe buffer index load and fix a signed overflow X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" Archived-At: List-Archive: List-Post: ------=_Part_142696_987248917.1689740396363 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit It's not needed anymore, as no pools are used between threads. This also fixes a small potential integer overflow. Patch attached. ------=_Part_142696_987248917.1689740396363 Content-Type: text/x-diff; charset=us-ascii; name=0002-lavu-vulkan-remove-threadsafe-buffer-index-load-and-.patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0002-lavu-vulkan-remove-threadsafe-buffer-index-load-and-.patch >From 797c62be618fe8e6223b7b01184bce7c6f231a96 Mon Sep 17 00:00:00 2001 From: Lynne Date: Wed, 19 Jul 2023 04:54:37 +0200 Subject: [PATCH 2/3] lavu/vulkan: remove threadsafe buffer index load and fix a signed overflow It's not needed anymore. --- libavutil/vulkan.c | 4 +--- libavutil/vulkan.h | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c index 26b9b6f1fb..48f5f4b5dc 100644 --- a/libavutil/vulkan.c +++ b/libavutil/vulkan.c @@ -282,8 +282,6 @@ int ff_vk_exec_pool_init(FFVulkanContext *s, FFVkQueueFamilyCtx *qf, VkCommandPoolCreateInfo cqueue_create; VkCommandBufferAllocateInfo cbuf_create; - atomic_init(&pool->idx, 0); - /* Create command pool */ cqueue_create = (VkCommandPoolCreateInfo) { .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, @@ -472,7 +470,7 @@ VkResult ff_vk_exec_get_query(FFVulkanContext *s, FFVkExecContext *e, FFVkExecContext *ff_vk_exec_get(FFVkExecPool *pool) { - int idx = atomic_fetch_add_explicit(&pool->idx, 1, memory_order_relaxed); + uint32_t idx = pool->idx++; idx %= pool->pool_size; return &pool->contexts[idx]; } diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h index bbbc9374ae..7171fb3c42 100644 --- a/libavutil/vulkan.h +++ b/libavutil/vulkan.h @@ -151,7 +151,7 @@ typedef struct FFVulkanPipeline { } FFVulkanPipeline; typedef struct FFVkExecContext { - int idx; + uint32_t idx; const struct FFVkExecPool *parent; pthread_mutex_t lock; -- 2.40.1 ------=_Part_142696_987248917.1689740396363 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ------=_Part_142696_987248917.1689740396363--