blob: 8a76c927e07dd5f0cddb9f64d403dfaae9693587 [file] [log] [blame]
// Copyright (C) 2018 The Android Open Source Project
// Copyright (C) 2018 Google Inc.
//
// 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.
// Autogenerated module VkEncoder
// (impl) generated by android/android-emugl/host/libs/libOpenglRender/vulkan-registry/xml/genvk.py -registry android/android-emugl/host/libs/libOpenglRender/vulkan-registry/xml/vk.xml cereal -o android/android-emugl/host/libs/libOpenglRender/vulkan/cereal
// Please do not modify directly;
// re-run android/scripts/generate-vulkan-sources.sh,
// or directly from Python by defining:
// VULKAN_REGISTRY_XML_DIR : Directory containing genvk.py and vk.xml
// CEREAL_OUTPUT_DIR: Where to put the generated sources.
// python3 $VULKAN_REGISTRY_XML_DIR/genvk.py -registry $VULKAN_REGISTRY_XML_DIR/vk.xml cereal -o $CEREAL_OUTPUT_DIR
#include "VkEncoder.h"
#include "IOStream.h"
#include "Resources.h"
#include "ResourceTracker.h"
#include "Validation.h"
#include "VulkanStreamGuest.h"
#include "android/base/AlignedBuf.h"
#include "android/base/Pool.h"
#include "android/base/synchronization/AndroidLock.h"
#include <cutils/properties.h>
#include "goldfish_vk_marshaling_guest.h"
#include "goldfish_vk_deepcopy_guest.h"
#include "goldfish_vk_handlemap_guest.h"
#include "goldfish_vk_private_defs.h"
#include "goldfish_vk_transform_guest.h"
#include <unordered_map>
namespace goldfish_vk {
using namespace goldfish_vk;
using android::aligned_buf_alloc;
using android::aligned_buf_free;
using android::base::guest::AutoLock;
using android::base::guest::Lock;
using android::base::Pool;
class VkEncoder::Impl {
public:
Impl(IOStream* stream) : m_stream(stream), m_logEncodes(false) {
const char* emuVkLogEncodesPropName = "qemu.vk.log";
char encodeProp[PROPERTY_VALUE_MAX];
if (property_get(emuVkLogEncodesPropName, encodeProp, nullptr) > 0) {
m_logEncodes = atoi(encodeProp) > 0;
}
}
~Impl() {
for (auto it : mCleanupCallbacks) {
fprintf(stderr, "%s: run cleanup callback for %p\n", __func__, it.first);
it.second();
}
}
VulkanCountingStream* countingStream() { return &m_countingStream; }
VulkanStreamGuest* stream() { return &m_stream; }
Pool* pool() { return &m_pool; }
ResourceTracker* resources() { return ResourceTracker::get(); }
Validation* validation() { return &m_validation; }
void log(const char* text) {
if (!m_logEncodes) return;
ALOGD("encoder log: %s", text);
}
void flush() {
AutoLock encoderLock(lock);
m_stream.flush();
}
// Assume the lock for the current encoder is held.
void registerCleanupCallback(void* handle, VkEncoder::CleanupCallback cb) {
if (mCleanupCallbacks.end() == mCleanupCallbacks.find(handle)) {
mCleanupCallbacks[handle] = cb;
} else {
return;
}
}
void unregisterCleanupCallback(void* handle) {
mCleanupCallbacks.erase(handle);
}
Lock lock;
private:
VulkanCountingStream m_countingStream;
VulkanStreamGuest m_stream;
Pool m_pool { 8, 4096, 64 };
Validation m_validation;
bool m_logEncodes;
std::unordered_map<void*, VkEncoder::CleanupCallback> mCleanupCallbacks;
};
VkEncoder::VkEncoder(IOStream *stream) :
mImpl(new VkEncoder::Impl(stream)) { }
VkEncoder::~VkEncoder() = default;
void VkEncoder::flush() {
mImpl->flush();
}
void VkEncoder::registerCleanupCallback(void* handle, VkEncoder::CleanupCallback cb) {
mImpl->registerCleanupCallback(handle, cb);
}
void VkEncoder::unregisterCleanupCallback(void* handle) {
mImpl->unregisterCleanupCallback(handle);
}
#define VALIDATE_RET(retType, success, validate) \
retType goldfish_vk_validateResult = validate; \
if (goldfish_vk_validateResult != success) return goldfish_vk_validateResult; \
#define VALIDATE_VOID(validate) \
VkResult goldfish_vk_validateResult = validate; \
if (goldfish_vk_validateResult != VK_SUCCESS) return; \
#ifdef VK_VERSION_1_0
VkResult VkEncoder::vkCreateInstance(
const VkInstanceCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkInstance* pInstance)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkCreateInstance encode");
mImpl->log("start vkCreateInstance");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkInstanceCreateInfo* local_pCreateInfo;
VkAllocationCallbacks* local_pAllocator;
local_pCreateInfo = nullptr;
if (pCreateInfo)
{
local_pCreateInfo = (VkInstanceCreateInfo*)pool->alloc(sizeof(const VkInstanceCreateInfo));
deepcopy_VkInstanceCreateInfo(pool, pCreateInfo, (VkInstanceCreateInfo*)(local_pCreateInfo));
}
local_pAllocator = nullptr;
if (pAllocator)
{
local_pAllocator = (VkAllocationCallbacks*)pool->alloc(sizeof(const VkAllocationCallbacks));
deepcopy_VkAllocationCallbacks(pool, pAllocator, (VkAllocationCallbacks*)(local_pAllocator));
}
local_pAllocator = nullptr;
if (local_pCreateInfo)
{
transform_tohost_VkInstanceCreateInfo(mImpl->resources(), (VkInstanceCreateInfo*)(local_pCreateInfo));
}
if (local_pAllocator)
{
transform_tohost_VkAllocationCallbacks(mImpl->resources(), (VkAllocationCallbacks*)(local_pAllocator));
}
countingStream->rewind();
{
marshal_VkInstanceCreateInfo(countingStream, (VkInstanceCreateInfo*)(local_pCreateInfo));
// WARNING PTR CHECK
uint64_t cgen_var_0 = (uint64_t)(uintptr_t)local_pAllocator;
countingStream->putBe64(cgen_var_0);
if (local_pAllocator)
{
marshal_VkAllocationCallbacks(countingStream, (VkAllocationCallbacks*)(local_pAllocator));
}
uint64_t cgen_var_1;
countingStream->handleMapping()->mapHandles_VkInstance_u64(pInstance, &cgen_var_1, 1);
countingStream->write((uint64_t*)&cgen_var_1, 8);
}
uint32_t packetSize_vkCreateInstance = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkCreateInstance = OP_vkCreateInstance;
stream->write(&opcode_vkCreateInstance, sizeof(uint32_t));
stream->write(&packetSize_vkCreateInstance, sizeof(uint32_t));
marshal_VkInstanceCreateInfo(stream, (VkInstanceCreateInfo*)(local_pCreateInfo));
// WARNING PTR CHECK
uint64_t cgen_var_2 = (uint64_t)(uintptr_t)local_pAllocator;
stream->putBe64(cgen_var_2);
if (local_pAllocator)
{
marshal_VkAllocationCallbacks(stream, (VkAllocationCallbacks*)(local_pAllocator));
}
stream->unsetHandleMapping() /* emit_marshal, is handle, possibly out */;
uint64_t cgen_var_3;
stream->handleMapping()->mapHandles_VkInstance_u64(pInstance, &cgen_var_3, 1);
stream->write((uint64_t*)&cgen_var_3, 8);
stream->setHandleMapping(resources->unwrapMapping());
AEMU_SCOPED_TRACE("vkCreateInstance readParams");
stream->setHandleMapping(resources->createMapping());
uint64_t cgen_var_4;
stream->read((uint64_t*)&cgen_var_4, 8);
stream->handleMapping()->mapHandles_u64_VkInstance(&cgen_var_4, (VkInstance*)pInstance, 1);
stream->unsetHandleMapping();
AEMU_SCOPED_TRACE("vkCreateInstance returnUnmarshal");
VkResult vkCreateInstance_VkResult_return = (VkResult)0;
stream->read(&vkCreateInstance_VkResult_return, sizeof(VkResult));
countingStream->clearPool();
stream->clearPool();
pool->freeAll();
encoderLock.unlock();
mImpl->resources()->on_vkCreateInstance(this, vkCreateInstance_VkResult_return, pCreateInfo, pAllocator, pInstance);
encoderLock.lock();
mImpl->log("finish vkCreateInstance");;
return vkCreateInstance_VkResult_return;
}
void VkEncoder::vkDestroyInstance(
VkInstance instance,
const VkAllocationCallbacks* pAllocator)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkDestroyInstance encode");
mImpl->log("start vkDestroyInstance");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkInstance local_instance;
VkAllocationCallbacks* local_pAllocator;
local_instance = instance;
local_pAllocator = nullptr;
if (pAllocator)
{
local_pAllocator = (VkAllocationCallbacks*)pool->alloc(sizeof(const VkAllocationCallbacks));
deepcopy_VkAllocationCallbacks(pool, pAllocator, (VkAllocationCallbacks*)(local_pAllocator));
}
local_pAllocator = nullptr;
if (local_pAllocator)
{
transform_tohost_VkAllocationCallbacks(mImpl->resources(), (VkAllocationCallbacks*)(local_pAllocator));
}
countingStream->rewind();
{
uint64_t cgen_var_5;
countingStream->handleMapping()->mapHandles_VkInstance_u64(&local_instance, &cgen_var_5, 1);
countingStream->write((uint64_t*)&cgen_var_5, 1 * 8);
// WARNING PTR CHECK
uint64_t cgen_var_6 = (uint64_t)(uintptr_t)local_pAllocator;
countingStream->putBe64(cgen_var_6);
if (local_pAllocator)
{
marshal_VkAllocationCallbacks(countingStream, (VkAllocationCallbacks*)(local_pAllocator));
}
}
uint32_t packetSize_vkDestroyInstance = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkDestroyInstance = OP_vkDestroyInstance;
stream->write(&opcode_vkDestroyInstance, sizeof(uint32_t));
stream->write(&packetSize_vkDestroyInstance, sizeof(uint32_t));
uint64_t cgen_var_7;
stream->handleMapping()->mapHandles_VkInstance_u64(&local_instance, &cgen_var_7, 1);
stream->write((uint64_t*)&cgen_var_7, 1 * 8);
// WARNING PTR CHECK
uint64_t cgen_var_8 = (uint64_t)(uintptr_t)local_pAllocator;
stream->putBe64(cgen_var_8);
if (local_pAllocator)
{
marshal_VkAllocationCallbacks(stream, (VkAllocationCallbacks*)(local_pAllocator));
}
AEMU_SCOPED_TRACE("vkDestroyInstance readParams");
AEMU_SCOPED_TRACE("vkDestroyInstance returnUnmarshal");
resources->destroyMapping()->mapHandles_VkInstance((VkInstance*)&instance);
mImpl->log("finish vkDestroyInstance");;
}
VkResult VkEncoder::vkEnumeratePhysicalDevices(
VkInstance instance,
uint32_t* pPhysicalDeviceCount,
VkPhysicalDevice* pPhysicalDevices)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkEnumeratePhysicalDevices encode");
mImpl->log("start vkEnumeratePhysicalDevices");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkInstance local_instance;
local_instance = instance;
countingStream->rewind();
{
uint64_t cgen_var_9;
countingStream->handleMapping()->mapHandles_VkInstance_u64(&local_instance, &cgen_var_9, 1);
countingStream->write((uint64_t*)&cgen_var_9, 1 * 8);
// WARNING PTR CHECK
uint64_t cgen_var_10 = (uint64_t)(uintptr_t)pPhysicalDeviceCount;
countingStream->putBe64(cgen_var_10);
if (pPhysicalDeviceCount)
{
countingStream->write((uint32_t*)pPhysicalDeviceCount, sizeof(uint32_t));
}
// WARNING PTR CHECK
uint64_t cgen_var_11 = (uint64_t)(uintptr_t)pPhysicalDevices;
countingStream->putBe64(cgen_var_11);
if (pPhysicalDevices)
{
if ((*(pPhysicalDeviceCount)))
{
uint64_t* cgen_var_12;
countingStream->alloc((void**)&cgen_var_12, (*(pPhysicalDeviceCount)) * 8);
countingStream->handleMapping()->mapHandles_VkPhysicalDevice_u64(pPhysicalDevices, cgen_var_12, (*(pPhysicalDeviceCount)));
countingStream->write((uint64_t*)cgen_var_12, (*(pPhysicalDeviceCount)) * 8);
}
}
}
uint32_t packetSize_vkEnumeratePhysicalDevices = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkEnumeratePhysicalDevices = OP_vkEnumeratePhysicalDevices;
stream->write(&opcode_vkEnumeratePhysicalDevices, sizeof(uint32_t));
stream->write(&packetSize_vkEnumeratePhysicalDevices, sizeof(uint32_t));
uint64_t cgen_var_13;
stream->handleMapping()->mapHandles_VkInstance_u64(&local_instance, &cgen_var_13, 1);
stream->write((uint64_t*)&cgen_var_13, 1 * 8);
// WARNING PTR CHECK
uint64_t cgen_var_14 = (uint64_t)(uintptr_t)pPhysicalDeviceCount;
stream->putBe64(cgen_var_14);
if (pPhysicalDeviceCount)
{
stream->write((uint32_t*)pPhysicalDeviceCount, sizeof(uint32_t));
}
stream->unsetHandleMapping() /* emit_marshal, is handle, possibly out */;
// WARNING PTR CHECK
uint64_t cgen_var_15 = (uint64_t)(uintptr_t)pPhysicalDevices;
stream->putBe64(cgen_var_15);
if (pPhysicalDevices)
{
if ((*(pPhysicalDeviceCount)))
{
uint64_t* cgen_var_16;
stream->alloc((void**)&cgen_var_16, (*(pPhysicalDeviceCount)) * 8);
stream->handleMapping()->mapHandles_VkPhysicalDevice_u64(pPhysicalDevices, cgen_var_16, (*(pPhysicalDeviceCount)));
stream->write((uint64_t*)cgen_var_16, (*(pPhysicalDeviceCount)) * 8);
}
}
stream->setHandleMapping(resources->unwrapMapping());
AEMU_SCOPED_TRACE("vkEnumeratePhysicalDevices readParams");
// WARNING PTR CHECK
uint32_t* check_pPhysicalDeviceCount;
check_pPhysicalDeviceCount = (uint32_t*)(uintptr_t)stream->getBe64();
if (pPhysicalDeviceCount)
{
if (!(check_pPhysicalDeviceCount))
{
fprintf(stderr, "fatal: pPhysicalDeviceCount inconsistent between guest and host\n");
}
stream->read((uint32_t*)pPhysicalDeviceCount, sizeof(uint32_t));
}
stream->setHandleMapping(resources->createMapping());
// WARNING PTR CHECK
VkPhysicalDevice* check_pPhysicalDevices;
check_pPhysicalDevices = (VkPhysicalDevice*)(uintptr_t)stream->getBe64();
if (pPhysicalDevices)
{
if (!(check_pPhysicalDevices))
{
fprintf(stderr, "fatal: pPhysicalDevices inconsistent between guest and host\n");
}
if ((*(pPhysicalDeviceCount)))
{
uint64_t* cgen_var_19;
stream->alloc((void**)&cgen_var_19, (*(pPhysicalDeviceCount)) * 8);
stream->read((uint64_t*)cgen_var_19, (*(pPhysicalDeviceCount)) * 8);
stream->handleMapping()->mapHandles_u64_VkPhysicalDevice(cgen_var_19, (VkPhysicalDevice*)pPhysicalDevices, (*(pPhysicalDeviceCount)));
}
}
stream->unsetHandleMapping();
AEMU_SCOPED_TRACE("vkEnumeratePhysicalDevices returnUnmarshal");
VkResult vkEnumeratePhysicalDevices_VkResult_return = (VkResult)0;
stream->read(&vkEnumeratePhysicalDevices_VkResult_return, sizeof(VkResult));
countingStream->clearPool();
stream->clearPool();
pool->freeAll();
mImpl->log("finish vkEnumeratePhysicalDevices");;
return vkEnumeratePhysicalDevices_VkResult_return;
}
void VkEncoder::vkGetPhysicalDeviceFeatures(
VkPhysicalDevice physicalDevice,
VkPhysicalDeviceFeatures* pFeatures)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkGetPhysicalDeviceFeatures encode");
mImpl->log("start vkGetPhysicalDeviceFeatures");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkPhysicalDevice local_physicalDevice;
local_physicalDevice = physicalDevice;
countingStream->rewind();
{
uint64_t cgen_var_20;
countingStream->handleMapping()->mapHandles_VkPhysicalDevice_u64(&local_physicalDevice, &cgen_var_20, 1);
countingStream->write((uint64_t*)&cgen_var_20, 1 * 8);
marshal_VkPhysicalDeviceFeatures(countingStream, (VkPhysicalDeviceFeatures*)(pFeatures));
}
uint32_t packetSize_vkGetPhysicalDeviceFeatures = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkGetPhysicalDeviceFeatures = OP_vkGetPhysicalDeviceFeatures;
stream->write(&opcode_vkGetPhysicalDeviceFeatures, sizeof(uint32_t));
stream->write(&packetSize_vkGetPhysicalDeviceFeatures, sizeof(uint32_t));
uint64_t cgen_var_21;
stream->handleMapping()->mapHandles_VkPhysicalDevice_u64(&local_physicalDevice, &cgen_var_21, 1);
stream->write((uint64_t*)&cgen_var_21, 1 * 8);
marshal_VkPhysicalDeviceFeatures(stream, (VkPhysicalDeviceFeatures*)(pFeatures));
AEMU_SCOPED_TRACE("vkGetPhysicalDeviceFeatures readParams");
unmarshal_VkPhysicalDeviceFeatures(stream, (VkPhysicalDeviceFeatures*)(pFeatures));
if (pFeatures)
{
transform_fromhost_VkPhysicalDeviceFeatures(mImpl->resources(), (VkPhysicalDeviceFeatures*)(pFeatures));
}
AEMU_SCOPED_TRACE("vkGetPhysicalDeviceFeatures returnUnmarshal");
mImpl->log("finish vkGetPhysicalDeviceFeatures");;
}
void VkEncoder::vkGetPhysicalDeviceFormatProperties(
VkPhysicalDevice physicalDevice,
VkFormat format,
VkFormatProperties* pFormatProperties)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkGetPhysicalDeviceFormatProperties encode");
mImpl->log("start vkGetPhysicalDeviceFormatProperties");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkPhysicalDevice local_physicalDevice;
VkFormat local_format;
local_physicalDevice = physicalDevice;
local_format = format;
countingStream->rewind();
{
uint64_t cgen_var_22;
countingStream->handleMapping()->mapHandles_VkPhysicalDevice_u64(&local_physicalDevice, &cgen_var_22, 1);
countingStream->write((uint64_t*)&cgen_var_22, 1 * 8);
countingStream->write((VkFormat*)&local_format, sizeof(VkFormat));
marshal_VkFormatProperties(countingStream, (VkFormatProperties*)(pFormatProperties));
}
uint32_t packetSize_vkGetPhysicalDeviceFormatProperties = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkGetPhysicalDeviceFormatProperties = OP_vkGetPhysicalDeviceFormatProperties;
stream->write(&opcode_vkGetPhysicalDeviceFormatProperties, sizeof(uint32_t));
stream->write(&packetSize_vkGetPhysicalDeviceFormatProperties, sizeof(uint32_t));
uint64_t cgen_var_23;
stream->handleMapping()->mapHandles_VkPhysicalDevice_u64(&local_physicalDevice, &cgen_var_23, 1);
stream->write((uint64_t*)&cgen_var_23, 1 * 8);
stream->write((VkFormat*)&local_format, sizeof(VkFormat));
marshal_VkFormatProperties(stream, (VkFormatProperties*)(pFormatProperties));
AEMU_SCOPED_TRACE("vkGetPhysicalDeviceFormatProperties readParams");
unmarshal_VkFormatProperties(stream, (VkFormatProperties*)(pFormatProperties));
if (pFormatProperties)
{
transform_fromhost_VkFormatProperties(mImpl->resources(), (VkFormatProperties*)(pFormatProperties));
}
AEMU_SCOPED_TRACE("vkGetPhysicalDeviceFormatProperties returnUnmarshal");
mImpl->log("finish vkGetPhysicalDeviceFormatProperties");;
}
VkResult VkEncoder::vkGetPhysicalDeviceImageFormatProperties(
VkPhysicalDevice physicalDevice,
VkFormat format,
VkImageType type,
VkImageTiling tiling,
VkImageUsageFlags usage,
VkImageCreateFlags flags,
VkImageFormatProperties* pImageFormatProperties)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkGetPhysicalDeviceImageFormatProperties encode");
mImpl->log("start vkGetPhysicalDeviceImageFormatProperties");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkPhysicalDevice local_physicalDevice;
VkFormat local_format;
VkImageType local_type;
VkImageTiling local_tiling;
VkImageUsageFlags local_usage;
VkImageCreateFlags local_flags;
local_physicalDevice = physicalDevice;
local_format = format;
local_type = type;
local_tiling = tiling;
local_usage = usage;
local_flags = flags;
countingStream->rewind();
{
uint64_t cgen_var_24;
countingStream->handleMapping()->mapHandles_VkPhysicalDevice_u64(&local_physicalDevice, &cgen_var_24, 1);
countingStream->write((uint64_t*)&cgen_var_24, 1 * 8);
countingStream->write((VkFormat*)&local_format, sizeof(VkFormat));
countingStream->write((VkImageType*)&local_type, sizeof(VkImageType));
countingStream->write((VkImageTiling*)&local_tiling, sizeof(VkImageTiling));
countingStream->write((VkImageUsageFlags*)&local_usage, sizeof(VkImageUsageFlags));
countingStream->write((VkImageCreateFlags*)&local_flags, sizeof(VkImageCreateFlags));
marshal_VkImageFormatProperties(countingStream, (VkImageFormatProperties*)(pImageFormatProperties));
}
uint32_t packetSize_vkGetPhysicalDeviceImageFormatProperties = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkGetPhysicalDeviceImageFormatProperties = OP_vkGetPhysicalDeviceImageFormatProperties;
stream->write(&opcode_vkGetPhysicalDeviceImageFormatProperties, sizeof(uint32_t));
stream->write(&packetSize_vkGetPhysicalDeviceImageFormatProperties, sizeof(uint32_t));
uint64_t cgen_var_25;
stream->handleMapping()->mapHandles_VkPhysicalDevice_u64(&local_physicalDevice, &cgen_var_25, 1);
stream->write((uint64_t*)&cgen_var_25, 1 * 8);
stream->write((VkFormat*)&local_format, sizeof(VkFormat));
stream->write((VkImageType*)&local_type, sizeof(VkImageType));
stream->write((VkImageTiling*)&local_tiling, sizeof(VkImageTiling));
stream->write((VkImageUsageFlags*)&local_usage, sizeof(VkImageUsageFlags));
stream->write((VkImageCreateFlags*)&local_flags, sizeof(VkImageCreateFlags));
marshal_VkImageFormatProperties(stream, (VkImageFormatProperties*)(pImageFormatProperties));
AEMU_SCOPED_TRACE("vkGetPhysicalDeviceImageFormatProperties readParams");
unmarshal_VkImageFormatProperties(stream, (VkImageFormatProperties*)(pImageFormatProperties));
if (pImageFormatProperties)
{
transform_fromhost_VkImageFormatProperties(mImpl->resources(), (VkImageFormatProperties*)(pImageFormatProperties));
}
AEMU_SCOPED_TRACE("vkGetPhysicalDeviceImageFormatProperties returnUnmarshal");
VkResult vkGetPhysicalDeviceImageFormatProperties_VkResult_return = (VkResult)0;
stream->read(&vkGetPhysicalDeviceImageFormatProperties_VkResult_return, sizeof(VkResult));
countingStream->clearPool();
stream->clearPool();
pool->freeAll();
mImpl->log("finish vkGetPhysicalDeviceImageFormatProperties");;
return vkGetPhysicalDeviceImageFormatProperties_VkResult_return;
}
void VkEncoder::vkGetPhysicalDeviceProperties(
VkPhysicalDevice physicalDevice,
VkPhysicalDeviceProperties* pProperties)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkGetPhysicalDeviceProperties encode");
mImpl->log("start vkGetPhysicalDeviceProperties");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkPhysicalDevice local_physicalDevice;
local_physicalDevice = physicalDevice;
countingStream->rewind();
{
uint64_t cgen_var_26;
countingStream->handleMapping()->mapHandles_VkPhysicalDevice_u64(&local_physicalDevice, &cgen_var_26, 1);
countingStream->write((uint64_t*)&cgen_var_26, 1 * 8);
marshal_VkPhysicalDeviceProperties(countingStream, (VkPhysicalDeviceProperties*)(pProperties));
}
uint32_t packetSize_vkGetPhysicalDeviceProperties = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkGetPhysicalDeviceProperties = OP_vkGetPhysicalDeviceProperties;
stream->write(&opcode_vkGetPhysicalDeviceProperties, sizeof(uint32_t));
stream->write(&packetSize_vkGetPhysicalDeviceProperties, sizeof(uint32_t));
uint64_t cgen_var_27;
stream->handleMapping()->mapHandles_VkPhysicalDevice_u64(&local_physicalDevice, &cgen_var_27, 1);
stream->write((uint64_t*)&cgen_var_27, 1 * 8);
marshal_VkPhysicalDeviceProperties(stream, (VkPhysicalDeviceProperties*)(pProperties));
AEMU_SCOPED_TRACE("vkGetPhysicalDeviceProperties readParams");
unmarshal_VkPhysicalDeviceProperties(stream, (VkPhysicalDeviceProperties*)(pProperties));
if (pProperties)
{
transform_fromhost_VkPhysicalDeviceProperties(mImpl->resources(), (VkPhysicalDeviceProperties*)(pProperties));
}
AEMU_SCOPED_TRACE("vkGetPhysicalDeviceProperties returnUnmarshal");
encoderLock.unlock();
mImpl->resources()->on_vkGetPhysicalDeviceProperties(this, physicalDevice, pProperties);
encoderLock.lock();
mImpl->log("finish vkGetPhysicalDeviceProperties");;
}
void VkEncoder::vkGetPhysicalDeviceQueueFamilyProperties(
VkPhysicalDevice physicalDevice,
uint32_t* pQueueFamilyPropertyCount,
VkQueueFamilyProperties* pQueueFamilyProperties)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkGetPhysicalDeviceQueueFamilyProperties encode");
mImpl->log("start vkGetPhysicalDeviceQueueFamilyProperties");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkPhysicalDevice local_physicalDevice;
local_physicalDevice = physicalDevice;
countingStream->rewind();
{
uint64_t cgen_var_28;
countingStream->handleMapping()->mapHandles_VkPhysicalDevice_u64(&local_physicalDevice, &cgen_var_28, 1);
countingStream->write((uint64_t*)&cgen_var_28, 1 * 8);
// WARNING PTR CHECK
uint64_t cgen_var_29 = (uint64_t)(uintptr_t)pQueueFamilyPropertyCount;
countingStream->putBe64(cgen_var_29);
if (pQueueFamilyPropertyCount)
{
countingStream->write((uint32_t*)pQueueFamilyPropertyCount, sizeof(uint32_t));
}
// WARNING PTR CHECK
uint64_t cgen_var_30 = (uint64_t)(uintptr_t)pQueueFamilyProperties;
countingStream->putBe64(cgen_var_30);
if (pQueueFamilyProperties)
{
for (uint32_t i = 0; i < (uint32_t)(*(pQueueFamilyPropertyCount)); ++i)
{
marshal_VkQueueFamilyProperties(countingStream, (VkQueueFamilyProperties*)(pQueueFamilyProperties + i));
}
}
}
uint32_t packetSize_vkGetPhysicalDeviceQueueFamilyProperties = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkGetPhysicalDeviceQueueFamilyProperties = OP_vkGetPhysicalDeviceQueueFamilyProperties;
stream->write(&opcode_vkGetPhysicalDeviceQueueFamilyProperties, sizeof(uint32_t));
stream->write(&packetSize_vkGetPhysicalDeviceQueueFamilyProperties, sizeof(uint32_t));
uint64_t cgen_var_31;
stream->handleMapping()->mapHandles_VkPhysicalDevice_u64(&local_physicalDevice, &cgen_var_31, 1);
stream->write((uint64_t*)&cgen_var_31, 1 * 8);
// WARNING PTR CHECK
uint64_t cgen_var_32 = (uint64_t)(uintptr_t)pQueueFamilyPropertyCount;
stream->putBe64(cgen_var_32);
if (pQueueFamilyPropertyCount)
{
stream->write((uint32_t*)pQueueFamilyPropertyCount, sizeof(uint32_t));
}
// WARNING PTR CHECK
uint64_t cgen_var_33 = (uint64_t)(uintptr_t)pQueueFamilyProperties;
stream->putBe64(cgen_var_33);
if (pQueueFamilyProperties)
{
for (uint32_t i = 0; i < (uint32_t)(*(pQueueFamilyPropertyCount)); ++i)
{
marshal_VkQueueFamilyProperties(stream, (VkQueueFamilyProperties*)(pQueueFamilyProperties + i));
}
}
AEMU_SCOPED_TRACE("vkGetPhysicalDeviceQueueFamilyProperties readParams");
// WARNING PTR CHECK
uint32_t* check_pQueueFamilyPropertyCount;
check_pQueueFamilyPropertyCount = (uint32_t*)(uintptr_t)stream->getBe64();
if (pQueueFamilyPropertyCount)
{
if (!(check_pQueueFamilyPropertyCount))
{
fprintf(stderr, "fatal: pQueueFamilyPropertyCount inconsistent between guest and host\n");
}
stream->read((uint32_t*)pQueueFamilyPropertyCount, sizeof(uint32_t));
}
// WARNING PTR CHECK
VkQueueFamilyProperties* check_pQueueFamilyProperties;
check_pQueueFamilyProperties = (VkQueueFamilyProperties*)(uintptr_t)stream->getBe64();
if (pQueueFamilyProperties)
{
if (!(check_pQueueFamilyProperties))
{
fprintf(stderr, "fatal: pQueueFamilyProperties inconsistent between guest and host\n");
}
for (uint32_t i = 0; i < (uint32_t)(*(pQueueFamilyPropertyCount)); ++i)
{
unmarshal_VkQueueFamilyProperties(stream, (VkQueueFamilyProperties*)(pQueueFamilyProperties + i));
}
}
if (pQueueFamilyProperties)
{
for (uint32_t i = 0; i < (uint32_t)(*(pQueueFamilyPropertyCount)); ++i)
{
transform_fromhost_VkQueueFamilyProperties(mImpl->resources(), (VkQueueFamilyProperties*)(pQueueFamilyProperties + i));
}
}
AEMU_SCOPED_TRACE("vkGetPhysicalDeviceQueueFamilyProperties returnUnmarshal");
mImpl->log("finish vkGetPhysicalDeviceQueueFamilyProperties");;
}
void VkEncoder::vkGetPhysicalDeviceMemoryProperties(
VkPhysicalDevice physicalDevice,
VkPhysicalDeviceMemoryProperties* pMemoryProperties)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkGetPhysicalDeviceMemoryProperties encode");
mImpl->log("start vkGetPhysicalDeviceMemoryProperties");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkPhysicalDevice local_physicalDevice;
local_physicalDevice = physicalDevice;
countingStream->rewind();
{
uint64_t cgen_var_36;
countingStream->handleMapping()->mapHandles_VkPhysicalDevice_u64(&local_physicalDevice, &cgen_var_36, 1);
countingStream->write((uint64_t*)&cgen_var_36, 1 * 8);
marshal_VkPhysicalDeviceMemoryProperties(countingStream, (VkPhysicalDeviceMemoryProperties*)(pMemoryProperties));
}
uint32_t packetSize_vkGetPhysicalDeviceMemoryProperties = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkGetPhysicalDeviceMemoryProperties = OP_vkGetPhysicalDeviceMemoryProperties;
stream->write(&opcode_vkGetPhysicalDeviceMemoryProperties, sizeof(uint32_t));
stream->write(&packetSize_vkGetPhysicalDeviceMemoryProperties, sizeof(uint32_t));
uint64_t cgen_var_37;
stream->handleMapping()->mapHandles_VkPhysicalDevice_u64(&local_physicalDevice, &cgen_var_37, 1);
stream->write((uint64_t*)&cgen_var_37, 1 * 8);
marshal_VkPhysicalDeviceMemoryProperties(stream, (VkPhysicalDeviceMemoryProperties*)(pMemoryProperties));
AEMU_SCOPED_TRACE("vkGetPhysicalDeviceMemoryProperties readParams");
unmarshal_VkPhysicalDeviceMemoryProperties(stream, (VkPhysicalDeviceMemoryProperties*)(pMemoryProperties));
if (pMemoryProperties)
{
transform_fromhost_VkPhysicalDeviceMemoryProperties(mImpl->resources(), (VkPhysicalDeviceMemoryProperties*)(pMemoryProperties));
}
AEMU_SCOPED_TRACE("vkGetPhysicalDeviceMemoryProperties returnUnmarshal");
encoderLock.unlock();
mImpl->resources()->on_vkGetPhysicalDeviceMemoryProperties(this, physicalDevice, pMemoryProperties);
encoderLock.lock();
mImpl->log("finish vkGetPhysicalDeviceMemoryProperties");;
}
PFN_vkVoidFunction VkEncoder::vkGetInstanceProcAddr(
VkInstance instance,
const char* pName)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkGetInstanceProcAddr encode");
mImpl->log("start vkGetInstanceProcAddr");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkInstance local_instance;
char* local_pName;
local_instance = instance;
local_pName = nullptr;
if (pName)
{
local_pName = pool->strDup(pName);
}
countingStream->rewind();
{
uint64_t cgen_var_38;
countingStream->handleMapping()->mapHandles_VkInstance_u64(&local_instance, &cgen_var_38, 1);
countingStream->write((uint64_t*)&cgen_var_38, 1 * 8);
countingStream->putString(local_pName);
}
uint32_t packetSize_vkGetInstanceProcAddr = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkGetInstanceProcAddr = OP_vkGetInstanceProcAddr;
stream->write(&opcode_vkGetInstanceProcAddr, sizeof(uint32_t));
stream->write(&packetSize_vkGetInstanceProcAddr, sizeof(uint32_t));
uint64_t cgen_var_39;
stream->handleMapping()->mapHandles_VkInstance_u64(&local_instance, &cgen_var_39, 1);
stream->write((uint64_t*)&cgen_var_39, 1 * 8);
stream->putString(local_pName);
AEMU_SCOPED_TRACE("vkGetInstanceProcAddr readParams");
AEMU_SCOPED_TRACE("vkGetInstanceProcAddr returnUnmarshal");
PFN_vkVoidFunction vkGetInstanceProcAddr_PFN_vkVoidFunction_return = (PFN_vkVoidFunction)0;
stream->read(&vkGetInstanceProcAddr_PFN_vkVoidFunction_return, sizeof(PFN_vkVoidFunction));
countingStream->clearPool();
stream->clearPool();
pool->freeAll();
mImpl->log("finish vkGetInstanceProcAddr");;
return vkGetInstanceProcAddr_PFN_vkVoidFunction_return;
}
PFN_vkVoidFunction VkEncoder::vkGetDeviceProcAddr(
VkDevice device,
const char* pName)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkGetDeviceProcAddr encode");
mImpl->log("start vkGetDeviceProcAddr");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkDevice local_device;
char* local_pName;
local_device = device;
local_pName = nullptr;
if (pName)
{
local_pName = pool->strDup(pName);
}
countingStream->rewind();
{
uint64_t cgen_var_40;
countingStream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_40, 1);
countingStream->write((uint64_t*)&cgen_var_40, 1 * 8);
countingStream->putString(local_pName);
}
uint32_t packetSize_vkGetDeviceProcAddr = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkGetDeviceProcAddr = OP_vkGetDeviceProcAddr;
stream->write(&opcode_vkGetDeviceProcAddr, sizeof(uint32_t));
stream->write(&packetSize_vkGetDeviceProcAddr, sizeof(uint32_t));
uint64_t cgen_var_41;
stream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_41, 1);
stream->write((uint64_t*)&cgen_var_41, 1 * 8);
stream->putString(local_pName);
AEMU_SCOPED_TRACE("vkGetDeviceProcAddr readParams");
AEMU_SCOPED_TRACE("vkGetDeviceProcAddr returnUnmarshal");
PFN_vkVoidFunction vkGetDeviceProcAddr_PFN_vkVoidFunction_return = (PFN_vkVoidFunction)0;
stream->read(&vkGetDeviceProcAddr_PFN_vkVoidFunction_return, sizeof(PFN_vkVoidFunction));
countingStream->clearPool();
stream->clearPool();
pool->freeAll();
mImpl->log("finish vkGetDeviceProcAddr");;
return vkGetDeviceProcAddr_PFN_vkVoidFunction_return;
}
VkResult VkEncoder::vkCreateDevice(
VkPhysicalDevice physicalDevice,
const VkDeviceCreateInfo* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkDevice* pDevice)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkCreateDevice encode");
mImpl->log("start vkCreateDevice");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkPhysicalDevice local_physicalDevice;
VkDeviceCreateInfo* local_pCreateInfo;
VkAllocationCallbacks* local_pAllocator;
local_physicalDevice = physicalDevice;
local_pCreateInfo = nullptr;
if (pCreateInfo)
{
local_pCreateInfo = (VkDeviceCreateInfo*)pool->alloc(sizeof(const VkDeviceCreateInfo));
deepcopy_VkDeviceCreateInfo(pool, pCreateInfo, (VkDeviceCreateInfo*)(local_pCreateInfo));
}
local_pAllocator = nullptr;
if (pAllocator)
{
local_pAllocator = (VkAllocationCallbacks*)pool->alloc(sizeof(const VkAllocationCallbacks));
deepcopy_VkAllocationCallbacks(pool, pAllocator, (VkAllocationCallbacks*)(local_pAllocator));
}
local_pAllocator = nullptr;
if (local_pCreateInfo)
{
transform_tohost_VkDeviceCreateInfo(mImpl->resources(), (VkDeviceCreateInfo*)(local_pCreateInfo));
}
if (local_pAllocator)
{
transform_tohost_VkAllocationCallbacks(mImpl->resources(), (VkAllocationCallbacks*)(local_pAllocator));
}
countingStream->rewind();
{
uint64_t cgen_var_42;
countingStream->handleMapping()->mapHandles_VkPhysicalDevice_u64(&local_physicalDevice, &cgen_var_42, 1);
countingStream->write((uint64_t*)&cgen_var_42, 1 * 8);
marshal_VkDeviceCreateInfo(countingStream, (VkDeviceCreateInfo*)(local_pCreateInfo));
// WARNING PTR CHECK
uint64_t cgen_var_43 = (uint64_t)(uintptr_t)local_pAllocator;
countingStream->putBe64(cgen_var_43);
if (local_pAllocator)
{
marshal_VkAllocationCallbacks(countingStream, (VkAllocationCallbacks*)(local_pAllocator));
}
uint64_t cgen_var_44;
countingStream->handleMapping()->mapHandles_VkDevice_u64(pDevice, &cgen_var_44, 1);
countingStream->write((uint64_t*)&cgen_var_44, 8);
}
uint32_t packetSize_vkCreateDevice = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkCreateDevice = OP_vkCreateDevice;
stream->write(&opcode_vkCreateDevice, sizeof(uint32_t));
stream->write(&packetSize_vkCreateDevice, sizeof(uint32_t));
uint64_t cgen_var_45;
stream->handleMapping()->mapHandles_VkPhysicalDevice_u64(&local_physicalDevice, &cgen_var_45, 1);
stream->write((uint64_t*)&cgen_var_45, 1 * 8);
marshal_VkDeviceCreateInfo(stream, (VkDeviceCreateInfo*)(local_pCreateInfo));
// WARNING PTR CHECK
uint64_t cgen_var_46 = (uint64_t)(uintptr_t)local_pAllocator;
stream->putBe64(cgen_var_46);
if (local_pAllocator)
{
marshal_VkAllocationCallbacks(stream, (VkAllocationCallbacks*)(local_pAllocator));
}
stream->unsetHandleMapping() /* emit_marshal, is handle, possibly out */;
uint64_t cgen_var_47;
stream->handleMapping()->mapHandles_VkDevice_u64(pDevice, &cgen_var_47, 1);
stream->write((uint64_t*)&cgen_var_47, 8);
stream->setHandleMapping(resources->unwrapMapping());
AEMU_SCOPED_TRACE("vkCreateDevice readParams");
stream->setHandleMapping(resources->createMapping());
uint64_t cgen_var_48;
stream->read((uint64_t*)&cgen_var_48, 8);
stream->handleMapping()->mapHandles_u64_VkDevice(&cgen_var_48, (VkDevice*)pDevice, 1);
stream->unsetHandleMapping();
AEMU_SCOPED_TRACE("vkCreateDevice returnUnmarshal");
VkResult vkCreateDevice_VkResult_return = (VkResult)0;
stream->read(&vkCreateDevice_VkResult_return, sizeof(VkResult));
countingStream->clearPool();
stream->clearPool();
pool->freeAll();
encoderLock.unlock();
mImpl->resources()->on_vkCreateDevice(this, vkCreateDevice_VkResult_return, physicalDevice, pCreateInfo, pAllocator, pDevice);
encoderLock.lock();
mImpl->log("finish vkCreateDevice");;
return vkCreateDevice_VkResult_return;
}
void VkEncoder::vkDestroyDevice(
VkDevice device,
const VkAllocationCallbacks* pAllocator)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkDestroyDevice encode");
mImpl->log("start vkDestroyDevice");
encoderLock.unlock();
mImpl->resources()->on_vkDestroyDevice_pre(this, device, pAllocator);
encoderLock.lock();
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkDevice local_device;
VkAllocationCallbacks* local_pAllocator;
local_device = device;
local_pAllocator = nullptr;
if (pAllocator)
{
local_pAllocator = (VkAllocationCallbacks*)pool->alloc(sizeof(const VkAllocationCallbacks));
deepcopy_VkAllocationCallbacks(pool, pAllocator, (VkAllocationCallbacks*)(local_pAllocator));
}
local_pAllocator = nullptr;
if (local_pAllocator)
{
transform_tohost_VkAllocationCallbacks(mImpl->resources(), (VkAllocationCallbacks*)(local_pAllocator));
}
countingStream->rewind();
{
uint64_t cgen_var_49;
countingStream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_49, 1);
countingStream->write((uint64_t*)&cgen_var_49, 1 * 8);
// WARNING PTR CHECK
uint64_t cgen_var_50 = (uint64_t)(uintptr_t)local_pAllocator;
countingStream->putBe64(cgen_var_50);
if (local_pAllocator)
{
marshal_VkAllocationCallbacks(countingStream, (VkAllocationCallbacks*)(local_pAllocator));
}
}
uint32_t packetSize_vkDestroyDevice = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkDestroyDevice = OP_vkDestroyDevice;
stream->write(&opcode_vkDestroyDevice, sizeof(uint32_t));
stream->write(&packetSize_vkDestroyDevice, sizeof(uint32_t));
uint64_t cgen_var_51;
stream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_51, 1);
stream->write((uint64_t*)&cgen_var_51, 1 * 8);
// WARNING PTR CHECK
uint64_t cgen_var_52 = (uint64_t)(uintptr_t)local_pAllocator;
stream->putBe64(cgen_var_52);
if (local_pAllocator)
{
marshal_VkAllocationCallbacks(stream, (VkAllocationCallbacks*)(local_pAllocator));
}
AEMU_SCOPED_TRACE("vkDestroyDevice readParams");
AEMU_SCOPED_TRACE("vkDestroyDevice returnUnmarshal");
resources->destroyMapping()->mapHandles_VkDevice((VkDevice*)&device);
stream->flush();
mImpl->log("finish vkDestroyDevice");;
}
VkResult VkEncoder::vkEnumerateInstanceExtensionProperties(
const char* pLayerName,
uint32_t* pPropertyCount,
VkExtensionProperties* pProperties)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkEnumerateInstanceExtensionProperties encode");
mImpl->log("start vkEnumerateInstanceExtensionProperties");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
char* local_pLayerName;
local_pLayerName = nullptr;
if (pLayerName)
{
local_pLayerName = pool->strDup(pLayerName);
}
countingStream->rewind();
{
if (countingStream->getFeatureBits() & VULKAN_STREAM_FEATURE_NULL_OPTIONAL_STRINGS_BIT)
{
// WARNING PTR CHECK
uint64_t cgen_var_53 = (uint64_t)(uintptr_t)local_pLayerName;
countingStream->putBe64(cgen_var_53);
if (local_pLayerName)
{
countingStream->putString(local_pLayerName);
}
}
else
{
countingStream->putString(local_pLayerName);
}
// WARNING PTR CHECK
uint64_t cgen_var_54 = (uint64_t)(uintptr_t)pPropertyCount;
countingStream->putBe64(cgen_var_54);
if (pPropertyCount)
{
countingStream->write((uint32_t*)pPropertyCount, sizeof(uint32_t));
}
// WARNING PTR CHECK
uint64_t cgen_var_55 = (uint64_t)(uintptr_t)pProperties;
countingStream->putBe64(cgen_var_55);
if (pProperties)
{
for (uint32_t i = 0; i < (uint32_t)(*(pPropertyCount)); ++i)
{
marshal_VkExtensionProperties(countingStream, (VkExtensionProperties*)(pProperties + i));
}
}
}
uint32_t packetSize_vkEnumerateInstanceExtensionProperties = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkEnumerateInstanceExtensionProperties = OP_vkEnumerateInstanceExtensionProperties;
stream->write(&opcode_vkEnumerateInstanceExtensionProperties, sizeof(uint32_t));
stream->write(&packetSize_vkEnumerateInstanceExtensionProperties, sizeof(uint32_t));
if (stream->getFeatureBits() & VULKAN_STREAM_FEATURE_NULL_OPTIONAL_STRINGS_BIT)
{
// WARNING PTR CHECK
uint64_t cgen_var_56 = (uint64_t)(uintptr_t)local_pLayerName;
stream->putBe64(cgen_var_56);
if (local_pLayerName)
{
stream->putString(local_pLayerName);
}
}
else
{
stream->putString(local_pLayerName);
}
// WARNING PTR CHECK
uint64_t cgen_var_57 = (uint64_t)(uintptr_t)pPropertyCount;
stream->putBe64(cgen_var_57);
if (pPropertyCount)
{
stream->write((uint32_t*)pPropertyCount, sizeof(uint32_t));
}
// WARNING PTR CHECK
uint64_t cgen_var_58 = (uint64_t)(uintptr_t)pProperties;
stream->putBe64(cgen_var_58);
if (pProperties)
{
for (uint32_t i = 0; i < (uint32_t)(*(pPropertyCount)); ++i)
{
marshal_VkExtensionProperties(stream, (VkExtensionProperties*)(pProperties + i));
}
}
AEMU_SCOPED_TRACE("vkEnumerateInstanceExtensionProperties readParams");
// WARNING PTR CHECK
uint32_t* check_pPropertyCount;
check_pPropertyCount = (uint32_t*)(uintptr_t)stream->getBe64();
if (pPropertyCount)
{
if (!(check_pPropertyCount))
{
fprintf(stderr, "fatal: pPropertyCount inconsistent between guest and host\n");
}
stream->read((uint32_t*)pPropertyCount, sizeof(uint32_t));
}
// WARNING PTR CHECK
VkExtensionProperties* check_pProperties;
check_pProperties = (VkExtensionProperties*)(uintptr_t)stream->getBe64();
if (pProperties)
{
if (!(check_pProperties))
{
fprintf(stderr, "fatal: pProperties inconsistent between guest and host\n");
}
for (uint32_t i = 0; i < (uint32_t)(*(pPropertyCount)); ++i)
{
unmarshal_VkExtensionProperties(stream, (VkExtensionProperties*)(pProperties + i));
}
}
if (pProperties)
{
for (uint32_t i = 0; i < (uint32_t)(*(pPropertyCount)); ++i)
{
transform_fromhost_VkExtensionProperties(mImpl->resources(), (VkExtensionProperties*)(pProperties + i));
}
}
AEMU_SCOPED_TRACE("vkEnumerateInstanceExtensionProperties returnUnmarshal");
VkResult vkEnumerateInstanceExtensionProperties_VkResult_return = (VkResult)0;
stream->read(&vkEnumerateInstanceExtensionProperties_VkResult_return, sizeof(VkResult));
countingStream->clearPool();
stream->clearPool();
pool->freeAll();
mImpl->log("finish vkEnumerateInstanceExtensionProperties");;
return vkEnumerateInstanceExtensionProperties_VkResult_return;
}
VkResult VkEncoder::vkEnumerateDeviceExtensionProperties(
VkPhysicalDevice physicalDevice,
const char* pLayerName,
uint32_t* pPropertyCount,
VkExtensionProperties* pProperties)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkEnumerateDeviceExtensionProperties encode");
mImpl->log("start vkEnumerateDeviceExtensionProperties");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkPhysicalDevice local_physicalDevice;
char* local_pLayerName;
local_physicalDevice = physicalDevice;
local_pLayerName = nullptr;
if (pLayerName)
{
local_pLayerName = pool->strDup(pLayerName);
}
countingStream->rewind();
{
uint64_t cgen_var_61;
countingStream->handleMapping()->mapHandles_VkPhysicalDevice_u64(&local_physicalDevice, &cgen_var_61, 1);
countingStream->write((uint64_t*)&cgen_var_61, 1 * 8);
if (countingStream->getFeatureBits() & VULKAN_STREAM_FEATURE_NULL_OPTIONAL_STRINGS_BIT)
{
// WARNING PTR CHECK
uint64_t cgen_var_62 = (uint64_t)(uintptr_t)local_pLayerName;
countingStream->putBe64(cgen_var_62);
if (local_pLayerName)
{
countingStream->putString(local_pLayerName);
}
}
else
{
countingStream->putString(local_pLayerName);
}
// WARNING PTR CHECK
uint64_t cgen_var_63 = (uint64_t)(uintptr_t)pPropertyCount;
countingStream->putBe64(cgen_var_63);
if (pPropertyCount)
{
countingStream->write((uint32_t*)pPropertyCount, sizeof(uint32_t));
}
// WARNING PTR CHECK
uint64_t cgen_var_64 = (uint64_t)(uintptr_t)pProperties;
countingStream->putBe64(cgen_var_64);
if (pProperties)
{
for (uint32_t i = 0; i < (uint32_t)(*(pPropertyCount)); ++i)
{
marshal_VkExtensionProperties(countingStream, (VkExtensionProperties*)(pProperties + i));
}
}
}
uint32_t packetSize_vkEnumerateDeviceExtensionProperties = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkEnumerateDeviceExtensionProperties = OP_vkEnumerateDeviceExtensionProperties;
stream->write(&opcode_vkEnumerateDeviceExtensionProperties, sizeof(uint32_t));
stream->write(&packetSize_vkEnumerateDeviceExtensionProperties, sizeof(uint32_t));
uint64_t cgen_var_65;
stream->handleMapping()->mapHandles_VkPhysicalDevice_u64(&local_physicalDevice, &cgen_var_65, 1);
stream->write((uint64_t*)&cgen_var_65, 1 * 8);
if (stream->getFeatureBits() & VULKAN_STREAM_FEATURE_NULL_OPTIONAL_STRINGS_BIT)
{
// WARNING PTR CHECK
uint64_t cgen_var_66 = (uint64_t)(uintptr_t)local_pLayerName;
stream->putBe64(cgen_var_66);
if (local_pLayerName)
{
stream->putString(local_pLayerName);
}
}
else
{
stream->putString(local_pLayerName);
}
// WARNING PTR CHECK
uint64_t cgen_var_67 = (uint64_t)(uintptr_t)pPropertyCount;
stream->putBe64(cgen_var_67);
if (pPropertyCount)
{
stream->write((uint32_t*)pPropertyCount, sizeof(uint32_t));
}
// WARNING PTR CHECK
uint64_t cgen_var_68 = (uint64_t)(uintptr_t)pProperties;
stream->putBe64(cgen_var_68);
if (pProperties)
{
for (uint32_t i = 0; i < (uint32_t)(*(pPropertyCount)); ++i)
{
marshal_VkExtensionProperties(stream, (VkExtensionProperties*)(pProperties + i));
}
}
AEMU_SCOPED_TRACE("vkEnumerateDeviceExtensionProperties readParams");
// WARNING PTR CHECK
uint32_t* check_pPropertyCount;
check_pPropertyCount = (uint32_t*)(uintptr_t)stream->getBe64();
if (pPropertyCount)
{
if (!(check_pPropertyCount))
{
fprintf(stderr, "fatal: pPropertyCount inconsistent between guest and host\n");
}
stream->read((uint32_t*)pPropertyCount, sizeof(uint32_t));
}
// WARNING PTR CHECK
VkExtensionProperties* check_pProperties;
check_pProperties = (VkExtensionProperties*)(uintptr_t)stream->getBe64();
if (pProperties)
{
if (!(check_pProperties))
{
fprintf(stderr, "fatal: pProperties inconsistent between guest and host\n");
}
for (uint32_t i = 0; i < (uint32_t)(*(pPropertyCount)); ++i)
{
unmarshal_VkExtensionProperties(stream, (VkExtensionProperties*)(pProperties + i));
}
}
if (pProperties)
{
for (uint32_t i = 0; i < (uint32_t)(*(pPropertyCount)); ++i)
{
transform_fromhost_VkExtensionProperties(mImpl->resources(), (VkExtensionProperties*)(pProperties + i));
}
}
AEMU_SCOPED_TRACE("vkEnumerateDeviceExtensionProperties returnUnmarshal");
VkResult vkEnumerateDeviceExtensionProperties_VkResult_return = (VkResult)0;
stream->read(&vkEnumerateDeviceExtensionProperties_VkResult_return, sizeof(VkResult));
countingStream->clearPool();
stream->clearPool();
pool->freeAll();
mImpl->log("finish vkEnumerateDeviceExtensionProperties");;
return vkEnumerateDeviceExtensionProperties_VkResult_return;
}
VkResult VkEncoder::vkEnumerateInstanceLayerProperties(
uint32_t* pPropertyCount,
VkLayerProperties* pProperties)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkEnumerateInstanceLayerProperties encode");
mImpl->log("start vkEnumerateInstanceLayerProperties");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
countingStream->rewind();
{
// WARNING PTR CHECK
uint64_t cgen_var_71 = (uint64_t)(uintptr_t)pPropertyCount;
countingStream->putBe64(cgen_var_71);
if (pPropertyCount)
{
countingStream->write((uint32_t*)pPropertyCount, sizeof(uint32_t));
}
// WARNING PTR CHECK
uint64_t cgen_var_72 = (uint64_t)(uintptr_t)pProperties;
countingStream->putBe64(cgen_var_72);
if (pProperties)
{
for (uint32_t i = 0; i < (uint32_t)(*(pPropertyCount)); ++i)
{
marshal_VkLayerProperties(countingStream, (VkLayerProperties*)(pProperties + i));
}
}
}
uint32_t packetSize_vkEnumerateInstanceLayerProperties = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkEnumerateInstanceLayerProperties = OP_vkEnumerateInstanceLayerProperties;
stream->write(&opcode_vkEnumerateInstanceLayerProperties, sizeof(uint32_t));
stream->write(&packetSize_vkEnumerateInstanceLayerProperties, sizeof(uint32_t));
// WARNING PTR CHECK
uint64_t cgen_var_73 = (uint64_t)(uintptr_t)pPropertyCount;
stream->putBe64(cgen_var_73);
if (pPropertyCount)
{
stream->write((uint32_t*)pPropertyCount, sizeof(uint32_t));
}
// WARNING PTR CHECK
uint64_t cgen_var_74 = (uint64_t)(uintptr_t)pProperties;
stream->putBe64(cgen_var_74);
if (pProperties)
{
for (uint32_t i = 0; i < (uint32_t)(*(pPropertyCount)); ++i)
{
marshal_VkLayerProperties(stream, (VkLayerProperties*)(pProperties + i));
}
}
AEMU_SCOPED_TRACE("vkEnumerateInstanceLayerProperties readParams");
// WARNING PTR CHECK
uint32_t* check_pPropertyCount;
check_pPropertyCount = (uint32_t*)(uintptr_t)stream->getBe64();
if (pPropertyCount)
{
if (!(check_pPropertyCount))
{
fprintf(stderr, "fatal: pPropertyCount inconsistent between guest and host\n");
}
stream->read((uint32_t*)pPropertyCount, sizeof(uint32_t));
}
// WARNING PTR CHECK
VkLayerProperties* check_pProperties;
check_pProperties = (VkLayerProperties*)(uintptr_t)stream->getBe64();
if (pProperties)
{
if (!(check_pProperties))
{
fprintf(stderr, "fatal: pProperties inconsistent between guest and host\n");
}
for (uint32_t i = 0; i < (uint32_t)(*(pPropertyCount)); ++i)
{
unmarshal_VkLayerProperties(stream, (VkLayerProperties*)(pProperties + i));
}
}
if (pProperties)
{
for (uint32_t i = 0; i < (uint32_t)(*(pPropertyCount)); ++i)
{
transform_fromhost_VkLayerProperties(mImpl->resources(), (VkLayerProperties*)(pProperties + i));
}
}
AEMU_SCOPED_TRACE("vkEnumerateInstanceLayerProperties returnUnmarshal");
VkResult vkEnumerateInstanceLayerProperties_VkResult_return = (VkResult)0;
stream->read(&vkEnumerateInstanceLayerProperties_VkResult_return, sizeof(VkResult));
countingStream->clearPool();
stream->clearPool();
pool->freeAll();
mImpl->log("finish vkEnumerateInstanceLayerProperties");;
return vkEnumerateInstanceLayerProperties_VkResult_return;
}
VkResult VkEncoder::vkEnumerateDeviceLayerProperties(
VkPhysicalDevice physicalDevice,
uint32_t* pPropertyCount,
VkLayerProperties* pProperties)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkEnumerateDeviceLayerProperties encode");
mImpl->log("start vkEnumerateDeviceLayerProperties");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkPhysicalDevice local_physicalDevice;
local_physicalDevice = physicalDevice;
countingStream->rewind();
{
uint64_t cgen_var_77;
countingStream->handleMapping()->mapHandles_VkPhysicalDevice_u64(&local_physicalDevice, &cgen_var_77, 1);
countingStream->write((uint64_t*)&cgen_var_77, 1 * 8);
// WARNING PTR CHECK
uint64_t cgen_var_78 = (uint64_t)(uintptr_t)pPropertyCount;
countingStream->putBe64(cgen_var_78);
if (pPropertyCount)
{
countingStream->write((uint32_t*)pPropertyCount, sizeof(uint32_t));
}
// WARNING PTR CHECK
uint64_t cgen_var_79 = (uint64_t)(uintptr_t)pProperties;
countingStream->putBe64(cgen_var_79);
if (pProperties)
{
for (uint32_t i = 0; i < (uint32_t)(*(pPropertyCount)); ++i)
{
marshal_VkLayerProperties(countingStream, (VkLayerProperties*)(pProperties + i));
}
}
}
uint32_t packetSize_vkEnumerateDeviceLayerProperties = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkEnumerateDeviceLayerProperties = OP_vkEnumerateDeviceLayerProperties;
stream->write(&opcode_vkEnumerateDeviceLayerProperties, sizeof(uint32_t));
stream->write(&packetSize_vkEnumerateDeviceLayerProperties, sizeof(uint32_t));
uint64_t cgen_var_80;
stream->handleMapping()->mapHandles_VkPhysicalDevice_u64(&local_physicalDevice, &cgen_var_80, 1);
stream->write((uint64_t*)&cgen_var_80, 1 * 8);
// WARNING PTR CHECK
uint64_t cgen_var_81 = (uint64_t)(uintptr_t)pPropertyCount;
stream->putBe64(cgen_var_81);
if (pPropertyCount)
{
stream->write((uint32_t*)pPropertyCount, sizeof(uint32_t));
}
// WARNING PTR CHECK
uint64_t cgen_var_82 = (uint64_t)(uintptr_t)pProperties;
stream->putBe64(cgen_var_82);
if (pProperties)
{
for (uint32_t i = 0; i < (uint32_t)(*(pPropertyCount)); ++i)
{
marshal_VkLayerProperties(stream, (VkLayerProperties*)(pProperties + i));
}
}
AEMU_SCOPED_TRACE("vkEnumerateDeviceLayerProperties readParams");
// WARNING PTR CHECK
uint32_t* check_pPropertyCount;
check_pPropertyCount = (uint32_t*)(uintptr_t)stream->getBe64();
if (pPropertyCount)
{
if (!(check_pPropertyCount))
{
fprintf(stderr, "fatal: pPropertyCount inconsistent between guest and host\n");
}
stream->read((uint32_t*)pPropertyCount, sizeof(uint32_t));
}
// WARNING PTR CHECK
VkLayerProperties* check_pProperties;
check_pProperties = (VkLayerProperties*)(uintptr_t)stream->getBe64();
if (pProperties)
{
if (!(check_pProperties))
{
fprintf(stderr, "fatal: pProperties inconsistent between guest and host\n");
}
for (uint32_t i = 0; i < (uint32_t)(*(pPropertyCount)); ++i)
{
unmarshal_VkLayerProperties(stream, (VkLayerProperties*)(pProperties + i));
}
}
if (pProperties)
{
for (uint32_t i = 0; i < (uint32_t)(*(pPropertyCount)); ++i)
{
transform_fromhost_VkLayerProperties(mImpl->resources(), (VkLayerProperties*)(pProperties + i));
}
}
AEMU_SCOPED_TRACE("vkEnumerateDeviceLayerProperties returnUnmarshal");
VkResult vkEnumerateDeviceLayerProperties_VkResult_return = (VkResult)0;
stream->read(&vkEnumerateDeviceLayerProperties_VkResult_return, sizeof(VkResult));
countingStream->clearPool();
stream->clearPool();
pool->freeAll();
mImpl->log("finish vkEnumerateDeviceLayerProperties");;
return vkEnumerateDeviceLayerProperties_VkResult_return;
}
void VkEncoder::vkGetDeviceQueue(
VkDevice device,
uint32_t queueFamilyIndex,
uint32_t queueIndex,
VkQueue* pQueue)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkGetDeviceQueue encode");
mImpl->log("start vkGetDeviceQueue");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkDevice local_device;
uint32_t local_queueFamilyIndex;
uint32_t local_queueIndex;
local_device = device;
local_queueFamilyIndex = queueFamilyIndex;
local_queueIndex = queueIndex;
countingStream->rewind();
{
uint64_t cgen_var_85;
countingStream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_85, 1);
countingStream->write((uint64_t*)&cgen_var_85, 1 * 8);
countingStream->write((uint32_t*)&local_queueFamilyIndex, sizeof(uint32_t));
countingStream->write((uint32_t*)&local_queueIndex, sizeof(uint32_t));
uint64_t cgen_var_86;
countingStream->handleMapping()->mapHandles_VkQueue_u64(pQueue, &cgen_var_86, 1);
countingStream->write((uint64_t*)&cgen_var_86, 8);
}
uint32_t packetSize_vkGetDeviceQueue = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkGetDeviceQueue = OP_vkGetDeviceQueue;
stream->write(&opcode_vkGetDeviceQueue, sizeof(uint32_t));
stream->write(&packetSize_vkGetDeviceQueue, sizeof(uint32_t));
uint64_t cgen_var_87;
stream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_87, 1);
stream->write((uint64_t*)&cgen_var_87, 1 * 8);
stream->write((uint32_t*)&local_queueFamilyIndex, sizeof(uint32_t));
stream->write((uint32_t*)&local_queueIndex, sizeof(uint32_t));
stream->unsetHandleMapping() /* emit_marshal, is handle, possibly out */;
uint64_t cgen_var_88;
stream->handleMapping()->mapHandles_VkQueue_u64(pQueue, &cgen_var_88, 1);
stream->write((uint64_t*)&cgen_var_88, 8);
stream->setHandleMapping(resources->unwrapMapping());
AEMU_SCOPED_TRACE("vkGetDeviceQueue readParams");
stream->setHandleMapping(resources->createMapping());
uint64_t cgen_var_89;
stream->read((uint64_t*)&cgen_var_89, 8);
stream->handleMapping()->mapHandles_u64_VkQueue(&cgen_var_89, (VkQueue*)pQueue, 1);
stream->unsetHandleMapping();
AEMU_SCOPED_TRACE("vkGetDeviceQueue returnUnmarshal");
mImpl->log("finish vkGetDeviceQueue");;
}
VkResult VkEncoder::vkQueueSubmit(
VkQueue queue,
uint32_t submitCount,
const VkSubmitInfo* pSubmits,
VkFence fence)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkQueueSubmit encode");
mImpl->log("start vkQueueSubmit");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkQueue local_queue;
uint32_t local_submitCount;
VkSubmitInfo* local_pSubmits;
VkFence local_fence;
local_queue = queue;
local_submitCount = submitCount;
local_pSubmits = nullptr;
if (pSubmits)
{
local_pSubmits = (VkSubmitInfo*)pool->alloc(((submitCount)) * sizeof(const VkSubmitInfo));
for (uint32_t i = 0; i < (uint32_t)((submitCount)); ++i)
{
deepcopy_VkSubmitInfo(pool, pSubmits + i, (VkSubmitInfo*)(local_pSubmits + i));
}
}
local_fence = fence;
if (local_pSubmits)
{
for (uint32_t i = 0; i < (uint32_t)((submitCount)); ++i)
{
transform_tohost_VkSubmitInfo(mImpl->resources(), (VkSubmitInfo*)(local_pSubmits + i));
}
}
countingStream->rewind();
{
uint64_t cgen_var_90;
countingStream->handleMapping()->mapHandles_VkQueue_u64(&local_queue, &cgen_var_90, 1);
countingStream->write((uint64_t*)&cgen_var_90, 1 * 8);
countingStream->write((uint32_t*)&local_submitCount, sizeof(uint32_t));
for (uint32_t i = 0; i < (uint32_t)((submitCount)); ++i)
{
marshal_VkSubmitInfo(countingStream, (VkSubmitInfo*)(local_pSubmits + i));
}
uint64_t cgen_var_91;
countingStream->handleMapping()->mapHandles_VkFence_u64(&local_fence, &cgen_var_91, 1);
countingStream->write((uint64_t*)&cgen_var_91, 1 * 8);
}
uint32_t packetSize_vkQueueSubmit = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkQueueSubmit = OP_vkQueueSubmit;
stream->write(&opcode_vkQueueSubmit, sizeof(uint32_t));
stream->write(&packetSize_vkQueueSubmit, sizeof(uint32_t));
uint64_t cgen_var_92;
stream->handleMapping()->mapHandles_VkQueue_u64(&local_queue, &cgen_var_92, 1);
stream->write((uint64_t*)&cgen_var_92, 1 * 8);
stream->write((uint32_t*)&local_submitCount, sizeof(uint32_t));
for (uint32_t i = 0; i < (uint32_t)((submitCount)); ++i)
{
marshal_VkSubmitInfo(stream, (VkSubmitInfo*)(local_pSubmits + i));
}
uint64_t cgen_var_93;
stream->handleMapping()->mapHandles_VkFence_u64(&local_fence, &cgen_var_93, 1);
stream->write((uint64_t*)&cgen_var_93, 1 * 8);
AEMU_SCOPED_TRACE("vkQueueSubmit readParams");
AEMU_SCOPED_TRACE("vkQueueSubmit returnUnmarshal");
VkResult vkQueueSubmit_VkResult_return = (VkResult)0;
stream->read(&vkQueueSubmit_VkResult_return, sizeof(VkResult));
countingStream->clearPool();
stream->clearPool();
pool->freeAll();
mImpl->log("finish vkQueueSubmit");;
return vkQueueSubmit_VkResult_return;
}
VkResult VkEncoder::vkQueueWaitIdle(
VkQueue queue)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkQueueWaitIdle encode");
mImpl->log("start vkQueueWaitIdle");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkQueue local_queue;
local_queue = queue;
countingStream->rewind();
{
uint64_t cgen_var_94;
countingStream->handleMapping()->mapHandles_VkQueue_u64(&local_queue, &cgen_var_94, 1);
countingStream->write((uint64_t*)&cgen_var_94, 1 * 8);
}
uint32_t packetSize_vkQueueWaitIdle = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkQueueWaitIdle = OP_vkQueueWaitIdle;
stream->write(&opcode_vkQueueWaitIdle, sizeof(uint32_t));
stream->write(&packetSize_vkQueueWaitIdle, sizeof(uint32_t));
uint64_t cgen_var_95;
stream->handleMapping()->mapHandles_VkQueue_u64(&local_queue, &cgen_var_95, 1);
stream->write((uint64_t*)&cgen_var_95, 1 * 8);
AEMU_SCOPED_TRACE("vkQueueWaitIdle readParams");
AEMU_SCOPED_TRACE("vkQueueWaitIdle returnUnmarshal");
VkResult vkQueueWaitIdle_VkResult_return = (VkResult)0;
stream->read(&vkQueueWaitIdle_VkResult_return, sizeof(VkResult));
countingStream->clearPool();
stream->clearPool();
pool->freeAll();
mImpl->log("finish vkQueueWaitIdle");;
return vkQueueWaitIdle_VkResult_return;
}
VkResult VkEncoder::vkDeviceWaitIdle(
VkDevice device)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkDeviceWaitIdle encode");
mImpl->log("start vkDeviceWaitIdle");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkDevice local_device;
local_device = device;
countingStream->rewind();
{
uint64_t cgen_var_96;
countingStream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_96, 1);
countingStream->write((uint64_t*)&cgen_var_96, 1 * 8);
}
uint32_t packetSize_vkDeviceWaitIdle = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkDeviceWaitIdle = OP_vkDeviceWaitIdle;
stream->write(&opcode_vkDeviceWaitIdle, sizeof(uint32_t));
stream->write(&packetSize_vkDeviceWaitIdle, sizeof(uint32_t));
uint64_t cgen_var_97;
stream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_97, 1);
stream->write((uint64_t*)&cgen_var_97, 1 * 8);
AEMU_SCOPED_TRACE("vkDeviceWaitIdle readParams");
AEMU_SCOPED_TRACE("vkDeviceWaitIdle returnUnmarshal");
VkResult vkDeviceWaitIdle_VkResult_return = (VkResult)0;
stream->read(&vkDeviceWaitIdle_VkResult_return, sizeof(VkResult));
countingStream->clearPool();
stream->clearPool();
pool->freeAll();
mImpl->log("finish vkDeviceWaitIdle");;
return vkDeviceWaitIdle_VkResult_return;
}
VkResult VkEncoder::vkAllocateMemory(
VkDevice device,
const VkMemoryAllocateInfo* pAllocateInfo,
const VkAllocationCallbacks* pAllocator,
VkDeviceMemory* pMemory)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkAllocateMemory encode");
mImpl->log("start vkAllocateMemory");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkDevice local_device;
VkMemoryAllocateInfo* local_pAllocateInfo;
VkAllocationCallbacks* local_pAllocator;
local_device = device;
local_pAllocateInfo = nullptr;
if (pAllocateInfo)
{
local_pAllocateInfo = (VkMemoryAllocateInfo*)pool->alloc(sizeof(const VkMemoryAllocateInfo));
deepcopy_VkMemoryAllocateInfo(pool, pAllocateInfo, (VkMemoryAllocateInfo*)(local_pAllocateInfo));
}
local_pAllocator = nullptr;
if (pAllocator)
{
local_pAllocator = (VkAllocationCallbacks*)pool->alloc(sizeof(const VkAllocationCallbacks));
deepcopy_VkAllocationCallbacks(pool, pAllocator, (VkAllocationCallbacks*)(local_pAllocator));
}
local_pAllocator = nullptr;
if (local_pAllocateInfo)
{
transform_tohost_VkMemoryAllocateInfo(mImpl->resources(), (VkMemoryAllocateInfo*)(local_pAllocateInfo));
}
if (local_pAllocator)
{
transform_tohost_VkAllocationCallbacks(mImpl->resources(), (VkAllocationCallbacks*)(local_pAllocator));
}
countingStream->rewind();
{
uint64_t cgen_var_98;
countingStream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_98, 1);
countingStream->write((uint64_t*)&cgen_var_98, 1 * 8);
marshal_VkMemoryAllocateInfo(countingStream, (VkMemoryAllocateInfo*)(local_pAllocateInfo));
// WARNING PTR CHECK
uint64_t cgen_var_99 = (uint64_t)(uintptr_t)local_pAllocator;
countingStream->putBe64(cgen_var_99);
if (local_pAllocator)
{
marshal_VkAllocationCallbacks(countingStream, (VkAllocationCallbacks*)(local_pAllocator));
}
uint64_t cgen_var_100;
countingStream->handleMapping()->mapHandles_VkDeviceMemory_u64(pMemory, &cgen_var_100, 1);
countingStream->write((uint64_t*)&cgen_var_100, 8);
}
uint32_t packetSize_vkAllocateMemory = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkAllocateMemory = OP_vkAllocateMemory;
stream->write(&opcode_vkAllocateMemory, sizeof(uint32_t));
stream->write(&packetSize_vkAllocateMemory, sizeof(uint32_t));
uint64_t cgen_var_101;
stream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_101, 1);
stream->write((uint64_t*)&cgen_var_101, 1 * 8);
marshal_VkMemoryAllocateInfo(stream, (VkMemoryAllocateInfo*)(local_pAllocateInfo));
// WARNING PTR CHECK
uint64_t cgen_var_102 = (uint64_t)(uintptr_t)local_pAllocator;
stream->putBe64(cgen_var_102);
if (local_pAllocator)
{
marshal_VkAllocationCallbacks(stream, (VkAllocationCallbacks*)(local_pAllocator));
}
stream->unsetHandleMapping() /* emit_marshal, is handle, possibly out */;
uint64_t cgen_var_103;
stream->handleMapping()->mapHandles_VkDeviceMemory_u64(pMemory, &cgen_var_103, 1);
stream->write((uint64_t*)&cgen_var_103, 8);
stream->setHandleMapping(resources->unwrapMapping());
AEMU_SCOPED_TRACE("vkAllocateMemory readParams");
stream->setHandleMapping(resources->createMapping());
uint64_t cgen_var_104;
stream->read((uint64_t*)&cgen_var_104, 8);
stream->handleMapping()->mapHandles_u64_VkDeviceMemory(&cgen_var_104, (VkDeviceMemory*)pMemory, 1);
stream->unsetHandleMapping();
AEMU_SCOPED_TRACE("vkAllocateMemory returnUnmarshal");
VkResult vkAllocateMemory_VkResult_return = (VkResult)0;
stream->read(&vkAllocateMemory_VkResult_return, sizeof(VkResult));
countingStream->clearPool();
stream->clearPool();
pool->freeAll();
mImpl->log("finish vkAllocateMemory");;
return vkAllocateMemory_VkResult_return;
}
void VkEncoder::vkFreeMemory(
VkDevice device,
VkDeviceMemory memory,
const VkAllocationCallbacks* pAllocator)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkFreeMemory encode");
mImpl->log("start vkFreeMemory");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkDevice local_device;
VkDeviceMemory local_memory;
VkAllocationCallbacks* local_pAllocator;
local_device = device;
local_memory = memory;
local_pAllocator = nullptr;
if (pAllocator)
{
local_pAllocator = (VkAllocationCallbacks*)pool->alloc(sizeof(const VkAllocationCallbacks));
deepcopy_VkAllocationCallbacks(pool, pAllocator, (VkAllocationCallbacks*)(local_pAllocator));
}
local_pAllocator = nullptr;
mImpl->resources()->deviceMemoryTransform_tohost((VkDeviceMemory*)&local_memory, 1, (VkDeviceSize*)nullptr, 0, (VkDeviceSize*)nullptr, 0, (uint32_t*)nullptr, 0, (uint32_t*)nullptr, 0);
countingStream->rewind();
{
uint64_t cgen_var_105;
countingStream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_105, 1);
countingStream->write((uint64_t*)&cgen_var_105, 1 * 8);
uint64_t cgen_var_106;
countingStream->handleMapping()->mapHandles_VkDeviceMemory_u64(&local_memory, &cgen_var_106, 1);
countingStream->write((uint64_t*)&cgen_var_106, 1 * 8);
// WARNING PTR CHECK
uint64_t cgen_var_107 = (uint64_t)(uintptr_t)local_pAllocator;
countingStream->putBe64(cgen_var_107);
if (local_pAllocator)
{
marshal_VkAllocationCallbacks(countingStream, (VkAllocationCallbacks*)(local_pAllocator));
}
}
uint32_t packetSize_vkFreeMemory = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkFreeMemory = OP_vkFreeMemory;
stream->write(&opcode_vkFreeMemory, sizeof(uint32_t));
stream->write(&packetSize_vkFreeMemory, sizeof(uint32_t));
uint64_t cgen_var_108;
stream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_108, 1);
stream->write((uint64_t*)&cgen_var_108, 1 * 8);
uint64_t cgen_var_109;
stream->handleMapping()->mapHandles_VkDeviceMemory_u64(&local_memory, &cgen_var_109, 1);
stream->write((uint64_t*)&cgen_var_109, 1 * 8);
// WARNING PTR CHECK
uint64_t cgen_var_110 = (uint64_t)(uintptr_t)local_pAllocator;
stream->putBe64(cgen_var_110);
if (local_pAllocator)
{
marshal_VkAllocationCallbacks(stream, (VkAllocationCallbacks*)(local_pAllocator));
}
AEMU_SCOPED_TRACE("vkFreeMemory readParams");
AEMU_SCOPED_TRACE("vkFreeMemory returnUnmarshal");
resources->destroyMapping()->mapHandles_VkDeviceMemory((VkDeviceMemory*)&memory);
mImpl->log("finish vkFreeMemory");;
}
VkResult VkEncoder::vkMapMemory(
VkDevice device,
VkDeviceMemory memory,
VkDeviceSize offset,
VkDeviceSize size,
VkMemoryMapFlags flags,
void** ppData)
{
AEMU_SCOPED_TRACE("vkMapMemory resourceEvent");
VkResult vkMapMemory_VkResult_return = (VkResult)0;
vkMapMemory_VkResult_return = mImpl->resources()->on_vkMapMemory(this, VK_SUCCESS, device, memory, offset, size, flags, ppData);
mImpl->log("finish vkMapMemory");;
return vkMapMemory_VkResult_return;
}
void VkEncoder::vkUnmapMemory(
VkDevice device,
VkDeviceMemory memory)
{
AEMU_SCOPED_TRACE("vkUnmapMemory resourceEvent");
mImpl->resources()->on_vkUnmapMemory(this, device, memory);
}
VkResult VkEncoder::vkFlushMappedMemoryRanges(
VkDevice device,
uint32_t memoryRangeCount,
const VkMappedMemoryRange* pMemoryRanges)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkFlushMappedMemoryRanges encode");
mImpl->log("start vkFlushMappedMemoryRanges");
VALIDATE_RET(VkResult, VK_SUCCESS, mImpl->validation()->on_vkFlushMappedMemoryRanges(this, VK_SUCCESS, device, memoryRangeCount, pMemoryRanges));
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkDevice local_device;
uint32_t local_memoryRangeCount;
VkMappedMemoryRange* local_pMemoryRanges;
local_device = device;
local_memoryRangeCount = memoryRangeCount;
local_pMemoryRanges = nullptr;
if (pMemoryRanges)
{
local_pMemoryRanges = (VkMappedMemoryRange*)pool->alloc(((memoryRangeCount)) * sizeof(const VkMappedMemoryRange));
for (uint32_t i = 0; i < (uint32_t)((memoryRangeCount)); ++i)
{
deepcopy_VkMappedMemoryRange(pool, pMemoryRanges + i, (VkMappedMemoryRange*)(local_pMemoryRanges + i));
}
}
if (local_pMemoryRanges)
{
for (uint32_t i = 0; i < (uint32_t)((memoryRangeCount)); ++i)
{
transform_tohost_VkMappedMemoryRange(mImpl->resources(), (VkMappedMemoryRange*)(local_pMemoryRanges + i));
}
}
countingStream->rewind();
{
uint64_t cgen_var_111;
countingStream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_111, 1);
countingStream->write((uint64_t*)&cgen_var_111, 1 * 8);
countingStream->write((uint32_t*)&local_memoryRangeCount, sizeof(uint32_t));
for (uint32_t i = 0; i < (uint32_t)((memoryRangeCount)); ++i)
{
marshal_VkMappedMemoryRange(countingStream, (VkMappedMemoryRange*)(local_pMemoryRanges + i));
}
}
if (!resources->usingDirectMapping())
{
for (uint32_t i = 0; i < memoryRangeCount; ++i)
{
auto range = pMemoryRanges[i];
auto memory = pMemoryRanges[i].memory;
auto size = pMemoryRanges[i].size;
auto offset = pMemoryRanges[i].offset;
uint64_t streamSize = 0;
if (!memory) { countingStream->write(&streamSize, sizeof(uint64_t)); continue; };
auto hostPtr = resources->getMappedPointer(memory);
auto actualSize = size == VK_WHOLE_SIZE ? resources->getMappedSize(memory) : size;
if (!hostPtr) { countingStream->write(&streamSize, sizeof(uint64_t)); continue; };
streamSize = actualSize;
countingStream->write(&streamSize, sizeof(uint64_t));
uint8_t* targetRange = hostPtr + offset;
countingStream->write(targetRange, actualSize);
}
}
uint32_t packetSize_vkFlushMappedMemoryRanges = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkFlushMappedMemoryRanges = OP_vkFlushMappedMemoryRanges;
stream->write(&opcode_vkFlushMappedMemoryRanges, sizeof(uint32_t));
stream->write(&packetSize_vkFlushMappedMemoryRanges, sizeof(uint32_t));
uint64_t cgen_var_112;
stream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_112, 1);
stream->write((uint64_t*)&cgen_var_112, 1 * 8);
stream->write((uint32_t*)&local_memoryRangeCount, sizeof(uint32_t));
for (uint32_t i = 0; i < (uint32_t)((memoryRangeCount)); ++i)
{
marshal_VkMappedMemoryRange(stream, (VkMappedMemoryRange*)(local_pMemoryRanges + i));
}
if (!resources->usingDirectMapping())
{
for (uint32_t i = 0; i < memoryRangeCount; ++i)
{
auto range = pMemoryRanges[i];
auto memory = pMemoryRanges[i].memory;
auto size = pMemoryRanges[i].size;
auto offset = pMemoryRanges[i].offset;
uint64_t streamSize = 0;
if (!memory) { stream->write(&streamSize, sizeof(uint64_t)); continue; };
auto hostPtr = resources->getMappedPointer(memory);
auto actualSize = size == VK_WHOLE_SIZE ? resources->getMappedSize(memory) : size;
if (!hostPtr) { stream->write(&streamSize, sizeof(uint64_t)); continue; };
streamSize = actualSize;
stream->write(&streamSize, sizeof(uint64_t));
uint8_t* targetRange = hostPtr + offset;
stream->write(targetRange, actualSize);
}
}
AEMU_SCOPED_TRACE("vkFlushMappedMemoryRanges readParams");
AEMU_SCOPED_TRACE("vkFlushMappedMemoryRanges returnUnmarshal");
VkResult vkFlushMappedMemoryRanges_VkResult_return = (VkResult)0;
stream->read(&vkFlushMappedMemoryRanges_VkResult_return, sizeof(VkResult));
countingStream->clearPool();
stream->clearPool();
pool->freeAll();
mImpl->log("finish vkFlushMappedMemoryRanges");;
return vkFlushMappedMemoryRanges_VkResult_return;
}
VkResult VkEncoder::vkInvalidateMappedMemoryRanges(
VkDevice device,
uint32_t memoryRangeCount,
const VkMappedMemoryRange* pMemoryRanges)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkInvalidateMappedMemoryRanges encode");
mImpl->log("start vkInvalidateMappedMemoryRanges");
VALIDATE_RET(VkResult, VK_SUCCESS, mImpl->validation()->on_vkInvalidateMappedMemoryRanges(this, VK_SUCCESS, device, memoryRangeCount, pMemoryRanges));
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkDevice local_device;
uint32_t local_memoryRangeCount;
VkMappedMemoryRange* local_pMemoryRanges;
local_device = device;
local_memoryRangeCount = memoryRangeCount;
local_pMemoryRanges = nullptr;
if (pMemoryRanges)
{
local_pMemoryRanges = (VkMappedMemoryRange*)pool->alloc(((memoryRangeCount)) * sizeof(const VkMappedMemoryRange));
for (uint32_t i = 0; i < (uint32_t)((memoryRangeCount)); ++i)
{
deepcopy_VkMappedMemoryRange(pool, pMemoryRanges + i, (VkMappedMemoryRange*)(local_pMemoryRanges + i));
}
}
if (local_pMemoryRanges)
{
for (uint32_t i = 0; i < (uint32_t)((memoryRangeCount)); ++i)
{
transform_tohost_VkMappedMemoryRange(mImpl->resources(), (VkMappedMemoryRange*)(local_pMemoryRanges + i));
}
}
countingStream->rewind();
{
uint64_t cgen_var_113;
countingStream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_113, 1);
countingStream->write((uint64_t*)&cgen_var_113, 1 * 8);
countingStream->write((uint32_t*)&local_memoryRangeCount, sizeof(uint32_t));
for (uint32_t i = 0; i < (uint32_t)((memoryRangeCount)); ++i)
{
marshal_VkMappedMemoryRange(countingStream, (VkMappedMemoryRange*)(local_pMemoryRanges + i));
}
}
uint32_t packetSize_vkInvalidateMappedMemoryRanges = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkInvalidateMappedMemoryRanges = OP_vkInvalidateMappedMemoryRanges;
stream->write(&opcode_vkInvalidateMappedMemoryRanges, sizeof(uint32_t));
stream->write(&packetSize_vkInvalidateMappedMemoryRanges, sizeof(uint32_t));
uint64_t cgen_var_114;
stream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_114, 1);
stream->write((uint64_t*)&cgen_var_114, 1 * 8);
stream->write((uint32_t*)&local_memoryRangeCount, sizeof(uint32_t));
for (uint32_t i = 0; i < (uint32_t)((memoryRangeCount)); ++i)
{
marshal_VkMappedMemoryRange(stream, (VkMappedMemoryRange*)(local_pMemoryRanges + i));
}
AEMU_SCOPED_TRACE("vkInvalidateMappedMemoryRanges readParams");
AEMU_SCOPED_TRACE("vkInvalidateMappedMemoryRanges returnUnmarshal");
VkResult vkInvalidateMappedMemoryRanges_VkResult_return = (VkResult)0;
stream->read(&vkInvalidateMappedMemoryRanges_VkResult_return, sizeof(VkResult));
countingStream->clearPool();
stream->clearPool();
pool->freeAll();
if (!resources->usingDirectMapping())
{
for (uint32_t i = 0; i < memoryRangeCount; ++i)
{
auto range = pMemoryRanges[i];
auto memory = pMemoryRanges[i].memory;
auto size = pMemoryRanges[i].size;
auto offset = pMemoryRanges[i].offset;
uint64_t streamSize = 0;
if (!memory) { stream->read(&streamSize, sizeof(uint64_t)); continue; };
auto hostPtr = resources->getMappedPointer(memory);
auto actualSize = size == VK_WHOLE_SIZE ? resources->getMappedSize(memory) : size;
if (!hostPtr) { stream->read(&streamSize, sizeof(uint64_t)); continue; };
streamSize = actualSize;
stream->read(&streamSize, sizeof(uint64_t));
uint8_t* targetRange = hostPtr + offset;
stream->read(targetRange, actualSize);
}
}
mImpl->log("finish vkInvalidateMappedMemoryRanges");;
return vkInvalidateMappedMemoryRanges_VkResult_return;
}
void VkEncoder::vkGetDeviceMemoryCommitment(
VkDevice device,
VkDeviceMemory memory,
VkDeviceSize* pCommittedMemoryInBytes)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkGetDeviceMemoryCommitment encode");
mImpl->log("start vkGetDeviceMemoryCommitment");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkDevice local_device;
VkDeviceMemory local_memory;
local_device = device;
local_memory = memory;
mImpl->resources()->deviceMemoryTransform_tohost((VkDeviceMemory*)&local_memory, 1, (VkDeviceSize*)nullptr, 0, (VkDeviceSize*)nullptr, 0, (uint32_t*)nullptr, 0, (uint32_t*)nullptr, 0);
countingStream->rewind();
{
uint64_t cgen_var_115;
countingStream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_115, 1);
countingStream->write((uint64_t*)&cgen_var_115, 1 * 8);
uint64_t cgen_var_116;
countingStream->handleMapping()->mapHandles_VkDeviceMemory_u64(&local_memory, &cgen_var_116, 1);
countingStream->write((uint64_t*)&cgen_var_116, 1 * 8);
countingStream->write((VkDeviceSize*)pCommittedMemoryInBytes, sizeof(VkDeviceSize));
}
uint32_t packetSize_vkGetDeviceMemoryCommitment = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkGetDeviceMemoryCommitment = OP_vkGetDeviceMemoryCommitment;
stream->write(&opcode_vkGetDeviceMemoryCommitment, sizeof(uint32_t));
stream->write(&packetSize_vkGetDeviceMemoryCommitment, sizeof(uint32_t));
uint64_t cgen_var_117;
stream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_117, 1);
stream->write((uint64_t*)&cgen_var_117, 1 * 8);
uint64_t cgen_var_118;
stream->handleMapping()->mapHandles_VkDeviceMemory_u64(&local_memory, &cgen_var_118, 1);
stream->write((uint64_t*)&cgen_var_118, 1 * 8);
stream->write((VkDeviceSize*)pCommittedMemoryInBytes, sizeof(VkDeviceSize));
AEMU_SCOPED_TRACE("vkGetDeviceMemoryCommitment readParams");
stream->read((VkDeviceSize*)pCommittedMemoryInBytes, sizeof(VkDeviceSize));
AEMU_SCOPED_TRACE("vkGetDeviceMemoryCommitment returnUnmarshal");
mImpl->log("finish vkGetDeviceMemoryCommitment");;
}
VkResult VkEncoder::vkBindBufferMemory(
VkDevice device,
VkBuffer buffer,
VkDeviceMemory memory,
VkDeviceSize memoryOffset)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkBindBufferMemory encode");
mImpl->log("start vkBindBufferMemory");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkDevice local_device;
VkBuffer local_buffer;
VkDeviceMemory local_memory;
VkDeviceSize local_memoryOffset;
local_device = device;
local_buffer = buffer;
local_memory = memory;
local_memoryOffset = memoryOffset;
mImpl->resources()->deviceMemoryTransform_tohost((VkDeviceMemory*)&local_memory, 1, (VkDeviceSize*)&local_memoryOffset, 1, (VkDeviceSize*)nullptr, 0, (uint32_t*)nullptr, 0, (uint32_t*)nullptr, 0);
countingStream->rewind();
{
uint64_t cgen_var_119;
countingStream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_119, 1);
countingStream->write((uint64_t*)&cgen_var_119, 1 * 8);
uint64_t cgen_var_120;
countingStream->handleMapping()->mapHandles_VkBuffer_u64(&local_buffer, &cgen_var_120, 1);
countingStream->write((uint64_t*)&cgen_var_120, 1 * 8);
uint64_t cgen_var_121;
countingStream->handleMapping()->mapHandles_VkDeviceMemory_u64(&local_memory, &cgen_var_121, 1);
countingStream->write((uint64_t*)&cgen_var_121, 1 * 8);
countingStream->write((VkDeviceSize*)&local_memoryOffset, sizeof(VkDeviceSize));
}
uint32_t packetSize_vkBindBufferMemory = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkBindBufferMemory = OP_vkBindBufferMemory;
stream->write(&opcode_vkBindBufferMemory, sizeof(uint32_t));
stream->write(&packetSize_vkBindBufferMemory, sizeof(uint32_t));
uint64_t cgen_var_122;
stream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_122, 1);
stream->write((uint64_t*)&cgen_var_122, 1 * 8);
uint64_t cgen_var_123;
stream->handleMapping()->mapHandles_VkBuffer_u64(&local_buffer, &cgen_var_123, 1);
stream->write((uint64_t*)&cgen_var_123, 1 * 8);
uint64_t cgen_var_124;
stream->handleMapping()->mapHandles_VkDeviceMemory_u64(&local_memory, &cgen_var_124, 1);
stream->write((uint64_t*)&cgen_var_124, 1 * 8);
stream->write((VkDeviceSize*)&local_memoryOffset, sizeof(VkDeviceSize));
AEMU_SCOPED_TRACE("vkBindBufferMemory readParams");
AEMU_SCOPED_TRACE("vkBindBufferMemory returnUnmarshal");
VkResult vkBindBufferMemory_VkResult_return = (VkResult)0;
stream->read(&vkBindBufferMemory_VkResult_return, sizeof(VkResult));
countingStream->clearPool();
stream->clearPool();
pool->freeAll();
mImpl->log("finish vkBindBufferMemory");;
return vkBindBufferMemory_VkResult_return;
}
VkResult VkEncoder::vkBindImageMemory(
VkDevice device,
VkImage image,
VkDeviceMemory memory,
VkDeviceSize memoryOffset)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkBindImageMemory encode");
mImpl->log("start vkBindImageMemory");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkDevice local_device;
VkImage local_image;
VkDeviceMemory local_memory;
VkDeviceSize local_memoryOffset;
local_device = device;
local_image = image;
local_memory = memory;
local_memoryOffset = memoryOffset;
mImpl->resources()->deviceMemoryTransform_tohost((VkDeviceMemory*)&local_memory, 1, (VkDeviceSize*)&local_memoryOffset, 1, (VkDeviceSize*)nullptr, 0, (uint32_t*)nullptr, 0, (uint32_t*)nullptr, 0);
countingStream->rewind();
{
uint64_t cgen_var_125;
countingStream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_125, 1);
countingStream->write((uint64_t*)&cgen_var_125, 1 * 8);
uint64_t cgen_var_126;
countingStream->handleMapping()->mapHandles_VkImage_u64(&local_image, &cgen_var_126, 1);
countingStream->write((uint64_t*)&cgen_var_126, 1 * 8);
uint64_t cgen_var_127;
countingStream->handleMapping()->mapHandles_VkDeviceMemory_u64(&local_memory, &cgen_var_127, 1);
countingStream->write((uint64_t*)&cgen_var_127, 1 * 8);
countingStream->write((VkDeviceSize*)&local_memoryOffset, sizeof(VkDeviceSize));
}
uint32_t packetSize_vkBindImageMemory = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkBindImageMemory = OP_vkBindImageMemory;
stream->write(&opcode_vkBindImageMemory, sizeof(uint32_t));
stream->write(&packetSize_vkBindImageMemory, sizeof(uint32_t));
uint64_t cgen_var_128;
stream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_128, 1);
stream->write((uint64_t*)&cgen_var_128, 1 * 8);
uint64_t cgen_var_129;
stream->handleMapping()->mapHandles_VkImage_u64(&local_image, &cgen_var_129, 1);
stream->write((uint64_t*)&cgen_var_129, 1 * 8);
uint64_t cgen_var_130;
stream->handleMapping()->mapHandles_VkDeviceMemory_u64(&local_memory, &cgen_var_130, 1);
stream->write((uint64_t*)&cgen_var_130, 1 * 8);
stream->write((VkDeviceSize*)&local_memoryOffset, sizeof(VkDeviceSize));
AEMU_SCOPED_TRACE("vkBindImageMemory readParams");
AEMU_SCOPED_TRACE("vkBindImageMemory returnUnmarshal");
VkResult vkBindImageMemory_VkResult_return = (VkResult)0;
stream->read(&vkBindImageMemory_VkResult_return, sizeof(VkResult));
countingStream->clearPool();
stream->clearPool();
pool->freeAll();
mImpl->log("finish vkBindImageMemory");;
return vkBindImageMemory_VkResult_return;
}
void VkEncoder::vkGetBufferMemoryRequirements(
VkDevice device,
VkBuffer buffer,
VkMemoryRequirements* pMemoryRequirements)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkGetBufferMemoryRequirements encode");
mImpl->log("start vkGetBufferMemoryRequirements");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkDevice local_device;
VkBuffer local_buffer;
local_device = device;
local_buffer = buffer;
countingStream->rewind();
{
uint64_t cgen_var_131;
countingStream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_131, 1);
countingStream->write((uint64_t*)&cgen_var_131, 1 * 8);
uint64_t cgen_var_132;
countingStream->handleMapping()->mapHandles_VkBuffer_u64(&local_buffer, &cgen_var_132, 1);
countingStream->write((uint64_t*)&cgen_var_132, 1 * 8);
marshal_VkMemoryRequirements(countingStream, (VkMemoryRequirements*)(pMemoryRequirements));
}
uint32_t packetSize_vkGetBufferMemoryRequirements = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkGetBufferMemoryRequirements = OP_vkGetBufferMemoryRequirements;
stream->write(&opcode_vkGetBufferMemoryRequirements, sizeof(uint32_t));
stream->write(&packetSize_vkGetBufferMemoryRequirements, sizeof(uint32_t));
uint64_t cgen_var_133;
stream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_133, 1);
stream->write((uint64_t*)&cgen_var_133, 1 * 8);
uint64_t cgen_var_134;
stream->handleMapping()->mapHandles_VkBuffer_u64(&local_buffer, &cgen_var_134, 1);
stream->write((uint64_t*)&cgen_var_134, 1 * 8);
marshal_VkMemoryRequirements(stream, (VkMemoryRequirements*)(pMemoryRequirements));
AEMU_SCOPED_TRACE("vkGetBufferMemoryRequirements readParams");
unmarshal_VkMemoryRequirements(stream, (VkMemoryRequirements*)(pMemoryRequirements));
if (pMemoryRequirements)
{
transform_fromhost_VkMemoryRequirements(mImpl->resources(), (VkMemoryRequirements*)(pMemoryRequirements));
}
AEMU_SCOPED_TRACE("vkGetBufferMemoryRequirements returnUnmarshal");
mImpl->log("finish vkGetBufferMemoryRequirements");;
}
void VkEncoder::vkGetImageMemoryRequirements(
VkDevice device,
VkImage image,
VkMemoryRequirements* pMemoryRequirements)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkGetImageMemoryRequirements encode");
mImpl->log("start vkGetImageMemoryRequirements");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkDevice local_device;
VkImage local_image;
local_device = device;
local_image = image;
countingStream->rewind();
{
uint64_t cgen_var_135;
countingStream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_135, 1);
countingStream->write((uint64_t*)&cgen_var_135, 1 * 8);
uint64_t cgen_var_136;
countingStream->handleMapping()->mapHandles_VkImage_u64(&local_image, &cgen_var_136, 1);
countingStream->write((uint64_t*)&cgen_var_136, 1 * 8);
marshal_VkMemoryRequirements(countingStream, (VkMemoryRequirements*)(pMemoryRequirements));
}
uint32_t packetSize_vkGetImageMemoryRequirements = 4 + 4 + (uint32_t)countingStream->bytesWritten();
countingStream->rewind();
uint32_t opcode_vkGetImageMemoryRequirements = OP_vkGetImageMemoryRequirements;
stream->write(&opcode_vkGetImageMemoryRequirements, sizeof(uint32_t));
stream->write(&packetSize_vkGetImageMemoryRequirements, sizeof(uint32_t));
uint64_t cgen_var_137;
stream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_137, 1);
stream->write((uint64_t*)&cgen_var_137, 1 * 8);
uint64_t cgen_var_138;
stream->handleMapping()->mapHandles_VkImage_u64(&local_image, &cgen_var_138, 1);
stream->write((uint64_t*)&cgen_var_138, 1 * 8);
marshal_VkMemoryRequirements(stream, (VkMemoryRequirements*)(pMemoryRequirements));
AEMU_SCOPED_TRACE("vkGetImageMemoryRequirements readParams");
unmarshal_VkMemoryRequirements(stream, (VkMemoryRequirements*)(pMemoryRequirements));
if (pMemoryRequirements)
{
transform_fromhost_VkMemoryRequirements(mImpl->resources(), (VkMemoryRequirements*)(pMemoryRequirements));
}
AEMU_SCOPED_TRACE("vkGetImageMemoryRequirements returnUnmarshal");
mImpl->log("finish vkGetImageMemoryRequirements");;
}
void VkEncoder::vkGetImageSparseMemoryRequirements(
VkDevice device,
VkImage image,
uint32_t* pSparseMemoryRequirementCount,
VkSparseImageMemoryRequirements* pSparseMemoryRequirements)
{
AutoLock encoderLock(mImpl->lock);
AEMU_SCOPED_TRACE("vkGetImageSparseMemoryRequirements encode");
mImpl->log("start vkGetImageSparseMemoryRequirements");
auto stream = mImpl->stream();
auto countingStream = mImpl->countingStream();
auto resources = mImpl->resources();
auto pool = mImpl->pool();
stream->setHandleMapping(resources->unwrapMapping());
VkDevice local_device;
VkImage local_image;
local_device = device;
local_image = image;
countingStream->rewind();
{
uint64_t cgen_var_139;
countingStream->handleMapping()->mapHandles_VkDevice_u64(&local_device, &cgen_var_139, 1);
countingStream->write((uint64_t*)&cgen_var_139, 1 * 8);
uint64_t cgen_var_140;
countingStream->handleMapping()->mapHandles_VkImage_u64(&local_image, &cgen_var_140, 1);
countingStream->write((uint64_t*)&cgen_var_140, 1 * 8);
// WARNING PTR CHECK
uint64_t cgen_var_141 = (uint64_t)(uintptr_t)pSparseMemoryRequirementCount;
countingStream->putBe64(cgen_var_141);
if (pSparseMemoryRequirementCount)
{
countingStream->write((uint32_t*)pSparseMemoryRequirementCount, sizeof(uint32_t));
}
// WARNING PTR CHECK
uint64_t cgen_var_142 = (uint64_t)(uintptr_t)pSparseMemoryRequirements;
countingStream->putBe64(cgen_var_142);
if (pSparseMemoryRequirements)
{
for (uint32_t i = 0; i < (uint32_t)(*(