Lines Matching full:device
84 create_event_pipelines(struct v3dv_device *device) in create_event_pipelines() argument
88 if (!device->events.descriptor_set_layout) { in create_event_pipelines()
109 v3dv_CreateDescriptorSetLayout(v3dv_device_to_handle(device), in create_event_pipelines()
111 &device->vk.alloc, in create_event_pipelines()
112 &device->events.descriptor_set_layout); in create_event_pipelines()
118 if (!device->events.pipeline_layout) { in create_event_pipelines()
122 .pSetLayouts = &device->events.descriptor_set_layout, in create_event_pipelines()
129 v3dv_CreatePipelineLayout(v3dv_device_to_handle(device), in create_event_pipelines()
131 &device->vk.alloc, in create_event_pipelines()
132 &device->events.pipeline_layout); in create_event_pipelines()
140 if (!device->events.set_event_pipeline) { in create_event_pipelines()
142 result = v3dv_create_compute_pipeline_from_nir(device, in create_event_pipelines()
144 device->events.pipeline_layout, in create_event_pipelines()
150 device->events.set_event_pipeline = pipeline; in create_event_pipelines()
153 if (!device->events.wait_event_pipeline) { in create_event_pipelines()
155 result = v3dv_create_compute_pipeline_from_nir(device, in create_event_pipelines()
157 device->events.pipeline_layout, in create_event_pipelines()
163 device->events.wait_event_pipeline = pipeline; in create_event_pipelines()
170 destroy_event_pipelines(struct v3dv_device *device) in destroy_event_pipelines() argument
172 VkDevice _device = v3dv_device_to_handle(device); in destroy_event_pipelines()
174 v3dv_DestroyPipeline(_device, device->events.set_event_pipeline, in destroy_event_pipelines()
175 &device->vk.alloc); in destroy_event_pipelines()
176 device->events.set_event_pipeline = VK_NULL_HANDLE; in destroy_event_pipelines()
178 v3dv_DestroyPipeline(_device, device->events.wait_event_pipeline, in destroy_event_pipelines()
179 &device->vk.alloc); in destroy_event_pipelines()
180 device->events.wait_event_pipeline = VK_NULL_HANDLE; in destroy_event_pipelines()
182 v3dv_DestroyPipelineLayout(_device, device->events.pipeline_layout, in destroy_event_pipelines()
183 &device->vk.alloc); in destroy_event_pipelines()
184 device->events.pipeline_layout = VK_NULL_HANDLE; in destroy_event_pipelines()
187 device->events.descriptor_set_layout, in destroy_event_pipelines()
188 &device->vk.alloc); in destroy_event_pipelines()
189 device->events.descriptor_set_layout = VK_NULL_HANDLE; in destroy_event_pipelines()
193 init_event(struct v3dv_device *device, struct v3dv_event *event, uint32_t index) in init_event() argument
195 vk_object_base_init(&device->vk, &event->base, VK_OBJECT_TYPE_EVENT); in init_event()
197 list_addtail(&event->link, &device->events.free_list); in init_event()
201 v3dv_event_allocate_resources(struct v3dv_device *device) in v3dv_event_allocate_resources() argument
204 VkDevice _device = v3dv_device_to_handle(device); in v3dv_event_allocate_resources()
213 struct v3dv_bo *bo = v3dv_bo_alloc(device, bo_size, "events", true); in v3dv_event_allocate_resources()
215 result = vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY); in v3dv_event_allocate_resources()
219 device->events.bo = bo; in v3dv_event_allocate_resources()
221 if (!v3dv_bo_map(device, bo, bo_size)) { in v3dv_event_allocate_resources()
222 result = vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); in v3dv_event_allocate_resources()
227 device->events.event_count = bo_size; in v3dv_event_allocate_resources()
228 device->events.events = in v3dv_event_allocate_resources()
229 vk_zalloc2(&device->vk.alloc, NULL, in v3dv_event_allocate_resources()
230 device->events.event_count * sizeof(struct v3dv_event), 8, in v3dv_event_allocate_resources()
232 if (!device->events.events) { in v3dv_event_allocate_resources()
233 result = vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); in v3dv_event_allocate_resources()
237 list_inithead(&device->events.free_list); in v3dv_event_allocate_resources()
238 for (int i = 0; i < device->events.event_count; i++) in v3dv_event_allocate_resources()
239 init_event(device, &device->events.events[i], i); in v3dv_event_allocate_resources()
248 &device->events.buffer); in v3dv_event_allocate_resources()
253 vk_object_zalloc(&device->vk, NULL, sizeof(*mem), in v3dv_event_allocate_resources()
261 mem->type = &device->pdevice->memory.memoryTypes[0]; in v3dv_event_allocate_resources()
263 device->events.mem = v3dv_device_memory_to_handle(mem); in v3dv_event_allocate_resources()
266 .buffer = device->events.buffer, in v3dv_event_allocate_resources()
267 .memory = device->events.mem, in v3dv_event_allocate_resources()
273 if (!create_event_pipelines(device)) { in v3dv_event_allocate_resources()
292 &device->events.descriptor_pool); in v3dv_event_allocate_resources()
299 .descriptorPool = device->events.descriptor_pool, in v3dv_event_allocate_resources()
301 .pSetLayouts = &device->events.descriptor_set_layout, in v3dv_event_allocate_resources()
304 &device->events.descriptor_set); in v3dv_event_allocate_resources()
309 .buffer = device->events.buffer, in v3dv_event_allocate_resources()
316 .dstSet = device->events.descriptor_set, in v3dv_event_allocate_resources()
328 v3dv_event_free_resources(device); in v3dv_event_allocate_resources()
333 v3dv_event_free_resources(struct v3dv_device *device) in v3dv_event_free_resources() argument
335 if (device->events.bo) { in v3dv_event_free_resources()
336 v3dv_bo_free(device, device->events.bo); in v3dv_event_free_resources()
337 device->events.bo = NULL; in v3dv_event_free_resources()
340 if (device->events.events) { in v3dv_event_free_resources()
341 vk_free2(&device->vk.alloc, NULL, device->events.events); in v3dv_event_free_resources()
342 device->events.events = NULL; in v3dv_event_free_resources()
345 if (device->events.mem) { in v3dv_event_free_resources()
346 vk_object_free(&device->vk, NULL, in v3dv_event_free_resources()
347 v3dv_device_memory_from_handle(device->events.mem)); in v3dv_event_free_resources()
348 device->events.mem = VK_NULL_HANDLE; in v3dv_event_free_resources()
351 v3dv_DestroyBuffer(v3dv_device_to_handle(device), in v3dv_event_free_resources()
352 device->events.buffer, NULL); in v3dv_event_free_resources()
353 device->events.buffer = VK_NULL_HANDLE; in v3dv_event_free_resources()
355 v3dv_FreeDescriptorSets(v3dv_device_to_handle(device), in v3dv_event_free_resources()
356 device->events.descriptor_pool, in v3dv_event_free_resources()
357 1, &device->events.descriptor_set); in v3dv_event_free_resources()
358 device->events.descriptor_set = VK_NULL_HANDLE; in v3dv_event_free_resources()
360 v3dv_DestroyDescriptorPool(v3dv_device_to_handle(device), in v3dv_event_free_resources()
361 device->events.descriptor_pool, in v3dv_event_free_resources()
363 device->events.descriptor_pool = VK_NULL_HANDLE; in v3dv_event_free_resources()
365 destroy_event_pipelines(device); in v3dv_event_free_resources()
369 allocate_event(struct v3dv_device *device) in allocate_event() argument
371 mtx_lock(&device->events.lock); in allocate_event()
372 if (list_is_empty(&device->events.free_list)) { in allocate_event()
373 mtx_unlock(&device->events.lock); in allocate_event()
378 list_first_entry(&device->events.free_list, struct v3dv_event, link); in allocate_event()
380 mtx_unlock(&device->events.lock); in allocate_event()
386 free_event(struct v3dv_device *device, uint32_t index) in free_event() argument
388 assert(index < device->events.event_count); in free_event()
389 mtx_lock(&device->events.lock); in free_event()
390 list_addtail(&device->events.events[index].link, &device->events.free_list); in free_event()
391 mtx_unlock(&device->events.lock); in free_event()
395 event_set_value(struct v3dv_device *device, in event_set_value() argument
400 uint8_t *data = (uint8_t *) device->events.bo->map; in event_set_value()
405 event_get_value(struct v3dv_device *device, struct v3dv_event *event) in event_get_value() argument
407 uint8_t *data = (uint8_t *) device->events.bo->map; in event_get_value()
417 V3DV_FROM_HANDLE(v3dv_device, device, _device); in v3dv_CreateEvent()
420 struct v3dv_event *event = allocate_event(device); in v3dv_CreateEvent()
422 result = vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY); in v3dv_CreateEvent()
426 event_set_value(device, event, 0); in v3dv_CreateEvent()
439 V3DV_FROM_HANDLE(v3dv_device, device, _device); in v3dv_DestroyEvent()
445 free_event(device, event->index); in v3dv_DestroyEvent()
451 V3DV_FROM_HANDLE(v3dv_device, device, _device); in v3dv_GetEventStatus()
453 return event_get_value(device, event) ? VK_EVENT_SET : VK_EVENT_RESET; in v3dv_GetEventStatus()
459 V3DV_FROM_HANDLE(v3dv_device, device, _device); in v3dv_SetEvent()
461 event_set_value(device, event, 1); in v3dv_SetEvent()
468 V3DV_FROM_HANDLE(v3dv_device, device, _device); in v3dv_ResetEvent()
470 event_set_value(device, event, 0); in v3dv_ResetEvent()
481 struct v3dv_device *device = cmd_buffer->device; in cmd_buffer_emit_set_event() local
488 device->events.set_event_pipeline); in cmd_buffer_emit_set_event()
492 device->events.pipeline_layout, in cmd_buffer_emit_set_event()
493 0, 1, &device->events.descriptor_set, 0, NULL); in cmd_buffer_emit_set_event()
495 assert(event->index < device->events.event_count); in cmd_buffer_emit_set_event()
498 device->events.pipeline_layout, in cmd_buffer_emit_set_event()
503 device->events.pipeline_layout, in cmd_buffer_emit_set_event()
516 struct v3dv_device *device = cmd_buffer->device; in cmd_buffer_emit_wait_event() local
523 device->events.wait_event_pipeline); in cmd_buffer_emit_wait_event()
527 device->events.pipeline_layout, in cmd_buffer_emit_wait_event()
528 0, 1, &device->events.descriptor_set, 0, NULL); in cmd_buffer_emit_wait_event()
530 assert(event->index < device->events.event_count); in cmd_buffer_emit_wait_event()
533 device->events.pipeline_layout, in cmd_buffer_emit_wait_event()
559 struct v3dv_device *device = cmd_buffer->device; in v3dv_CmdSetEvent2() local
563 vk_alloc2(&device->vk.alloc, NULL, in v3dv_CmdSetEvent2()
573 vk_alloc2(&device->vk.alloc, NULL, in v3dv_CmdSetEvent2()
583 vk_alloc2(&device->vk.alloc, NULL, in v3dv_CmdSetEvent2()
607 vk_free2(&device->vk.alloc, NULL, memory_barriers); in v3dv_CmdSetEvent2()
609 vk_free2(&device->vk.alloc, NULL, buffer_barriers); in v3dv_CmdSetEvent2()
611 vk_free2(&device->vk.alloc, NULL, image_barriers); in v3dv_CmdSetEvent2()
658 struct v3dv_device *device = cmd_buffer->device; in v3dv_CmdWaitEvents2() local
664 vk_alloc2(&device->vk.alloc, NULL, in v3dv_CmdWaitEvents2()
674 vk_alloc2(&device->vk.alloc, NULL, in v3dv_CmdWaitEvents2()
684 vk_alloc2(&device->vk.alloc, NULL, in v3dv_CmdWaitEvents2()
706 vk_free2(&device->vk.alloc, NULL, memory_barriers); in v3dv_CmdWaitEvents2()
708 vk_free2(&device->vk.alloc, NULL, buffer_barriers); in v3dv_CmdWaitEvents2()
710 vk_free2(&device->vk.alloc, NULL, image_barriers); in v3dv_CmdWaitEvents2()