blob: e5b7cce32707b829275b9b2d1896664b3e6f8baf [file] [log] [blame]
/*
* Copyright 2015, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* THIS FILE WAS GENERATED BY apic. DO NOT EDIT.
*/
#include "abort_exception.h"
#include "vulkan_imports.h"
#include "vulkan_types.h"
#include "vulkan_spy.h"
#include <gapic/log.h>
#include <gapic/coder/memory.h>
#include <gapic/coder/atom.h>
#include <gapic/coder/vulkan.h>
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#include <stdint.h>
#include <memory>
#include <string>
namespace gapii {
uint32_t VulkanSpy::vkAcquireImageANDROID(CallObserver* observer, VkDevice device, VkImage image, int nativeFenceFd, VkSemaphore semaphore, VkFence fence) {
GAPID_DEBUG("vkAcquireImageANDROID(%zu, %" PRIu64 ", %d, %" PRIu64 ", %" PRIu64 ")", device, image, nativeFenceFd, semaphore, fence);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkAcquireImageANDROID == nullptr) {
GAPID_WARNING("Application called unsupported function vkAcquireImageANDROID");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, device, image, nativeFenceFd, semaphore, fence] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[device].vkAcquireImageANDROID(device, image, nativeFenceFd, semaphore, fence);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
call();
break;
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::vulkan::VkAcquireImageANDROID coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< uint64_t >(image, *observer->getScratch()), nativeFenceFd, toEncoder< uint64_t >(semaphore, *observer->getScratch()), toEncoder< uint64_t >(fence, *observer->getScratch()), result);
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
return result;
}
uint32_t VulkanSpy::vkQueueSignalReleaseImageANDROID(CallObserver* observer, VkQueue queue, uint32_t waitSemaphoreCount, VkSemaphore* pWaitSemaphores, VkImage image, int* pNativeFenceFd) {
GAPID_DEBUG("vkQueueSignalReleaseImageANDROID(%zu, %" PRIu32 ", %p, %" PRIu64 ", %p)", queue, waitSemaphoreCount, pWaitSemaphores, image, pNativeFenceFd);
if (Queues.find(queue) == Queues.end() ||
mImports.mVkDeviceFunctions.find(Queues[queue]->mDevice) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[Queues[queue]->mDevice].vkQueueSignalReleaseImageANDROID == nullptr) {
GAPID_WARNING("Application called unsupported function vkQueueSignalReleaseImageANDROID");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, queue, waitSemaphoreCount, pWaitSemaphores, image, pNativeFenceFd] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[Queues[queue]->mDevice].vkQueueSignalReleaseImageANDROID(queue, waitSemaphoreCount, pWaitSemaphores, image, pNativeFenceFd);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
call();
break;
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::vulkan::VkQueueSignalReleaseImageANDROID coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(queue, *observer->getScratch()), waitSemaphoreCount, toEncoder< gapic::coder::vulkan::VkSemaphore__CP >(pWaitSemaphores, *observer->getScratch()), toEncoder< uint64_t >(image, *observer->getScratch()), toEncoder< gapic::coder::vulkan::Int__P >(pNativeFenceFd, *observer->getScratch()), result);
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
return result;
}
void VulkanSpy::vkGetPhysicalDeviceFeatures(CallObserver* observer, VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures* pFeatures) {
GAPID_DEBUG("vkGetPhysicalDeviceFeatures(%zu, %p)", physicalDevice, pFeatures);
if (PhysicalDevices.find(physicalDevice) == PhysicalDevices.end() ||
mImports.mVkInstanceFunctions.find(PhysicalDevices[physicalDevice]->mInstance) == mImports.mVkInstanceFunctions.end() ||
mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkGetPhysicalDeviceFeatures == nullptr) {
GAPID_WARNING("Application called unsupported function vkGetPhysicalDeviceFeatures");
return;
}
bool called = false;
auto call = [this, observer, &called, physicalDevice, pFeatures] {
called = true;
observer->observeReads();
mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkGetPhysicalDeviceFeatures(physicalDevice, pFeatures);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
call();
observer->write<VkPhysicalDeviceFeatures>(slice(pFeatures, 0ULL, 1ULL), 0ULL, slice(pFeatures, 0ULL, 1ULL)[0ULL]);
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::vulkan::VkGetPhysicalDeviceFeatures coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(physicalDevice, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkPhysicalDeviceFeatures__P >(pFeatures, *observer->getScratch()));
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
}
PFN_vkVoidFunction VulkanSpy::vkGetInstanceProcAddr(CallObserver* observer, VkInstance instance, const char* pName) {
GAPID_DEBUG("vkGetInstanceProcAddr(%zu, %s)", instance, pName);
PFN_vkVoidFunction result = nullptr;
bool called = false;
auto call = [this, observer, &called, &result, instance, pName] {
called = true;
observer->observeReads();
result = SpyOverride_vkGetInstanceProcAddr(instance, pName);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
call();
break;
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::vulkan::VkGetInstanceProcAddr coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(instance, *observer->getScratch()), toEncoder< const char* >(pName, *observer->getScratch()), toEncoder< gapic::coder::vulkan::PFN_vkVoidFunction >(result, *observer->getScratch()));
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
return result;
}
uint32_t VulkanSpy::vkEnumerateDeviceExtensionProperties(CallObserver* observer, VkPhysicalDevice physicalDevice, const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties) {
GAPID_DEBUG("vkEnumerateDeviceExtensionProperties(%zu, %s, %p, %p)", physicalDevice, pLayerName, pPropertyCount, pProperties);
if (PhysicalDevices.find(physicalDevice) == PhysicalDevices.end() ||
mImports.mVkInstanceFunctions.find(PhysicalDevices[physicalDevice]->mInstance) == mImports.mVkInstanceFunctions.end() ||
mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkEnumerateDeviceExtensionProperties == nullptr) {
GAPID_WARNING("Application called unsupported function vkEnumerateDeviceExtensionProperties");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, physicalDevice, pLayerName, pPropertyCount, pProperties] {
called = true;
observer->observeReads();
result = mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkEnumerateDeviceExtensionProperties(physicalDevice, pLayerName, pPropertyCount, pProperties);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
call();
subQueryExtensionProperties(observer, call, pPropertyCount, pProperties);
break;
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::vulkan::VkEnumerateDeviceExtensionProperties coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(physicalDevice, *observer->getScratch()), toEncoder< const char* >(pLayerName, *observer->getScratch()), toEncoder< gapic::coder::vulkan::U32__P >(pPropertyCount, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkExtensionProperties__P >(pProperties, *observer->getScratch()), result);
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
return result;
}
uint32_t VulkanSpy::vkEnumerateDeviceLayerProperties(CallObserver* observer, VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkLayerProperties* pProperties) {
GAPID_DEBUG("vkEnumerateDeviceLayerProperties(%zu, %p, %p)", physicalDevice, pPropertyCount, pProperties);
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, physicalDevice, pPropertyCount, pProperties] {
called = true;
observer->observeReads();
result = SpyOverride_vkEnumerateDeviceLayerProperties(physicalDevice, pPropertyCount, pProperties);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
call();
subQueryLayerProperties(observer, call, pPropertyCount, pProperties);
break;
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::vulkan::VkEnumerateDeviceLayerProperties coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(physicalDevice, *observer->getScratch()), toEncoder< gapic::coder::vulkan::U32__P >(pPropertyCount, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkLayerProperties__P >(pProperties, *observer->getScratch()), result);
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
return result;
}
uint32_t VulkanSpy::vkQueueWaitIdle(CallObserver* observer, VkQueue queue) {
GAPID_DEBUG("vkQueueWaitIdle(%zu)", queue);
if (Queues.find(queue) == Queues.end() ||
mImports.mVkDeviceFunctions.find(Queues[queue]->mDevice) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[Queues[queue]->mDevice].vkQueueWaitIdle == nullptr) {
GAPID_WARNING("Application called unsupported function vkQueueWaitIdle");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, queue] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[Queues[queue]->mDevice].vkQueueWaitIdle(queue);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
call();
break;
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::vulkan::VkQueueWaitIdle coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(queue, *observer->getScratch()), result);
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
return result;
}
uint32_t VulkanSpy::vkAllocateMemory(CallObserver* observer, VkDevice device, VkMemoryAllocateInfo* pAllocateInfo, VkAllocationCallbacks* pAllocator, VkDeviceMemory* pMemory) {
GAPID_DEBUG("vkAllocateMemory(%zu, %p, %p, %p)", device, pAllocateInfo, pAllocator, pMemory);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkAllocateMemory == nullptr) {
GAPID_WARNING("Application called unsupported function vkAllocateMemory");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, device, pAllocateInfo, pAllocator, pMemory] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[device].vkAllocateMemory(device, pAllocateInfo, pAllocator, pMemory);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
VkMemoryAllocateInfo l_allocateInfo = observer->read(slice(pAllocateInfo, 0ULL, 1ULL), 0ULL);
if ((l_allocateInfo.mpNext) != (nullptr)) {
uint32_t l_t = observer->read(slice((uint32_t*)(l_allocateInfo.mpNext), 0ULL, 1ULL), 0ULL);
switch (l_t) {
case VkStructureType::VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV: {
(void)observer->read(slice((VkDedicatedAllocationMemoryAllocateInfoNV*)(l_allocateInfo.mpNext), 0ULL, 1ULL), 0ULL);
break;
}
}
}
call();
auto l_memory = slice(pMemory, 0ULL, 1ULL)[0ULL];
std::shared_ptr<DeviceMemoryObject> l_memoryObject = std::shared_ptr<DeviceMemoryObject>(new DeviceMemoryObject(device, l_memory, l_allocateInfo.mallocationSize, U64ToVkDeviceSize(), (VkDeviceSize)(0ULL), (VkDeviceSize)(0ULL), nullptr, l_allocateInfo.mmemoryTypeIndex, make<uint8_t>((uint64_t)(l_allocateInfo.mallocationSize))));
this->DeviceMemories[l_memory] = l_memoryObject;
observer->write<VkDeviceMemory>(slice(pMemory, 0ULL, 1ULL), 0ULL, l_memory);
break;
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::vulkan::VkAllocateMemory coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkMemoryAllocateInfo__CP >(pAllocateInfo, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkAllocationCallbacks__CP >(pAllocator, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkDeviceMemory__P >(pMemory, *observer->getScratch()), result);
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
return result;
}
uint32_t VulkanSpy::vkQueueBindSparse(CallObserver* observer, VkQueue queue, uint32_t bindInfoCount, VkBindSparseInfo* pBindInfo, VkFence fence) {
GAPID_DEBUG("vkQueueBindSparse(%zu, %" PRIu32 ", %p, %" PRIu64 ")", queue, bindInfoCount, pBindInfo, fence);
if (Queues.find(queue) == Queues.end() ||
mImports.mVkDeviceFunctions.find(Queues[queue]->mDevice) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[Queues[queue]->mDevice].vkQueueBindSparse == nullptr) {
GAPID_WARNING("Application called unsupported function vkQueueBindSparse");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, queue, bindInfoCount, pBindInfo, fence] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[Queues[queue]->mDevice].vkQueueBindSparse(queue, bindInfoCount, pBindInfo, fence);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
call();
break;
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::vulkan::VkQueueBindSparse coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(queue, *observer->getScratch()), bindInfoCount, toEncoder< gapic::coder::vulkan::VkBindSparseInfo__CP >(pBindInfo, *observer->getScratch()), toEncoder< uint64_t >(fence, *observer->getScratch()), result);
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
return result;
}
uint32_t VulkanSpy::vkSetEvent(CallObserver* observer, VkDevice device, VkEvent event) {
GAPID_DEBUG("vkSetEvent(%zu, %" PRIu64 ")", device, event);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkSetEvent == nullptr) {
GAPID_WARNING("Application called unsupported function vkSetEvent");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, device, event] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[device].vkSetEvent(device, event);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
call();
break;
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::vulkan::VkSetEvent coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< uint64_t >(event, *observer->getScratch()), result);
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
return result;
}
uint32_t VulkanSpy::vkCreatePipelineCache(CallObserver* observer, VkDevice device, VkPipelineCacheCreateInfo* pCreateInfo, VkAllocationCallbacks* pAllocator, VkPipelineCache* pPipelineCache) {
GAPID_DEBUG("vkCreatePipelineCache(%zu, %p, %p, %p)", device, pCreateInfo, pAllocator, pPipelineCache);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkCreatePipelineCache == nullptr) {
GAPID_WARNING("Application called unsupported function vkCreatePipelineCache");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, device, pCreateInfo, pAllocator, pPipelineCache] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[device].vkCreatePipelineCache(device, pCreateInfo, pAllocator, pPipelineCache);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
VkPipelineCacheCreateInfo l_create_info = observer->read(slice(pCreateInfo, 0ULL, 1ULL), 0ULL);
observer->read(slice((uint8_t*)(l_create_info.mpInitialData), (uint64_t)(0L), (uint64_t)(l_create_info.minitialDataSize)));
call();
observer->write<VkPipelineCache>(slice(pPipelineCache, 0ULL, 1ULL), 0ULL, slice(pPipelineCache, 0ULL, 1ULL)[0ULL]);
break;
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::vulkan::VkCreatePipelineCache coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkPipelineCacheCreateInfo__CP >(pCreateInfo, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkAllocationCallbacks__CP >(pAllocator, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkPipelineCache__P >(pPipelineCache, *observer->getScratch()), result);
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
return result;
}
uint32_t VulkanSpy::vkGetPipelineCacheData(CallObserver* observer, VkDevice device, VkPipelineCache pipelineCache, size_val* pDataSize, void* pData) {
GAPID_DEBUG("vkGetPipelineCacheData(%zu, %" PRIu64 ", %p, %p)", device, pipelineCache, pDataSize, pData);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkGetPipelineCacheData == nullptr) {
GAPID_WARNING("Application called unsupported function vkGetPipelineCacheData");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, device, pipelineCache, pDataSize, pData] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[device].vkGetPipelineCacheData(device, pipelineCache, pDataSize, pData);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
call();
break;
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::vulkan::VkGetPipelineCacheData coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< uint64_t >(pipelineCache, *observer->getScratch()), toEncoder< gapic::coder::vulkan::Size__P >(pDataSize, *observer->getScratch()), toEncoder< gapic::coder::vulkan::Void__P >(pData, *observer->getScratch()), result);
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
return result;
}
uint32_t VulkanSpy::vkCreateComputePipelines(CallObserver* observer, VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, VkComputePipelineCreateInfo* pCreateInfos, VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines) {
GAPID_DEBUG("vkCreateComputePipelines(%zu, %" PRIu64 ", %" PRIu32 ", %p, %p, %p)", device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkCreateComputePipelines == nullptr) {
GAPID_WARNING("Application called unsupported function vkCreateComputePipelines");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[device].vkCreateComputePipelines(device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
Slice<VkComputePipelineCreateInfo> l_infos = slice(pCreateInfos, (uint64_t)(0UL), (uint64_t)(createInfoCount));
for (uint32_t l_i = 0UL; l_i < createInfoCount; ++l_i) {
VkPipelineShaderStageCreateInfo l_stage = observer->read(l_infos, (uint64_t)(l_i)).mstage;
(void)observer->string(l_stage.mpName);
if ((l_stage.mpSpecializationInfo) != (nullptr)) {
VkSpecializationInfo l_specInfo = observer->read(slice(l_stage.mpSpecializationInfo, 0ULL, 1ULL), 0ULL);
observer->read(slice(l_specInfo.mpMapEntries, (uint64_t)(0UL), (uint64_t)(l_specInfo.mmapEntryCount)));
if ((l_specInfo.mdataSize) != ((size_val)(0L))) {
observer->read(slice((uint8_t*)(l_specInfo.mpData), (uint64_t)(0L), (uint64_t)(l_specInfo.mdataSize)));
}
}
}
Slice<VkPipeline> l_pipelines = slice(pPipelines, (uint64_t)(0UL), (uint64_t)(createInfoCount));
call();
for (uint32_t l_i = 0UL; l_i < createInfoCount; ++l_i) {
auto l_handle = slice(pPipelines, (uint64_t)(0UL), (uint64_t)(createInfoCount))[(uint64_t)(l_i)];
observer->write<VkPipeline>(l_pipelines, (uint64_t)(l_i), l_handle);
this->ComputePipelines[l_handle] = std::shared_ptr<ComputePipelineObject>(new ComputePipelineObject(device, l_handle));
}
break;
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::vulkan::VkCreateComputePipelines coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< uint64_t >(pipelineCache, *observer->getScratch()), createInfoCount, toEncoder< gapic::coder::vulkan::VkComputePipelineCreateInfo__CP >(pCreateInfos, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkAllocationCallbacks__CP >(pAllocator, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkPipeline__P >(pPipelines, *observer->getScratch()), result);
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
return result;
}
void VulkanSpy::vkCmdSetDepthBounds(CallObserver* observer, VkCommandBuffer commandBuffer, float minDepthBounds, float maxDepthBounds) {
GAPID_DEBUG("vkCmdSetDepthBounds(%zu, %f, %f)", commandBuffer, minDepthBounds, maxDepthBounds);
if (CommandBuffers.find(commandBuffer) == CommandBuffers.end() ||
mImports.mVkDeviceFunctions.find(CommandBuffers[commandBuffer]->mDevice) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdSetDepthBounds == nullptr) {
GAPID_WARNING("Application called unsupported function vkCmdSetDepthBounds");
return;
}
bool called = false;
auto call = [this, observer, &called, commandBuffer, minDepthBounds, maxDepthBounds] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdSetDepthBounds(commandBuffer, minDepthBounds, maxDepthBounds);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
call();
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::vulkan::VkCmdSetDepthBounds coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(commandBuffer, *observer->getScratch()), minDepthBounds, maxDepthBounds);
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
}
void VulkanSpy::vkCmdBlitImage(CallObserver* observer, VkCommandBuffer commandBuffer, VkImage srcImage, uint32_t srcImageLayout, VkImage dstImage, uint32_t dstImageLayout, uint32_t regionCount, VkImageBlit* pRegions, uint32_t filter) {
GAPID_DEBUG("vkCmdBlitImage(%zu, %" PRIu64 ", %u, %" PRIu64 ", %u, %" PRIu32 ", %p, %u)", commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, filter);
if (CommandBuffers.find(commandBuffer) == CommandBuffers.end() ||
mImports.mVkDeviceFunctions.find(CommandBuffers[commandBuffer]->mDevice) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdBlitImage == nullptr) {
GAPID_WARNING("Application called unsupported function vkCmdBlitImage");
return;
}
bool called = false;
auto call = [this, observer, &called, commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, filter] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdBlitImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, filter);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
observer->read(slice(pRegions, (uint64_t)(0UL), (uint64_t)(regionCount)));
call();
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::vulkan::VkCmdBlitImage coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(commandBuffer, *observer->getScratch()), toEncoder< uint64_t >(srcImage, *observer->getScratch()), srcImageLayout, toEncoder< uint64_t >(dstImage, *observer->getScratch()), dstImageLayout, regionCount, toEncoder< gapic::coder::vulkan::VkImageBlit__CP >(pRegions, *observer->getScratch()), filter);
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
}
void VulkanSpy::vkCmdSetEvent(CallObserver* observer, VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask) {
GAPID_DEBUG("vkCmdSetEvent(%zu, %" PRIu64 ", %" PRIu32 ")", commandBuffer, event, stageMask);
if (CommandBuffers.find(commandBuffer) == CommandBuffers.end() ||
mImports.mVkDeviceFunctions.find(CommandBuffers[commandBuffer]->mDevice) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdSetEvent == nullptr) {
GAPID_WARNING("Application called unsupported function vkCmdSetEvent");
return;
}
bool called = false;
auto call = [this, observer, &called, commandBuffer, event, stageMask] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdSetEvent(commandBuffer, event, stageMask);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
call();
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::vulkan::VkCmdSetEvent coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(commandBuffer, *observer->getScratch()), toEncoder< uint64_t >(event, *observer->getScratch()), toEncoder< uint32_t >(stageMask, *observer->getScratch()));
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
}
void VulkanSpy::vkCmdWaitEvents(CallObserver* observer, VkCommandBuffer commandBuffer, uint32_t eventCount, VkEvent* pEvents, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, uint32_t memoryBarrierCount, VkMemoryBarrier* pMemoryBarriers, uint32_t bufferMemoryBarrierCount, VkBufferMemoryBarrier* pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, VkImageMemoryBarrier* pImageMemoryBarriers) {
GAPID_DEBUG("vkCmdWaitEvents(%zu, %" PRIu32 ", %p, %" PRIu32 ", %" PRIu32 ", %" PRIu32 ", %p, %" PRIu32 ", %p, %" PRIu32 ", %p)", commandBuffer, eventCount, pEvents, srcStageMask, dstStageMask, memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers);
if (CommandBuffers.find(commandBuffer) == CommandBuffers.end() ||
mImports.mVkDeviceFunctions.find(CommandBuffers[commandBuffer]->mDevice) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdWaitEvents == nullptr) {
GAPID_WARNING("Application called unsupported function vkCmdWaitEvents");
return;
}
bool called = false;
auto call = [this, observer, &called, commandBuffer, eventCount, pEvents, srcStageMask, dstStageMask, memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdWaitEvents(commandBuffer, eventCount, pEvents, srcStageMask, dstStageMask, memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
call();
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::vulkan::VkCmdWaitEvents coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(commandBuffer, *observer->getScratch()), eventCount, toEncoder< gapic::coder::vulkan::VkEvent__CP >(pEvents, *observer->getScratch()), toEncoder< uint32_t >(srcStageMask, *observer->getScratch()), toEncoder< uint32_t >(dstStageMask, *observer->getScratch()), memoryBarrierCount, toEncoder< gapic::coder::vulkan::VkMemoryBarrier__CP >(pMemoryBarriers, *observer->getScratch()), bufferMemoryBarrierCount, toEncoder< gapic::coder::vulkan::VkBufferMemoryBarrier__CP >(pBufferMemoryBarriers, *observer->getScratch()), imageMemoryBarrierCount, toEncoder< gapic::coder::vulkan::VkImageMemoryBarrier__CP >(pImageMemoryBarriers, *observer->getScratch()));
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
}
void VulkanSpy::vkCmdBeginRenderPass(CallObserver* observer, VkCommandBuffer commandBuffer, VkRenderPassBeginInfo* pRenderPassBegin, uint32_t contents) {
GAPID_DEBUG("vkCmdBeginRenderPass(%zu, %p, %u)", commandBuffer, pRenderPassBegin, contents);
if (CommandBuffers.find(commandBuffer) == CommandBuffers.end() ||
mImports.mVkDeviceFunctions.find(CommandBuffers[commandBuffer]->mDevice) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdBeginRenderPass == nullptr) {
GAPID_WARNING("Application called unsupported function vkCmdBeginRenderPass");
return;
}
bool called = false;
auto call = [this, observer, &called, commandBuffer, pRenderPassBegin, contents] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdBeginRenderPass(commandBuffer, pRenderPassBegin, contents);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
VkRenderPassBeginInfo l_begin_info = observer->read(slice(pRenderPassBegin, 0ULL, 1ULL), 0ULL);
observer->read(slice(l_begin_info.mpClearValues, (uint64_t)(0UL), (uint64_t)(l_begin_info.mclearValueCount)));
addCmd(observer, commandBuffer, CmdBeginRenderPass(l_begin_info.mframebuffer), &VulkanSpy::subDoCmdBeginRenderPass);
call();
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::vulkan::VkCmdBeginRenderPass coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(commandBuffer, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkRenderPassBeginInfo__CP >(pRenderPassBegin, *observer->getScratch()), contents);
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
}
void VulkanSpy::vkCmdEndRenderPass(CallObserver* observer, VkCommandBuffer commandBuffer) {
GAPID_DEBUG("vkCmdEndRenderPass(%zu)", commandBuffer);
if (CommandBuffers.find(commandBuffer) == CommandBuffers.end() ||
mImports.mVkDeviceFunctions.find(CommandBuffers[commandBuffer]->mDevice) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdEndRenderPass == nullptr) {
GAPID_WARNING("Application called unsupported function vkCmdEndRenderPass");
return;
}
bool called = false;
auto call = [this, observer, &called, commandBuffer] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdEndRenderPass(commandBuffer);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
call();
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::vulkan::VkCmdEndRenderPass coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(commandBuffer, *observer->getScratch()));
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
}
void VulkanSpy::vkDestroySurfaceKHR(CallObserver* observer, VkInstance instance, VkSurfaceKHR surface, VkAllocationCallbacks* pAllocator) {
GAPID_DEBUG("vkDestroySurfaceKHR(%zu, %" PRIu64 ", %p)", instance, surface, pAllocator);
if (mImports.mVkInstanceFunctions.find(instance) == mImports.mVkInstanceFunctions.end() ||
mImports.mVkInstanceFunctions[instance].vkDestroySurfaceKHR == nullptr) {
GAPID_WARNING("Application called unsupported function vkDestroySurfaceKHR");
return;
}
bool called = false;
auto call = [this, observer, &called, instance, surface, pAllocator] {
called = true;
observer->observeReads();
mImports.mVkInstanceFunctions[instance].vkDestroySurfaceKHR(instance, surface, pAllocator);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
this->Surfaces.erase(surface);
call();
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::vulkan::VkDestroySurfaceKHR coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(instance, *observer->getScratch()), toEncoder< uint64_t >(surface, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkAllocationCallbacks__CP >(pAllocator, *observer->getScratch()));
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
}
uint32_t VulkanSpy::vkGetPhysicalDeviceSurfaceSupportKHR(CallObserver* observer, VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, VkSurfaceKHR surface, VkBool32* pSupported) {
GAPID_DEBUG("vkGetPhysicalDeviceSurfaceSupportKHR(%zu, %" PRIu32 ", %" PRIu64 ", %p)", physicalDevice, queueFamilyIndex, surface, pSupported);
if (PhysicalDevices.find(physicalDevice) == PhysicalDevices.end() ||
mImports.mVkInstanceFunctions.find(PhysicalDevices[physicalDevice]->mInstance) == mImports.mVkInstanceFunctions.end() ||
mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkGetPhysicalDeviceSurfaceSupportKHR == nullptr) {
GAPID_WARNING("Application called unsupported function vkGetPhysicalDeviceSurfaceSupportKHR");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, physicalDevice, queueFamilyIndex, surface, pSupported] {
called = true;
observer->observeReads();
result = mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkGetPhysicalDeviceSurfaceSupportKHR(physicalDevice, queueFamilyIndex, surface, pSupported);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
call();
observer->write<VkBool32>(slice(pSupported, 0ULL, 1ULL), 0ULL, slice(pSupported, 0ULL, 1ULL)[0ULL]);
break;
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::vulkan::VkGetPhysicalDeviceSurfaceSupportKHR coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(physicalDevice, *observer->getScratch()), queueFamilyIndex, toEncoder< uint64_t >(surface, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkBool32__P >(pSupported, *observer->getScratch()), result);
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
return result;
}
uint32_t VulkanSpy::vkGetDisplayPlaneSupportedDisplaysKHR(CallObserver* observer, VkPhysicalDevice physicalDevice, uint32_t planeIndex, uint32_t* pDisplayCount, VkDisplayKHR* pDisplays) {
GAPID_DEBUG("vkGetDisplayPlaneSupportedDisplaysKHR(%zu, %" PRIu32 ", %p, %p)", physicalDevice, planeIndex, pDisplayCount, pDisplays);
if (PhysicalDevices.find(physicalDevice) == PhysicalDevices.end() ||
mImports.mVkInstanceFunctions.find(PhysicalDevices[physicalDevice]->mInstance) == mImports.mVkInstanceFunctions.end() ||
mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkGetDisplayPlaneSupportedDisplaysKHR == nullptr) {
GAPID_WARNING("Application called unsupported function vkGetDisplayPlaneSupportedDisplaysKHR");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, physicalDevice, planeIndex, pDisplayCount, pDisplays] {
called = true;
observer->observeReads();
result = mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkGetDisplayPlaneSupportedDisplaysKHR(physicalDevice, planeIndex, pDisplayCount, pDisplays);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
(void)observer->read(slice(pDisplayCount, 0ULL, 1ULL), 0ULL);
call();
if ((pDisplays) == (nullptr)) {
observer->write<uint32_t>(slice(pDisplayCount, 0ULL, 1ULL), 0ULL, slice(pDisplayCount, 0ULL, 1ULL)[0ULL]);
} else {
uint32_t l_count = (uint32_t)(slice(pDisplayCount, 0ULL, 1ULL)[0ULL]);
Slice<VkDisplayKHR> l_displays = slice(pDisplays, (uint64_t)(0UL), (uint64_t)(l_count));
for (uint32_t l_i = 0UL; l_i < l_count; ++l_i) {
observer->write<VkDisplayKHR>(l_displays, (uint64_t)(l_i), slice(pDisplays, (uint64_t)(0UL), (uint64_t)(l_count))[(uint64_t)(l_i)]);
}
observer->write<uint32_t>(slice(pDisplayCount, 0ULL, 1ULL), 0ULL, l_count);
}
break;
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::vulkan::VkGetDisplayPlaneSupportedDisplaysKHR coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(physicalDevice, *observer->getScratch()), planeIndex, toEncoder< gapic::coder::vulkan::U32__P >(pDisplayCount, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkDisplayKHR__P >(pDisplays, *observer->getScratch()), result);
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
return result;
}
uint32_t VulkanSpy::vkCreateDisplayModeKHR(CallObserver* observer, VkPhysicalDevice physicalDevice, VkDisplayKHR display, VkDisplayModeCreateInfoKHR* pCreateInfo, VkAllocationCallbacks* pAllocator, VkDisplayModeKHR* pMode) {
GAPID_DEBUG("vkCreateDisplayModeKHR(%zu, %" PRIu64 ", %p, %p, %p)", physicalDevice, display, pCreateInfo, pAllocator, pMode);
if (PhysicalDevices.find(physicalDevice) == PhysicalDevices.end() ||
mImports.mVkInstanceFunctions.find(PhysicalDevices[physicalDevice]->mInstance) == mImports.mVkInstanceFunctions.end() ||
mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkCreateDisplayModeKHR == nullptr) {
GAPID_WARNING("Application called unsupported function vkCreateDisplayModeKHR");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, physicalDevice, display, pCreateInfo, pAllocator, pMode] {
called = true;
observer->observeReads();
result = mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkCreateDisplayModeKHR(physicalDevice, display, pCreateInfo, pAllocator, pMode);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
(void)observer->read(slice(pCreateInfo, 0ULL, 1ULL), 0ULL);
call();
auto l_handle = slice(pMode, 0ULL, 1ULL)[0ULL];
observer->write<VkDisplayModeKHR>(slice(pMode, 0ULL, 1ULL), 0ULL, l_handle);
std::shared_ptr<DisplayModeObject> l_modeObject = std::shared_ptr<DisplayModeObject>(new DisplayModeObject(physicalDevice, display, l_handle));
this->DisplayModes[l_handle] = l_modeObject;
break;
} while(false);
} catch (gapii::AbortException& e) {
if (!called) {
call(); // abort() was called before the fence.
}
handleAbort(observer, e);
}
uint64_t counter_at_end = mCommandStartEndCounter++;
gapic::coder::atom::CommandCounter counter_value_encodable(counter_at_begin, counter_at_end);
observer->observeWrites();
gapic::coder::vulkan::VkCreateDisplayModeKHR coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(physicalDevice, *observer->getScratch()), toEncoder< uint64_t >(display, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkDisplayModeCreateInfoKHR__CP >(pCreateInfo, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkAllocationCallbacks__CP >(pAllocator, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkDisplayModeKHR__P >(pMode, *observer->getScratch()), result);
coder.mextras.append(observer->getExtras());
if (counter_at_end > counter_at_begin + 1 ||
counter_at_begin != mExpectedNextCommandStartCounterValue) {
coder.mextras.append(&counter_value_encodable);
}
mExpectedNextCommandStartCounterValue = counter_at_end + 1;
mEncoder->Variant(&coder);
return result;
}
} // namespace gapii