1// Manual inline for
2// void VkEncoder::vkQueueFlushCommandsGOOGLE( VkQueue queue, VkCommandBuffer commandBuffer, VkDeviceSize dataSize, const void* pData, uint32_t doLock);
3
4// We won't use the lock if this command is used (VulkanQueueSubmitWithCommands is enabled)
5(void)doLock;
6
7auto stream = mImpl->stream();
8auto pool = mImpl->pool();
9VkQueue local_queue;
10VkCommandBuffer local_commandBuffer;
11VkDeviceSize local_dataSize;
12void* local_pData;
13local_queue = queue;
14local_commandBuffer = commandBuffer;
15local_dataSize = dataSize;
16// Avoiding deepcopy for pData
17local_pData = (void*)pData;
18size_t count = 0;
19size_t* countPtr = &count;
20{
21    uint64_t cgen_var_1405;
22    *countPtr += 1 * 8;
23    uint64_t cgen_var_1406;
24    *countPtr += 1 * 8;
25    *countPtr += sizeof(VkDeviceSize);
26    *countPtr += ((dataSize)) * sizeof(uint8_t);
27}
28bool queueSubmitWithCommandsEnabled = sFeatureBits & VULKAN_STREAM_FEATURE_QUEUE_SUBMIT_WITH_COMMANDS_BIT;
29uint32_t packetSize_vkQueueFlushCommandsGOOGLE = 4 + 4 + (queueSubmitWithCommandsEnabled ? 4 : 0) + count;
30healthMonitorAnnotation_packetSize =
31    std::make_optional(packetSize_vkQueueFlushCommandsGOOGLE);
32uint8_t* streamPtr = stream->reserve(packetSize_vkQueueFlushCommandsGOOGLE - local_dataSize);
33uint8_t* packetBeginPtr = streamPtr;
34uint8_t** streamPtrPtr = &streamPtr;
35uint32_t opcode_vkQueueFlushCommandsGOOGLE = OP_vkQueueFlushCommandsGOOGLE;
36uint32_t seqno = ResourceTracker::nextSeqno();
37healthMonitorAnnotation_seqno = std::make_optional(seqno);
38memcpy(streamPtr, &opcode_vkQueueFlushCommandsGOOGLE, sizeof(uint32_t)); streamPtr += sizeof(uint32_t);
39memcpy(streamPtr, &packetSize_vkQueueFlushCommandsGOOGLE, sizeof(uint32_t)); streamPtr += sizeof(uint32_t);
40memcpy(streamPtr, &seqno, sizeof(uint32_t)); streamPtr += sizeof(uint32_t);
41uint64_t cgen_var_1407;
42*&cgen_var_1407 = get_host_u64_VkQueue((*&local_queue));
43memcpy(*streamPtrPtr, (uint64_t*)&cgen_var_1407, 1 * 8);
44*streamPtrPtr += 1 * 8;
45uint64_t cgen_var_1408;
46*&cgen_var_1408 = get_host_u64_VkCommandBuffer((*&local_commandBuffer));
47memcpy(*streamPtrPtr, (uint64_t*)&cgen_var_1408, 1 * 8);
48*streamPtrPtr += 1 * 8;
49memcpy(*streamPtrPtr, (VkDeviceSize*)&local_dataSize, sizeof(VkDeviceSize));
50*streamPtrPtr += sizeof(VkDeviceSize);
51if (watchdog) {
52    size_t watchdogBufSize = std::min<size_t>(
53        static_cast<size_t>(packetSize_vkQueueFlushCommandsGOOGLE), kWatchdogBufferMax);
54    healthMonitorAnnotation_packetContents.resize(watchdogBufSize);
55    memcpy(&healthMonitorAnnotation_packetContents[0], packetBeginPtr, watchdogBufSize);
56}
57
58AEMU_SCOPED_TRACE("vkQueueFlush large xfer");
59stream->flush();
60stream->writeLarge(local_pData, dataSize);
61
62++encodeCount;;
63if (0 == encodeCount % POOL_CLEAR_INTERVAL)
64{
65    pool->freeAll();
66    stream->clearPool();
67}
68