Lines Matching refs:instance
76 vn_instance_init_renderer_versions(struct vn_instance *instance) in vn_instance_init_renderer_versions() argument
80 vn_call_vkEnumerateInstanceVersion(instance, &instance_version); in vn_instance_init_renderer_versions()
83 vn_log(instance, "failed to enumerate renderer instance version"); in vn_instance_init_renderer_versions()
89 vn_log(instance, "unsupported renderer instance version %d.%d", in vn_instance_init_renderer_versions()
97 vn_log(instance, "renderer instance version %d.%d.%d", in vn_instance_init_renderer_versions()
104 instance->renderer_api_version = in vn_instance_init_renderer_versions()
105 MAX2(instance->base.base.app_info.api_version, VN_MIN_RENDERER_VERSION); in vn_instance_init_renderer_versions()
108 instance_version = MIN3(instance_version, instance->renderer_api_version, in vn_instance_init_renderer_versions()
109 instance->renderer->info.vk_xml_version); in vn_instance_init_renderer_versions()
112 instance->renderer_version = instance_version; in vn_instance_init_renderer_versions()
118 vn_instance_init_ring(struct vn_instance *instance) in vn_instance_init_ring() argument
120 const size_t buf_size = instance->experimental.largeRing in vn_instance_init_ring()
128 instance->ring.shmem = in vn_instance_init_ring()
129 vn_renderer_shmem_create(instance->renderer, layout.shmem_size); in vn_instance_init_ring()
130 if (!instance->ring.shmem) { in vn_instance_init_ring()
132 vn_log(instance, "failed to allocate/map ring shmem"); in vn_instance_init_ring()
136 mtx_init(&instance->ring.mutex, mtx_plain); in vn_instance_init_ring()
138 struct vn_ring *ring = &instance->ring.ring; in vn_instance_init_ring()
139 vn_ring_init(ring, instance->renderer, &layout, in vn_instance_init_ring()
140 instance->ring.shmem->mmap_ptr); in vn_instance_init_ring()
142 instance->ring.id = (uintptr_t)ring; in vn_instance_init_ring()
146 .resourceId = instance->ring.shmem->res_id, in vn_instance_init_ring()
161 vn_encode_vkCreateRingMESA(&local_enc, 0, instance->ring.id, &info); in vn_instance_init_ring()
162 vn_renderer_submit_simple(instance->renderer, create_ring_data, in vn_instance_init_ring()
165 vn_cs_encoder_init(&instance->ring.upload, instance, in vn_instance_init_ring()
168 mtx_init(&instance->ring.roundtrip_mutex, mtx_plain); in vn_instance_init_ring()
169 instance->ring.roundtrip_next = 1; in vn_instance_init_ring()
175 vn_instance_get_reply_shmem_locked(struct vn_instance *instance,
180 vn_instance_init_experimental_features(struct vn_instance *instance) in vn_instance_init_experimental_features() argument
182 if (instance->renderer->info.vk_mesa_venus_protocol_spec_version != in vn_instance_init_experimental_features()
185 vn_log(instance, "renderer supports no experimental features"); in vn_instance_init_experimental_features()
189 size_t struct_size = sizeof(instance->experimental); in vn_instance_init_experimental_features()
194 &struct_size, &instance->experimental); in vn_instance_init_experimental_features()
197 vn_instance_get_reply_shmem_locked(instance, reply_size, &reply_ptr); in vn_instance_init_experimental_features()
207 &instance->experimental); in vn_instance_init_experimental_features()
210 instance->renderer, local_data, vn_cs_encoder_get_len(&local_enc)); in vn_instance_init_experimental_features()
212 vn_renderer_shmem_unref(instance->renderer, reply_shmem); in vn_instance_init_experimental_features()
219 &reply_dec, &struct_size, &instance->experimental); in vn_instance_init_experimental_features()
220 vn_renderer_shmem_unref(instance->renderer, reply_shmem); in vn_instance_init_experimental_features()
223 vn_log(instance, in vn_instance_init_experimental_features()
228 instance->experimental.memoryResourceAllocationSize, in vn_instance_init_experimental_features()
229 instance->experimental.globalFencing, in vn_instance_init_experimental_features()
230 instance->experimental.largeRing); in vn_instance_init_experimental_features()
237 vn_instance_init_renderer(struct vn_instance *instance) in vn_instance_init_renderer() argument
239 const VkAllocationCallbacks *alloc = &instance->base.base.alloc; in vn_instance_init_renderer()
241 VkResult result = vn_renderer_create(instance, alloc, &instance->renderer); in vn_instance_init_renderer()
245 struct vn_renderer_info *renderer_info = &instance->renderer->info; in vn_instance_init_renderer()
249 vn_log(instance, "wire format version %d != %d", in vn_instance_init_renderer()
260 vn_log(instance, "vk xml version %d.%d.%d < %d.%d.%d", in vn_instance_init_renderer()
283 vn_log(instance, "connected to renderer"); in vn_instance_init_renderer()
284 vn_log(instance, "wire format version %d", in vn_instance_init_renderer()
286 vn_log(instance, "vk xml version %d.%d.%d", in vn_instance_init_renderer()
290 vn_log(instance, "VK_EXT_command_serialization spec version %d", in vn_instance_init_renderer()
292 vn_log(instance, "VK_MESA_venus_protocol spec version %d", in vn_instance_init_renderer()
294 vn_log(instance, "supports blob id 0: %d", in vn_instance_init_renderer()
296 vn_log(instance, "allow_vk_wait_syncs: %d", in vn_instance_init_renderer()
304 vn_instance_submit_roundtrip(struct vn_instance *instance, in vn_instance_submit_roundtrip() argument
312 mtx_lock(&instance->ring.roundtrip_mutex); in vn_instance_submit_roundtrip()
313 const uint32_t seqno = instance->ring.roundtrip_next++; in vn_instance_submit_roundtrip()
314 vn_encode_vkWriteRingExtraMESA(&local_enc, 0, instance->ring.id, 0, seqno); in vn_instance_submit_roundtrip()
316 vn_renderer_submit_simple(instance->renderer, write_ring_extra_data, in vn_instance_submit_roundtrip()
318 mtx_unlock(&instance->ring.roundtrip_mutex); in vn_instance_submit_roundtrip()
332 vn_instance_wait_roundtrip(struct vn_instance *instance, in vn_instance_wait_roundtrip() argument
336 const struct vn_ring *ring = &instance->ring.ring; in vn_instance_wait_roundtrip()
469 vn_instance_submission_can_direct(const struct vn_instance *instance, in vn_instance_submission_can_direct() argument
472 const size_t threshold = instance->experimental.largeRing in vn_instance_submission_can_direct()
479 vn_instance_ring_cs_upload_locked(struct vn_instance *instance, in vn_instance_ring_cs_upload_locked() argument
489 struct vn_cs_encoder *upload = &instance->ring.upload; in vn_instance_ring_cs_upload_locked()
498 if (unlikely(!instance->renderer->info.supports_blob_id_0)) in vn_instance_ring_cs_upload_locked()
499 vn_instance_wait_roundtrip(instance, upload->current_buffer_roundtrip); in vn_instance_ring_cs_upload_locked()
505 vn_instance_ring_submit_locked(struct vn_instance *instance, in vn_instance_ring_submit_locked() argument
510 struct vn_ring *ring = &instance->ring.ring; in vn_instance_ring_submit_locked()
512 const bool direct = vn_instance_submission_can_direct(instance, cs); in vn_instance_ring_submit_locked()
514 cs = vn_instance_ring_cs_upload_locked(instance, cs); in vn_instance_ring_submit_locked()
532 vn_encode_vkNotifyRingMESA(&local_enc, 0, instance->ring.id, seqno, 0); in vn_instance_ring_submit_locked()
533 vn_renderer_submit_simple(instance->renderer, notify_ring_data, in vn_instance_ring_submit_locked()
546 vn_instance_ring_submit(struct vn_instance *instance, in vn_instance_ring_submit() argument
549 mtx_lock(&instance->ring.mutex); in vn_instance_ring_submit()
550 VkResult result = vn_instance_ring_submit_locked(instance, cs, NULL, NULL); in vn_instance_ring_submit()
551 mtx_unlock(&instance->ring.mutex); in vn_instance_ring_submit()
557 vn_instance_get_reply_shmem_locked(struct vn_instance *instance, in vn_instance_get_reply_shmem_locked() argument
562 struct vn_renderer_shmem_pool *pool = &instance->reply_shmem_pool; in vn_instance_get_reply_shmem_locked()
567 vn_renderer_shmem_pool_alloc(instance->renderer, pool, size, &offset); in vn_instance_get_reply_shmem_locked()
589 if (likely(instance->ring.id)) { in vn_instance_get_reply_shmem_locked()
590 if (unlikely(!instance->renderer->info.supports_blob_id_0)) in vn_instance_get_reply_shmem_locked()
591 vn_instance_roundtrip(instance); in vn_instance_get_reply_shmem_locked()
593 vn_instance_ring_submit_locked(instance, &local_enc, NULL, NULL); in vn_instance_get_reply_shmem_locked()
595 vn_renderer_submit_simple(instance->renderer, in vn_instance_get_reply_shmem_locked()
611 if (likely(instance->ring.id)) { in vn_instance_get_reply_shmem_locked()
612 vn_instance_ring_submit_locked(instance, &local_enc, NULL, NULL); in vn_instance_get_reply_shmem_locked()
614 vn_renderer_submit_simple(instance->renderer, in vn_instance_get_reply_shmem_locked()
623 vn_instance_submit_command(struct vn_instance *instance, in vn_instance_submit_command() argument
629 mtx_lock(&instance->ring.mutex); in vn_instance_submit_command()
637 instance, submit->reply_size, &reply_ptr); in vn_instance_submit_command()
644 instance, &submit->command, submit->reply_shmem, &ring_seqno); in vn_instance_submit_command()
646 mtx_unlock(&instance->ring.mutex); in vn_instance_submit_command()
651 vn_ring_wait(&instance->ring.ring, ring_seqno); in vn_instance_submit_command()
656 instance->ring.command_dropped++; in vn_instance_submit_command()
657 mtx_unlock(&instance->ring.mutex); in vn_instance_submit_command()
697 struct vn_instance *instance; in vn_CreateInstance() local
703 instance = vk_zalloc(alloc, sizeof(*instance), VN_DEFAULT_ALIGN, in vn_CreateInstance()
705 if (!instance) in vn_CreateInstance()
713 result = vn_instance_base_init(&instance->base, in vn_CreateInstance()
717 vk_free(alloc, instance); in vn_CreateInstance()
721 mtx_init(&instance->physical_device.mutex, mtx_plain); in vn_CreateInstance()
722 mtx_init(&instance->cs_shmem.mutex, mtx_plain); in vn_CreateInstance()
725 instance->base.base.app_info.api_version)) { in vn_CreateInstance()
735 result = vn_instance_init_renderer(instance); in vn_CreateInstance()
739 vn_cs_renderer_protocol_info_init(instance); in vn_CreateInstance()
741 vn_renderer_shmem_pool_init(instance->renderer, in vn_CreateInstance()
742 &instance->reply_shmem_pool, 1u << 20); in vn_CreateInstance()
744 result = vn_instance_init_experimental_features(instance); in vn_CreateInstance()
748 result = vn_instance_init_ring(instance); in vn_CreateInstance()
752 result = vn_instance_init_renderer_versions(instance); in vn_CreateInstance()
756 vn_renderer_shmem_pool_init(instance->renderer, &instance->cs_shmem.pool, in vn_CreateInstance()
765 if (instance->base.base.app_info.api_version < in vn_CreateInstance()
766 instance->renderer_api_version) { in vn_CreateInstance()
769 local_app_info.apiVersion = instance->renderer_api_version; in vn_CreateInstance()
773 .apiVersion = instance->renderer_api_version, in vn_CreateInstance()
779 VkInstance instance_handle = vn_instance_to_handle(instance); in vn_CreateInstance()
781 vn_call_vkCreateInstance(instance, pCreateInfo, NULL, &instance_handle); in vn_CreateInstance()
785 driParseOptionInfo(&instance->available_dri_options, vn_dri_options, in vn_CreateInstance()
787 driParseConfigFiles(&instance->dri_options, in vn_CreateInstance()
788 &instance->available_dri_options, 0, "venus", NULL, in vn_CreateInstance()
789 NULL, instance->base.base.app_info.app_name, in vn_CreateInstance()
790 instance->base.base.app_info.app_version, in vn_CreateInstance()
791 instance->base.base.app_info.engine_name, in vn_CreateInstance()
792 instance->base.base.app_info.engine_version); in vn_CreateInstance()
794 instance->renderer->info.has_implicit_fencing = in vn_CreateInstance()
795 driQueryOptionb(&instance->dri_options, "venus_implicit_fencing"); in vn_CreateInstance()
802 if (instance->ring.shmem) { in vn_CreateInstance()
806 vn_encode_vkDestroyRingMESA(&local_enc, 0, instance->ring.id); in vn_CreateInstance()
807 vn_renderer_submit_simple(instance->renderer, destroy_ring_data, in vn_CreateInstance()
810 mtx_destroy(&instance->ring.roundtrip_mutex); in vn_CreateInstance()
811 vn_cs_encoder_fini(&instance->ring.upload); in vn_CreateInstance()
812 vn_renderer_shmem_unref(instance->renderer, instance->ring.shmem); in vn_CreateInstance()
813 vn_ring_fini(&instance->ring.ring); in vn_CreateInstance()
814 mtx_destroy(&instance->ring.mutex); in vn_CreateInstance()
817 vn_renderer_shmem_pool_fini(instance->renderer, in vn_CreateInstance()
818 &instance->reply_shmem_pool); in vn_CreateInstance()
820 if (instance->renderer) in vn_CreateInstance()
821 vn_renderer_destroy(instance->renderer, alloc); in vn_CreateInstance()
823 mtx_destroy(&instance->physical_device.mutex); in vn_CreateInstance()
824 mtx_destroy(&instance->cs_shmem.mutex); in vn_CreateInstance()
826 vn_instance_base_fini(&instance->base); in vn_CreateInstance()
827 vk_free(alloc, instance); in vn_CreateInstance()
837 struct vn_instance *instance = vn_instance_from_handle(_instance); in vn_DestroyInstance() local
839 pAllocator ? pAllocator : &instance->base.base.alloc; in vn_DestroyInstance()
841 if (!instance) in vn_DestroyInstance()
844 if (instance->physical_device.initialized) { in vn_DestroyInstance()
845 for (uint32_t i = 0; i < instance->physical_device.device_count; i++) in vn_DestroyInstance()
846 vn_physical_device_fini(&instance->physical_device.devices[i]); in vn_DestroyInstance()
847 vk_free(alloc, instance->physical_device.devices); in vn_DestroyInstance()
848 vk_free(alloc, instance->physical_device.groups); in vn_DestroyInstance()
850 mtx_destroy(&instance->physical_device.mutex); in vn_DestroyInstance()
852 vn_call_vkDestroyInstance(instance, _instance, NULL); in vn_DestroyInstance()
854 vn_renderer_shmem_pool_fini(instance->renderer, &instance->cs_shmem.pool); in vn_DestroyInstance()
855 mtx_destroy(&instance->cs_shmem.mutex); in vn_DestroyInstance()
860 vn_encode_vkDestroyRingMESA(&local_enc, 0, instance->ring.id); in vn_DestroyInstance()
861 vn_renderer_submit_simple(instance->renderer, destroy_ring_data, in vn_DestroyInstance()
864 mtx_destroy(&instance->ring.roundtrip_mutex); in vn_DestroyInstance()
865 vn_cs_encoder_fini(&instance->ring.upload); in vn_DestroyInstance()
866 vn_ring_fini(&instance->ring.ring); in vn_DestroyInstance()
867 mtx_destroy(&instance->ring.mutex); in vn_DestroyInstance()
868 vn_renderer_shmem_unref(instance->renderer, instance->ring.shmem); in vn_DestroyInstance()
870 vn_renderer_shmem_pool_fini(instance->renderer, in vn_DestroyInstance()
871 &instance->reply_shmem_pool); in vn_DestroyInstance()
873 vn_renderer_destroy(instance->renderer, alloc); in vn_DestroyInstance()
875 driDestroyOptionCache(&instance->dri_options); in vn_DestroyInstance()
876 driDestroyOptionInfo(&instance->available_dri_options); in vn_DestroyInstance()
878 vn_instance_base_fini(&instance->base); in vn_DestroyInstance()
879 vk_free(alloc, instance); in vn_DestroyInstance()
885 struct vn_instance *instance = vn_instance_from_handle(_instance); in vn_GetInstanceProcAddr() local
886 return vk_instance_get_proc_addr(&instance->base.base, in vn_GetInstanceProcAddr()