From: Lynne <dev@lynne.ee>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH 31/92] Vulkan patchset part 1 - common code changes
Date: Wed, 19 Apr 2023 16:39:28 +0200 (CEST)
Message-ID: <NTOxBQy--3-9@lynne.ee> (raw)
In-Reply-To: <168172351803.3843.891431528072089458@lain.khirnov.net>
Apr 17, 2023, 11:25 by anton@khirnov.net:
> Quoting Lynne (2023-03-14 07:33:43)
>
>> From 6e2dfc44e50798264eb16bc2dcabfdbf2fbac2d7 Mon Sep 17 00:00:00 2001
>> From: Lynne <dev@lynne.ee>
>> Date: Thu, 15 Dec 2022 01:06:52 +0100
>> Subject: [PATCH 24/92] hwconfig: add a new HWACCEL_CAP_THREAD_SAFE for
>> threadsafe hwaccels
>>
>> Vulkan is fully threadsafe and stateless, so we can benefit from this.
>> ---
>> libavcodec/hwconfig.h | 1 +
>> libavcodec/pthread_frame.c | 2 +-
>> 2 files changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/hwconfig.h b/libavcodec/hwconfig.h
>> index 721424912c..e6b78f0160 100644
>> --- a/libavcodec/hwconfig.h
>> +++ b/libavcodec/hwconfig.h
>> @@ -24,6 +24,7 @@
>>
>>
>> #define HWACCEL_CAP_ASYNC_SAFE (1 << 0)
>> +#define HWACCEL_CAP_THREAD_SAFE (1 << 1)
>>
>>
>> typedef struct AVCodecHWConfigInternal {
>> diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
>> index 74864e19c5..c096287233 100644
>> --- a/libavcodec/pthread_frame.c
>> +++ b/libavcodec/pthread_frame.c
>> @@ -204,7 +204,7 @@ static attribute_align_arg void *frame_worker_thread(void *arg)
>>
>> /* if the previous thread uses hwaccel then we take the lock to ensure
>> * the threads don't run concurrently */
>> - if (avctx->hwaccel) {
>> + if (avctx->hwaccel && !(avctx->hwaccel->caps_internal & HWACCEL_CAP_THREAD_SAFE)) {
>>
>
> A major problem here is that hwaccel_priv_data exists in only a single
> instance shared across all the worker threads. If you want frame-threaded
> hwaccels, you'll need to add some mechanism for synchronizing it between
> threads.
>
> I really wonder how does your code survive all the races involved.
>
It works because hwaccel_priv_data is read-only. No need to synchronize
anything, the contexts Vulkan creates are defined as driver-synchronized,
and all the info a frame needs is provided when decoding it, rather than
kept as a state.
So I don't see a problem here.
_______________________________________________
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".
next prev parent reply other threads:[~2023-04-19 14:39 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-14 6:33 Lynne
2023-03-14 11:51 ` James Almer
2023-03-15 19:41 ` Lynne
2023-04-16 19:21 ` Anton Khirnov
2023-04-16 19:26 ` Anton Khirnov
2023-04-16 20:38 ` Anton Khirnov
2023-04-17 9:07 ` Anton Khirnov
2023-04-19 14:47 ` Lynne
2023-04-22 12:38 ` Anton Khirnov
2023-04-24 8:27 ` Lynne
2023-04-17 9:25 ` Anton Khirnov
2023-04-19 14:39 ` Lynne [this message]
2023-04-22 12:41 ` Anton Khirnov
2023-04-24 8:26 ` Lynne
2023-04-17 9:46 ` Anton Khirnov
2023-04-19 14:49 ` 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=NTOxBQy--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