diff mbox series

[FFmpeg-devel] vulkan: return VK_NOT_READY when no queries are available

Message ID Nhd3mld--F-9@lynne.ee
State New
Headers show
Series [FFmpeg-devel] vulkan: return VK_NOT_READY when no queries are available | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Lynne Oct. 25, 2023, 11:02 p.m. UTC
Fixes a validation issue.
The issue is that the function gets called before we've sumitted a frame
for decoding to that context. However, we cannot run queries before
they've been reset, which happens at submission time.
As we'd need to otherwise run a command queue at init-time, just check
if submissions have happened.

Patch attached.
diff mbox series

Patch

From 833a1c249f5e41305fe8ea68f5e2453a5505817d Mon Sep 17 00:00:00 2001
From: Lynne <dev@lynne.ee>
Date: Wed, 25 Oct 2023 22:58:20 +0000
Subject: [PATCH] vulkan: return VK_NOT_READY when no queries are available

Fixes a validation issue.
The issue is that the function gets called before we've sumitted a frame
for decoding to that context. However, we cannot run queries before
they've been reset, which happens at submission time.
As we'd need to otherwise run a command queue at init-time, just check
if submissions have happened.
---
 libavutil/vulkan.c | 5 +++++
 libavutil/vulkan.h | 1 +
 2 files changed, 6 insertions(+)

diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c
index dec8ccad64..5674ec2943 100644
--- a/libavutil/vulkan.c
+++ b/libavutil/vulkan.c
@@ -456,6 +456,9 @@  VkResult ff_vk_exec_get_query(FFVulkanContext *s, FFVkExecContext *e,
     int64_t res = 0;
     VkQueryResultFlags qf = 0;
 
+    if (!e->has_query)
+        return VK_NOT_READY;
+
     qf |= pool->query_64bit ?
           VK_QUERY_RESULT_64_BIT : 0x0;
     qf |= pool->query_statuses ?
@@ -779,6 +782,8 @@  int ff_vk_exec_submit(FFVulkanContext *s, FFVkExecContext *e)
         }
     }
 
+    e->has_query = 1;
+
     return 0;
 }
 
diff --git a/libavutil/vulkan.h b/libavutil/vulkan.h
index 25c5ad4b74..3069dd27c2 100644
--- a/libavutil/vulkan.h
+++ b/libavutil/vulkan.h
@@ -168,6 +168,7 @@  typedef struct FFVkExecContext {
 
     void *query_data;
     int query_idx;
+    int has_query;
 
     /* Buffer dependencies */
     AVBufferRef **buf_deps;
-- 
2.40.1