blob: 00f59b5af40279bff461b2e960f58118a96724f0 [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::vkCreateXcbSurfaceKHR(CallObserver* observer, VkInstance instance, VkXcbSurfaceCreateInfoKHR* pCreateInfo, VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface) {
GAPID_DEBUG("vkCreateXcbSurfaceKHR(%zu, %p, %p, %p)", instance, pCreateInfo, pAllocator, pSurface);
if (mImports.mVkInstanceFunctions.find(instance) == mImports.mVkInstanceFunctions.end() ||
mImports.mVkInstanceFunctions[instance].vkCreateXcbSurfaceKHR == nullptr) {
GAPID_WARNING("Application called unsupported function vkCreateXcbSurfaceKHR");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, instance, pCreateInfo, pAllocator, pSurface] {
called = true;
observer->observeReads();
result = mImports.mVkInstanceFunctions[instance].vkCreateXcbSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
std::shared_ptr<SurfaceObject> l_surface = subCreateXCBSurfaceObject(observer, call, pCreateInfo);
checkNotNull(l_surface).mInstance = instance;
call();
auto l_handle = slice(pSurface, 0ULL, 1ULL)[0ULL];
observer->write<VkSurfaceKHR>(slice(pSurface, 0ULL, 1ULL), 0ULL, l_handle);
checkNotNull(l_surface).mVulkanHandle = l_handle;
this->Surfaces[l_handle] = l_surface;
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::VkCreateXcbSurfaceKHR coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(instance, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkXcbSurfaceCreateInfoKHR__CP >(pCreateInfo, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkAllocationCallbacks__CP >(pAllocator, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkSurfaceKHR__P >(pSurface, *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;
}
VkBool32 VulkanSpy::vkGetPhysicalDeviceMirPresentationSupportKHR(CallObserver* observer, VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, MirConnection* connection) {
GAPID_DEBUG("vkGetPhysicalDeviceMirPresentationSupportKHR(%zu, %" PRIu32 ", %p)", physicalDevice, queueFamilyIndex, connection);
if (PhysicalDevices.find(physicalDevice) == PhysicalDevices.end() ||
mImports.mVkInstanceFunctions.find(PhysicalDevices[physicalDevice]->mInstance) == mImports.mVkInstanceFunctions.end() ||
mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkGetPhysicalDeviceMirPresentationSupportKHR == nullptr) {
GAPID_WARNING("Application called unsupported function vkGetPhysicalDeviceMirPresentationSupportKHR");
return 0;
}
VkBool32 result = 0;
bool called = false;
auto call = [this, observer, &called, &result, physicalDevice, queueFamilyIndex, connection] {
called = true;
observer->observeReads();
result = mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkGetPhysicalDeviceMirPresentationSupportKHR(physicalDevice, queueFamilyIndex, connection);
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::VkGetPhysicalDeviceMirPresentationSupportKHR coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(physicalDevice, *observer->getScratch()), queueFamilyIndex, toEncoder< gapic::coder::vulkan::MirConnection__P >(connection, *observer->getScratch()), toEncoder< uint32_t >(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;
}
void VulkanSpy::replayUnregisterVkDevice(CallObserver* observer, VkDevice device) {
GAPID_DEBUG("replayUnregisterVkDevice(%zu)", device);
bool called = false;
auto call = [this, observer, &called, device] {
called = true;
observer->observeReads();
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::ReplayUnregisterVkDevice coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *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::replayGetFenceStatus(CallObserver* observer, VkDevice device, VkFence fence, uint32_t expected) {
GAPID_DEBUG("replayGetFenceStatus(%zu, %" PRIu64 ", %u)", device, fence, expected);
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, device, fence, expected] {
called = true;
observer->observeReads();
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::ReplayGetFenceStatus coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< uint64_t >(fence, *observer->getScratch()), expected, 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::replayAllocateImageMemory(CallObserver* observer, VkDevice device, VkPhysicalDeviceMemoryProperties* pPhysicalDeviceMemoryProperties, VkImage image, VkDeviceMemory* pMemory) {
GAPID_DEBUG("replayAllocateImageMemory(%zu, %p, %" PRIu64 ", %p)", device, pPhysicalDeviceMemoryProperties, image, pMemory);
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, device, pPhysicalDeviceMemoryProperties, image, pMemory] {
called = true;
observer->observeReads();
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
(void)observer->read(slice(pPhysicalDeviceMemoryProperties, 0ULL, 1ULL), 0ULL);
call();
auto l_handle = slice(pMemory, 0ULL, 1ULL)[0ULL];
observer->write<VkDeviceMemory>(slice(pMemory, 0ULL, 1ULL), 0ULL, 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::ReplayAllocateImageMemory coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkPhysicalDeviceMemoryProperties__P >(pPhysicalDeviceMemoryProperties, *observer->getScratch()), toEncoder< uint64_t >(image, *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::vkCreateInstance(CallObserver* observer, VkInstanceCreateInfo* pCreateInfo, VkAllocationCallbacks* pAllocator, VkInstance* pInstance) {
GAPID_DEBUG("vkCreateInstance(%p, %p, %p)", pCreateInfo, pAllocator, pInstance);
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, pCreateInfo, pAllocator, pInstance] {
called = true;
observer->observeReads();
result = SpyOverride_vkCreateInstance(pCreateInfo, pAllocator, pInstance);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
std::shared_ptr<InstanceObject> l_instance = subCreateInstanceObject(observer, call, pCreateInfo);
call();
auto l_handle = slice(pInstance, 0ULL, 1ULL)[0ULL];
observer->write<VkInstance>(slice(pInstance, 0ULL, 1ULL), 0ULL, l_handle);
this->Instances[l_handle] = l_instance;
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::VkCreateInstance coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< gapic::coder::vulkan::VkInstanceCreateInfo__CP >(pCreateInfo, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkAllocationCallbacks__CP >(pAllocator, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkInstance__P >(pInstance, *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::vkGetPhysicalDeviceQueueFamilyProperties(CallObserver* observer, VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount, VkQueueFamilyProperties* pQueueFamilyProperties) {
GAPID_DEBUG("vkGetPhysicalDeviceQueueFamilyProperties(%zu, %p, %p)", physicalDevice, pQueueFamilyPropertyCount, pQueueFamilyProperties);
if (PhysicalDevices.find(physicalDevice) == PhysicalDevices.end() ||
mImports.mVkInstanceFunctions.find(PhysicalDevices[physicalDevice]->mInstance) == mImports.mVkInstanceFunctions.end() ||
mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkGetPhysicalDeviceQueueFamilyProperties == nullptr) {
GAPID_WARNING("Application called unsupported function vkGetPhysicalDeviceQueueFamilyProperties");
return;
}
bool called = false;
auto call = [this, observer, &called, physicalDevice, pQueueFamilyPropertyCount, pQueueFamilyProperties] {
called = true;
observer->observeReads();
mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, pQueueFamilyPropertyCount, pQueueFamilyProperties);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
(void)observer->read(slice(pQueueFamilyPropertyCount, 0ULL, 1ULL), 0ULL);
call();
if ((pQueueFamilyProperties) == (nullptr)) {
observer->write<uint32_t>(slice(pQueueFamilyPropertyCount, 0ULL, 1ULL), 0ULL, slice(pQueueFamilyPropertyCount, 0ULL, 1ULL)[0ULL]);
} else {
uint32_t l_count = (uint32_t)(slice(pQueueFamilyPropertyCount, 0ULL, 1ULL)[0ULL]);
Slice<VkQueueFamilyProperties> l_properties = slice(pQueueFamilyProperties, (uint64_t)(0UL), (uint64_t)(l_count));
for (uint32_t l_i = 0UL; l_i < l_count; ++l_i) {
observer->write<VkQueueFamilyProperties>(l_properties, (uint64_t)(l_i), slice(pQueueFamilyProperties, (uint64_t)(0UL), (uint64_t)(l_count))[(uint64_t)(l_i)]);
}
observer->write<uint32_t>(slice(pQueueFamilyPropertyCount, 0ULL, 1ULL), 0ULL, l_count);
}
} 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::VkGetPhysicalDeviceQueueFamilyProperties coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(physicalDevice, *observer->getScratch()), toEncoder< gapic::coder::vulkan::U32__P >(pQueueFamilyPropertyCount, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkQueueFamilyProperties__P >(pQueueFamilyProperties, *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::vkEnumerateInstanceExtensionProperties(CallObserver* observer, const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties) {
GAPID_DEBUG("vkEnumerateInstanceExtensionProperties(%s, %p, %p)", pLayerName, pPropertyCount, pProperties);
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, pLayerName, pPropertyCount, pProperties] {
called = true;
observer->observeReads();
result = SpyOverride_vkEnumerateInstanceExtensionProperties(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::VkEnumerateInstanceExtensionProperties coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), 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::vkQueueSubmit(CallObserver* observer, VkQueue queue, uint32_t submitCount, VkSubmitInfo* pSubmits, VkFence fence) {
GAPID_DEBUG("vkQueueSubmit(%zu, %" PRIu32 ", %p, %" PRIu64 ")", queue, submitCount, pSubmits, fence);
if (Queues.find(queue) == Queues.end() ||
mImports.mVkDeviceFunctions.find(Queues[queue]->mDevice) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[Queues[queue]->mDevice].vkQueueSubmit == nullptr) {
GAPID_WARNING("Application called unsupported function vkQueueSubmit");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, queue, submitCount, pSubmits, fence] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[Queues[queue]->mDevice].vkQueueSubmit(queue, submitCount, pSubmits, fence);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
Slice<VkSubmitInfo> l_submitInfo = slice(pSubmits, (uint64_t)(0UL), (uint64_t)(submitCount));
this->LastBoundQueue = queue;
for (uint32_t l_i = 0UL; l_i < submitCount; ++l_i) {
VkSubmitInfo l_info = observer->read(l_submitInfo, (uint64_t)(l_i));
observer->read(slice(l_info.mpWaitSemaphores, (uint64_t)(0UL), (uint64_t)(l_info.mwaitSemaphoreCount)));
observer->read(slice(l_info.mpWaitDstStageMask, (uint64_t)(0UL), (uint64_t)(l_info.mwaitSemaphoreCount)));
observer->read(slice(l_info.mpSignalSemaphores, (uint64_t)(0UL), (uint64_t)(l_info.msignalSemaphoreCount)));
Slice<VkCommandBuffer> l_command_buffers = slice(l_info.mpCommandBuffers, (uint64_t)(0UL), (uint64_t)(l_info.mcommandBufferCount));
for (uint32_t l_j = 0UL; l_j < l_info.mcommandBufferCount; ++l_j) {
execCommands(observer, observer->read(l_command_buffers, (uint64_t)(l_j)));
}
}
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::VkQueueSubmit coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(queue, *observer->getScratch()), submitCount, toEncoder< gapic::coder::vulkan::VkSubmitInfo__CP >(pSubmits, *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::vkInvalidateMappedMemoryRanges(CallObserver* observer, VkDevice device, uint32_t memoryRangeCount, VkMappedMemoryRange* pMemoryRanges) {
GAPID_DEBUG("vkInvalidateMappedMemoryRanges(%zu, %" PRIu32 ", %p)", device, memoryRangeCount, pMemoryRanges);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkInvalidateMappedMemoryRanges == nullptr) {
GAPID_WARNING("Application called unsupported function vkInvalidateMappedMemoryRanges");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, device, memoryRangeCount, pMemoryRanges] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[device].vkInvalidateMappedMemoryRanges(device, memoryRangeCount, pMemoryRanges);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
std::shared_ptr<MemoryRangeArray> l_ranges = std::shared_ptr<MemoryRangeArray>(new MemoryRangeArray(U32ToVoid__P(), U32ToU64(), U32ToU64()));
Slice<VkMappedMemoryRange> l_memoryRanges = slice(pMemoryRanges, (uint64_t)(0UL), (uint64_t)(memoryRangeCount));
for (uint32_t l_i = 0UL; l_i < memoryRangeCount; ++l_i) {
VkMappedMemoryRange l_invalidateRange = observer->read(l_memoryRanges, (uint64_t)(l_i));
VkDeviceSize l_invalidateOffset = l_invalidateRange.moffset;
void* l_mappedLocation = checkNotNull(findOrZero(this->DeviceMemories, l_invalidateRange.mmemory)).mMappedLocation;
VkDeviceSize l_mappedOffset = checkNotNull(findOrZero(this->DeviceMemories, l_invalidateRange.mmemory)).mMappedOffset;
VkDeviceSize l_mappedSize = checkNotNull(findOrZero(this->DeviceMemories, l_invalidateRange.mmemory)).mMappedSize;
checkNotNull(l_ranges).mPData[l_i] = l_mappedLocation;
checkNotNull(l_ranges).mStart[l_i] = (uint64_t)((l_invalidateOffset) - (l_mappedOffset));
if ((l_invalidateRange.msize) == ((VkDeviceSize)(18446744073709551615ULL))) {
checkNotNull(l_ranges).mEnd[l_i] = (uint64_t)(l_mappedSize);
} else {
checkNotNull(l_ranges).mEnd[l_i] = (findOrZero(checkNotNull(l_ranges).mStart, l_i)) + ((uint64_t)(l_invalidateRange.msize));
}
}
call();
for (uint32_t l_i = 0UL; l_i < memoryRangeCount; ++l_i) {
observer->write(slice(findOrZero(checkNotNull(l_ranges).mPData, l_i), findOrZero(checkNotNull(l_ranges).mStart, l_i), findOrZero(checkNotNull(l_ranges).mEnd, l_i)));
}
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::VkInvalidateMappedMemoryRanges coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), memoryRangeCount, toEncoder< gapic::coder::vulkan::VkMappedMemoryRange__CP >(pMemoryRanges, *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::vkBindImageMemory(CallObserver* observer, VkDevice device, VkImage image, VkDeviceMemory memory, VkDeviceSize memoryOffset) {
GAPID_DEBUG("vkBindImageMemory(%zu, %" PRIu64 ", %" PRIu64 ", %" PRIu64 ")", device, image, memory, memoryOffset);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkBindImageMemory == nullptr) {
GAPID_WARNING("Application called unsupported function vkBindImageMemory");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, device, image, memory, memoryOffset] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[device].vkBindImageMemory(device, image, memory, memoryOffset);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
checkNotNull(findOrZero(this->Images, image)).mBoundMemory = findOrZero(this->DeviceMemories, memory);
checkNotNull(findOrZero(this->DeviceMemories, memory)).mBoundObjects[(uint64_t)(image)] = memoryOffset;
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::VkBindImageMemory coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< uint64_t >(image, *observer->getScratch()), toEncoder< uint64_t >(memory, *observer->getScratch()), toEncoder< uint64_t >(memoryOffset, *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::vkGetFenceStatus(CallObserver* observer, VkDevice device, VkFence fence) {
GAPID_DEBUG("vkGetFenceStatus(%zu, %" PRIu64 ")", device, fence);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkGetFenceStatus == nullptr) {
GAPID_WARNING("Application called unsupported function vkGetFenceStatus");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, device, fence] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[device].vkGetFenceStatus(device, 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::VkGetFenceStatus coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *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::vkCreateBufferView(CallObserver* observer, VkDevice device, VkBufferViewCreateInfo* pCreateInfo, VkAllocationCallbacks* pAllocator, VkBufferView* pView) {
GAPID_DEBUG("vkCreateBufferView(%zu, %p, %p, %p)", device, pCreateInfo, pAllocator, pView);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkCreateBufferView == nullptr) {
GAPID_WARNING("Application called unsupported function vkCreateBufferView");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, device, pCreateInfo, pAllocator, pView] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[device].vkCreateBufferView(device, pCreateInfo, pAllocator, pView);
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::VkCreateBufferView coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkBufferViewCreateInfo__CP >(pCreateInfo, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkAllocationCallbacks__CP >(pAllocator, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkBufferView__P >(pView, *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::vkDestroyImage(CallObserver* observer, VkDevice device, VkImage image, VkAllocationCallbacks* pAllocator) {
GAPID_DEBUG("vkDestroyImage(%zu, %" PRIu64 ", %p)", device, image, pAllocator);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkDestroyImage == nullptr) {
GAPID_WARNING("Application called unsupported function vkDestroyImage");
return;
}
bool called = false;
auto call = [this, observer, &called, device, image, pAllocator] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[device].vkDestroyImage(device, image, pAllocator);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
std::shared_ptr<ImageObject> l_imageObject = findOrZero(this->Images, image);
if ((checkNotNull(l_imageObject).mBoundMemory) != (std::shared_ptr<DeviceMemoryObject>())) {
checkNotNull(checkNotNull(l_imageObject).mBoundMemory).mBoundObjects.erase((uint64_t)(image));
}
this->Images.erase(image);
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::VkDestroyImage coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< uint64_t >(image, *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);
}
void VulkanSpy::vkDestroyShaderModule(CallObserver* observer, VkDevice device, VkShaderModule shaderModule, VkAllocationCallbacks* pAllocator) {
GAPID_DEBUG("vkDestroyShaderModule(%zu, %" PRIu64 ", %p)", device, shaderModule, pAllocator);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkDestroyShaderModule == nullptr) {
GAPID_WARNING("Application called unsupported function vkDestroyShaderModule");
return;
}
bool called = false;
auto call = [this, observer, &called, device, shaderModule, pAllocator] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[device].vkDestroyShaderModule(device, shaderModule, pAllocator);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
this->ShaderModules.erase(shaderModule);
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::VkDestroyShaderModule coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< uint64_t >(shaderModule, *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);
}
void VulkanSpy::vkDestroyDescriptorSetLayout(CallObserver* observer, VkDevice device, VkDescriptorSetLayout descriptorSetLayout, VkAllocationCallbacks* pAllocator) {
GAPID_DEBUG("vkDestroyDescriptorSetLayout(%zu, %" PRIu64 ", %p)", device, descriptorSetLayout, pAllocator);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkDestroyDescriptorSetLayout == nullptr) {
GAPID_WARNING("Application called unsupported function vkDestroyDescriptorSetLayout");
return;
}
bool called = false;
auto call = [this, observer, &called, device, descriptorSetLayout, pAllocator] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[device].vkDestroyDescriptorSetLayout(device, descriptorSetLayout, pAllocator);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
this->DescriptorSetLayouts.erase(descriptorSetLayout);
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::VkDestroyDescriptorSetLayout coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< uint64_t >(descriptorSetLayout, *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::vkAllocateDescriptorSets(CallObserver* observer, VkDevice device, VkDescriptorSetAllocateInfo* pAllocateInfo, VkDescriptorSet* pDescriptorSets) {
GAPID_DEBUG("vkAllocateDescriptorSets(%zu, %p, %p)", device, pAllocateInfo, pDescriptorSets);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkAllocateDescriptorSets == nullptr) {
GAPID_WARNING("Application called unsupported function vkAllocateDescriptorSets");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, device, pAllocateInfo, pDescriptorSets] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[device].vkAllocateDescriptorSets(device, pAllocateInfo, pDescriptorSets);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
VkDescriptorSetAllocateInfo l_info = observer->read(slice(pAllocateInfo, 0ULL, 1ULL), 0ULL);
uint32_t l_count = l_info.mdescriptorSetCount;
Slice<VkDescriptorSetLayout> l_layouts = slice(l_info.mpSetLayouts, (uint64_t)(0UL), (uint64_t)(l_count));
observer->read(slice(l_info.mpSetLayouts, (uint64_t)(0UL), (uint64_t)(l_count)));
Slice<VkDescriptorSet> l_sets = slice(pDescriptorSets, (uint64_t)(0UL), (uint64_t)(l_count));
call();
for (uint32_t l_i = 0UL; l_i < l_count; ++l_i) {
auto l_handle = slice(pDescriptorSets, (uint64_t)(0UL), (uint64_t)(l_count))[(uint64_t)(l_i)];
observer->write<VkDescriptorSet>(l_sets, (uint64_t)(l_i), l_handle);
std::shared_ptr<DescriptorSetObject> l_object = std::shared_ptr<DescriptorSetObject>(new DescriptorSetObject(device, l_handle, U32ToU32ToBoundBuffer(), std::shared_ptr<DescriptorSetLayoutObject>()));
checkNotNull(l_object).mLayout = findOrZero(this->DescriptorSetLayouts, observer->read(l_layouts, (uint64_t)(l_i)));
this->DescriptorSets[l_handle] = l_object;
}
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::VkAllocateDescriptorSets coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkDescriptorSetAllocateInfo__CP >(pAllocateInfo, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkDescriptorSet__P >(pDescriptorSets, *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::vkCreateFramebuffer(CallObserver* observer, VkDevice device, VkFramebufferCreateInfo* pCreateInfo, VkAllocationCallbacks* pAllocator, VkFramebuffer* pFramebuffer) {
GAPID_DEBUG("vkCreateFramebuffer(%zu, %p, %p, %p)", device, pCreateInfo, pAllocator, pFramebuffer);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkCreateFramebuffer == nullptr) {
GAPID_WARNING("Application called unsupported function vkCreateFramebuffer");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, device, pCreateInfo, pAllocator, pFramebuffer] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[device].vkCreateFramebuffer(device, pCreateInfo, pAllocator, pFramebuffer);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
VkFramebufferCreateInfo l_create_info = observer->read(slice(pCreateInfo, 0ULL, 1ULL), 0ULL);
Slice<VkImageView> l_attachments = slice(l_create_info.mpAttachments, (uint64_t)(0UL), (uint64_t)(l_create_info.mattachmentCount));
Slice<VkImageView> l_clone_attachments = observer->clone(slice(l_attachments, (uint64_t)(0UL), (uint64_t)(l_create_info.mattachmentCount)));
call();
auto l_handle = slice(pFramebuffer, 0ULL, 1ULL)[0ULL];
std::shared_ptr<FramebufferObject> l_framebufferObject = std::shared_ptr<FramebufferObject>(new FramebufferObject(device, l_handle, U32ToImageViewObject__R(), l_create_info.mwidth, l_create_info.mheight));
for (uint32_t l_i = 0UL; l_i < l_create_info.mattachmentCount; ++l_i) {
checkNotNull(l_framebufferObject).mImageAttachments[l_i] = findOrZero(this->ImageViews, observer->read(l_clone_attachments, (uint64_t)(l_i)));
}
observer->write<VkFramebuffer>(slice(pFramebuffer, 0ULL, 1ULL), 0ULL, l_handle);
this->Framebuffers[l_handle] = l_framebufferObject;
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::VkCreateFramebuffer coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkFramebufferCreateInfo__CP >(pCreateInfo, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkAllocationCallbacks__CP >(pAllocator, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkFramebuffer__P >(pFramebuffer, *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::vkDestroyRenderPass(CallObserver* observer, VkDevice device, VkRenderPass renderPass, VkAllocationCallbacks* pAllocator) {
GAPID_DEBUG("vkDestroyRenderPass(%zu, %" PRIu64 ", %p)", device, renderPass, pAllocator);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkDestroyRenderPass == nullptr) {
GAPID_WARNING("Application called unsupported function vkDestroyRenderPass");
return;
}
bool called = false;
auto call = [this, observer, &called, device, renderPass, pAllocator] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[device].vkDestroyRenderPass(device, renderPass, pAllocator);
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::VkDestroyRenderPass coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< uint64_t >(renderPass, *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);
}
void VulkanSpy::vkGetRenderAreaGranularity(CallObserver* observer, VkDevice device, VkRenderPass renderPass, VkExtent2D* pGranularity) {
GAPID_DEBUG("vkGetRenderAreaGranularity(%zu, %" PRIu64 ", %p)", device, renderPass, pGranularity);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkGetRenderAreaGranularity == nullptr) {
GAPID_WARNING("Application called unsupported function vkGetRenderAreaGranularity");
return;
}
bool called = false;
auto call = [this, observer, &called, device, renderPass, pGranularity] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[device].vkGetRenderAreaGranularity(device, renderPass, pGranularity);
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::VkGetRenderAreaGranularity coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< uint64_t >(renderPass, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkExtent2D__P >(pGranularity, *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::vkAllocateCommandBuffers(CallObserver* observer, VkDevice device, VkCommandBufferAllocateInfo* pAllocateInfo, VkCommandBuffer* pCommandBuffers) {
GAPID_DEBUG("vkAllocateCommandBuffers(%zu, %p, %p)", device, pAllocateInfo, pCommandBuffers);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkAllocateCommandBuffers == nullptr) {
GAPID_WARNING("Application called unsupported function vkAllocateCommandBuffers");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, device, pAllocateInfo, pCommandBuffers] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[device].vkAllocateCommandBuffers(device, pAllocateInfo, pCommandBuffers);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
uint32_t l_count = observer->read(slice(pAllocateInfo, 0ULL, 1ULL), 0ULL).mcommandBufferCount;
Slice<VkCommandBuffer> l_cb = slice(pCommandBuffers, (uint64_t)(0UL), (uint64_t)(l_count));
call();
for (uint32_t l_i = 0UL; l_i < l_count; ++l_i) {
auto l_command_buffer = slice(pCommandBuffers, (uint64_t)(0UL), (uint64_t)(l_count))[(uint64_t)(l_i)];
this->CommandBuffers[l_command_buffer] = std::shared_ptr<CommandBufferObject>(new CommandBufferObject(device, l_command_buffer));
observer->write<VkCommandBuffer>(l_cb, (uint64_t)(l_i), l_command_buffer);
}
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::VkAllocateCommandBuffers coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkCommandBufferAllocateInfo__CP >(pAllocateInfo, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkCommandBuffer__P >(pCommandBuffers, *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::vkCmdSetStencilCompareMask(CallObserver* observer, VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t compareMask) {
GAPID_DEBUG("vkCmdSetStencilCompareMask(%zu, %" PRIu32 ", %" PRIu32 ")", commandBuffer, faceMask, compareMask);
if (CommandBuffers.find(commandBuffer) == CommandBuffers.end() ||
mImports.mVkDeviceFunctions.find(CommandBuffers[commandBuffer]->mDevice) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdSetStencilCompareMask == nullptr) {
GAPID_WARNING("Application called unsupported function vkCmdSetStencilCompareMask");
return;
}
bool called = false;
auto call = [this, observer, &called, commandBuffer, faceMask, compareMask] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdSetStencilCompareMask(commandBuffer, faceMask, compareMask);
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::VkCmdSetStencilCompareMask coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(commandBuffer, *observer->getScratch()), toEncoder< uint32_t >(faceMask, *observer->getScratch()), compareMask);
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::vkCmdSetStencilWriteMask(CallObserver* observer, VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t writeMask) {
GAPID_DEBUG("vkCmdSetStencilWriteMask(%zu, %" PRIu32 ", %" PRIu32 ")", commandBuffer, faceMask, writeMask);
if (CommandBuffers.find(commandBuffer) == CommandBuffers.end() ||
mImports.mVkDeviceFunctions.find(CommandBuffers[commandBuffer]->mDevice) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdSetStencilWriteMask == nullptr) {
GAPID_WARNING("Application called unsupported function vkCmdSetStencilWriteMask");
return;
}
bool called = false;
auto call = [this, observer, &called, commandBuffer, faceMask, writeMask] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdSetStencilWriteMask(commandBuffer, faceMask, writeMask);
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::VkCmdSetStencilWriteMask coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(commandBuffer, *observer->getScratch()), toEncoder< uint32_t >(faceMask, *observer->getScratch()), writeMask);
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::vkCmdBindDescriptorSets(CallObserver* observer, VkCommandBuffer commandBuffer, uint32_t pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t descriptorSetCount, VkDescriptorSet* pDescriptorSets, uint32_t dynamicOffsetCount, uint32_t* pDynamicOffsets) {
GAPID_DEBUG("vkCmdBindDescriptorSets(%zu, %u, %" PRIu64 ", %" PRIu32 ", %" PRIu32 ", %p, %" PRIu32 ", %p)", commandBuffer, pipelineBindPoint, layout, firstSet, descriptorSetCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets);
if (CommandBuffers.find(commandBuffer) == CommandBuffers.end() ||
mImports.mVkDeviceFunctions.find(CommandBuffers[commandBuffer]->mDevice) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdBindDescriptorSets == nullptr) {
GAPID_WARNING("Application called unsupported function vkCmdBindDescriptorSets");
return;
}
bool called = false;
auto call = [this, observer, &called, commandBuffer, pipelineBindPoint, layout, firstSet, descriptorSetCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdBindDescriptorSets(commandBuffer, pipelineBindPoint, layout, firstSet, descriptorSetCount, pDescriptorSets, dynamicOffsetCount, pDynamicOffsets);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
Slice<VkDescriptorSet> l_sets = slice(pDescriptorSets, (uint64_t)(0UL), (uint64_t)(descriptorSetCount));
observer->read(slice(pDynamicOffsets, (uint64_t)(0UL), (uint64_t)(dynamicOffsetCount)));
CmdBindBuffer l_bind_buffer = CmdBindBuffer(U32ToBoundBuffer());
MutableU32 l_dynamic_offset_index = MutableU32(0UL);
Slice<uint32_t> l_dynamic_offsets = slice(pDynamicOffsets, (uint64_t)(0UL), (uint64_t)(dynamicOffsetCount));
for (uint32_t l_i = 0UL; l_i < descriptorSetCount; ++l_i) {
if (this->DescriptorSets.count(observer->read(l_sets, (uint64_t)(l_i))) > 0) {
std::shared_ptr<DescriptorSetObject> l_set = findOrZero(this->DescriptorSets, observer->read(l_sets, (uint64_t)(l_i)));
for (uint32_t l_b = 0UL; l_b < (checkNotNull(checkNotNull(l_set).mLayout).mMaximumBinding) + (1UL); ++l_b) {
if (checkNotNull(l_set).mBoundBuffers.count(l_b) > 0) {
int32_t l_length = int32_t((l_bind_buffer.mBuffers.size()));
U32ToBoundBuffer l_buffers = findOrZero(checkNotNull(l_set).mBoundBuffers, l_b);
DescriptorSetLayoutBinding l_binding = findOrZero(checkNotNull(checkNotNull(l_set).mLayout).mBindings, l_b);
for (int32_t l_j = 0L; l_j < int32_t((l_buffers.size())); ++l_j) {
BoundBuffer l_v = findOrZero(l_buffers, (uint32_t)(l_j));
VkDeviceSize l_binding_offset = /* switch(l_binding.mType) */
/* case VkDescriptorType::VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, VkDescriptorType::VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: */(((l_binding.mType) == (VkDescriptorType::VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC))|| ((l_binding.mType) == (VkDescriptorType::VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC))) ? (((VkDeviceSize)(observer->read(l_dynamic_offsets, (uint64_t)(l_dynamic_offset_index.mVal)))) + (l_v.mOffset)) :
/* default: */ l_v.mOffset;
l_dynamic_offset_index.mVal = /* switch(l_binding.mType) */
/* case VkDescriptorType::VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, VkDescriptorType::VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: */(((l_binding.mType) == (VkDescriptorType::VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC))|| ((l_binding.mType) == (VkDescriptorType::VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC))) ? ((l_dynamic_offset_index.mVal) + (1UL)) :
/* default: */ l_dynamic_offset_index.mVal;
l_bind_buffer.mBuffers[(uint32_t)((l_length) + (l_j))] = BoundBuffer(l_v.mBuffer, l_binding_offset, l_v.mRange);
}
}
}
}
}
addCmd(observer, commandBuffer, l_bind_buffer, &VulkanSpy::subDoCmdBindBuffers);
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::VkCmdBindDescriptorSets coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(commandBuffer, *observer->getScratch()), pipelineBindPoint, toEncoder< uint64_t >(layout, *observer->getScratch()), firstSet, descriptorSetCount, toEncoder< gapic::coder::vulkan::VkDescriptorSet__CP >(pDescriptorSets, *observer->getScratch()), dynamicOffsetCount, toEncoder< gapic::coder::vulkan::U32__CP >(pDynamicOffsets, *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::vkCmdDrawIndexed(CallObserver* observer, VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance) {
GAPID_DEBUG("vkCmdDrawIndexed(%zu, %" PRIu32 ", %" PRIu32 ", %" PRIu32 ", %" PRId32 ", %" PRIu32 ")", commandBuffer, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
if (CommandBuffers.find(commandBuffer) == CommandBuffers.end() ||
mImports.mVkDeviceFunctions.find(CommandBuffers[commandBuffer]->mDevice) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdDrawIndexed == nullptr) {
GAPID_WARNING("Application called unsupported function vkCmdDrawIndexed");
return;
}
bool called = false;
auto call = [this, observer, &called, commandBuffer, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdDrawIndexed(commandBuffer, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
addCmd(observer, commandBuffer, CmdDrawIndexed(indexCount, instanceCount, firstIndex, vertexOffset, firstInstance), &VulkanSpy::subDoCmdDrawIndexed);
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::VkCmdDrawIndexed coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(commandBuffer, *observer->getScratch()), indexCount, instanceCount, firstIndex, vertexOffset, firstInstance);
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::vkCmdUpdateBuffer(CallObserver* observer, VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, void* pData) {
GAPID_DEBUG("vkCmdUpdateBuffer(%zu, %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %p)", commandBuffer, dstBuffer, dstOffset, dataSize, pData);
if (CommandBuffers.find(commandBuffer) == CommandBuffers.end() ||
mImports.mVkDeviceFunctions.find(CommandBuffers[commandBuffer]->mDevice) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdUpdateBuffer == nullptr) {
GAPID_WARNING("Application called unsupported function vkCmdUpdateBuffer");
return;
}
bool called = false;
auto call = [this, observer, &called, commandBuffer, dstBuffer, dstOffset, dataSize, pData] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdUpdateBuffer(commandBuffer, dstBuffer, dstOffset, dataSize, pData);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
observer->read(slice((uint8_t*)(pData), (uint64_t)((VkDeviceSize)(0ULL)), (uint64_t)(dataSize)));
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::VkCmdUpdateBuffer coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(commandBuffer, *observer->getScratch()), toEncoder< uint64_t >(dstBuffer, *observer->getScratch()), toEncoder< uint64_t >(dstOffset, *observer->getScratch()), toEncoder< uint64_t >(dataSize, *observer->getScratch()), toEncoder< gapic::coder::vulkan::Void__CP >(pData, *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::vkCmdFillBuffer(CallObserver* observer, VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) {
GAPID_DEBUG("vkCmdFillBuffer(%zu, %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu32 ")", commandBuffer, dstBuffer, dstOffset, size, data);
if (CommandBuffers.find(commandBuffer) == CommandBuffers.end() ||
mImports.mVkDeviceFunctions.find(CommandBuffers[commandBuffer]->mDevice) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdFillBuffer == nullptr) {
GAPID_WARNING("Application called unsupported function vkCmdFillBuffer");
return;
}
bool called = false;
auto call = [this, observer, &called, commandBuffer, dstBuffer, dstOffset, size, data] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdFillBuffer(commandBuffer, dstBuffer, dstOffset, size, data);
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::VkCmdFillBuffer coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(commandBuffer, *observer->getScratch()), toEncoder< uint64_t >(dstBuffer, *observer->getScratch()), toEncoder< uint64_t >(dstOffset, *observer->getScratch()), toEncoder< uint64_t >(size, *observer->getScratch()), data);
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::vkGetPhysicalDeviceSurfaceCapabilitiesKHR(CallObserver* observer, VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR* pSurfaceCapabilities) {
GAPID_DEBUG("vkGetPhysicalDeviceSurfaceCapabilitiesKHR(%zu, %" PRIu64 ", %p)", physicalDevice, surface, pSurfaceCapabilities);
if (PhysicalDevices.find(physicalDevice) == PhysicalDevices.end() ||
mImports.mVkInstanceFunctions.find(PhysicalDevices[physicalDevice]->mInstance) == mImports.mVkInstanceFunctions.end() ||
mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkGetPhysicalDeviceSurfaceCapabilitiesKHR == nullptr) {
GAPID_WARNING("Application called unsupported function vkGetPhysicalDeviceSurfaceCapabilitiesKHR");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, physicalDevice, surface, pSurfaceCapabilities] {
called = true;
observer->observeReads();
result = mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, surface, pSurfaceCapabilities);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
call();
observer->write<VkSurfaceCapabilitiesKHR>(slice(pSurfaceCapabilities, 0ULL, 1ULL), 0ULL, slice(pSurfaceCapabilities, 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::VkGetPhysicalDeviceSurfaceCapabilitiesKHR coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(physicalDevice, *observer->getScratch()), toEncoder< uint64_t >(surface, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkSurfaceCapabilitiesKHR__P >(pSurfaceCapabilities, *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::vkCreateSwapchainKHR(CallObserver* observer, VkDevice device, VkSwapchainCreateInfoKHR* pCreateInfo, VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchain) {
GAPID_DEBUG("vkCreateSwapchainKHR(%zu, %p, %p, %p)", device, pCreateInfo, pAllocator, pSwapchain);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkCreateSwapchainKHR == nullptr) {
GAPID_WARNING("Application called unsupported function vkCreateSwapchainKHR");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, device, pCreateInfo, pAllocator, pSwapchain] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[device].vkCreateSwapchainKHR(device, pCreateInfo, pAllocator, pSwapchain);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
VkSwapchainCreateInfoKHR l_create_info = observer->read(slice(pCreateInfo, 0ULL, 1ULL), 0ULL);
observer->read(slice(l_create_info.mpQueueFamilyIndices, (uint64_t)(0UL), (uint64_t)(l_create_info.mqueueFamilyIndexCount)));
call();
auto l_handle = slice(pSwapchain, 0ULL, 1ULL)[0ULL];
observer->write<VkSwapchainKHR>(slice(pSwapchain, 0ULL, 1ULL), 0ULL, l_handle);
std::shared_ptr<SwapchainObject> l_swapchainObject = std::shared_ptr<SwapchainObject>(new SwapchainObject(device, l_handle, l_create_info.mimageFormat, l_create_info.mimageUsage, U32ToImageObject__R(), l_create_info.mimageExtent.mwidth, l_create_info.mimageExtent.mheight));
this->Swapchains[l_handle] = l_swapchainObject;
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::VkCreateSwapchainKHR coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkSwapchainCreateInfoKHR__CP >(pCreateInfo, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkAllocationCallbacks__CP >(pAllocator, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkSwapchainKHR__P >(pSwapchain, *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::vkCreateSharedSwapchainsKHR(CallObserver* observer, VkDevice device, uint32_t swapchainCount, VkSwapchainCreateInfoKHR* pCreateInfos, VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchains) {
GAPID_DEBUG("vkCreateSharedSwapchainsKHR(%zu, %" PRIu32 ", %p, %p, %p)", device, swapchainCount, pCreateInfos, pAllocator, pSwapchains);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkCreateSharedSwapchainsKHR == nullptr) {
GAPID_WARNING("Application called unsupported function vkCreateSharedSwapchainsKHR");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, device, swapchainCount, pCreateInfos, pAllocator, pSwapchains] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[device].vkCreateSharedSwapchainsKHR(device, swapchainCount, pCreateInfos, pAllocator, pSwapchains);
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::VkCreateSharedSwapchainsKHR coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), swapchainCount, toEncoder< gapic::coder::vulkan::VkSwapchainCreateInfoKHR__CP >(pCreateInfos, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkAllocationCallbacks__CP >(pAllocator, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkSwapchainKHR__P >(pSwapchains, *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::vkDestroyDebugReportCallbackEXT(CallObserver* observer, VkInstance instance, VkDebugReportCallbackEXT callback, VkAllocationCallbacks* pAllocator) {
GAPID_DEBUG("vkDestroyDebugReportCallbackEXT(%zu, %" PRIu64 ", %p)", instance, callback, pAllocator);
if (mImports.mVkInstanceFunctions.find(instance) == mImports.mVkInstanceFunctions.end() ||
mImports.mVkInstanceFunctions[instance].vkDestroyDebugReportCallbackEXT == nullptr) {
GAPID_WARNING("Application called unsupported function vkDestroyDebugReportCallbackEXT");
return;
}
bool called = false;
auto call = [this, observer, &called, instance, callback, pAllocator] {
called = true;
observer->observeReads();
mImports.mVkInstanceFunctions[instance].vkDestroyDebugReportCallbackEXT(instance, callback, pAllocator);
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::VkDestroyDebugReportCallbackEXT coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(instance, *observer->getScratch()), toEncoder< uint64_t >(callback, *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);
}
} // namespace gapii