mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-03 09:20:13 +01:00
Implement vkQueueSubmit2 in the same way as vkQueueSubmit
This commit rewrites vkQueueSubmit as a template so that the implementation can be used by vkQueueSubmit and vkQueueSubmit2. Reviewed-by: Aaron Ruby <aruby@blackberry.com> Acked-by: Yonggang Luo <luoyonggang@gmail.com> Acked-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27246>
This commit is contained in:
parent
89c74a010b
commit
5856a73b99
2 changed files with 113 additions and 37 deletions
|
|
@ -1228,7 +1228,6 @@ public:
|
|||
const char*,
|
||||
uint32_t* pPropertyCount,
|
||||
VkExtensionProperties* pProperties) {
|
||||
|
||||
std::vector<const char*> allowedExtensionNames = {
|
||||
"VK_KHR_vulkan_memory_model",
|
||||
"VK_KHR_buffer_device_address",
|
||||
|
|
@ -1240,8 +1239,8 @@ public:
|
|||
"VK_KHR_get_memory_requirements2",
|
||||
"VK_KHR_sampler_ycbcr_conversion",
|
||||
"VK_KHR_shader_float16_int8",
|
||||
// Timeline semaphores buggy in newer NVIDIA drivers
|
||||
// (vkWaitSemaphoresKHR causes further vkCommandBuffer dispatches to deadlock)
|
||||
// Timeline semaphores buggy in newer NVIDIA drivers
|
||||
// (vkWaitSemaphoresKHR causes further vkCommandBuffer dispatches to deadlock)
|
||||
#ifndef VK_USE_PLATFORM_ANDROID_KHR
|
||||
"VK_KHR_timeline_semaphore",
|
||||
#endif
|
||||
|
|
@ -1276,8 +1275,8 @@ public:
|
|||
"VK_EXT_device_memory_report",
|
||||
#endif
|
||||
#if !defined(VK_USE_PLATFORM_ANDROID_KHR) && defined(__linux__)
|
||||
"VK_KHR_create_renderpass2",
|
||||
"VK_KHR_imageless_framebuffer",
|
||||
"VK_KHR_create_renderpass2",
|
||||
"VK_KHR_imageless_framebuffer",
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
@ -5902,11 +5901,61 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void flushStagingStreams(void* context, VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits) {
|
||||
uint32_t getWaitSemaphoreCount(const VkSubmitInfo& pSubmit) {
|
||||
return pSubmit.waitSemaphoreCount;
|
||||
}
|
||||
|
||||
uint32_t getWaitSemaphoreCount(const VkSubmitInfo2& pSubmit) {
|
||||
return pSubmit.waitSemaphoreInfoCount;
|
||||
}
|
||||
|
||||
uint32_t getCommandBufferCount(const VkSubmitInfo& pSubmit) {
|
||||
return pSubmit.commandBufferCount;
|
||||
}
|
||||
|
||||
uint32_t getCommandBufferCount(const VkSubmitInfo2& pSubmit) {
|
||||
return pSubmit.commandBufferInfoCount;
|
||||
}
|
||||
|
||||
uint32_t getSignalSemaphoreCount(const VkSubmitInfo& pSubmit) {
|
||||
return pSubmit.signalSemaphoreCount;
|
||||
}
|
||||
|
||||
uint32_t getSignalSemaphoreCount(const VkSubmitInfo2& pSubmit) {
|
||||
return pSubmit.signalSemaphoreInfoCount;
|
||||
}
|
||||
|
||||
VkSemaphore getWaitSemaphore(const VkSubmitInfo& pSubmit, int i) {
|
||||
return pSubmit.pWaitSemaphores[i];
|
||||
}
|
||||
|
||||
VkSemaphore getWaitSemaphore(const VkSubmitInfo2& pSubmit, int i) {
|
||||
return pSubmit.pWaitSemaphoreInfos[i].semaphore;
|
||||
}
|
||||
|
||||
VkSemaphore getSignalSemaphore(const VkSubmitInfo& pSubmit, int i) {
|
||||
return pSubmit.pSignalSemaphores[i];
|
||||
}
|
||||
|
||||
VkSemaphore getSignalSemaphore(const VkSubmitInfo2& pSubmit, int i) {
|
||||
return pSubmit.pSignalSemaphoreInfos[i].semaphore;
|
||||
}
|
||||
|
||||
VkCommandBuffer getCommandBuffer(const VkSubmitInfo& pSubmit, int i) {
|
||||
return pSubmit.pCommandBuffers[i];
|
||||
}
|
||||
|
||||
VkCommandBuffer getCommandBuffer(const VkSubmitInfo2& pSubmit, int i) {
|
||||
return pSubmit.pCommandBufferInfos[i].commandBuffer;
|
||||
}
|
||||
|
||||
template <class VkSubmitInfoType>
|
||||
void flushStagingStreams(void* context, VkQueue queue, uint32_t submitCount,
|
||||
const VkSubmitInfoType* pSubmits) {
|
||||
std::vector<VkCommandBuffer> toFlush;
|
||||
for (uint32_t i = 0; i < submitCount; ++i) {
|
||||
for (uint32_t j = 0; j < pSubmits[i].commandBufferCount; ++j) {
|
||||
toFlush.push_back(pSubmits[i].pCommandBuffers[j]);
|
||||
for (uint32_t j = 0; j < getCommandBufferCount(pSubmits[i]); ++j) {
|
||||
toFlush.push_back(getCommandBuffer(pSubmits[i], j));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -5925,7 +5974,41 @@ public:
|
|||
void* context, VkResult input_result,
|
||||
VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence) {
|
||||
AEMU_SCOPED_TRACE("on_vkQueueSubmit");
|
||||
return on_vkQueueSubmitTemplate<VkSubmitInfo>(context, input_result, queue, submitCount,
|
||||
pSubmits, fence);
|
||||
}
|
||||
|
||||
VkResult on_vkQueueSubmit2(void* context, VkResult input_result, VkQueue queue,
|
||||
uint32_t submitCount, const VkSubmitInfo2* pSubmits, VkFence fence) {
|
||||
AEMU_SCOPED_TRACE("on_vkQueueSubmit2");
|
||||
return on_vkQueueSubmitTemplate<VkSubmitInfo2>(context, input_result, queue, submitCount,
|
||||
pSubmits, fence);
|
||||
}
|
||||
|
||||
VkResult vkQueueSubmitEnc(VkEncoder* enc, VkQueue queue, uint32_t submitCount,
|
||||
const VkSubmitInfo* pSubmits, VkFence fence) {
|
||||
if (supportsAsyncQueueSubmit()) {
|
||||
enc->vkQueueSubmitAsyncGOOGLE(queue, submitCount, pSubmits, fence, true /* do lock */);
|
||||
return VK_SUCCESS;
|
||||
} else {
|
||||
return enc->vkQueueSubmit(queue, submitCount, pSubmits, fence, true /* do lock */);
|
||||
}
|
||||
}
|
||||
|
||||
VkResult vkQueueSubmitEnc(VkEncoder* enc, VkQueue queue, uint32_t submitCount,
|
||||
const VkSubmitInfo2* pSubmits, VkFence fence) {
|
||||
if (supportsAsyncQueueSubmit()) {
|
||||
enc->vkQueueSubmitAsync2GOOGLE(queue, submitCount, pSubmits, fence, true /* do lock */);
|
||||
return VK_SUCCESS;
|
||||
} else {
|
||||
return enc->vkQueueSubmit2(queue, submitCount, pSubmits, fence, true /* do lock */);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename VkSubmitInfoType>
|
||||
VkResult on_vkQueueSubmitTemplate(void* context, VkResult input_result, VkQueue queue,
|
||||
uint32_t submitCount, const VkSubmitInfoType* pSubmits,
|
||||
VkFence fence) {
|
||||
flushStagingStreams(context, queue, submitCount, pSubmits);
|
||||
|
||||
std::vector<VkSemaphore> pre_signal_semaphores;
|
||||
|
|
@ -5939,26 +6022,27 @@ public:
|
|||
AutoLock<RecursiveLock> lock(mLock);
|
||||
|
||||
for (uint32_t i = 0; i < submitCount; ++i) {
|
||||
for (uint32_t j = 0; j < pSubmits[i].waitSemaphoreCount; ++j) {
|
||||
auto it = info_VkSemaphore.find(pSubmits[i].pWaitSemaphores[j]);
|
||||
for (uint32_t j = 0; j < getWaitSemaphoreCount(pSubmits[i]); ++j) {
|
||||
VkSemaphore semaphore = getWaitSemaphore(pSubmits[i], j);
|
||||
auto it = info_VkSemaphore.find(semaphore);
|
||||
if (it != info_VkSemaphore.end()) {
|
||||
auto& semInfo = it->second;
|
||||
#ifdef VK_USE_PLATFORM_FUCHSIA
|
||||
if (semInfo.eventHandle) {
|
||||
pre_signal_events.push_back(semInfo.eventHandle);
|
||||
pre_signal_semaphores.push_back(pSubmits[i].pWaitSemaphores[j]);
|
||||
pre_signal_semaphores.push_back(semaphore);
|
||||
}
|
||||
#endif
|
||||
#if defined(VK_USE_PLATFORM_ANDROID_KHR) || defined(__linux__)
|
||||
if (semInfo.syncFd.has_value()) {
|
||||
pre_signal_sync_fds.push_back(semInfo.syncFd.value());
|
||||
pre_signal_semaphores.push_back(pSubmits[i].pWaitSemaphores[j]);
|
||||
pre_signal_semaphores.push_back(semaphore);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
for (uint32_t j = 0; j < pSubmits[i].signalSemaphoreCount; ++j) {
|
||||
auto it = info_VkSemaphore.find(pSubmits[i].pSignalSemaphores[j]);
|
||||
for (uint32_t j = 0; j < getSignalSemaphoreCount(pSubmits[i]); ++j) {
|
||||
auto it = info_VkSemaphore.find(getSignalSemaphore(pSubmits[i], j));
|
||||
if (it != info_VkSemaphore.end()) {
|
||||
auto& semInfo = it->second;
|
||||
#ifdef VK_USE_PLATFORM_FUCHSIA
|
||||
|
|
@ -5989,13 +6073,8 @@ public:
|
|||
lock.unlock();
|
||||
|
||||
if (pre_signal_semaphores.empty()) {
|
||||
if (supportsAsyncQueueSubmit()) {
|
||||
enc->vkQueueSubmitAsyncGOOGLE(queue, submitCount, pSubmits, fence, true /* do lock */);
|
||||
input_result = VK_SUCCESS;
|
||||
} else {
|
||||
input_result = enc->vkQueueSubmit(queue, submitCount, pSubmits, fence, true /* do lock */);
|
||||
if (input_result != VK_SUCCESS) return input_result;
|
||||
}
|
||||
input_result = vkQueueSubmitEnc(enc, queue, submitCount, pSubmits, fence);
|
||||
if (input_result != VK_SUCCESS) return input_result;
|
||||
} else {
|
||||
// Schedule waits on the OS external objects and
|
||||
// signal the wait semaphores
|
||||
|
|
@ -6030,6 +6109,7 @@ public:
|
|||
mWorkPool.waitAll(waitGroupHandle);
|
||||
}
|
||||
|
||||
// Use the old version of VkSubmitInfo
|
||||
VkSubmitInfo submit_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
|
||||
.waitSemaphoreCount = 0,
|
||||
|
|
@ -6038,22 +6118,10 @@ public:
|
|||
.signalSemaphoreCount =
|
||||
static_cast<uint32_t>(pre_signal_semaphores.size()),
|
||||
.pSignalSemaphores = pre_signal_semaphores.data()};
|
||||
|
||||
if (supportsAsyncQueueSubmit()) {
|
||||
enc->vkQueueSubmitAsyncGOOGLE(queue, 1, &submit_info, VK_NULL_HANDLE, true /* do lock */);
|
||||
} else {
|
||||
enc->vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE, true /* do lock */);
|
||||
}
|
||||
|
||||
if (supportsAsyncQueueSubmit()) {
|
||||
enc->vkQueueSubmitAsyncGOOGLE(queue, submitCount, pSubmits, fence, true /* do lock */);
|
||||
input_result = VK_SUCCESS;
|
||||
} else {
|
||||
input_result = enc->vkQueueSubmit(queue, submitCount, pSubmits, fence, true /* do lock */);
|
||||
if (input_result != VK_SUCCESS) return input_result;
|
||||
}
|
||||
vkQueueSubmitEnc(enc, queue, 1, &submit_info, VK_NULL_HANDLE);
|
||||
input_result = vkQueueSubmitEnc(enc, queue, submitCount, pSubmits, fence);
|
||||
if (input_result != VK_SUCCESS) return input_result;
|
||||
}
|
||||
|
||||
lock.lock();
|
||||
int externalFenceFdToSignal = -1;
|
||||
|
||||
|
|
@ -6108,7 +6176,6 @@ public:
|
|||
auto& queueWorkItems = mQueueSensitiveWorkPoolItems[queue];
|
||||
queueWorkItems.push_back(queueAsyncWaitHandle);
|
||||
}
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
@ -7994,6 +8061,12 @@ VkResult ResourceTracker::on_vkQueueSubmit(
|
|||
context, input_result, queue, submitCount, pSubmits, fence);
|
||||
}
|
||||
|
||||
VkResult ResourceTracker::on_vkQueueSubmit2(void* context, VkResult input_result, VkQueue queue,
|
||||
uint32_t submitCount, const VkSubmitInfo2* pSubmits,
|
||||
VkFence fence) {
|
||||
return mImpl->on_vkQueueSubmit2(context, input_result, queue, submitCount, pSubmits, fence);
|
||||
}
|
||||
|
||||
VkResult ResourceTracker::on_vkQueueWaitIdle(
|
||||
void* context, VkResult input_result,
|
||||
VkQueue queue) {
|
||||
|
|
|
|||
|
|
@ -252,6 +252,9 @@ public:
|
|||
void* context, VkResult input_result,
|
||||
VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence);
|
||||
|
||||
VkResult on_vkQueueSubmit2(void* context, VkResult input_result, VkQueue queue,
|
||||
uint32_t submitCount, const VkSubmitInfo2* pSubmits, VkFence fence);
|
||||
|
||||
VkResult on_vkQueueWaitIdle(
|
||||
void* context, VkResult input_result,
|
||||
VkQueue queue);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue