diff mbox series

[FFmpeg-devel] lavu/vulkan: fix handle type for 32-bit targets

Message ID 20230302162730.1281-1-kasper93@gmail.com
State Accepted
Commit cc76e8340d28438c1ac56ee7dfd774d25e944264
Headers show
Series [FFmpeg-devel] lavu/vulkan: fix handle type for 32-bit targets | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Kacper Michajłow March 2, 2023, 4:27 p.m. UTC
Fixes compilation with clang which errors out on Wint-conversion.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
---
 libavutil/hwcontext_vulkan.c | 2 +-
 libavutil/vulkan.h           | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

Comments

Martin Storsjö March 6, 2023, 9 a.m. UTC | #1
On Thu, 2 Mar 2023, Kacper Michajłow wrote:

> Fixes compilation with clang which errors out on Wint-conversion.
>
> Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
> ---
> libavutil/hwcontext_vulkan.c | 2 +-
> libavutil/vulkan.h           | 4 ++++
> 2 files changed, 5 insertions(+), 1 deletion(-)

Minor context; it's only recent Clang that treats this issue as an error 
by default - iirc it changed sometime last year, so possibly since Clang 
15 or so.

>
> diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
> index 2a9b5f4aac..b3eccea7af 100644
> --- a/libavutil/hwcontext_vulkan.c
> +++ b/libavutil/hwcontext_vulkan.c
> @@ -1149,7 +1149,7 @@ static void free_exec_ctx(AVHWFramesContext *hwfc, VulkanExecCtx *cmd)
>
>     av_freep(&cmd->queues);
>     av_freep(&cmd->bufs);
> -    cmd->pool = NULL;
> +    cmd->pool = VK_NULL_HANDLE;
> }

This LGTM - I had run into the same issue and tried to fix this issue 
differently, but this looks better to me.

