venus: init experimental features before the ring

We can no longer use
vn_call_vkGetVenusExperimentalFeatureData100000MESA which requires the
ring to be initialized.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12568>
This commit is contained in:
Chia-I Wu 2021-08-29 22:02:16 -07:00 committed by Marge Bot
parent e5a005dd0c
commit 0641a230a0
2 changed files with 49 additions and 10 deletions

View File

@ -158,19 +158,54 @@ vn_instance_init_ring(struct vn_instance *instance)
return VK_SUCCESS;
}
static void
static struct vn_renderer_shmem *
vn_instance_get_reply_shmem_locked(struct vn_instance *instance,
size_t size,
void **ptr);
static VkResult
vn_instance_init_experimental_features(struct vn_instance *instance)
{
if (instance->renderer_info.vk_mesa_venus_protocol_spec_version !=
100000) {
if (VN_DEBUG(INIT))
vn_log(instance, "renderer supports no experimental features");
return;
return VK_SUCCESS;
}
size_t size = sizeof(instance->experimental);
vn_call_vkGetVenusExperimentalFeatureData100000MESA(
instance, &size, &instance->experimental);
size_t struct_size = sizeof(instance->experimental);
/* prepare the reply shmem */
const size_t reply_size =
vn_sizeof_vkGetVenusExperimentalFeatureData100000MESA_reply(
&struct_size, &instance->experimental);
void *reply_ptr;
struct vn_renderer_shmem *reply_shmem =
vn_instance_get_reply_shmem_locked(instance, reply_size, &reply_ptr);
if (!reply_shmem)
return VK_ERROR_OUT_OF_HOST_MEMORY;
/* encode the command */
uint32_t local_data[16];
struct vn_cs_encoder local_enc =
VN_CS_ENCODER_INITIALIZER_LOCAL(local_data, sizeof(local_data));
vn_encode_vkGetVenusExperimentalFeatureData100000MESA(
&local_enc, VK_COMMAND_GENERATE_REPLY_BIT_EXT, &struct_size,
&instance->experimental);
VkResult result = vn_renderer_submit_simple_sync(
instance->renderer, local_data, vn_cs_encoder_get_len(&local_enc));
if (result != VK_SUCCESS) {
vn_renderer_shmem_unref(instance->renderer, reply_shmem);
return result;
}
struct vn_cs_decoder reply_dec =
VN_CS_DECODER_INITIALIZER(reply_ptr, reply_size);
vn_decode_vkGetVenusExperimentalFeatureData100000MESA_reply(
&reply_dec, &struct_size, &instance->experimental);
vn_renderer_shmem_unref(instance->renderer, reply_shmem);
if (VN_DEBUG(INIT)) {
vn_log(instance,
"VkVenusExperimentalFeatures100000MESA is as below:"
@ -179,6 +214,8 @@ vn_instance_init_experimental_features(struct vn_instance *instance)
instance->experimental.memoryResourceAllocationSize,
instance->experimental.globalFencing);
}
return VK_SUCCESS;
}
static VkResult
@ -700,11 +737,13 @@ vn_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
if (result != VK_SUCCESS)
goto fail;
result = vn_instance_init_ring(instance);
result = vn_instance_init_experimental_features(instance);
if (result != VK_SUCCESS)
goto fail;
vn_instance_init_experimental_features(instance);
result = vn_instance_init_ring(instance);
if (result != VK_SUCCESS)
goto fail;
result = vn_instance_init_renderer_versions(instance);
if (result != VK_SUCCESS)

View File

@ -39,6 +39,9 @@ struct vn_instance {
struct vn_renderer *renderer;
struct vn_renderer_info renderer_info;
/* XXX staged features to be merged to core venus protocol */
VkVenusExperimentalFeatures100000MESA experimental;
struct {
mtx_t mutex;
struct vn_renderer_shmem *shmem;
@ -80,9 +83,6 @@ struct vn_instance {
VkPhysicalDeviceGroupProperties *groups;
uint32_t group_count;
} physical_device;
/* XXX staged features to be merged to core venus protocol */
VkVenusExperimentalFeatures100000MESA experimental;
};
VK_DEFINE_HANDLE_CASTS(vn_instance,
base.base.base,