venus: make tls hint specific to pipeline creation

This is to prepare for a new multi-ring design. A preview is as below:
- primary ring will migrate to be asynchronous only
- synchronous commands will be via thread local rings
- pipeline creations will be synchronous and dispatched to thread local
  rings unless being forced to be async on primary ring
- perf option no_multi_ring is made generic to force a single ring

Pipeline cache retrieval is temporarily moved back to primary ring, but
will be moved to thread local later since it's a synchronous command.
The dependency resolving will follow the same with pipeline create with
detailed rationale later.

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26838>
This commit is contained in:
Yiwei Zhang 2023-12-28 17:22:42 -08:00 committed by Marge Bot
parent 813b1939f6
commit 30316246d0
7 changed files with 13 additions and 24 deletions

View file

@ -342,7 +342,7 @@ vn_GetSwapchainGrallocUsage2ANDROID(
if (swapchainImageUsage & VK_SWAPCHAIN_IMAGE_USAGE_SHARED_BIT_ANDROID)
*grallocProducerUsage |= vn_android_gralloc_get_shared_present_usage();
vn_tls_set_primary_ring_submission();
vn_tls_set_async_pipeline_create();
return VK_SUCCESS;
}

View file

@ -687,7 +687,7 @@ vn_CreateCommandPool(VkDevice device,
vn_async_vkCreateCommandPool(dev->primary_ring, device, pCreateInfo, NULL,
&pool_handle);
vn_tls_set_primary_ring_submission();
vn_tls_set_async_pipeline_create();
*pCommandPool = pool_handle;

View file

@ -211,13 +211,10 @@ struct vn_relax_state {
};
struct vn_tls {
/* Track swapchain and command pool creations on threads so dispatch of the
* following on non-tracked threads can be routed as synchronous on the
* secondary ring:
* - pipeline creations
* - pipeline cache retrievals
/* Track the threads on which swapchain and command pool creations occur.
* Pipeline create on those threads are forced async via the primary ring.
*/
bool primary_ring_submission;
bool async_pipeline_create;
};
void
@ -488,19 +485,19 @@ struct vn_tls *
vn_tls_get(void);
static inline void
vn_tls_set_primary_ring_submission(void)
vn_tls_set_async_pipeline_create(void)
{
struct vn_tls *tls = vn_tls_get();
if (likely(tls))
tls->primary_ring_submission = true;
tls->async_pipeline_create = true;
}
static inline bool
vn_tls_get_primary_ring_submission(void)
vn_tls_get_async_pipeline_create(void)
{
const struct vn_tls *tls = vn_tls_get();
if (likely(tls))
return tls->primary_ring_submission;
return tls->async_pipeline_create;
return true;
}

View file

@ -441,8 +441,6 @@ vn_device_secondary_ring_init_once(struct vn_device *dev)
{
VN_TRACE_FUNC();
assert(!dev->force_primary_ring_submission);
static bool ok = true;
if (!ok)
return ok;
@ -489,9 +487,6 @@ vn_device_init(struct vn_device *dev,
dev->renderer = instance->renderer;
dev->primary_ring = instance->ring.ring;
/* can be extended for app compat purpose */
dev->force_primary_ring_submission = VN_PERF(NO_MULTI_RING);
create_info =
vn_device_fix_create_info(dev, create_info, alloc, &local_create_info);
if (!create_info)

View file

@ -30,7 +30,6 @@ struct vn_device {
struct vn_physical_device *physical_device;
struct vn_renderer *renderer;
struct vn_ring *primary_ring;
bool force_primary_ring_submission;
mtx_t ring_mutex;
struct vn_ring *secondary_ring;

View file

@ -449,10 +449,10 @@ vn_DestroyPipelineCache(VkDevice device,
static struct vn_ring *
vn_get_target_ring(struct vn_device *dev)
{
if (dev->force_primary_ring_submission)
if (VN_PERF(NO_MULTI_RING))
return dev->primary_ring;
if (vn_tls_get_primary_ring_submission())
if (vn_tls_get_async_pipeline_create())
return dev->primary_ring;
if (!dev->secondary_ring) {
@ -483,9 +483,7 @@ vn_GetPipelineCacheData(VkDevice device,
VN_TRACE_FUNC();
struct vn_device *dev = vn_device_from_handle(device);
struct vn_physical_device *physical_dev = dev->physical_device;
struct vn_ring *target_ring = vn_get_target_ring(dev);
assert(target_ring);
struct vn_ring *target_ring = dev->primary_ring;
struct vk_pipeline_cache_header *header = pData;
VkResult result;

View file

@ -273,7 +273,7 @@ vn_CreateSwapchainKHR(VkDevice device,
VN_WSI_PTR(pCreateInfo->oldSwapchain));
}
vn_tls_set_primary_ring_submission();
vn_tls_set_async_pipeline_create();
return vn_result(dev->instance, result);
}