> static VkCommandBuffer get_buf_exec_ctx(AVHWFramesContext *hwfc, VulkanExecCtx *cmd)
> diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h
> index d1ea1e24fb..90922c6cf3 100644
> --- a/libavutil/vulkan.h
> +++ b/libavutil/vulkan.h
> @@ -122,7 +122,11 @@ typedef struct FFVulkanPipeline {
>     VkDescriptorSetLayout         *desc_layout;
>     VkDescriptorPool               desc_pool;
>     VkDescriptorSet               *desc_set;
> +#if VK_USE_64_BIT_PTR_DEFINES == 1
>     void                         **desc_staging;
> +#else
> +    uint64_t                      *desc_staging;
> +#endif
>     VkDescriptorSetLayoutBinding **desc_binding;
>     VkDescriptorUpdateTemplate    *desc_template;
>     int                           *desc_set_initialized;
> -- 
> 2.34.1

What issue does this fix? I don't run into any errors relating to this, 
when building with Clang for Windows on i386 or armv7. I think the fix is 
correct though, the vulkan data types are a bit hard to get a grip of.

// Martin
Kacper Michajłow March 7, 2023, 2:39 p.m. UTC | #2
On Mon, 6 Mar 2023 at 10:00, Martin Storsjö <martin@martin.st> wrote:
>
> On Thu, 2 Mar 2023, Kacper Michajłow wrote:
>
> > Fixes compilation with clang which errors out on Wint-conversion.
> >
> > Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
> > ---
> > libavutil/hwcontext_vulkan.c | 2 +-
> > libavutil/vulkan.h           | 4 ++++
> > 2 files changed, 5 insertions(+), 1 deletion(-)
>
> Minor context; it's only recent Clang that treats this issue as an error
> by default - iirc it changed sometime last year, so possibly since Clang
> 15 or so.
>
> >
> > diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
> > index 2a9b5f4aac..b3eccea7af 100644
> > --- a/libavutil/hwcontext_vulkan.c
> > +++ b/libavutil/hwcontext_vulkan.c
> > @@ -1149,7 +1149,7 @@ static void free_exec_ctx(AVHWFramesContext *hwfc, VulkanExecCtx *cmd)
> >
> >     av_freep(&cmd->queues);
> >     av_freep(&cmd->bufs);
> > -    cmd->pool = NULL;
> > +    cmd->pool = VK_NULL_HANDLE;
> > }
>
> This LGTM - I had run into the same issue and tried to fix this issue
> differently, but this looks better to me.
>
> > static VkCommandBuffer get_buf_exec_ctx(AVHWFramesContext *hwfc, VulkanExecCtx *cmd)
> > diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h
> > index d1ea1e24fb..90922c6cf3 100644
> > --- a/libavutil/vulkan.h
> > +++ b/libavutil/vulkan.h
> > @@ -122,7 +122,11 @@ typedef struct FFVulkanPipeline {
> >     VkDescriptorSetLayout         *desc_layout;
> >     VkDescriptorPool               desc_pool;
> >     VkDescriptorSet               *desc_set;
> > +#if VK_USE_64_BIT_PTR_DEFINES == 1
> >     void                         **desc_staging;
> > +#else
> > +    uint64_t                      *desc_staging;
> > +#endif
> >     VkDescriptorSetLayoutBinding **desc_binding;
> >     VkDescriptorUpdateTemplate    *desc_template;
> >     int                           *desc_set_initialized;
> > --
> > 2.34.1
>
> What issue does this fix? I don't run into any errors relating to this,
> when building with Clang for Windows on i386 or armv7. I think the fix is
> correct though, the vulkan data types are a bit hard to get a grip of.

Indeed, by default `libavfilter/vulkan.c` is not built, even is vulkan
is enabled.
You can trigger it, with `--enable-libplacebo` for example.

It fixes those:

In file included from F:/dev/ffmpeg/libavfilter/vulk
an.c:19:
F:/dev/ffmpeg/libavutil/vulkan.c:1173:70: error: incompatible integer
to pointer conversion assigning to 'void *' from
'VkDescriptorSetLayout' (aka 'unsigned long long') [-Wint-conversion]
pl->desc_staging[spawn_pipeline_layout.setLayoutCount++] = pl->desc_layout[i];

F:/dev/ffmpeg/libavutil/vulkan.c:1272:29: error: incompatible integer
to pointer conversion assigning to 'void *' from 'VkDescriptorSet'
(aka 'unsigned long long') [-Wint-conversion]
pl->desc_staging[i] = pl->desc_set[i*pl->qf->nb_queues + pl->qf->cur_queue];

(sorry for double message)

-Kacper
Martin Storsjö March 7, 2023, 8:53 p.m. UTC | #3
On Tue, 7 Mar 2023, Kacper Michajlow wrote:

> On Mon, 6 Mar 2023 at 10:00, Martin Storsjö <martin@martin.st> wrote:
>>
>> On Thu, 2 Mar 2023, Kacper Michajłow wrote:
>>
>>> Fixes compilation with clang which errors out on Wint-conversion.
>>>
>>> Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
>>> ---
>>> libavutil/hwcontext_vulkan.c | 2 +-
>>> libavutil/vulkan.h           | 4 ++++
>>> 2 files changed, 5 insertions(+), 1 deletion(-)
>>
>> Minor context; it's only recent Clang that treats this issue as an error
>> by default - iirc it changed sometime last year, so possibly since Clang
>> 15 or so.
>>
>>>
>>> diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
>>> index 2a9b5f4aac..b3eccea7af 100644
>>> --- a/libavutil/hwcontext_vulkan.c
>>> +++ b/libavutil/hwcontext_vulkan.c
>>> @@ -1149,7 +1149,7 @@ static void free_exec_ctx(AVHWFramesContext *hwfc, VulkanExecCtx *cmd)
>>>
>>>     av_freep(&cmd->queues);
>>>     av_freep(&cmd->bufs);
>>> -    cmd->pool = NULL;
>>> +    cmd->pool = VK_NULL_HANDLE;
>>> }
>>
>> This LGTM - I had run into the same issue and tried to fix this issue
>> differently, but this looks better to me.
>>
>>> static VkCommandBuffer get_buf_exec_ctx(AVHWFramesContext *hwfc, VulkanExecCtx *cmd)
>>> diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h
>>> index d1ea1e24fb..90922c6cf3 100644
>>> --- a/libavutil/vulkan.h
>>> +++ b/libavutil/vulkan.h
>>> @@ -122,7 +122,11 @@ typedef struct FFVulkanPipeline {
>>>     VkDescriptorSetLayout         *desc_layout;
>>>     VkDescriptorPool               desc_pool;
>>>     VkDescriptorSet               *desc_set;
>>> +#if VK_USE_64_BIT_PTR_DEFINES == 1
>>>     void                         **desc_staging;
>>> +#else
>>> +    uint64_t                      *desc_staging;
>>> +#endif
>>>     VkDescriptorSetLayoutBinding **desc_binding;
>>>     VkDescriptorUpdateTemplate    *desc_template;
>>>     int                           *desc_set_initialized;
>>> --
>>> 2.34.1
>>
>> What issue does this fix? I don't run into any errors relating to this,
>> when building with Clang for Windows on i386 or armv7. I think the fix is
>> correct though, the vulkan data types are a bit hard to get a grip of.
>
> Indeed, by default `libavfilter/vulkan.c` is not built, even is vulkan
> is enabled.
> You can trigger it, with `--enable-libplacebo` for example.
>
> It fixes those:
>
> In file included from F:/dev/ffmpeg/libavfilter/vulk
> an.c:19:
> F:/dev/ffmpeg/libavutil/vulkan.c:1173:70: error: incompatible integer
> to pointer conversion assigning to 'void *' from
> 'VkDescriptorSetLayout' (aka 'unsigned long long') [-Wint-conversion]
> pl->desc_staging[spawn_pipeline_layout.setLayoutCount++] = pl->desc_layout[i];
>
> F:/dev/ffmpeg/libavutil/vulkan.c:1272:29: error: incompatible integer
> to pointer conversion assigning to 'void *' from 'VkDescriptorSet'
> (aka 'unsigned long long') [-Wint-conversion]
> pl->desc_staging[i] = pl->desc_set[i*pl->qf->nb_queues + pl->qf->cur_queue];

Ah, I see, thanks.

Then this patch looks good to me - I'll go ahead and push it together with 
one half from my patch (which was OK'd by Lynne).

// Martin
diff mbox series

Patch

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index 2a9b5f4aac..b3eccea7af 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -1149,7 +1149,7 @@  static void free_exec_ctx(AVHWFramesContext *hwfc, VulkanExecCtx *cmd)
 
     av_freep(&cmd->queues);
     av_freep(&cmd->bufs);
-    cmd->pool = NULL;
+    cmd->pool = VK_NULL_HANDLE;
 }
 
 static VkCommandBuffer get_buf_exec_ctx(AVHWFramesContext *hwfc, VulkanExecCtx *cmd)
diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h
index d1ea1e24fb..90922c6cf3 100644
--- a/libavutil/vulkan.h
+++ b/libavutil/vulkan.h
@@ -122,7 +122,11 @@  typedef struct FFVulkanPipeline {
     VkDescriptorSetLayout         *desc_layout;
     VkDescriptorPool               desc_pool;
     VkDescriptorSet               *desc_set;
+#if VK_USE_64_BIT_PTR_DEFINES == 1
     void                         **desc_staging;
+#else
+    uint64_t                      *desc_staging;
+#endif
     VkDescriptorSetLayoutBinding **desc_binding;
     VkDescriptorUpdateTemplate    *desc_template;
     int                           *desc_set_initialized;