blob: e922dfc6ad6e704e74c36bb502e54df94a1ebdfd [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::vkCreateAndroidSurfaceKHR(CallObserver* observer, VkInstance instance, VkAndroidSurfaceCreateInfoKHR* pCreateInfo, VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface) {
GAPID_DEBUG("vkCreateAndroidSurfaceKHR(%zu, %p, %p, %p)", instance, pCreateInfo, pAllocator, pSurface);
if (mImports.mVkInstanceFunctions.find(instance) == mImports.mVkInstanceFunctions.end() ||
mImports.mVkInstanceFunctions[instance].vkCreateAndroidSurfaceKHR == nullptr) {
GAPID_WARNING("Application called unsupported function vkCreateAndroidSurfaceKHR");
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].vkCreateAndroidSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
std::shared_ptr<SurfaceObject> l_surface = subCreateAndroidSurfaceObject(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::VkCreateAndroidSurfaceKHR coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(instance, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkAndroidSurfaceCreateInfoKHR__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;
}
uint32_t VulkanSpy::vkCreateXlibSurfaceKHR(CallObserver* observer, VkInstance instance, VkXlibSurfaceCreateInfoKHR* pCreateInfo, VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface) {
GAPID_DEBUG("vkCreateXlibSurfaceKHR(%zu, %p, %p, %p)", instance, pCreateInfo, pAllocator, pSurface);
if (mImports.mVkInstanceFunctions.find(instance) == mImports.mVkInstanceFunctions.end() ||
mImports.mVkInstanceFunctions[instance].vkCreateXlibSurfaceKHR == nullptr) {
GAPID_WARNING("Application called unsupported function vkCreateXlibSurfaceKHR");
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].vkCreateXlibSurfaceKHR(instance, pCreateInfo, pAllocator, pSurface);
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::VkCreateXlibSurfaceKHR coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(instance, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkXlibSurfaceCreateInfoKHR__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;
}
uint32_t VulkanSpy::ReplayCreateVkDevice(CallObserver* observer, VkPhysicalDevice physicalDevice, VkDeviceCreateInfo* pCreateInfo, VkAllocationCallbacks* pAllocator, VkDevice* pDevice) {
GAPID_DEBUG("ReplayCreateVkDevice(%zu, %p, %p, %p)", physicalDevice, pCreateInfo, pAllocator, pDevice);
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, physicalDevice, pCreateInfo, pAllocator, pDevice] {
called = true;
observer->observeReads();
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
std::shared_ptr<DeviceObject> l_device = subCreateDeviceObject(observer, call, pCreateInfo);
checkNotNull(l_device).mPhysicalDevice = physicalDevice;
call();
auto l_handle = slice(pDevice, 0ULL, 1ULL)[0ULL];
observer->write<VkDevice>(slice(pDevice, 0ULL, 1ULL), 0ULL, l_handle);
checkNotNull(l_device).mVulkanHandle = l_handle;
this->Devices[l_handle] = l_device;
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::ReplayCreateVkDevice coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(physicalDevice, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkDeviceCreateInfo__CP >(pCreateInfo, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkAllocationCallbacks__CP >(pAllocator, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkDevice__P >(pDevice, *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::replayRegisterVkInstance(CallObserver* observer, VkInstance instance) {
GAPID_DEBUG("replayRegisterVkInstance(%zu)", instance);
bool called = false;
auto call = [this, observer, &called, instance] {
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::ReplayRegisterVkInstance coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(instance, *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::vkDestroyInstance(CallObserver* observer, VkInstance instance, VkAllocationCallbacks* pAllocator) {
GAPID_DEBUG("vkDestroyInstance(%zu, %p)", instance, pAllocator);
bool called = false;
auto call = [this, observer, &called, instance, pAllocator] {
called = true;
observer->observeReads();
SpyOverride_vkDestroyInstance(instance, pAllocator);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
this->Instances.erase(instance);
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::VkDestroyInstance coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(instance, *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::vkGetPhysicalDeviceFormatProperties(CallObserver* observer, VkPhysicalDevice physicalDevice, uint32_t format, VkFormatProperties* pFormatProperties) {
GAPID_DEBUG("vkGetPhysicalDeviceFormatProperties(%zu, %u, %p)", physicalDevice, format, pFormatProperties);
if (PhysicalDevices.find(physicalDevice) == PhysicalDevices.end() ||
mImports.mVkInstanceFunctions.find(PhysicalDevices[physicalDevice]->mInstance) == mImports.mVkInstanceFunctions.end() ||
mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkGetPhysicalDeviceFormatProperties == nullptr) {
GAPID_WARNING("Application called unsupported function vkGetPhysicalDeviceFormatProperties");
return;
}
bool called = false;
auto call = [this, observer, &called, physicalDevice, format, pFormatProperties] {
called = true;
observer->observeReads();
mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkGetPhysicalDeviceFormatProperties(physicalDevice, format, pFormatProperties);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
call();
observer->write<VkFormatProperties>(slice(pFormatProperties, 0ULL, 1ULL), 0ULL, slice(pFormatProperties, 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::VkGetPhysicalDeviceFormatProperties coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(physicalDevice, *observer->getScratch()), format, toEncoder< gapic::coder::vulkan::VkFormatProperties__P >(pFormatProperties, *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::vkGetPhysicalDeviceMemoryProperties(CallObserver* observer, VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties* pMemoryProperties) {
GAPID_DEBUG("vkGetPhysicalDeviceMemoryProperties(%zu, %p)", physicalDevice, pMemoryProperties);
if (PhysicalDevices.find(physicalDevice) == PhysicalDevices.end() ||
mImports.mVkInstanceFunctions.find(PhysicalDevices[physicalDevice]->mInstance) == mImports.mVkInstanceFunctions.end() ||
mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkGetPhysicalDeviceMemoryProperties == nullptr) {
GAPID_WARNING("Application called unsupported function vkGetPhysicalDeviceMemoryProperties");
return;
}
bool called = false;
auto call = [this, observer, &called, physicalDevice, pMemoryProperties] {
called = true;
observer->observeReads();
mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkGetPhysicalDeviceMemoryProperties(physicalDevice, pMemoryProperties);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
call();
auto l_memoryProperties = slice(pMemoryProperties, 0ULL, 1ULL)[0ULL];
observer->write<VkPhysicalDeviceMemoryProperties>(slice(pMemoryProperties, 0ULL, 1ULL), 0ULL, l_memoryProperties);
std::shared_ptr<PhysicalDeviceObject> l_dev = findOrZero(this->PhysicalDevices, physicalDevice);
checkNotNull(l_dev).mMemoryProperties = l_memoryProperties;
this->PhysicalDevices[physicalDevice] = l_dev;
} 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::VkGetPhysicalDeviceMemoryProperties coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(physicalDevice, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkPhysicalDeviceMemoryProperties__P >(pMemoryProperties, *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::vkDeviceWaitIdle(CallObserver* observer, VkDevice device) {
GAPID_DEBUG("vkDeviceWaitIdle(%zu)", device);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkDeviceWaitIdle == nullptr) {
GAPID_WARNING("Application called unsupported function vkDeviceWaitIdle");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, device] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[device].vkDeviceWaitIdle(device);
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::VkDeviceWaitIdle coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *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::vkGetBufferMemoryRequirements(CallObserver* observer, VkDevice device, VkBuffer buffer, VkMemoryRequirements* pMemoryRequirements) {
GAPID_DEBUG("vkGetBufferMemoryRequirements(%zu, %" PRIu64 ", %p)", device, buffer, pMemoryRequirements);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkGetBufferMemoryRequirements == nullptr) {
GAPID_WARNING("Application called unsupported function vkGetBufferMemoryRequirements");
return;
}
bool called = false;
auto call = [this, observer, &called, device, buffer, pMemoryRequirements] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[device].vkGetBufferMemoryRequirements(device, buffer, pMemoryRequirements);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
call();
auto l_requirements = slice(pMemoryRequirements, 0ULL, 1ULL)[0ULL];
observer->write<VkMemoryRequirements>(slice(pMemoryRequirements, 0ULL, 1ULL), 0ULL, l_requirements);
} 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::VkGetBufferMemoryRequirements coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< uint64_t >(buffer, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkMemoryRequirements__P >(pMemoryRequirements, *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::vkCreateFence(CallObserver* observer, VkDevice device, VkFenceCreateInfo* pCreateInfo, VkAllocationCallbacks* pAllocator, VkFence* pFence) {
GAPID_DEBUG("vkCreateFence(%zu, %p, %p, %p)", device, pCreateInfo, pAllocator, pFence);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkCreateFence == nullptr) {
GAPID_WARNING("Application called unsupported function vkCreateFence");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, device, pCreateInfo, pAllocator, pFence] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[device].vkCreateFence(device, pCreateInfo, pAllocator, pFence);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
std::shared_ptr<FenceObject> l_f = std::shared_ptr<FenceObject>(new FenceObject(0, 0, false));
VkFenceCreateInfo l_create_info = observer->read(slice(pCreateInfo, 0ULL, 1ULL), 0ULL);
checkNotNull(l_f).mDevice = device;
if ((((uint32_t)(l_create_info.mflags)) & ((uint32_t)(VkFenceCreateFlagBits::VK_FENCE_CREATE_SIGNALED_BIT))) != (0UL)) {
checkNotNull(l_f).mSignaled = true;
} else {
checkNotNull(l_f).mSignaled = false;
}
call();
auto l_handle = slice(pFence, 0ULL, 1ULL)[0ULL];
observer->write<VkFence>(slice(pFence, 0ULL, 1ULL), 0ULL, l_handle);
checkNotNull(l_f).mVulkanHandle = l_handle;
this->Fences[l_handle] = l_f;
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::VkCreateFence coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkFenceCreateInfo__CP >(pCreateInfo, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkAllocationCallbacks__CP >(pAllocator, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkFence__P >(pFence, *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::vkResetEvent(CallObserver* observer, VkDevice device, VkEvent event) {
GAPID_DEBUG("vkResetEvent(%zu, %" PRIu64 ")", device, event);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkResetEvent == nullptr) {
GAPID_WARNING("Application called unsupported function vkResetEvent");
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].vkResetEvent(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::VkResetEvent 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;
}
void VulkanSpy::vkDestroyBufferView(CallObserver* observer, VkDevice device, VkBufferView bufferView, VkAllocationCallbacks* pAllocator) {
GAPID_DEBUG("vkDestroyBufferView(%zu, %" PRIu64 ", %p)", device, bufferView, pAllocator);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkDestroyBufferView == nullptr) {
GAPID_WARNING("Application called unsupported function vkDestroyBufferView");
return;
}
bool called = false;
auto call = [this, observer, &called, device, bufferView, pAllocator] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[device].vkDestroyBufferView(device, bufferView, 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::VkDestroyBufferView coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< uint64_t >(bufferView, *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::vkCreateShaderModule(CallObserver* observer, VkDevice device, VkShaderModuleCreateInfo* pCreateInfo, VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule) {
GAPID_DEBUG("vkCreateShaderModule(%zu, %p, %p, %p)", device, pCreateInfo, pAllocator, pShaderModule);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkCreateShaderModule == nullptr) {
GAPID_WARNING("Application called unsupported function vkCreateShaderModule");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, device, pCreateInfo, pAllocator, pShaderModule] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[device].vkCreateShaderModule(device, pCreateInfo, pAllocator, pShaderModule);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
VkShaderModuleCreateInfo l_create_info = observer->read(slice(pCreateInfo, 0ULL, 1ULL), 0ULL);
uint64_t l_num_words = ((uint64_t)(l_create_info.mcodeSize)) / (4ULL);
std::shared_ptr<ShaderModuleObject> l_object = std::shared_ptr<ShaderModuleObject>(new ShaderModuleObject(device, observer->clone(slice(l_create_info.mpCode, 0ULL, l_num_words)), 0));
call();
auto l_handle = slice(pShaderModule, 0ULL, 1ULL)[0ULL];
observer->write<VkShaderModule>(slice(pShaderModule, 0ULL, 1ULL), 0ULL, l_handle);
checkNotNull(l_object).mVulkanHandle = l_handle;
this->ShaderModules[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::VkCreateShaderModule coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkShaderModuleCreateInfo__CP >(pCreateInfo, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkAllocationCallbacks__CP >(pAllocator, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkShaderModule__P >(pShaderModule, *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::vkDestroyDescriptorPool(CallObserver* observer, VkDevice device, VkDescriptorPool descriptorPool, VkAllocationCallbacks* pAllocator) {
GAPID_DEBUG("vkDestroyDescriptorPool(%zu, %" PRIu64 ", %p)", device, descriptorPool, pAllocator);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkDestroyDescriptorPool == nullptr) {
GAPID_WARNING("Application called unsupported function vkDestroyDescriptorPool");
return;
}
bool called = false;
auto call = [this, observer, &called, device, descriptorPool, pAllocator] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[device].vkDestroyDescriptorPool(device, descriptorPool, pAllocator);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
this->DescriptorPools.erase(descriptorPool);
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::VkDestroyDescriptorPool coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< uint64_t >(descriptorPool, *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::vkUpdateDescriptorSets(CallObserver* observer, VkDevice device, uint32_t descriptorWriteCount, VkWriteDescriptorSet* pDescriptorWrites, uint32_t descriptorCopyCount, VkCopyDescriptorSet* pDescriptorCopies) {
GAPID_DEBUG("vkUpdateDescriptorSets(%zu, %" PRIu32 ", %p, %" PRIu32 ", %p)", device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkUpdateDescriptorSets == nullptr) {
GAPID_WARNING("Application called unsupported function vkUpdateDescriptorSets");
return;
}
bool called = false;
auto call = [this, observer, &called, device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[device].vkUpdateDescriptorSets(device, descriptorWriteCount, pDescriptorWrites, descriptorCopyCount, pDescriptorCopies);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
Slice<VkWriteDescriptorSet> l_writes = slice(pDescriptorWrites, (uint64_t)(0UL), (uint64_t)(descriptorWriteCount));
for (uint32_t l_i = 0UL; l_i < descriptorWriteCount; ++l_i) {
VkWriteDescriptorSet l_write = observer->read(l_writes, (uint64_t)(l_i));
std::shared_ptr<DescriptorSetObject> l_set = findOrZero(this->DescriptorSets, l_write.mdstSet);
uint32_t l_count = l_write.mdescriptorCount;
switch (l_write.mdescriptorType) {
case VkDescriptorType::VK_DESCRIPTOR_TYPE_SAMPLER: // fall-through...
case VkDescriptorType::VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: // fall-through...
case VkDescriptorType::VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE: // fall-through...
case VkDescriptorType::VK_DESCRIPTOR_TYPE_STORAGE_IMAGE: // fall-through...
case VkDescriptorType::VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: {
observer->read(slice(l_write.mpImageInfo, (uint64_t)(0UL), (uint64_t)(l_count)));
break;
}
case VkDescriptorType::VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER: // fall-through...
case VkDescriptorType::VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: {
observer->read(slice(l_write.mpTexelBufferView, (uint64_t)(0UL), (uint64_t)(l_count)));
break;
}
case VkDescriptorType::VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: // fall-through...
case VkDescriptorType::VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: // fall-through...
case VkDescriptorType::VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: // fall-through...
case VkDescriptorType::VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: {
Slice<VkDescriptorBufferInfo> l_bufInfo = slice(l_write.mpBufferInfo, (uint64_t)(0UL), (uint64_t)(l_count));
checkNotNull(l_set).mBoundBuffers.erase(l_write.mdstBinding);
U32ToBoundBuffer l_binding = findOrZero(checkNotNull(l_set).mBoundBuffers, l_write.mdstBinding);
for (uint32_t l_j = 0UL; l_j < l_count; ++l_j) {
l_binding[l_j] = BoundBuffer(findOrZero(this->Buffers, observer->read(l_bufInfo, (uint64_t)(l_j)).mbuffer), observer->read(l_bufInfo, (uint64_t)(l_j)).moffset, observer->read(l_bufInfo, (uint64_t)(l_j)).mrange);
}
checkNotNull(l_set).mBoundBuffers[l_write.mdstBinding] = l_binding;
break;
}
}
}
observer->read(slice(pDescriptorCopies, (uint64_t)(0UL), (uint64_t)(descriptorCopyCount)));
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::VkUpdateDescriptorSets coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), descriptorWriteCount, toEncoder< gapic::coder::vulkan::VkWriteDescriptorSet__CP >(pDescriptorWrites, *observer->getScratch()), descriptorCopyCount, toEncoder< gapic::coder::vulkan::VkCopyDescriptorSet__CP >(pDescriptorCopies, *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::vkCreateRenderPass(CallObserver* observer, VkDevice device, VkRenderPassCreateInfo* pCreateInfo, VkAllocationCallbacks* pAllocator, VkRenderPass* pRenderPass) {
GAPID_DEBUG("vkCreateRenderPass(%zu, %p, %p, %p)", device, pCreateInfo, pAllocator, pRenderPass);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkCreateRenderPass == nullptr) {
GAPID_WARNING("Application called unsupported function vkCreateRenderPass");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, device, pCreateInfo, pAllocator, pRenderPass] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[device].vkCreateRenderPass(device, pCreateInfo, pAllocator, pRenderPass);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
std::shared_ptr<RenderPassObject> l_renderPass = std::shared_ptr<RenderPassObject>(new RenderPassObject(0, 0));
checkNotNull(l_renderPass).mDevice = device;
VkRenderPassCreateInfo l_info = observer->read(slice(pCreateInfo, 0ULL, 1ULL), 0ULL);
observer->read(slice(l_info.mpAttachments, (uint64_t)(0UL), (uint64_t)(l_info.mattachmentCount)));
Slice<VkSubpassDescription> l_subpasses = slice(l_info.mpSubpasses, (uint64_t)(0UL), (uint64_t)(l_info.msubpassCount));
observer->read(l_subpasses);
for (uint32_t l_i = 0UL; l_i < l_info.msubpassCount; ++l_i) {
VkSubpassDescription l_subpass = observer->read(l_subpasses, (uint64_t)(l_i));
observer->read(slice(l_subpass.mpInputAttachments, (uint64_t)(0UL), (uint64_t)(l_subpass.minputAttachmentCount)));
observer->read(slice(l_subpass.mpColorAttachments, (uint64_t)(0UL), (uint64_t)(l_subpass.mcolorAttachmentCount)));
if ((l_subpass.mpResolveAttachments) != (nullptr)) {
observer->read(slice(l_subpass.mpResolveAttachments, (uint64_t)(0UL), (uint64_t)(l_subpass.mcolorAttachmentCount)));
}
if ((l_subpass.mpDepthStencilAttachment) != (nullptr)) {
(void)observer->read(slice(l_subpass.mpDepthStencilAttachment, 0ULL, 1ULL), 0ULL);
}
observer->read(slice(l_subpass.mpPreserveAttachments, (uint64_t)(0UL), (uint64_t)(l_subpass.mpreserveAttachmentCount)));
}
observer->read(slice(l_info.mpDependencies, (uint64_t)(0UL), (uint64_t)(l_info.mdependencyCount)));
call();
observer->write<VkRenderPass>(slice(pRenderPass, 0ULL, 1ULL), 0ULL, slice(pRenderPass, 0ULL, 1ULL)[0ULL]);
checkNotNull(l_renderPass).mVulkanHandle = observer->read(slice(pRenderPass, 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::VkCreateRenderPass coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkRenderPassCreateInfo__CP >(pCreateInfo, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkAllocationCallbacks__CP >(pAllocator, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkRenderPass__P >(pRenderPass, *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::vkCmdDrawIndexedIndirect(CallObserver* observer, VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride) {
GAPID_DEBUG("vkCmdDrawIndexedIndirect(%zu, %" PRIu64 ", %" PRIu64 ", %" PRIu32 ", %" PRIu32 ")", commandBuffer, buffer, offset, drawCount, stride);
if (CommandBuffers.find(commandBuffer) == CommandBuffers.end() ||
mImports.mVkDeviceFunctions.find(CommandBuffers[commandBuffer]->mDevice) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdDrawIndexedIndirect == nullptr) {
GAPID_WARNING("Application called unsupported function vkCmdDrawIndexedIndirect");
return;
}
bool called = false;
auto call = [this, observer, &called, commandBuffer, buffer, offset, drawCount, stride] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdDrawIndexedIndirect(commandBuffer, buffer, offset, drawCount, stride);
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::VkCmdDrawIndexedIndirect coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(commandBuffer, *observer->getScratch()), toEncoder< uint64_t >(buffer, *observer->getScratch()), toEncoder< uint64_t >(offset, *observer->getScratch()), drawCount, stride);
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::vkCmdCopyImageToBuffer(CallObserver* observer, VkCommandBuffer commandBuffer, VkImage srcImage, uint32_t srcImageLayout, VkBuffer dstBuffer, uint32_t regionCount, VkBufferImageCopy* pRegions) {
GAPID_DEBUG("vkCmdCopyImageToBuffer(%zu, %" PRIu64 ", %u, %" PRIu64 ", %" PRIu32 ", %p)", commandBuffer, srcImage, srcImageLayout, dstBuffer, regionCount, pRegions);
if (CommandBuffers.find(commandBuffer) == CommandBuffers.end() ||
mImports.mVkDeviceFunctions.find(CommandBuffers[commandBuffer]->mDevice) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdCopyImageToBuffer == nullptr) {
GAPID_WARNING("Application called unsupported function vkCmdCopyImageToBuffer");
return;
}
bool called = false;
auto call = [this, observer, &called, commandBuffer, srcImage, srcImageLayout, dstBuffer, regionCount, pRegions] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdCopyImageToBuffer(commandBuffer, srcImage, srcImageLayout, dstBuffer, regionCount, pRegions);
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::VkCmdCopyImageToBuffer coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(commandBuffer, *observer->getScratch()), toEncoder< uint64_t >(srcImage, *observer->getScratch()), srcImageLayout, toEncoder< uint64_t >(dstBuffer, *observer->getScratch()), regionCount, toEncoder< gapic::coder::vulkan::VkBufferImageCopy__CP >(pRegions, *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::vkCmdClearColorImage(CallObserver* observer, VkCommandBuffer commandBuffer, VkImage image, uint32_t imageLayout, VkClearColorValue* pColor, uint32_t rangeCount, VkImageSubresourceRange* pRanges) {
GAPID_DEBUG("vkCmdClearColorImage(%zu, %" PRIu64 ", %u, %p, %" PRIu32 ", %p)", commandBuffer, image, imageLayout, pColor, rangeCount, pRanges);
if (CommandBuffers.find(commandBuffer) == CommandBuffers.end() ||
mImports.mVkDeviceFunctions.find(CommandBuffers[commandBuffer]->mDevice) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdClearColorImage == nullptr) {
GAPID_WARNING("Application called unsupported function vkCmdClearColorImage");
return;
}
bool called = false;
auto call = [this, observer, &called, commandBuffer, image, imageLayout, pColor, rangeCount, pRanges] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdClearColorImage(commandBuffer, image, imageLayout, pColor, rangeCount, pRanges);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
(void)observer->read(slice(pColor, 0ULL, 1ULL), 0ULL);
observer->read(slice(pRanges, (uint64_t)(0UL), (uint64_t)(rangeCount)));
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::VkCmdClearColorImage coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(commandBuffer, *observer->getScratch()), toEncoder< uint64_t >(image, *observer->getScratch()), imageLayout, toEncoder< gapic::coder::vulkan::VkClearColorValue__CP >(pColor, *observer->getScratch()), rangeCount, toEncoder< gapic::coder::vulkan::VkImageSubresourceRange__CP >(pRanges, *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::vkCmdResetEvent(CallObserver* observer, VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask) {
GAPID_DEBUG("vkCmdResetEvent(%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].vkCmdResetEvent == nullptr) {
GAPID_WARNING("Application called unsupported function vkCmdResetEvent");
return;
}
bool called = false;
auto call = [this, observer, &called, commandBuffer, event, stageMask] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdResetEvent(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::VkCmdResetEvent 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::vkCmdPipelineBarrier(CallObserver* observer, VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount, VkMemoryBarrier* pMemoryBarriers, uint32_t bufferMemoryBarrierCount, VkBufferMemoryBarrier* pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, VkImageMemoryBarrier* pImageMemoryBarriers) {
GAPID_DEBUG("vkCmdPipelineBarrier(%zu, %" PRIu32 ", %" PRIu32 ", %" PRIu32 ", %" PRIu32 ", %p, %" PRIu32 ", %p, %" PRIu32 ", %p)", commandBuffer, srcStageMask, dstStageMask, dependencyFlags, 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].vkCmdPipelineBarrier == nullptr) {
GAPID_WARNING("Application called unsupported function vkCmdPipelineBarrier");
return;
}
bool called = false;
auto call = [this, observer, &called, commandBuffer, srcStageMask, dstStageMask, dependencyFlags, memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdPipelineBarrier(commandBuffer, srcStageMask, dstStageMask, dependencyFlags, memoryBarrierCount, pMemoryBarriers, bufferMemoryBarrierCount, pBufferMemoryBarriers, imageMemoryBarrierCount, pImageMemoryBarriers);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
observer->read(slice(pMemoryBarriers, (uint64_t)(0UL), (uint64_t)(memoryBarrierCount)));
observer->read(slice(pBufferMemoryBarriers, (uint64_t)(0UL), (uint64_t)(bufferMemoryBarrierCount)));
Slice<VkImageMemoryBarrier> l_imageMemoryBarriers = slice(pImageMemoryBarriers, (uint64_t)(0UL), (uint64_t)(imageMemoryBarrierCount));
CmdPipelineBarrier l_barrier = CmdPipelineBarrier(U32ToVkImageMemoryBarrier());
for (uint32_t l_i = 0UL; l_i < imageMemoryBarrierCount; ++l_i) {
l_barrier.mImageBarriers[l_i] = observer->read(l_imageMemoryBarriers, (uint64_t)(l_i));
}
addCmd(observer, commandBuffer, l_barrier, &VulkanSpy::subDoCmdPipelineBarrier);
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::VkCmdPipelineBarrier coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(commandBuffer, *observer->getScratch()), toEncoder< uint32_t >(srcStageMask, *observer->getScratch()), toEncoder< uint32_t >(dstStageMask, *observer->getScratch()), toEncoder< uint32_t >(dependencyFlags, *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::vkCmdWriteTimestamp(CallObserver* observer, VkCommandBuffer commandBuffer, uint32_t pipelineStage, VkQueryPool queryPool, uint32_t query) {
GAPID_DEBUG("vkCmdWriteTimestamp(%zu, %u, %" PRIu64 ", %" PRIu32 ")", commandBuffer, pipelineStage, queryPool, query);
if (CommandBuffers.find(commandBuffer) == CommandBuffers.end() ||
mImports.mVkDeviceFunctions.find(CommandBuffers[commandBuffer]->mDevice) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdWriteTimestamp == nullptr) {
GAPID_WARNING("Application called unsupported function vkCmdWriteTimestamp");
return;
}
bool called = false;
auto call = [this, observer, &called, commandBuffer, pipelineStage, queryPool, query] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdWriteTimestamp(commandBuffer, pipelineStage, queryPool, query);
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::VkCmdWriteTimestamp coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(commandBuffer, *observer->getScratch()), pipelineStage, toEncoder< uint64_t >(queryPool, *observer->getScratch()), query);
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::vkCmdExecuteCommands(CallObserver* observer, VkCommandBuffer commandBuffer, uint32_t commandBufferCount, VkCommandBuffer* pCommandBuffers) {
GAPID_DEBUG("vkCmdExecuteCommands(%zu, %" PRIu32 ", %p)", commandBuffer, commandBufferCount, pCommandBuffers);
if (CommandBuffers.find(commandBuffer) == CommandBuffers.end() ||
mImports.mVkDeviceFunctions.find(CommandBuffers[commandBuffer]->mDevice) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdExecuteCommands == nullptr) {
GAPID_WARNING("Application called unsupported function vkCmdExecuteCommands");
return;
}
bool called = false;
auto call = [this, observer, &called, commandBuffer, commandBufferCount, pCommandBuffers] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[CommandBuffers[commandBuffer]->mDevice].vkCmdExecuteCommands(commandBuffer, commandBufferCount, pCommandBuffers);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
observer->read(slice(pCommandBuffers, (uint64_t)(0UL), (uint64_t)(commandBufferCount)));
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::VkCmdExecuteCommands coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(commandBuffer, *observer->getScratch()), commandBufferCount, toEncoder< gapic::coder::vulkan::VkCommandBuffer__CP >(pCommandBuffers, *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::vkGetPhysicalDeviceSurfaceFormatsKHR(CallObserver* observer, VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pSurfaceFormatCount, VkSurfaceFormatKHR* pSurfaceFormats) {
GAPID_DEBUG("vkGetPhysicalDeviceSurfaceFormatsKHR(%zu, %" PRIu64 ", %p, %p)", physicalDevice, surface, pSurfaceFormatCount, pSurfaceFormats);
if (PhysicalDevices.find(physicalDevice) == PhysicalDevices.end() ||
mImports.mVkInstanceFunctions.find(PhysicalDevices[physicalDevice]->mInstance) == mImports.mVkInstanceFunctions.end() ||
mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkGetPhysicalDeviceSurfaceFormatsKHR == nullptr) {
GAPID_WARNING("Application called unsupported function vkGetPhysicalDeviceSurfaceFormatsKHR");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, physicalDevice, surface, pSurfaceFormatCount, pSurfaceFormats] {
called = true;
observer->observeReads();
result = mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, surface, pSurfaceFormatCount, pSurfaceFormats);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
(void)observer->read(slice(pSurfaceFormatCount, 0ULL, 1ULL), 0ULL);
call();
if ((pSurfaceFormats) == (nullptr)) {
observer->write<uint32_t>(slice(pSurfaceFormatCount, 0ULL, 1ULL), 0ULL, slice(pSurfaceFormatCount, 0ULL, 1ULL)[0ULL]);
} else {
uint32_t l_count = (uint32_t)(slice(pSurfaceFormatCount, 0ULL, 1ULL)[0ULL]);
Slice<VkSurfaceFormatKHR> l_formats = slice(pSurfaceFormats, (uint64_t)(0UL), (uint64_t)(l_count));
for (uint32_t l_i = 0UL; l_i < l_count; ++l_i) {
observer->write<VkSurfaceFormatKHR>(l_formats, (uint64_t)(l_i), slice(pSurfaceFormats, (uint64_t)(0UL), (uint64_t)(l_count))[(uint64_t)(l_i)]);
}
observer->write<uint32_t>(slice(pSurfaceFormatCount, 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::VkGetPhysicalDeviceSurfaceFormatsKHR coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(physicalDevice, *observer->getScratch()), toEncoder< uint64_t >(surface, *observer->getScratch()), toEncoder< gapic::coder::vulkan::U32__P >(pSurfaceFormatCount, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkSurfaceFormatKHR__P >(pSurfaceFormats, *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::vkDestroySwapchainKHR(CallObserver* observer, VkDevice device, VkSwapchainKHR swapchain, VkAllocationCallbacks* pAllocator) {
GAPID_DEBUG("vkDestroySwapchainKHR(%zu, %" PRIu64 ", %p)", device, swapchain, pAllocator);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkDestroySwapchainKHR == nullptr) {
GAPID_WARNING("Application called unsupported function vkDestroySwapchainKHR");
return;
}
bool called = false;
auto call = [this, observer, &called, device, swapchain, pAllocator] {
called = true;
observer->observeReads();
mImports.mVkDeviceFunctions[device].vkDestroySwapchainKHR(device, swapchain, pAllocator);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
std::shared_ptr<SwapchainObject> l_swapObject = findOrZero(this->Swapchains, swapchain);
if ((l_swapObject) != (std::shared_ptr<SwapchainObject>())) {
{
int32_t l__ = 0;
for (U32ToImageObject__R::iterator it = checkNotNull(l_swapObject).mSwapchainImages.begin(); it != checkNotNull(l_swapObject).mSwapchainImages.end(); ++it, ++l__) {
uint32_t l__ = it->first;
std::shared_ptr<ImageObject> l_v = it->second;
this->Images.erase(checkNotNull(l_v).mVulkanHandle);
}
}
this->Swapchains.erase(swapchain);
}
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::VkDestroySwapchainKHR coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< uint64_t >(swapchain, *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::vkGetSwapchainImagesKHR(CallObserver* observer, VkDevice device, VkSwapchainKHR swapchain, uint32_t* pSwapchainImageCount, VkImage* pSwapchainImages) {
GAPID_DEBUG("vkGetSwapchainImagesKHR(%zu, %" PRIu64 ", %p, %p)", device, swapchain, pSwapchainImageCount, pSwapchainImages);
if (mImports.mVkDeviceFunctions.find(device) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[device].vkGetSwapchainImagesKHR == nullptr) {
GAPID_WARNING("Application called unsupported function vkGetSwapchainImagesKHR");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, device, swapchain, pSwapchainImageCount, pSwapchainImages] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[device].vkGetSwapchainImagesKHR(device, swapchain, pSwapchainImageCount, pSwapchainImages);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
std::shared_ptr<SwapchainObject> l_swapchainObject = findOrZero(this->Swapchains, swapchain);
if ((pSwapchainImages) != (nullptr)) {
(void)observer->read(slice(pSwapchainImageCount, 0ULL, 1ULL), 0ULL);
}
call();
if ((pSwapchainImages) == (nullptr)) {
observer->write<uint32_t>(slice(pSwapchainImageCount, 0ULL, 1ULL), 0ULL, slice(pSwapchainImageCount, 0ULL, 1ULL)[0ULL]);
} else {
uint32_t l_count = observer->read(slice(pSwapchainImageCount, 0ULL, 1ULL), 0ULL);
Slice<VkImage> l_images = slice(pSwapchainImages, (uint64_t)(0UL), (uint64_t)(l_count));
for (uint32_t l_i = 0UL; l_i < l_count; ++l_i) {
observer->write<VkImage>(l_images, (uint64_t)(l_i), slice(pSwapchainImages, (uint64_t)(0UL), (uint64_t)(l_count))[(uint64_t)(l_i)]);
std::shared_ptr<ImageObject> l_object = std::shared_ptr<ImageObject>(new ImageObject(device, 0, std::shared_ptr<DeviceMemoryObject>(), false, observer->read(l_images, (uint64_t)(l_i)), 0, VkImageType::VK_IMAGE_TYPE_2D, 0, checkNotNull(l_swapchainObject).mUsage, VkImageLayout::VK_IMAGE_LAYOUT_UNDEFINED, 0, U32ToImageLayer__R()));
checkNotNull(l_object).mIsSwapchainImage = true;
uint32_t l_width = checkNotNull(l_swapchainObject).mWidth;
uint32_t l_height = checkNotNull(l_swapchainObject).mHeight;
uint32_t l_format = checkNotNull(l_swapchainObject).mFormat;
std::shared_ptr<ImageLayer> l_layer = std::shared_ptr<ImageLayer>(new ImageLayer(U32ToImageLevel__R()));
std::shared_ptr<ImageLevel> l_level = std::shared_ptr<ImageLevel>(new ImageLevel(l_width, l_height, 1UL, Slice<uint8_t>(), 0));
ElementAndTexelBlockSize l_elementAndTexelBlockSize = subGetElementAndTexelBlockSize(observer, call, l_format);
uint32_t l_widthInBlocks = subRoundUpTo(observer, call, l_width, l_elementAndTexelBlockSize.mTexelBlockSize.mWidth);
uint32_t l_heightInBlocks = subRoundUpTo(observer, call, l_height, l_elementAndTexelBlockSize.mTexelBlockSize.mHeight);
uint32_t l_size = (l_widthInBlocks) * ((l_heightInBlocks) * (l_elementAndTexelBlockSize.mElementSize));
checkNotNull(l_level).mData = make<uint8_t>((uint64_t)(l_size));
checkNotNull(l_object).mFormat = l_format;
checkNotNull(l_object).mLayers[0UL] = l_layer;
checkNotNull(findOrZero(checkNotNull(l_object).mLayers, 0UL)).mLevels[0UL] = l_level;
checkNotNull(l_object).mSamples = VkSampleCountFlagBits::VK_SAMPLE_COUNT_1_BIT;
this->Images[observer->read(l_images, (uint64_t)(l_i))] = l_object;
checkNotNull(l_swapchainObject).mSwapchainImages[l_i] = findOrZero(this->Images, observer->read(l_images, (uint64_t)(l_i)));
}
observer->write<uint32_t>(slice(pSwapchainImageCount, 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::VkGetSwapchainImagesKHR coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(device, *observer->getScratch()), toEncoder< uint64_t >(swapchain, *observer->getScratch()), toEncoder< gapic::coder::vulkan::U32__P >(pSwapchainImageCount, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkImage__P >(pSwapchainImages, *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::vkQueuePresentKHR(CallObserver* observer, VkQueue queue, VkPresentInfoKHR* pPresentInfo) {
GAPID_DEBUG("vkQueuePresentKHR(%zu, %p)", queue, pPresentInfo);
if (Queues.find(queue) == Queues.end() ||
mImports.mVkDeviceFunctions.find(Queues[queue]->mDevice) == mImports.mVkDeviceFunctions.end() ||
mImports.mVkDeviceFunctions[Queues[queue]->mDevice].vkQueuePresentKHR == nullptr) {
GAPID_WARNING("Application called unsupported function vkQueuePresentKHR");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, queue, pPresentInfo] {
called = true;
observer->observeReads();
result = mImports.mVkDeviceFunctions[Queues[queue]->mDevice].vkQueuePresentKHR(queue, pPresentInfo);
onPostFence(observer);
};
onPreEndOfFrame();
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
this->LastBoundQueue = queue;
VkPresentInfoKHR l_info = observer->read(slice(pPresentInfo, 0ULL, 1ULL), 0ULL);
if ((l_info.mpWaitSemaphores) != (nullptr)) {
observer->read(slice(l_info.mpWaitSemaphores, (uint64_t)(0UL), (uint64_t)(l_info.mwaitSemaphoreCount)));
}
Slice<VkSwapchainKHR> l_swapchains = slice(l_info.mpSwapchains, (uint64_t)(0UL), (uint64_t)(l_info.mswapchainCount));
Slice<uint32_t> l_imageIndices = slice(l_info.mpImageIndices, (uint64_t)(0UL), (uint64_t)(l_info.mswapchainCount));
for (uint32_t l_i = 0UL; l_i < l_info.mswapchainCount; ++l_i) {
std::shared_ptr<SwapchainObject> l_swapchain = findOrZero(this->Swapchains, observer->read(l_swapchains, (uint64_t)(l_i)));
std::shared_ptr<ImageObject> l_image = findOrZero(checkNotNull(l_swapchain).mSwapchainImages, observer->read(l_imageIndices, (uint64_t)(l_i)));
checkNotNull(l_image).mLastBoundQueue = queue;
}
call();
if ((l_info.mpResults) != (nullptr)) {
observer->read(slice(l_info.mpResults, (uint64_t)(0UL), (uint64_t)(l_info.mswapchainCount)));
}
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::VkQueuePresentKHR coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(queue, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkPresentInfoKHR__CP >(pPresentInfo, *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::vkGetPhysicalDeviceDisplayPropertiesKHR(CallObserver* observer, VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkDisplayPropertiesKHR* pProperties) {
GAPID_DEBUG("vkGetPhysicalDeviceDisplayPropertiesKHR(%zu, %p, %p)", physicalDevice, pPropertyCount, pProperties);
if (PhysicalDevices.find(physicalDevice) == PhysicalDevices.end() ||
mImports.mVkInstanceFunctions.find(PhysicalDevices[physicalDevice]->mInstance) == mImports.mVkInstanceFunctions.end() ||
mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkGetPhysicalDeviceDisplayPropertiesKHR == nullptr) {
GAPID_WARNING("Application called unsupported function vkGetPhysicalDeviceDisplayPropertiesKHR");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, physicalDevice, pPropertyCount, pProperties] {
called = true;
observer->observeReads();
result = mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkGetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, pPropertyCount, pProperties);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
(void)observer->read(slice(pPropertyCount, 0ULL, 1ULL), 0ULL);
call();
if ((pProperties) == (nullptr)) {
observer->write<uint32_t>(slice(pPropertyCount, 0ULL, 1ULL), 0ULL, slice(pPropertyCount, 0ULL, 1ULL)[0ULL]);
} else {
uint32_t l_count = (uint32_t)(slice(pPropertyCount, 0ULL, 1ULL)[0ULL]);
Slice<VkDisplayPropertiesKHR> l_properties = slice(pProperties, (uint64_t)(0UL), (uint64_t)(l_count));
for (uint32_t l_i = 0UL; l_i < l_count; ++l_i) {
observer->write<VkDisplayPropertiesKHR>(l_properties, (uint64_t)(l_i), slice(pProperties, (uint64_t)(0UL), (uint64_t)(l_count))[(uint64_t)(l_i)]);
}
observer->write<uint32_t>(slice(pPropertyCount, 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::VkGetPhysicalDeviceDisplayPropertiesKHR 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::VkDisplayPropertiesKHR__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::vkGetPhysicalDeviceDisplayPlanePropertiesKHR(CallObserver* observer, VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkDisplayPlanePropertiesKHR* pProperties) {
GAPID_DEBUG("vkGetPhysicalDeviceDisplayPlanePropertiesKHR(%zu, %p, %p)", physicalDevice, pPropertyCount, pProperties);
if (PhysicalDevices.find(physicalDevice) == PhysicalDevices.end() ||
mImports.mVkInstanceFunctions.find(PhysicalDevices[physicalDevice]->mInstance) == mImports.mVkInstanceFunctions.end() ||
mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkGetPhysicalDeviceDisplayPlanePropertiesKHR == nullptr) {
GAPID_WARNING("Application called unsupported function vkGetPhysicalDeviceDisplayPlanePropertiesKHR");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, physicalDevice, pPropertyCount, pProperties] {
called = true;
observer->observeReads();
result = mImports.mVkInstanceFunctions[PhysicalDevices[physicalDevice]->mInstance].vkGetPhysicalDeviceDisplayPlanePropertiesKHR(physicalDevice, pPropertyCount, pProperties);
onPostFence(observer);
};
uint64_t counter_at_begin = mCommandStartEndCounter++;
try {
do {
(void)observer->read(slice(pPropertyCount, 0ULL, 1ULL), 0ULL);
call();
if ((pProperties) == (nullptr)) {
observer->write<uint32_t>(slice(pPropertyCount, 0ULL, 1ULL), 0ULL, slice(pPropertyCount, 0ULL, 1ULL)[0ULL]);
} else {
uint32_t l_count = (uint32_t)(slice(pPropertyCount, 0ULL, 1ULL)[0ULL]);
Slice<VkDisplayPlanePropertiesKHR> l_properties = slice(pProperties, (uint64_t)(0UL), (uint64_t)(l_count));
for (uint32_t l_i = 0UL; l_i < l_count; ++l_i) {
observer->write<VkDisplayPlanePropertiesKHR>(l_properties, (uint64_t)(l_i), slice(pProperties, (uint64_t)(0UL), (uint64_t)(l_count))[(uint64_t)(l_i)]);
}
observer->write<uint32_t>(slice(pPropertyCount, 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::VkGetPhysicalDeviceDisplayPlanePropertiesKHR 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::VkDisplayPlanePropertiesKHR__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::vkCreateDebugReportCallbackEXT(CallObserver* observer, VkInstance instance, VkDebugReportCallbackCreateInfoEXT* pCreateInfo, VkAllocationCallbacks* pAllocator, VkDebugReportCallbackEXT* pCallback) {
GAPID_DEBUG("vkCreateDebugReportCallbackEXT(%zu, %p, %p, %p)", instance, pCreateInfo, pAllocator, pCallback);
if (mImports.mVkInstanceFunctions.find(instance) == mImports.mVkInstanceFunctions.end() ||
mImports.mVkInstanceFunctions[instance].vkCreateDebugReportCallbackEXT == nullptr) {
GAPID_WARNING("Application called unsupported function vkCreateDebugReportCallbackEXT");
return 0;
}
uint32_t result = 0;
bool called = false;
auto call = [this, observer, &called, &result, instance, pCreateInfo, pAllocator, pCallback] {
called = true;
observer->observeReads();
result = mImports.mVkInstanceFunctions[instance].vkCreateDebugReportCallbackEXT(instance, pCreateInfo, pAllocator, pCallback);
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::VkCreateDebugReportCallbackEXT coder(observer->getScratch()->vector<gapic::Encodable*>(kMaxExtras), toEncoder< size_val >(instance, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkDebugReportCallbackCreateInfoEXT__CP >(pCreateInfo, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkAllocationCallbacks__CP >(pAllocator, *observer->getScratch()), toEncoder< gapic::coder::vulkan::VkDebugReportCallbackEXT__P >(pCallback, *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