• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2024 Valve Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is 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
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  */
23 
24 #include "radv_private.h"
25 
26 VKAPI_ATTR VkResult VKAPI_CALL
ctx_roll_QueuePresentKHR(VkQueue _queue,const VkPresentInfoKHR * pPresentInfo)27 ctx_roll_QueuePresentKHR(VkQueue _queue, const VkPresentInfoKHR *pPresentInfo)
28 {
29    RADV_FROM_HANDLE(radv_queue, queue, _queue);
30 
31    simple_mtx_lock(&queue->device->ctx_roll_mtx);
32 
33    if (queue->device->ctx_roll_file) {
34       fclose(queue->device->ctx_roll_file);
35       queue->device->ctx_roll_file = NULL;
36    }
37 
38    simple_mtx_unlock(&queue->device->ctx_roll_mtx);
39 
40    return queue->device->layer_dispatch.ctx_roll.QueuePresentKHR(_queue, pPresentInfo);
41 }
42 
43 VKAPI_ATTR VkResult VKAPI_CALL
ctx_roll_QueueSubmit2(VkQueue _queue,uint32_t submitCount,const VkSubmitInfo2 * pSubmits,VkFence _fence)44 ctx_roll_QueueSubmit2(VkQueue _queue, uint32_t submitCount, const VkSubmitInfo2 *pSubmits, VkFence _fence)
45 {
46    RADV_FROM_HANDLE(radv_queue, queue, _queue);
47 
48    simple_mtx_lock(&queue->device->ctx_roll_mtx);
49 
50    if (queue->device->ctx_roll_file) {
51       for (uint32_t submit_index = 0; submit_index < submitCount; submit_index++) {
52          const VkSubmitInfo2 *submit = pSubmits + submit_index;
53          for (uint32_t i = 0; i < submit->commandBufferInfoCount; i++) {
54             RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, submit->pCommandBufferInfos[i].commandBuffer);
55             fprintf(queue->device->ctx_roll_file, "\n%s:\n", vk_object_base_name(&cmd_buffer->vk.base));
56             queue->device->ws->cs_dump(cmd_buffer->cs, queue->device->ctx_roll_file, NULL, 0,
57                                        RADV_CS_DUMP_TYPE_CTX_ROLLS);
58          }
59       }
60    }
61 
62    simple_mtx_unlock(&queue->device->ctx_roll_mtx);
63 
64    return queue->device->layer_dispatch.ctx_roll.QueueSubmit2(_queue, submitCount, pSubmits, _fence);
65 }
66