Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Lynne <dev@lynne.ee>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] lavu/vulkan: remove threadsafe buffer index load and fix a signed overflow
Date: Wed, 19 Jul 2023 06:19:56 +0200 (CEST)
Message-ID: <N_gN3Pp--3-9@lynne.ee> (raw)
In-Reply-To: <N_gMYP2--3-9@lynne.ee-N_gMbDd----9>

[-- Attachment #1: Type: text/plain, Size: 134 bytes --]

It's not needed anymore, as no pools are used between threads.

This also fixes a small potential integer overflow.

Patch attached.


[-- Attachment #2: 0002-lavu-vulkan-remove-threadsafe-buffer-index-load-and-.patch --]
[-- Type: text/x-diff, Size: 1570 bytes --]

From 797c62be618fe8e6223b7b01184bce7c6f231a96 Mon Sep 17 00:00:00 2001
From: Lynne <dev@lynne.ee>
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


[-- Attachment #3: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

  parent reply	other threads:[~2023-07-19  4:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-19  4:17 [FFmpeg-devel] [PATCH 1/3] lavc/vulkan_decode: use a single execution pool per thread Lynne
     [not found] ` <N_gMYP2--3-9@lynne.ee-N_gMbDd----9>
2023-07-19  4:19   ` Lynne [this message]
     [not found]   ` <N_gN3Pp--3-9@lynne.ee-N_gN6Vi----9>
2023-07-19  4:20     ` [FFmpeg-devel] [PATCH 3/3] lavu/vulkan: remove unused field from the execution pool structure Lynne
2023-07-21 18:08   ` [FFmpeg-devel] [PATCH 1/3] lavc/vulkan_decode: use a single execution pool per thread Lynne

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=N_gN3Pp--3-9@lynne.ee \
    --to=dev@lynne.ee \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git