• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 #pragma once
15 
16 #include <vulkan/vulkan.h>
17 
18 #include <memory>
19 #include <optional>
20 #include <unordered_map>
21 #include <utility>
22 #include <vector>
23 
24 #include "VkDecoderContext.h"
25 #include "VkQsriTimeline.h"
26 #include "VkSnapshotApiCall.h"
27 #include "VulkanDispatch.h"
28 #include "VulkanHandleMapping.h"
29 #include "aemu/base/AsyncResult.h"
30 #include "aemu/base/HealthMonitor.h"
31 #include "aemu/base/synchronization/Lock.h"
32 #include "cereal/common/goldfish_vk_transform.h"
33 #include "gfxstream/host/Features.h"
34 #include "goldfish_vk_private_defs.h"
35 #include "host-common/GfxstreamFatalError.h"
36 #include "utils/GfxApiLogger.h"
37 #include "vk_util.h"
38 
39 using android::base::AutoLock;
40 using android::base::Lock;
41 using emugl::ABORT_REASON_OTHER;
42 using emugl::FatalError;
43 using emugl::HealthMonitor;
44 
45 namespace android {
46 namespace base {
47 class BumpPool;
48 class Stream;
49 }  // namespace base
50 }  // namespace android
51 
52 namespace gfxstream {
53 namespace vk {
54 
55 class VkDecoderSnapshot;
56 class VkEmulation;
57 
58 // Class for tracking host-side state. Currently we only care about
59 // tracking VkDeviceMemory to make it easier to pass the right data
60 // from mapped pointers to the guest, but this could get more stuff
61 // added to it if for instance, we want to only expose a certain set
62 // of physical device capabilities, or do snapshots.
63 
64 // This class may be autogenerated in the future.
65 // Currently, it works by interfacing with VkDecoder calling on_<apicall>
66 // functions.
67 class VkDecoderGlobalState {
68    public:
69     VkDecoderGlobalState(VkEmulation* emulation);
70     ~VkDecoderGlobalState();
71 
72     static void initialize(VkEmulation* emulation);
73 
74     // There should only be one instance of VkDecoderGlobalState per process
75     // Note: currently not thread-safe
76     static VkDecoderGlobalState* get();
77 
78     // For testing only - destroys the global instance of VkDecoderGlobalState.
79     static void reset();
80 
81     // Snapshot save/load
82     bool snapshotsEnabled() const;
83     bool isSnapshotCurrentlyLoading() const;
84 
85     bool batchedDescriptorSetUpdateEnabled() const;
86 
87     const gfxstream::host::FeatureSet& getFeatures() const;
88 
89     // Whether to clean up VK instance.
90     // bug 149997534
91     bool vkCleanupEnabled() const;
92 
93     void save(android::base::Stream* stream);
94     void load(android::base::Stream* stream, emugl::GfxApiLogger& gfxLogger,
95               emugl::HealthMonitor<>* healthMonitor);
96 
97     VkResult on_vkEnumerateInstanceVersion(android::base::BumpPool* pool,
98                                            VkSnapshotApiCallInfo* snapshotInfo,
99                                            uint32_t* pApiVersion);
100     VkResult on_vkEnumerateInstanceExtensionProperties(android::base::BumpPool* pool,
101                                                        VkSnapshotApiCallInfo* snapshotInfo,
102                                                        const char* pLayerName,
103                                                        uint32_t* pPropertyCount,
104                                                        VkExtensionProperties* pProperties);
105 
106     // Fast way to get dispatch tables associated with a Vulkan object.
107     // VkInstance
108     // VkPhysicalDevice
109     // VkDevice
110     // VkQueue
111     // VkCommandBuffer
112 
113     VkResult on_vkCreateInstance(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
114                                  const VkInstanceCreateInfo* pCreateInfo,
115                                  const VkAllocationCallbacks* pAllocator, VkInstance* pInstance);
116 
117     void on_vkDestroyInstance(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
118                               VkInstance instance, const VkAllocationCallbacks* pAllocator);
119 
120     VkResult on_vkEnumeratePhysicalDevices(android::base::BumpPool* pool,
121                                            VkSnapshotApiCallInfo* snapshotInfo, VkInstance instance,
122                                            uint32_t* physicalDeviceCount,
123                                            VkPhysicalDevice* physicalDevices);
124 
125     // Override features
126     void on_vkGetPhysicalDeviceFeatures(android::base::BumpPool* pool,
127                                         VkSnapshotApiCallInfo* snapshotInfo,
128                                         VkPhysicalDevice physicalDevice,
129                                         VkPhysicalDeviceFeatures* pFeatures);
130     void on_vkGetPhysicalDeviceFeatures2(android::base::BumpPool* pool,
131                                          VkSnapshotApiCallInfo* snapshotInfo,
132                                          VkPhysicalDevice physicalDevice,
133                                          VkPhysicalDeviceFeatures2* pFeatures);
134     void on_vkGetPhysicalDeviceFeatures2KHR(android::base::BumpPool* pool,
135                                             VkSnapshotApiCallInfo* snapshotInfo,
136                                             VkPhysicalDevice physicalDevice,
137                                             VkPhysicalDeviceFeatures2* pFeatures);
138 
139     // Override image format properties
140     VkResult on_vkGetPhysicalDeviceImageFormatProperties(
141         android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
142         VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling,
143         VkImageUsageFlags usage, VkImageCreateFlags flags,
144         VkImageFormatProperties* pImageFormatProperties);
145     VkResult on_vkGetPhysicalDeviceImageFormatProperties2(
146         android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
147         VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo,
148         VkImageFormatProperties2* pImageFormatProperties);
149     VkResult on_vkGetPhysicalDeviceImageFormatProperties2KHR(
150         android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
151         VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo,
152         VkImageFormatProperties2* pImageFormatProperties);
153 
154     // Override format features
155     void on_vkGetPhysicalDeviceFormatProperties(android::base::BumpPool* pool,
156                                                 VkSnapshotApiCallInfo* snapshotInfo,
157                                                 VkPhysicalDevice physicalDevice, VkFormat format,
158                                                 VkFormatProperties* pFormatProperties);
159     void on_vkGetPhysicalDeviceFormatProperties2(android::base::BumpPool* pool,
160                                                  VkSnapshotApiCallInfo* snapshotInfo,
161                                                  VkPhysicalDevice physicalDevice, VkFormat format,
162                                                  VkFormatProperties2* pFormatProperties);
163     void on_vkGetPhysicalDeviceFormatProperties2KHR(android::base::BumpPool* pool,
164                                                     VkSnapshotApiCallInfo* snapshotInfo,
165                                                     VkPhysicalDevice physicalDevice,
166                                                     VkFormat format,
167                                                     VkFormatProperties2* pFormatProperties);
168 
169     // Override API version
170     void on_vkGetPhysicalDeviceProperties(android::base::BumpPool* pool,
171                                           VkSnapshotApiCallInfo* snapshotInfo,
172                                           VkPhysicalDevice physicalDevice,
173                                           VkPhysicalDeviceProperties* pProperties);
174     void on_vkGetPhysicalDeviceProperties2(android::base::BumpPool* pool,
175                                            VkSnapshotApiCallInfo* snapshotInfo,
176                                            VkPhysicalDevice physicalDevice,
177                                            VkPhysicalDeviceProperties2* pProperties);
178     void on_vkGetPhysicalDeviceProperties2KHR(android::base::BumpPool* pool,
179                                               VkSnapshotApiCallInfo* snapshotInfo,
180                                               VkPhysicalDevice physicalDevice,
181                                               VkPhysicalDeviceProperties2* pProperties);
182 
183     // Override queue properties
184     void on_vkGetPhysicalDeviceQueueFamilyProperties(
185         android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
186         VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount,
187         VkQueueFamilyProperties* pQueueFamilyProperties);
188     void on_vkGetPhysicalDeviceQueueFamilyProperties2(
189         android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
190         VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount,
191         VkQueueFamilyProperties2* pQueueFamilyProperties);
192 
193     // Override memory types advertised from host
194     //
195     void on_vkGetPhysicalDeviceMemoryProperties(
196         android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
197         VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties* pMemoryProperties);
198     void on_vkGetPhysicalDeviceMemoryProperties2(
199         android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
200         VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2* pMemoryProperties);
201     void on_vkGetPhysicalDeviceMemoryProperties2KHR(
202         android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
203         VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2* pMemoryProperties);
204 
205     // Override supported device extension lists
206     VkResult on_vkEnumerateDeviceExtensionProperties(android::base::BumpPool* pool,
207                                                      VkSnapshotApiCallInfo* snapshotInfo,
208                                                      VkPhysicalDevice physicalDevice,
209                                                      const char* pLayerName,
210                                                      uint32_t* pPropertyCount,
211                                                      VkExtensionProperties* pProperties);
212 
213     VkResult on_vkCreateDevice(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
214                                VkPhysicalDevice physicalDevice,
215                                const VkDeviceCreateInfo* pCreateInfo,
216                                const VkAllocationCallbacks* pAllocator, VkDevice* pDevice);
217 
218     void on_vkGetDeviceQueue(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
219                              VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex,
220                              VkQueue* pQueue);
221 
222     void on_vkGetDeviceQueue2(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
223                               VkDevice device, const VkDeviceQueueInfo2* pQueueInfo,
224                               VkQueue* pQueue);
225 
226     void on_vkDestroyDevice(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
227                             VkDevice device, const VkAllocationCallbacks* pAllocator);
228 
229     VkResult on_vkCreateBuffer(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
230                                VkDevice device, const VkBufferCreateInfo* pCreateInfo,
231                                const VkAllocationCallbacks* pAllocator, VkBuffer* pBuffer);
232 
233     void on_vkDestroyBuffer(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
234                             VkDevice device, VkBuffer buffer,
235                             const VkAllocationCallbacks* pAllocator);
236 
237     VkResult on_vkBindBufferMemory(android::base::BumpPool* pool,
238                                    VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
239                                    VkBuffer buffer, VkDeviceMemory memory,
240                                    VkDeviceSize memoryOffset);
241     VkResult on_vkBindBufferMemory2(android::base::BumpPool* pool,
242                                     VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
243                                     uint32_t bindInfoCount,
244                                     const VkBindBufferMemoryInfo* pBindInfos);
245     VkResult on_vkBindBufferMemory2KHR(android::base::BumpPool* pool,
246                                        VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
247                                        uint32_t bindInfoCount,
248                                        const VkBindBufferMemoryInfo* pBindInfos);
249 
250     VkResult on_vkCreateImage(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
251                               VkDevice device, const VkImageCreateInfo* pCreateInfo,
252                               const VkAllocationCallbacks* pAllocator, VkImage* pImage);
253 
254     void on_vkDestroyImage(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
255                            VkDevice device, VkImage image, const VkAllocationCallbacks* pAllocator);
256 
257     VkResult on_vkBindImageMemory(android::base::BumpPool* pool,
258                                   VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
259                                   VkImage image, VkDeviceMemory memory, VkDeviceSize memoryOffset);
260     // It might modify pBindInfos to support snapshot.
261     VkResult on_vkBindImageMemory2(android::base::BumpPool* pool,
262                                    VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
263                                    uint32_t bindInfoCount, const VkBindImageMemoryInfo* pBindInfos);
264     // It might modify pBindInfos to support snapshot.
265     VkResult on_vkBindImageMemory2KHR(android::base::BumpPool* pool,
266                                       VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
267                                       uint32_t bindInfoCount,
268                                       const VkBindImageMemoryInfo* pBindInfos);
269 
270     VkResult on_vkCreateImageView(android::base::BumpPool* pool,
271                                   VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
272                                   const VkImageViewCreateInfo* pCreateInfo,
273                                   const VkAllocationCallbacks* pAllocator, VkImageView* pView);
274 
275     void on_vkDestroyImageView(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
276                                VkDevice device, VkImageView imageView,
277                                const VkAllocationCallbacks* pAllocator);
278 
279     VkResult on_vkCreateSampler(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
280                                 VkDevice device, const VkSamplerCreateInfo* pCreateInfo,
281                                 const VkAllocationCallbacks* pAllocator, VkSampler* pSampler);
282 
283     void on_vkDestroySampler(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
284                              VkDevice device, VkSampler sampler,
285                              const VkAllocationCallbacks* pAllocator);
286 
287     VkResult on_vkCreateDescriptorSetLayout(android::base::BumpPool* pool,
288                                             VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
289                                             const VkDescriptorSetLayoutCreateInfo* pCreateInfo,
290                                             const VkAllocationCallbacks* pAllocator,
291                                             VkDescriptorSetLayout* pSetLayout);
292 
293     void on_vkDestroyDescriptorSetLayout(android::base::BumpPool* pool,
294                                          VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
295                                          VkDescriptorSetLayout descriptorSetLayout,
296                                          const VkAllocationCallbacks* pAllocator);
297 
298     VkResult on_vkCreateDescriptorPool(android::base::BumpPool* pool,
299                                        VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
300                                        const VkDescriptorPoolCreateInfo* pCreateInfo,
301                                        const VkAllocationCallbacks* pAllocator,
302                                        VkDescriptorPool* pDescriptorPool);
303 
304     void on_vkDestroyDescriptorPool(android::base::BumpPool* pool,
305                                     VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
306                                     VkDescriptorPool descriptorPool,
307                                     const VkAllocationCallbacks* pAllocator);
308 
309     VkResult on_vkResetDescriptorPool(android::base::BumpPool* pool,
310                                       VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
311                                       VkDescriptorPool descriptorPool,
312                                       VkDescriptorPoolResetFlags flags);
313 
314     VkResult on_vkAllocateDescriptorSets(android::base::BumpPool* pool,
315                                          VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
316                                          const VkDescriptorSetAllocateInfo* pAllocateInfo,
317                                          VkDescriptorSet* pDescriptorSets);
318 
319     VkResult on_vkFreeDescriptorSets(android::base::BumpPool* pool,
320                                      VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
321                                      VkDescriptorPool descriptorPool, uint32_t descriptorSetCount,
322                                      const VkDescriptorSet* pDescriptorSets);
323 
324     void on_vkUpdateDescriptorSets(android::base::BumpPool* pool,
325                                    VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
326                                    uint32_t descriptorWriteCount,
327                                    const VkWriteDescriptorSet* pDescriptorWrites,
328                                    uint32_t descriptorCopyCount,
329                                    const VkCopyDescriptorSet* pDescriptorCopies);
330 
331     VkResult on_vkCreateShaderModule(android::base::BumpPool* pool,
332                                      VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
333                                      const VkShaderModuleCreateInfo* pCreateInfo,
334                                      const VkAllocationCallbacks* pAllocator,
335                                      VkShaderModule* pShaderModule);
336 
337     void on_vkDestroyShaderModule(android::base::BumpPool* pool,
338                                   VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
339                                   VkShaderModule shaderModule,
340                                   const VkAllocationCallbacks* pAllocator);
341 
342     VkResult on_vkCreatePipelineCache(android::base::BumpPool* pool,
343                                       VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
344                                       const VkPipelineCacheCreateInfo* pCreateInfo,
345                                       const VkAllocationCallbacks* pAllocator,
346                                       VkPipelineCache* pPipelineCache);
347 
348     void on_vkDestroyPipelineCache(android::base::BumpPool* pool,
349                                    VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
350                                    VkPipelineCache pipelineCache,
351                                    const VkAllocationCallbacks* pAllocator);
352 
353     VkResult on_vkCreatePipelineLayout(android::base::BumpPool* pool,
354                                       VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
355                                       const VkPipelineLayoutCreateInfo* pCreateInfo,
356                                       const VkAllocationCallbacks* pAllocator,
357                                       VkPipelineLayout* pPipelineLayout);
358 
359     void on_vkDestroyPipelineLayout(android::base::BumpPool* pool,
360                                    VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
361                                    VkPipelineLayout pipelineLayout,
362                                    const VkAllocationCallbacks* pAllocator);
363 
364     VkResult on_vkCreateGraphicsPipelines(android::base::BumpPool* pool,
365                                           VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
366                                           VkPipelineCache pipelineCache, uint32_t createInfoCount,
367                                           const VkGraphicsPipelineCreateInfo* pCreateInfos,
368                                           const VkAllocationCallbacks* pAllocator,
369                                           VkPipeline* pPipelines);
370 
371     VkResult on_vkCreateComputePipelines(android::base::BumpPool* pool,
372                                          VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
373                                          VkPipelineCache pipelineCache, uint32_t createInfoCount,
374                                          const VkComputePipelineCreateInfo* pCreateInfos,
375                                          const VkAllocationCallbacks* pAllocator,
376                                          VkPipeline* pPipelines);
377 
378     void on_vkDestroyPipeline(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
379                               VkDevice device, VkPipeline pipeline,
380                               const VkAllocationCallbacks* pAllocator);
381 
382     void on_vkCmdCopyBufferToImage(android::base::BumpPool* pool,
383                                    VkSnapshotApiCallInfo* snapshotInfo,
384                                    VkCommandBuffer commandBuffer, VkBuffer srcBuffer,
385                                    VkImage dstImage, VkImageLayout dstImageLayout,
386                                    uint32_t regionCount, const VkBufferImageCopy* pRegions,
387                                    const VkDecoderContext& context);
388 
389     void on_vkCmdCopyImage(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
390                            VkCommandBuffer commandBuffer, VkImage srcImage,
391                            VkImageLayout srcImageLayout, VkImage dstImage,
392                            VkImageLayout dstImageLayout, uint32_t regionCount,
393                            const VkImageCopy* pRegions);
394     void on_vkCmdCopyImageToBuffer(android::base::BumpPool* pool,
395                                    VkSnapshotApiCallInfo* snapshotInfo,
396                                    VkCommandBuffer commandBuffer, VkImage srcImage,
397                                    VkImageLayout srcImageLayout, VkBuffer dstBuffer,
398                                    uint32_t regionCount, const VkBufferImageCopy* pRegions);
399 
400     void on_vkCmdCopyBufferToImage2(android::base::BumpPool* pool,
401                                     VkSnapshotApiCallInfo* snapshotInfo,
402                                     VkCommandBuffer commandBuffer,
403                                     const VkCopyBufferToImageInfo2* pCopyBufferToImageInfo,
404                                     const VkDecoderContext& context);
405 
406     void on_vkCmdCopyImage2(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
407                             VkCommandBuffer commandBuffer, const VkCopyImageInfo2* pCopyImageInfo);
408     void on_vkCmdCopyImageToBuffer2(android::base::BumpPool* pool,
409                                     VkSnapshotApiCallInfo* snapshotInfo,
410                                     VkCommandBuffer commandBuffer,
411                                     const VkCopyImageToBufferInfo2* pCopyImageToBufferInfo);
412 
413     void on_vkCmdCopyBufferToImage2KHR(android::base::BumpPool* pool,
414                                        VkSnapshotApiCallInfo* snapshotInfo,
415                                        VkCommandBuffer commandBuffer,
416                                        const VkCopyBufferToImageInfo2KHR* pCopyBufferToImageInfo,
417                                        const VkDecoderContext& context);
418 
419     void on_vkCmdCopyImage2KHR(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
420                                VkCommandBuffer commandBuffer,
421                                const VkCopyImageInfo2KHR* pCopyImageInfo);
422     void on_vkCmdCopyImageToBuffer2KHR(android::base::BumpPool* pool,
423                                        VkSnapshotApiCallInfo* snapshotInfo,
424                                        VkCommandBuffer commandBuffer,
425                                        const VkCopyImageToBufferInfo2KHR* pCopyImageToBufferInfo);
426 
427     void on_vkGetImageMemoryRequirements(android::base::BumpPool* pool,
428                                          VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
429                                          VkImage image, VkMemoryRequirements* pMemoryRequirements);
430 
431     void on_vkGetImageMemoryRequirements2(android::base::BumpPool* pool,
432                                           VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
433                                           const VkImageMemoryRequirementsInfo2* pInfo,
434                                           VkMemoryRequirements2* pMemoryRequirements);
435 
436     void on_vkGetImageMemoryRequirements2KHR(android::base::BumpPool* pool,
437                                              VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
438                                              const VkImageMemoryRequirementsInfo2* pInfo,
439                                              VkMemoryRequirements2* pMemoryRequirements);
440 
441     void on_vkGetBufferMemoryRequirements(android::base::BumpPool* pool,
442                                           VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
443                                           VkBuffer buffer,
444                                           VkMemoryRequirements* pMemoryRequirements);
445 
446     void on_vkGetBufferMemoryRequirements2(android::base::BumpPool* pool,
447                                            VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
448                                            const VkBufferMemoryRequirementsInfo2* pInfo,
449                                            VkMemoryRequirements2* pMemoryRequirements);
450 
451     void on_vkGetBufferMemoryRequirements2KHR(android::base::BumpPool* pool,
452                                               VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
453                                               const VkBufferMemoryRequirementsInfo2* pInfo,
454                                               VkMemoryRequirements2* pMemoryRequirements);
455 
456     void on_vkCmdPipelineBarrier(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
457                                  VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask,
458                                  VkPipelineStageFlags dstStageMask,
459                                  VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount,
460                                  const VkMemoryBarrier* pMemoryBarriers,
461                                  uint32_t bufferMemoryBarrierCount,
462                                  const VkBufferMemoryBarrier* pBufferMemoryBarriers,
463                                  uint32_t imageMemoryBarrierCount,
464                                  const VkImageMemoryBarrier* pImageMemoryBarriers);
465 
466     void on_vkCmdPipelineBarrier2(android::base::BumpPool* pool,
467                                   VkSnapshotApiCallInfo* snapshotInfo,
468                                   VkCommandBuffer commandBuffer,
469                                   const VkDependencyInfo* pDependencyInfo);
470 
471     // Do we need to wrap vk(Create|Destroy)Instance to
472     // update our maps of VkDevices? Spec suggests no:
473     // https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkDestroyInstance.html
474     // Valid Usage
475     // All child objects created using instance
476     // must have been destroyed prior to destroying instance
477     //
478     // This suggests that we should emulate the invalid behavior by
479     // not destroying our own VkDevice maps on instance destruction.
480 
481     VkResult on_vkAllocateMemory(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
482                                  VkDevice device, const VkMemoryAllocateInfo* pAllocateInfo,
483                                  const VkAllocationCallbacks* pAllocator, VkDeviceMemory* pMemory);
484 
485     void on_vkFreeMemory(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
486                          VkDevice device, VkDeviceMemory memory,
487                          const VkAllocationCallbacks* pAllocator);
488 
489     VkResult on_vkMapMemory(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
490                             VkDevice device, VkDeviceMemory memory, VkDeviceSize offset,
491                             VkDeviceSize size, VkMemoryMapFlags flags, void** ppData);
492 
493     void on_vkUnmapMemory(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
494                           VkDevice device, VkDeviceMemory memory);
495 
496     uint8_t* getMappedHostPointer(VkDeviceMemory memory);
497     VkDeviceSize getDeviceMemorySize(VkDeviceMemory memory);
498     bool usingDirectMapping() const;
499 
500     struct HostFeatureSupport {
501         bool supportsVulkan = false;
502         bool supportsVulkan1_1 = false;
503         bool useDeferredCommands = false;
504         bool useCreateResourcesWithRequirements = false;
505         uint32_t apiVersion = 0;
506         uint32_t driverVersion = 0;
507         uint32_t deviceID = 0;
508         uint32_t vendorID = 0;
509     };
510 
511     HostFeatureSupport getHostFeatureSupport() const;
512 
513     // VK_ANDROID_native_buffer
514     VkResult on_vkGetSwapchainGrallocUsageANDROID(android::base::BumpPool* pool,
515                                                   VkSnapshotApiCallInfo* snapshotInfo,
516                                                   VkDevice device, VkFormat format,
517                                                   VkImageUsageFlags imageUsage, int* grallocUsage);
518     VkResult on_vkGetSwapchainGrallocUsage2ANDROID(
519         android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
520         VkFormat format, VkImageUsageFlags imageUsage,
521         VkSwapchainImageUsageFlagsANDROID swapchainImageUsage, uint64_t* grallocConsumerUsage,
522         uint64_t* grallocProducerUsage);
523     VkResult on_vkAcquireImageANDROID(android::base::BumpPool* pool,
524                                       VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
525                                       VkImage image, int nativeFenceFd, VkSemaphore semaphore,
526                                       VkFence fence);
527     VkResult on_vkQueueSignalReleaseImageANDROID(android::base::BumpPool* pool,
528                                                  VkSnapshotApiCallInfo* snapshotInfo, VkQueue queue,
529                                                  uint32_t waitSemaphoreCount,
530                                                  const VkSemaphore* pWaitSemaphores, VkImage image,
531                                                  int* pNativeFenceFd);
532 
533     // VK_GOOGLE_gfxstream
534     VkResult on_vkMapMemoryIntoAddressSpaceGOOGLE(android::base::BumpPool* pool,
535                                                   VkSnapshotApiCallInfo* snapshotInfo,
536                                                   VkDevice device, VkDeviceMemory memory,
537                                                   uint64_t* pAddress);
538     VkResult on_vkGetMemoryHostAddressInfoGOOGLE(android::base::BumpPool* pool,
539                                                  VkSnapshotApiCallInfo* snapshotInfo,
540                                                  VkDevice device, VkDeviceMemory memory,
541                                                  uint64_t* pAddress, uint64_t* pSize,
542                                                  uint64_t* pHostmemId);
543     VkResult on_vkGetBlobGOOGLE(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
544                                 VkDevice device, VkDeviceMemory memory);
545 
546     VkResult on_vkFreeMemorySyncGOOGLE(android::base::BumpPool* pool,
547                                        VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
548                                        VkDeviceMemory memory,
549                                        const VkAllocationCallbacks* pAllocator);
550 
551     VkResult on_vkAllocateCommandBuffers(android::base::BumpPool* pool,
552                                          VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
553                                          const VkCommandBufferAllocateInfo* pAllocateInfo,
554                                          VkCommandBuffer* pCommandBuffers);
555 
556     void on_vkCmdExecuteCommands(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
557                                  VkCommandBuffer commandBuffer, uint32_t commandBufferCount,
558                                  const VkCommandBuffer* pCommandBuffers);
559 
560     VkResult on_vkQueueSubmit(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
561                               VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits,
562                               VkFence fence);
563 
564     VkResult on_vkQueueSubmit2(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
565                                VkQueue queue, uint32_t submitCount, const VkSubmitInfo2* pSubmits,
566                                VkFence fence);
567 
568     VkResult on_vkQueueWaitIdle(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
569                                 VkQueue queue);
570 
571     VkResult on_vkResetCommandBuffer(android::base::BumpPool* pool,
572                                      VkSnapshotApiCallInfo* snapshotInfo,
573                                      VkCommandBuffer commandBuffer,
574                                      VkCommandBufferResetFlags flags);
575 
576     void on_vkFreeCommandBuffers(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
577                                  VkDevice device, VkCommandPool commandPool,
578                                  uint32_t commandBufferCount,
579                                  const VkCommandBuffer* pCommandBuffers);
580 
581     VkResult on_vkCreateCommandPool(android::base::BumpPool* pool,
582                                     VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
583                                     const VkCommandPoolCreateInfo* pCreateInfo,
584                                     const VkAllocationCallbacks* pAllocator,
585                                     VkCommandPool* pCommandPool);
586 
587     void on_vkDestroyCommandPool(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
588                                  VkDevice device, VkCommandPool commandPool,
589                                  const VkAllocationCallbacks* pAllocator);
590 
591     VkResult on_vkResetCommandPool(android::base::BumpPool* pool,
592                                    VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
593                                    VkCommandPool commandPool, VkCommandPoolResetFlags flags);
594 
595     void on_vkGetPhysicalDeviceExternalSemaphoreProperties(
596         android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
597         VkPhysicalDevice physicalDevice,
598         const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo,
599         VkExternalSemaphoreProperties* pExternalSemaphoreProperties);
600 
601     void on_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR(
602         android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
603         VkPhysicalDevice physicalDevice,
604         const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo,
605         VkExternalSemaphoreProperties* pExternalSemaphoreProperties);
606 
607     VkResult on_vkCreateSemaphore(android::base::BumpPool* pool,
608                                   VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
609                                   const VkSemaphoreCreateInfo* pCreateInfo,
610                                   const VkAllocationCallbacks* pAllocator, VkSemaphore* pSemaphore);
611     VkResult on_vkImportSemaphoreFdKHR(android::base::BumpPool* pool,
612                                        VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
613                                        const VkImportSemaphoreFdInfoKHR* pImportSemaphoreFdInfo);
614     VkResult on_vkGetSemaphoreFdKHR(android::base::BumpPool* pool,
615                                     VkSnapshotApiCallInfo* snapshotInfo, VkDevice boxed_device,
616                                     const VkSemaphoreGetFdInfoKHR* pGetFdInfo, int* pFd);
617     VkResult on_vkGetSemaphoreGOOGLE(android::base::BumpPool* pool,
618                                      VkSnapshotApiCallInfo* snapshotInfo, VkDevice boxed_device,
619                                      VkSemaphore semaphore, uint64_t syncId);
620     void on_vkDestroySemaphore(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
621                                VkDevice boxed_device, VkSemaphore semaphore,
622                                const VkAllocationCallbacks* pAllocator);
623     VkResult on_vkWaitSemaphores(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
624         VkDevice boxed_device, const VkSemaphoreWaitInfo* pWaitInfo, uint64_t timeout);
625     VkResult on_vkSignalSemaphore(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
626         VkDevice boxed_device, const VkSemaphoreSignalInfo* pSignalInfo);
627 
628     VkResult on_vkCreateFence(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
629                               VkDevice device, const VkFenceCreateInfo* pCreateInfo,
630                               const VkAllocationCallbacks* pAllocator, VkFence* pFence);
631     VkResult on_vkGetFenceStatus(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
632                                  VkDevice device, VkFence pFence);
633     VkResult on_vkWaitForFences(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
634                                 VkDevice device, uint32_t fenceCount, const VkFence* pFences,
635                                 VkBool32 waitAll, uint64_t timeout);
636     VkResult on_vkResetFences(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
637                               VkDevice device, uint32_t fenceCount, const VkFence* pFences);
638     void on_vkDestroyFence(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
639                            VkDevice device, VkFence fence, const VkAllocationCallbacks* pAllocator);
640 
641     // Descriptor update templates
642     VkResult on_vkCreateDescriptorUpdateTemplate(
643         android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo, VkDevice boxed_device,
644         const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo,
645         const VkAllocationCallbacks* pAllocator,
646         VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate);
647 
648     VkResult on_vkCreateDescriptorUpdateTemplateKHR(
649         android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo, VkDevice boxed_device,
650         const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo,
651         const VkAllocationCallbacks* pAllocator,
652         VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate);
653 
654     void on_vkDestroyDescriptorUpdateTemplate(android::base::BumpPool* pool,
655                                               VkSnapshotApiCallInfo* snapshotInfo,
656                                               VkDevice boxed_device,
657                                               VkDescriptorUpdateTemplate descriptorUpdateTemplate,
658                                               const VkAllocationCallbacks* pAllocator);
659 
660     void on_vkDestroyDescriptorUpdateTemplateKHR(
661         android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo, VkDevice boxed_device,
662         VkDescriptorUpdateTemplate descriptorUpdateTemplate,
663         const VkAllocationCallbacks* pAllocator);
664 
665     void on_vkUpdateDescriptorSetWithTemplateSizedGOOGLE(
666         android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo, VkDevice boxed_device,
667         VkDescriptorSet descriptorSet, VkDescriptorUpdateTemplate descriptorUpdateTemplate,
668         uint32_t imageInfoCount, uint32_t bufferInfoCount, uint32_t bufferViewCount,
669         const uint32_t* pImageInfoEntryIndices, const uint32_t* pBufferInfoEntryIndices,
670         const uint32_t* pBufferViewEntryIndices, const VkDescriptorImageInfo* pImageInfos,
671         const VkDescriptorBufferInfo* pBufferInfos, const VkBufferView* pBufferViews);
672 
673     void on_vkUpdateDescriptorSetWithTemplateSized2GOOGLE(
674         android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo, VkDevice boxed_device,
675         VkDescriptorSet descriptorSet, VkDescriptorUpdateTemplate descriptorUpdateTemplate,
676         uint32_t imageInfoCount, uint32_t bufferInfoCount, uint32_t bufferViewCount,
677         uint32_t inlineUniformBlockCount, const uint32_t* pImageInfoEntryIndices,
678         const uint32_t* pBufferInfoEntryIndices, const uint32_t* pBufferViewEntryIndices,
679         const VkDescriptorImageInfo* pImageInfos, const VkDescriptorBufferInfo* pBufferInfos,
680         const VkBufferView* pBufferViews, const uint8_t* pInlineUniformBlockData);
681 
682     VkResult on_vkBeginCommandBuffer(android::base::BumpPool* pool,
683                                      VkSnapshotApiCallInfo* snapshotInfo,
684                                      VkCommandBuffer commandBuffer,
685                                      const VkCommandBufferBeginInfo* pBeginInfo,
686                                      const VkDecoderContext& context);
687     void on_vkBeginCommandBufferAsyncGOOGLE(android::base::BumpPool* pool,
688                                             VkSnapshotApiCallInfo* snapshotInfo,
689                                             VkCommandBuffer commandBuffer,
690                                             const VkCommandBufferBeginInfo* pBeginInfo,
691                                             const VkDecoderContext& context);
692     VkResult on_vkEndCommandBuffer(android::base::BumpPool* pool,
693                                    VkSnapshotApiCallInfo* snapshotInfo,
694                                    VkCommandBuffer commandBuffer, const VkDecoderContext& context);
695     void on_vkEndCommandBufferAsyncGOOGLE(android::base::BumpPool* pool,
696                                           VkSnapshotApiCallInfo* snapshotInfo,
697                                           VkCommandBuffer commandBuffer,
698                                           const VkDecoderContext& context);
699     void on_vkResetCommandBufferAsyncGOOGLE(android::base::BumpPool* pool,
700                                             VkSnapshotApiCallInfo* snapshotInfo,
701                                             VkCommandBuffer commandBuffer,
702                                             VkCommandBufferResetFlags flags);
703     void on_vkCommandBufferHostSyncGOOGLE(android::base::BumpPool* pool,
704                                           VkSnapshotApiCallInfo* snapshotInfo,
705                                           VkCommandBuffer commandBuffer, uint32_t needHostSync,
706                                           uint32_t sequenceNumber);
707 
708     VkResult on_vkCreateImageWithRequirementsGOOGLE(
709         android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
710         const VkImageCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator,
711         VkImage* pImage, VkMemoryRequirements* pMemoryRequirements);
712     VkResult on_vkCreateBufferWithRequirementsGOOGLE(
713         android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
714         const VkBufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator,
715         VkBuffer* pBuffer, VkMemoryRequirements* pMemoryRequirements);
716 
717     void on_vkCmdBindPipeline(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
718                               VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint,
719                               VkPipeline pipeline);
720 
721     void on_vkCmdBindDescriptorSets(android::base::BumpPool* pool,
722                                     VkSnapshotApiCallInfo* snapshotInfo,
723                                     VkCommandBuffer commandBuffer,
724                                     VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout,
725                                     uint32_t firstSet, uint32_t descriptorSetCount,
726                                     const VkDescriptorSet* pDescriptorSets,
727                                     uint32_t dynamicOffsetCount, const uint32_t* pDynamicOffsets);
728 
729     VkResult on_vkCreateRenderPass(android::base::BumpPool* pool,
730                                    VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
731                                    const VkRenderPassCreateInfo* pCreateInfo,
732                                    const VkAllocationCallbacks* pAllocator,
733                                    VkRenderPass* pRenderPass);
734     VkResult on_vkCreateRenderPass2(android::base::BumpPool* pool,
735                                     VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
736                                     const VkRenderPassCreateInfo2* pCreateInfo,
737                                     const VkAllocationCallbacks* pAllocator,
738                                     VkRenderPass* pRenderPass);
739     VkResult on_vkCreateRenderPass2KHR(android::base::BumpPool* pool,
740                                        VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
741                                        const VkRenderPassCreateInfo2KHR* pCreateInfo,
742                                        const VkAllocationCallbacks* pAllocator,
743                                        VkRenderPass* pRenderPass);
744     void on_vkDestroyRenderPass(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
745                                 VkDevice device, VkRenderPass renderPass,
746                                 const VkAllocationCallbacks* pAllocator);
747     void on_vkCmdBeginRenderPass(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
748                                  VkCommandBuffer commandBuffer,
749                                  const VkRenderPassBeginInfo* pRenderPassBegin,
750                                  VkSubpassContents contents);
751     void on_vkCmdBeginRenderPass2(android::base::BumpPool* pool,
752                                   VkSnapshotApiCallInfo* snapshotInfo,
753                                   VkCommandBuffer commandBuffer,
754                                   const VkRenderPassBeginInfo* pRenderPassBegin,
755                                   const VkSubpassBeginInfo* pSubpassBeginInfo);
756     void on_vkCmdBeginRenderPass2KHR(android::base::BumpPool* pool,
757                                      VkSnapshotApiCallInfo* snapshotInfo,
758                                      VkCommandBuffer commandBuffer,
759                                      const VkRenderPassBeginInfo* pRenderPassBegin,
760                                      const VkSubpassBeginInfo* pSubpassBeginInfo);
761 
762     VkResult on_vkCreateFramebuffer(android::base::BumpPool* pool,
763                                     VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
764                                     const VkFramebufferCreateInfo* pCreateInfo,
765                                     const VkAllocationCallbacks* pAllocator,
766                                     VkFramebuffer* pFramebuffer);
767     void on_vkDestroyFramebuffer(android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo,
768                                  VkDevice device, VkFramebuffer framebuffer,
769                                  const VkAllocationCallbacks* pAllocator);
770 
771     void on_vkCmdCopyQueryPoolResults(android::base::BumpPool* pool,
772                                       VkSnapshotApiCallInfo* snapshotInfo,
773                                       VkCommandBuffer commandBuffer, VkQueryPool queryPool,
774                                       uint32_t firstQuery, uint32_t queryCount, VkBuffer dstBuffer,
775                                       VkDeviceSize dstOffset, VkDeviceSize stride,
776                                       VkQueryResultFlags flags);
777 
778     // VK_GOOGLE_gfxstream
779     void on_vkQueueHostSyncGOOGLE(android::base::BumpPool* pool,
780                                   VkSnapshotApiCallInfo* snapshotInfo, VkQueue queue,
781                                   uint32_t needHostSync, uint32_t sequenceNumber);
782     void on_vkQueueSubmitAsyncGOOGLE(android::base::BumpPool* pool,
783                                      VkSnapshotApiCallInfo* snapshotInfo, VkQueue queue,
784                                      uint32_t submitCount, const VkSubmitInfo* pSubmits,
785                                      VkFence fence);
786     void on_vkQueueSubmitAsync2GOOGLE(android::base::BumpPool* pool,
787                                       VkSnapshotApiCallInfo* snapshotInfo, VkQueue queue,
788                                       uint32_t submitCount, const VkSubmitInfo2* pSubmits,
789                                       VkFence fence);
790     void on_vkQueueWaitIdleAsyncGOOGLE(android::base::BumpPool* pool,
791                                        VkSnapshotApiCallInfo* snapshotInfo, VkQueue queue);
792     void on_vkQueueBindSparseAsyncGOOGLE(android::base::BumpPool* pool,
793                                          VkSnapshotApiCallInfo* snapshotInfo, VkQueue queue,
794                                          uint32_t bindInfoCount, const VkBindSparseInfo* pBindInfo,
795                                          VkFence fence);
796 
797     // VK_GOOGLE_gfxstream
798     void on_vkGetLinearImageLayoutGOOGLE(android::base::BumpPool* pool,
799                                          VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
800                                          VkFormat format, VkDeviceSize* pOffset,
801                                          VkDeviceSize* pRowPitchAlignment);
802     void on_vkGetLinearImageLayout2GOOGLE(android::base::BumpPool* pool,
803                                           VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
804                                           const VkImageCreateInfo* pCreateInfo,
805                                           VkDeviceSize* pOffset, VkDeviceSize* pRowPitchAlignment);
806 
807     // VK_GOOGLE_gfxstream
808     void on_vkQueueFlushCommandsGOOGLE(android::base::BumpPool* pool,
809                                        VkSnapshotApiCallInfo* snapshotInfo, VkQueue queue,
810                                        VkCommandBuffer commandBuffer, VkDeviceSize dataSize,
811                                        const void* pData, const VkDecoderContext& context);
812     void on_vkQueueFlushCommandsFromAuxMemoryGOOGLE(android::base::BumpPool* pool,
813                                                     VkSnapshotApiCallInfo* snapshotInfo,
814                                                     VkQueue queue, VkCommandBuffer commandBuffer,
815                                                     VkDeviceMemory deviceMemory,
816                                                     VkDeviceSize dataOffset, VkDeviceSize dataSize,
817                                                     const VkDecoderContext& context);
818     void on_vkQueueCommitDescriptorSetUpdatesGOOGLE(
819         android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo, VkQueue queue,
820         uint32_t descriptorPoolCount, const VkDescriptorPool* pDescriptorPools,
821         uint32_t descriptorSetCount, const VkDescriptorSetLayout* pDescriptorSetLayouts,
822         const uint64_t* pDescriptorSetPoolIds, const uint32_t* pDescriptorSetWhichPool,
823         const uint32_t* pDescriptorSetPendingAllocation,
824         const uint32_t* pDescriptorWriteStartingIndices, uint32_t pendingDescriptorWriteCount,
825         const VkWriteDescriptorSet* pPendingDescriptorWrites);
826     void on_vkCollectDescriptorPoolIdsGOOGLE(android::base::BumpPool* pool,
827                                              VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
828                                              VkDescriptorPool descriptorPool,
829                                              uint32_t* pPoolIdCount, uint64_t* pPoolIds);
830     VkResult on_vkQueueBindSparse(android::base::BumpPool* pool,
831                                   VkSnapshotApiCallInfo* snapshotInfo, VkQueue queue,
832                                   uint32_t bindInfoCount, const VkBindSparseInfo* pBindInfo,
833                                   VkFence fence);
834     void on_vkQueueSignalReleaseImageANDROIDAsyncGOOGLE(android::base::BumpPool* pool,
835                                                         VkSnapshotApiCallInfo* snapshotInfo,
836                                                         VkQueue queue, uint32_t waitSemaphoreCount,
837                                                         const VkSemaphore* pWaitSemaphores,
838                                                         VkImage image);
839     VkResult on_vkQueuePresentKHR(android::base::BumpPool* pool,
840                                   VkSnapshotApiCallInfo* snapshotInfo, VkQueue queue,
841                                   const VkPresentInfoKHR* pPresentInfo);
842 
843     VkResult on_vkCreateSamplerYcbcrConversion(
844         android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
845         const VkSamplerYcbcrConversionCreateInfo* pCreateInfo,
846         const VkAllocationCallbacks* pAllocator, VkSamplerYcbcrConversion* pYcbcrConversion);
847     VkResult on_vkCreateSamplerYcbcrConversionKHR(
848         android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
849         const VkSamplerYcbcrConversionCreateInfo* pCreateInfo,
850         const VkAllocationCallbacks* pAllocator, VkSamplerYcbcrConversion* pYcbcrConversion);
851     void on_vkDestroySamplerYcbcrConversion(android::base::BumpPool* pool,
852                                             VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
853                                             VkSamplerYcbcrConversion ycbcrConversion,
854                                             const VkAllocationCallbacks* pAllocator);
855     void on_vkDestroySamplerYcbcrConversionKHR(android::base::BumpPool* pool,
856                                                VkSnapshotApiCallInfo* snapshotInfo, VkDevice device,
857                                                VkSamplerYcbcrConversion ycbcrConversion,
858                                                const VkAllocationCallbacks* pAllocator);
859 
860     VkResult on_vkEnumeratePhysicalDeviceGroups(
861         android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo, VkInstance instance,
862         uint32_t* pPhysicalDeviceGroupCount,
863         VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties);
864     VkResult on_vkEnumeratePhysicalDeviceGroupsKHR(
865         android::base::BumpPool* pool, VkSnapshotApiCallInfo* snapshotInfo, VkInstance instance,
866         uint32_t* pPhysicalDeviceGroupCount,
867         VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties);
868 
869     void on_DeviceLost();
870 
871     void on_CheckOutOfMemory(VkResult result, uint32_t opCode, const VkDecoderContext& context,
872                              std::optional<uint64_t> allocationSize = std::nullopt);
873 
874     // Fence waits
875     VkResult waitForFence(VkFence boxed_fence, uint64_t timeout);
876 
877     // Wait for present (vkQueueSignalReleaseImageANDROID). This explicitly
878     // requires the image to be presented again versus how many times it's been
879     // presented so far, so it ends up incrementing a "target present count"
880     // for this image, and then waiting for the image to get vkQSRI'ed at least
881     // that many times.
882     AsyncResult registerQsriCallback(VkImage boxed_image, VkQsriTimeline::Callback callback);
883 
884     // Transformations
885     void deviceMemoryTransform_tohost(VkDeviceMemory* memory, uint32_t memoryCount,
886                                       VkDeviceSize* offset, uint32_t offsetCount,
887                                       VkDeviceSize* size, uint32_t sizeCount, uint32_t* typeIndex,
888                                       uint32_t typeIndexCount, uint32_t* typeBits,
889                                       uint32_t typeBitsCount);
890     void deviceMemoryTransform_fromhost(VkDeviceMemory* memory, uint32_t memoryCount,
891                                         VkDeviceSize* offset, uint32_t offsetCount,
892                                         VkDeviceSize* size, uint32_t sizeCount, uint32_t* typeIndex,
893                                         uint32_t typeIndexCount, uint32_t* typeBits,
894                                         uint32_t typeBitsCount);
895 
896     // Snapshot access
897     VkDecoderSnapshot* snapshot();
898 
899     // get a generic handle, this handle
900     // currently is used to represent some
901     // action related api call, such as
902     // vkUpdateDescriptorSets, vkBeginCommandBuffer,
903     // vkCmd***
904     // this generic handle differs from other
905     // cration handles (such as vkAllocate***,
906     // vkCreate***); but important for snapshoter
907     // to use this generic handle to represent some
908     // actions and their dependency. with this,
909     // the action apis will naturally fit into
910     // the dependency graph to ensure correct
911     // ordering of api calls during snapshot save and during
912     // snapshot load; this will deprecate the current
913     // approach of appending "modifying api's"
914     // near the end of snapshot save and loading; the reason
915     // to deprecate the modifying api approach is that it
916     // cannot handle dependencies properly.
917     uint64_t newGlobalVkGenericHandle();
918 
919 #define DEFINE_TRANSFORMED_TYPE_PROTOTYPE(type)                \
920     void transformImpl_##type##_tohost(const type*, uint32_t); \
921     void transformImpl_##type##_fromhost(const type*, uint32_t);
922 
923     LIST_TRANSFORMED_TYPES(DEFINE_TRANSFORMED_TYPE_PROTOTYPE)
924 
925    private:
926     class Impl;
927     std::unique_ptr<Impl> mImpl;
928 };
929 
930 }  // namespace vk
931 }  // namespace gfxstream
932