xref: /aosp_15_r20/external/mesa3d/src/imagination/vulkan/winsys/pvrsrvkm/pvr_srv_job_null.c (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright © 2022 Imagination Technologies Ltd.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21  * SOFTWARE.
22  */
23 
24 #include <assert.h>
25 #include <stddef.h>
26 #include <stdint.h>
27 #include <unistd.h>
28 #include <vulkan/vulkan.h>
29 
30 #include "pvr_srv_job_null.h"
31 #include "pvr_srv_sync.h"
32 #include "pvr_winsys.h"
33 #include "util/libsync.h"
34 #include "vk_log.h"
35 #include "vk_sync.h"
36 
pvr_srv_winsys_null_job_submit(struct pvr_winsys * ws,struct vk_sync_wait * waits,uint32_t wait_count,struct vk_sync_signal * signal)37 VkResult pvr_srv_winsys_null_job_submit(struct pvr_winsys *ws,
38                                         struct vk_sync_wait *waits,
39                                         uint32_t wait_count,
40                                         struct vk_sync_signal *signal)
41 {
42    int fd = -1;
43 
44    /* Services doesn't support timeline syncs.
45     * Timeline syncs should be emulated by the Vulkan runtime and converted
46     * to binary syncs before this point.
47     */
48    assert((signal->signal_value == 0) &&
49           !(signal->sync->flags & VK_SYNC_IS_TIMELINE));
50 
51    for (uint32_t wait_idx = 0; wait_idx < wait_count; wait_idx++) {
52       struct pvr_srv_sync *srv_wait_sync = to_srv_sync(waits[wait_idx].sync);
53       int ret;
54 
55       if (srv_wait_sync->fd < 0)
56          continue;
57 
58       assert((waits[wait_idx].wait_value == 0) &&
59              !(waits[wait_idx].sync->flags & VK_SYNC_IS_TIMELINE));
60 
61       ret = sync_accumulate("", &fd, srv_wait_sync->fd);
62       if (ret) {
63          if (fd >= 0)
64             close(fd);
65 
66          return vk_error(NULL, VK_ERROR_OUT_OF_HOST_MEMORY);
67       }
68    }
69 
70    pvr_srv_set_sync_payload(to_srv_sync(signal->sync), fd);
71 
72    return VK_SUCCESS;
73 }
74