Commit 16636f48 by Trevor David Black Committed by Trevor Black

Added support for AndroidHardwareBuffer

Bug: b/141698760 Change-Id: I8d3895b2ee79a0ba71f20917ae1edc83dd19dab8 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/48508Reviewed-by: 's avatarTrevor Black <vantablack@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Result: Trevor Black <vantablack@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Presubmit-Ready: Trevor Black <vantablack@google.com> Tested-by: 's avatarTrevor Black <vantablack@google.com>
parent 375fee94
......@@ -56,6 +56,7 @@ cc_defaults {
shared_libs: [
"android.hardware.graphics.mapper@3.0",
"android.hardware.graphics.mapper@4.0",
"libdrm",
"libnativewindow",
"libhardware",
"libhidlbase",
......@@ -590,6 +591,7 @@ cc_defaults {
shared_libs: [
"android.hardware.graphics.mapper@3.0",
"android.hardware.graphics.mapper@4.0",
"libdrm",
"libnativewindow",
"libhardware",
"libhidlbase",
......@@ -661,7 +663,9 @@ cc_defaults {
include_dirs: [
"external/swiftshader/third_party/SPIRV-Headers/include",
"external/swiftshader/include"
"external/swiftshader/include",
"external/minigbm",
"external/libdrm"
],
}
......
......@@ -146,6 +146,10 @@ Device::Device(const VkDeviceCreateInfo *pCreateInfo, void *mem, PhysicalDevice
debugger.server = vk::dbg::Server::create(debugger.context, atoi(port));
}
#endif // ENABLE_VK_DEBUGGER
#if SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
ahbAddressMap.reset(new AHBAddressMap());
#endif
}
void Device::destroy(const VkAllocationCallbacks *pAllocator)
......@@ -375,4 +379,60 @@ void Device::contentsChanged(ImageView *imageView)
}
}
#if SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
Device::AHBAddressMap *Device::getAHBAddressMap() const
{
return ahbAddressMap.get();
}
void *Device::AHBAddressMap::query(const uint32_t key)
{
std::unique_lock<std::mutex> lock(addressMapMutex);
if(addressMap.find(key) == addressMap.end())
return nullptr;
return addressMap[key].address;
}
void Device::AHBAddressMap::add(const uint32_t key, void *value)
{
std::unique_lock<std::mutex> lock(addressMapMutex);
auto it = addressMap.find(key);
if(it == addressMap.end())
{
MapValue mv;
mv.refCount = 1;
mv.address = value;
addressMap[key] = mv;
}
else
{
it->second.address = value;
it->second.refCount++;
}
}
int Device::AHBAddressMap::incrementReference(const uint32_t key)
{
std::unique_lock<std::mutex> lock(addressMapMutex);
auto it = addressMap.find(key);
if(it == addressMap.end())
return -1;
it->second.refCount++;
return it->second.refCount;
}
int Device::AHBAddressMap::decrementReference(const uint32_t key)
{
std::unique_lock<std::mutex> lock(addressMapMutex);
auto it = addressMap.find(key);
if(it == addressMap.end())
return -1;
it->second.refCount--;
return it->second.refCount;
}
#endif // SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
} // namespace vk
......@@ -193,6 +193,41 @@ private:
std::shared_ptr<vk::dbg::Server> server;
} debugger;
#endif // ENABLE_VK_DEBUGGER
#if SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
public:
class AHBAddressMap
{
public:
AHBAddressMap() {}
~AHBAddressMap() {}
struct MapValue
{
MapValue()
: refCount(0)
, address(nullptr)
{
}
int refCount;
void *address;
};
void *query(const uint32_t key);
int incrementReference(const uint32_t key);
int decrementReference(const uint32_t key);
void add(const uint32_t key, void *value);
private:
std::map<uint32_t, MapValue> addressMap;
std::mutex addressMapMutex;
};
AHBAddressMap *getAHBAddressMap() const;
private:
std::unique_ptr<AHBAddressMap> ahbAddressMap;
#endif
};
using DispatchableDevice = DispatchableObject<Device, VkDevice>;
......
......@@ -14,54 +14,13 @@
#include "VkDeviceMemory.hpp"
#include "VkBuffer.hpp"
#include "VkDeviceMemoryExternalBase.hpp"
#include "VkImage.hpp"
#include "VkConfig.hpp"
namespace vk {
// Base abstract interface for a device memory implementation.
class DeviceMemory::ExternalBase
{
public:
virtual ~ExternalBase() = default;
// Allocate the memory according to |size|. On success return VK_SUCCESS
// and sets |*pBuffer|.
virtual VkResult allocate(size_t size, void **pBuffer) = 0;
// Deallocate previously allocated memory at |buffer|.
virtual void deallocate(void *buffer, size_t size) = 0;
// Return the handle type flag bit supported by this implementation.
// A value of 0 corresponds to non-external memory.
virtual VkExternalMemoryHandleTypeFlagBits getFlagBit() const = 0;
#if SWIFTSHADER_EXTERNAL_MEMORY_OPAQUE_FD
virtual VkResult exportFd(int *pFd) const
{
return VK_ERROR_INVALID_EXTERNAL_HANDLE;
}
#endif
#if SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
virtual VkResult exportAhb(struct AHardwareBuffer **pAhb) const
{
return VK_ERROR_INVALID_EXTERNAL_HANDLE;
}
#endif
#if VK_USE_PLATFORM_FUCHSIA
virtual VkResult exportHandle(zx_handle_t *pHandle) const
{
return VK_ERROR_INVALID_EXTERNAL_HANDLE;
}
#endif
protected:
ExternalBase() = default;
};
// Small class describing a given DeviceMemory::ExternalBase derived class.
// |typeFlagBit| corresponds to the external memory handle type.
// |instanceSize| is the size of each class instance in bytes.
......@@ -83,7 +42,7 @@ template<typename T>
static bool parseCreateInfo(const VkMemoryAllocateInfo *pAllocateInfo,
ExternalMemoryTraits *pTraits)
{
if(T::supportsAllocateInfo(pAllocateInfo))
if(T::SupportsAllocateInfo(pAllocateInfo))
{
pTraits->typeFlagBit = T::typeFlagBit;
pTraits->instanceSize = sizeof(T);
......@@ -105,7 +64,7 @@ public:
static const VkExternalMemoryHandleTypeFlagBits typeFlagBit = (VkExternalMemoryHandleTypeFlagBits)0;
// Always return true as is used as a fallback in findTraits() below.
static bool supportsAllocateInfo(const VkMemoryAllocateInfo *pAllocateInfo)
static bool SupportsAllocateInfo(const VkMemoryAllocateInfo *pAllocateInfo)
{
return true;
}
......@@ -177,7 +136,7 @@ public:
static const VkExternalMemoryHandleTypeFlagBits typeFlagBit = (VkExternalMemoryHandleTypeFlagBits)(VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT | VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_MAPPED_FOREIGN_MEMORY_BIT_EXT);
static bool supportsAllocateInfo(const VkMemoryAllocateInfo *pAllocateInfo)
static bool SupportsAllocateInfo(const VkMemoryAllocateInfo *pAllocateInfo)
{
AllocateInfo info(pAllocateInfo);
return info.supported;
......@@ -235,14 +194,14 @@ namespace vk {
static void findTraits(const VkMemoryAllocateInfo *pAllocateInfo,
ExternalMemoryTraits *pTraits)
{
#if SWIFTSHADER_EXTERNAL_MEMORY_OPAQUE_FD
if(parseCreateInfo<OpaqueFdExternalMemory>(pAllocateInfo, pTraits))
#if SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
if(parseCreateInfo<AHardwareBufferExternalMemory>(pAllocateInfo, pTraits))
{
return;
}
#endif
#if SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
if(parseCreateInfo<AHardwareBufferExternalMemory>(pAllocateInfo, pTraits))
#if SWIFTSHADER_EXTERNAL_MEMORY_OPAQUE_FD
if(parseCreateInfo<OpaqueFdExternalMemory>(pAllocateInfo, pTraits))
{
return;
}
......@@ -260,9 +219,10 @@ static void findTraits(const VkMemoryAllocateInfo *pAllocateInfo,
parseCreateInfo<DeviceMemoryHostExternalBase>(pAllocateInfo, pTraits);
}
DeviceMemory::DeviceMemory(const VkMemoryAllocateInfo *pAllocateInfo, void *mem)
DeviceMemory::DeviceMemory(const VkMemoryAllocateInfo *pAllocateInfo, void *mem, Device *pDevice)
: size(pAllocateInfo->allocationSize)
, memoryTypeIndex(pAllocateInfo->memoryTypeIndex)
, device(pDevice)
{
ASSERT(size);
......@@ -270,6 +230,7 @@ DeviceMemory::DeviceMemory(const VkMemoryAllocateInfo *pAllocateInfo, void *mem)
findTraits(pAllocateInfo, &traits);
traits.instanceInit(mem, pAllocateInfo);
external = reinterpret_cast<ExternalBase *>(mem);
external->setDevicePtr(device);
}
void DeviceMemory::destroy(const VkAllocationCallbacks *pAllocator)
......@@ -320,7 +281,6 @@ VkDeviceSize DeviceMemory::getCommittedMemoryInBytes() const
void *DeviceMemory::getOffsetPointer(VkDeviceSize pOffset) const
{
ASSERT(buffer);
return reinterpret_cast<char *>(buffer) + pOffset;
}
......@@ -354,14 +314,14 @@ VkResult DeviceMemory::exportFd(int *pFd) const
#endif
#if SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
VkResult DeviceMemory::exportAhb(struct AHardwareBuffer **pAhb) const
VkResult DeviceMemory::exportAndroidHardwareBuffer(struct AHardwareBuffer **pAhb) const
{
return external->exportAhb(pAhb);
return external->exportAndroidHardwareBuffer(pAhb);
}
VkResult DeviceMemory::getAhbProperties(const struct AHardwareBuffer *buffer, VkAndroidHardwareBufferPropertiesANDROID *pProperties)
VkResult DeviceMemory::GetAndroidHardwareBufferProperties(VkDevice &ahbDevice, const struct AHardwareBuffer *buffer, VkAndroidHardwareBufferPropertiesANDROID *pProperties)
{
return AHardwareBufferExternalMemory::getAhbProperties(buffer, pProperties);
return AHardwareBufferExternalMemory::GetAndroidHardwareBufferProperties(ahbDevice, buffer, pProperties);
}
#endif
......
......@@ -20,10 +20,12 @@
namespace vk {
class Device;
class DeviceMemory : public Object<DeviceMemory, VkDeviceMemory>
{
public:
DeviceMemory(const VkMemoryAllocateInfo *pCreateInfo, void *mem);
DeviceMemory(const VkMemoryAllocateInfo *pCreateInfo, void *mem, Device *pDevice);
static size_t ComputeRequiredAllocationSize(const VkMemoryAllocateInfo *pCreateInfo);
......@@ -32,8 +34,8 @@ public:
#endif
#if SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
VkResult exportAhb(struct AHardwareBuffer **pAhb) const;
static VkResult getAhbProperties(const struct AHardwareBuffer *buffer, VkAndroidHardwareBufferPropertiesANDROID *pProperties);
VkResult exportAndroidHardwareBuffer(struct AHardwareBuffer **pAhb) const;
static VkResult GetAndroidHardwareBufferProperties(VkDevice &device, const struct AHardwareBuffer *buffer, VkAndroidHardwareBufferPropertiesANDROID *pProperties);
#endif
#if VK_USE_PLATFORM_FUCHSIA
......@@ -60,6 +62,7 @@ private:
VkDeviceSize size = 0;
uint32_t memoryTypeIndex = 0;
ExternalBase *external = nullptr;
Device *device;
};
static inline DeviceMemory *Cast(VkDeviceMemory object)
......
......@@ -12,14 +12,33 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "VkStringify.hpp"
#ifndef VK_DEVICE_MEMORY_EXTERNAL_ANDROID_HPP_
#define VK_DEVICE_MEMORY_EXTERNAL_ANDROID_HPP_
#include "System/Debug.hpp"
#if SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
#include <android/hardware_buffer.h>
# include "VkDevice.hpp"
# include "VkDeviceMemory.hpp"
# include "VkDeviceMemoryExternalBase.hpp"
#include <errno.h>
#include <string.h>
# include "VkBuffer.hpp"
# include "VkDeviceMemory.hpp"
# include "VkImage.hpp"
# include "VkStringify.hpp"
# include "System/Debug.hpp"
# include "System/Linux/MemFd.hpp"
# include <android/hardware_buffer.h>
# include <cros_gralloc/cros_gralloc_handle.h>
# include <unistd.h>
# include <virtgpu_drm.h>
# include <xf86drm.h>
# include <errno.h>
# include <string.h>
# include <map>
class AHardwareBufferExternalMemory : public vk::DeviceMemory::ExternalBase
{
......@@ -38,52 +57,12 @@ public:
AllocateInfo() = default;
// Parse the VkMemoryAllocateInfo.pNext chain to initialize an AllocateInfo.
AllocateInfo(const VkMemoryAllocateInfo *pAllocateInfo)
{
const auto *createInfo = reinterpret_cast<const VkBaseInStructure *>(pAllocateInfo->pNext);
while(createInfo)
{
switch(createInfo->sType)
{
case VK_STRUCTURE_TYPE_IMPORT_ANDROID_HARDWARE_BUFFER_INFO_ANDROID:
{
const auto *importInfo = reinterpret_cast<const VkImportAndroidHardwareBufferInfoANDROID *>(createInfo);
importAhb = true;
ahb = importInfo->buffer;
}
break;
case VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO:
{
const auto *exportInfo = reinterpret_cast<const VkExportMemoryAllocateInfo *>(createInfo);
if(exportInfo->handleTypes != VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID)
{
UNSUPPORTED("VkExportMemoryAllocateInfo::handleTypes %d", int(exportInfo->handleTypes));
}
exportAhb = true;
}
break;
case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO:
{
// AHB requires dedicated allocation -- for images, the gralloc gets to decide the image layout,
// not us.
const auto *dedicatedAllocateInfo = reinterpret_cast<const VkMemoryDedicatedAllocateInfo *>(createInfo);
imageHandle = vk::Cast(dedicatedAllocateInfo->image);
bufferHandle = vk::Cast(dedicatedAllocateInfo->buffer);
}
break;
default:
WARN("VkMemoryAllocateInfo->pNext sType = %s", vk::Stringify(createInfo->sType).c_str());
}
createInfo = createInfo->pNext;
}
}
AllocateInfo(const VkMemoryAllocateInfo *pAllocateInfo);
};
static const VkExternalMemoryHandleTypeFlagBits typeFlagBit = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
static bool supportsAllocateInfo(const VkMemoryAllocateInfo *pAllocateInfo)
static bool SupportsAllocateInfo(const VkMemoryAllocateInfo *pAllocateInfo)
{
AllocateInfo info(pAllocateInfo);
return (info.importAhb || info.exportAhb) && (info.bufferHandle || info.imageHandle);
......@@ -94,67 +73,47 @@ public:
{
}
~AHardwareBufferExternalMemory()
{
if(ahb)
AHardwareBuffer_release(ahb);
}
VkResult allocate(size_t size, void **pBuffer) override
{
if(allocateInfo.importAhb)
{
//ahb = allocateInfo.ahb;
//AHardwareBuffer_acquire(ahb);
// TODO: also allocate our internal shadow memory
return VK_ERROR_INVALID_EXTERNAL_HANDLE;
}
else
{
ASSERT(allocateInfo.exportAhb);
// TODO: create and import the AHB
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
}
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
/*
void *addr = memfd.mapReadWrite(0, size);
if(!addr)
{
return VK_ERROR_MEMORY_MAP_FAILED;
}
*pBuffer = addr;
return VK_SUCCESS;
*/
}
void deallocate(void *buffer, size_t size) override
{
// FIXME
}
~AHardwareBufferExternalMemory();
VkResult allocate(size_t size, void **pBuffer) override;
void deallocate(void *buffer, size_t size) override;
VkResult allocateAndroidHardwareBuffer(size_t size, void **pBuffer);
VkExternalMemoryHandleTypeFlagBits getFlagBit() const override
{
return typeFlagBit;
}
VkResult exportAhb(struct AHardwareBuffer **pAhb) const override
VkResult exportAndroidHardwareBuffer(struct AHardwareBuffer **pAhb) const override;
void setDevicePtr(vk::Device *pDevice) override
{
// Each call to vkGetMemoryAndroidHardwareBufferANDROID *must* return an Android hardware buffer with a new reference
// acquired in addition to the reference held by the VkDeviceMemory. To avoid leaking resources, the application *must*
// release the reference by calling AHardwareBuffer_release when it is no longer needed.
AHardwareBuffer_acquire(ahb);
*pAhb = ahb;
return VK_SUCCESS;
device = pDevice;
}
static VkResult getAhbProperties(const struct AHardwareBuffer *buffer, VkAndroidHardwareBufferPropertiesANDROID *pProperties)
bool isAndroidHardwareBuffer() override
{
UNIMPLEMENTED("b/141698760: getAhbProperties"); // FIXME(b/141698760)
return VK_SUCCESS;
return true;
}
static uint32_t GetAndroidHardwareBufferDescFormat(VkFormat format);
static VkFormat GetVkFormat(uint32_t ahbFormat);
static VkFormatFeatureFlags GetVkFormatFeatures(VkFormat format);
static VkResult GetAndroidHardwareBufferFormatProperties(const AHardwareBuffer_Desc &ahbDesc, VkAndroidHardwareBufferFormatPropertiesANDROID *pFormat);
static VkResult GetAndroidHardwareBufferProperties(VkDevice &device, const struct AHardwareBuffer *buffer, VkAndroidHardwareBufferPropertiesANDROID *pProperties);
static VkResult GetAndroidHardwareBufferUsageFromVkUsage(const VkImageCreateFlags createFlags, const VkImageUsageFlags usageFlags, uint64_t &ahbDescUsage);
// All reliance on minigbm and DRM is contained in these functions
VkResult getPrimeHandle(const native_handle_t *h, uint32_t &primeHandle);
void createRenderNodeFD();
VkResult mapMemory(uint32_t &primeHandle, void **ptr);
VkResult closeMemory(uint32_t &primeHandle);
private:
struct AHardwareBuffer *ahb = nullptr;
int rendernodeFD;
vk::Device *device = nullptr;
AllocateInfo allocateInfo;
};
#endif // SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
#endif // VK_DEVICE_MEMORY_EXTERNAL_ANDROID_HPP_
// Copyright 2020 The SwiftShader Authors. All Rights Reserved.
//
// 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.
#ifndef VK_DEVICE_MEMORY_EXTERNAL_BASE_HPP_
#define VK_DEVICE_MEMORY_EXTERNAL_BASE_HPP_
#include "VkDeviceMemory.hpp"
namespace vk {
// Base abstract interface for a device memory implementation.
class DeviceMemory::ExternalBase
{
public:
virtual ~ExternalBase() = default;
// Allocate the memory according to |size|. On success return VK_SUCCESS
// and sets |*pBuffer|.
virtual VkResult allocate(size_t size, void **pBuffer) = 0;
// Deallocate previously allocated memory at |buffer|.
virtual void deallocate(void *buffer, size_t size) = 0;
// Return the handle type flag bit supported by this implementation.
// A value of 0 corresponds to non-external memory.
virtual VkExternalMemoryHandleTypeFlagBits getFlagBit() const = 0;
virtual void setDevicePtr(Device *pDevice) {}
#if SWIFTSHADER_EXTERNAL_MEMORY_OPAQUE_FD
virtual VkResult exportFd(int *pFd) const
{
return VK_ERROR_INVALID_EXTERNAL_HANDLE;
}
#endif
#if SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
virtual VkResult exportAndroidHardwareBuffer(struct AHardwareBuffer **pAhb) const
{
return VK_ERROR_INVALID_EXTERNAL_HANDLE;
}
virtual bool isAndroidHardwareBuffer()
{
return false;
}
#endif
protected:
ExternalBase() = default;
};
} // namespace vk
#endif // VK_DEVICE_MEMORY_EXTERNAL_BASE_HPP_
......@@ -82,7 +82,7 @@ public:
static const VkExternalMemoryHandleTypeFlagBits typeFlagBit = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT;
static bool supportsAllocateInfo(const VkMemoryAllocateInfo *pAllocateInfo)
static bool SupportsAllocateInfo(const VkMemoryAllocateInfo *pAllocateInfo)
{
AllocateInfo info(pAllocateInfo);
return info.importFd || info.exportFd;
......
......@@ -81,6 +81,7 @@ public:
uint32_t getArrayLayers() const { return arrayLayers; }
uint32_t getMipLevels() const { return mipLevels; }
VkImageUsageFlags getUsage() const { return usage; }
VkImageCreateFlags getFlags() const { return flags; }
VkSampleCountFlagBits getSampleCountFlagBits() const { return samples; }
const VkExtent3D &getExtent() const { return extent; }
VkExtent3D getMipLevelExtent(VkImageAspectFlagBits aspect, uint32_t mipLevel) const;
......@@ -110,8 +111,11 @@ public:
}
bool hasExternalMemory() const { return backingMemory.externalMemory; }
VkDeviceMemory getExternalMemory() const;
VkExternalMemoryHandleTypeFlags getSupportedExternalMemoryHandleTypes() const { return supportedExternalMemoryHandleTypes; }
#endif
DeviceMemory *deviceMemory = nullptr;
private:
void copy(Buffer *buffer, const VkBufferImageCopy &region, bool bufferIsSource);
VkDeviceSize getStorageSize(VkImageAspectFlags flags) const;
......@@ -135,7 +139,6 @@ private:
void decodeASTC(const VkImageSubresource &subresource);
const Device *const device = nullptr;
DeviceMemory *deviceMemory = nullptr;
VkDeviceSize memoryOffset = 0;
VkImageCreateFlags flags = 0;
VkImageType imageType = VK_IMAGE_TYPE_2D;
......
......@@ -22,41 +22,21 @@
#include <cstring>
#include <limits>
#ifdef __ANDROID__
# include <android/hardware_buffer.h>
#endif
namespace vk {
static void setExternalMemoryProperties(VkExternalMemoryHandleTypeFlagBits handleType, VkExternalMemoryProperties *properties)
{
#if SWIFTSHADER_EXTERNAL_MEMORY_OPAQUE_FD
if(handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT)
{
properties->compatibleHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT;
properties->exportFromImportedHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT;
properties->externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT | VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT;
return;
}
#endif
#if SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
if(handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID)
{
properties->compatibleHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
properties->exportFromImportedHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
properties->externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT | VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT;
return;
}
#endif
#if VK_USE_PLATFORM_FUCHSIA
if(handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_TEMP_ZIRCON_VMO_BIT_FUCHSIA)
{
properties->compatibleHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_TEMP_ZIRCON_VMO_BIT_FUCHSIA;
properties->exportFromImportedHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_TEMP_ZIRCON_VMO_BIT_FUCHSIA;
properties->externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT | VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT;
return;
}
#endif
properties->compatibleHandleTypes = 0;
properties->exportFromImportedHandleTypes = 0;
properties->externalMemoryFeatures = 0;
if(handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_TEMP_ZIRCON_VMO_BIT_FUCHSIA)
{
properties->compatibleHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_TEMP_ZIRCON_VMO_BIT_FUCHSIA;
properties->exportFromImportedHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_TEMP_ZIRCON_VMO_BIT_FUCHSIA;
properties->externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT | VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT;
return;
}
#endif
PhysicalDevice::PhysicalDevice(const void *, void *mem)
{
......@@ -537,7 +517,72 @@ void PhysicalDevice::getProperties(VkPhysicalDeviceSubgroupProperties *propertie
void PhysicalDevice::getProperties(const VkExternalMemoryHandleTypeFlagBits *handleType, VkExternalImageFormatProperties *properties) const
{
setExternalMemoryProperties(*handleType, &properties->externalMemoryProperties);
VkExternalMemoryProperties *extMemProperties = &properties->externalMemoryProperties;
#if SWIFTSHADER_EXTERNAL_MEMORY_OPAQUE_FD
if(*handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT)
{
extMemProperties->compatibleHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT;
extMemProperties->exportFromImportedHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT;
extMemProperties->externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT | VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT;
return;
}
#endif
#if SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
if(*handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID)
{
extMemProperties->compatibleHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
extMemProperties->exportFromImportedHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
extMemProperties->externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT | VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT | VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT;
return;
}
#endif
#if VK_USE_PLATFORM_FUCHSIA
if(handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_TEMP_ZIRCON_VMO_BIT_FUCHSIA)
{
properties->compatibleHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_TEMP_ZIRCON_VMO_BIT_FUCHSIA;
properties->exportFromImportedHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_TEMP_ZIRCON_VMO_BIT_FUCHSIA;
properties->externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT | VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT;
return;
}
#endif
extMemProperties->compatibleHandleTypes = 0;
extMemProperties->exportFromImportedHandleTypes = 0;
extMemProperties->externalMemoryFeatures = 0;
}
void PhysicalDevice::getProperties(const VkExternalMemoryHandleTypeFlagBits *handleType, VkExternalBufferProperties *properties) const
{
VkExternalMemoryProperties *extMemProperties = &properties->externalMemoryProperties;
#if SWIFTSHADER_EXTERNAL_MEMORY_OPAQUE_FD
if(*handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT)
{
extMemProperties->compatibleHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT;
extMemProperties->exportFromImportedHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT;
extMemProperties->externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT | VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT;
return;
}
#endif
#if SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
if(*handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID)
{
extMemProperties->compatibleHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
extMemProperties->exportFromImportedHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
extMemProperties->externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT | VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT;
return;
}
#endif
#if VK_USE_PLATFORM_FUCHSIA
if(handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_TEMP_ZIRCON_VMO_BIT_FUCHSIA)
{
properties->compatibleHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_TEMP_ZIRCON_VMO_BIT_FUCHSIA;
properties->exportFromImportedHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_TEMP_ZIRCON_VMO_BIT_FUCHSIA;
properties->externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT | VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT;
return;
}
#endif
extMemProperties->compatibleHandleTypes = 0;
extMemProperties->exportFromImportedHandleTypes = 0;
extMemProperties->externalMemoryFeatures = 0;
}
void PhysicalDevice::getProperties(VkSamplerYcbcrConversionImageFormatProperties *properties) const
......@@ -550,11 +595,46 @@ void PhysicalDevice::getProperties(VkPhysicalDevicePresentationPropertiesANDROID
{
properties->sharedImage = VK_FALSE;
}
void PhysicalDevice::getProperties(VkAndroidHardwareBufferUsageANDROID *properties) const
{
// TODO(b/169439421)
// This AHB could be either a framebuffer, OR a sampled image
// Here we just say it's both
// Need to pass down info on the type of image in question
properties->androidHardwareBufferUsage |= AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE | AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT;
}
#endif
void PhysicalDevice::getProperties(const VkPhysicalDeviceExternalBufferInfo *pExternalBufferInfo, VkExternalBufferProperties *pExternalBufferProperties) const
{
setExternalMemoryProperties(pExternalBufferInfo->handleType, &pExternalBufferProperties->externalMemoryProperties);
VkExternalMemoryProperties *properties = &pExternalBufferProperties->externalMemoryProperties;
#if SWIFTSHADER_EXTERNAL_MEMORY_OPAQUE_FD || SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
const VkExternalMemoryHandleTypeFlagBits *handleType = &pExternalBufferInfo->handleType;
#endif
#if SWIFTSHADER_EXTERNAL_MEMORY_OPAQUE_FD
if(*handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT)
{
properties->compatibleHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT;
properties->exportFromImportedHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT;
properties->externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT | VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT;
return;
}
#endif
#if SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
if(*handleType == VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID)
{
properties->compatibleHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
properties->exportFromImportedHandleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
properties->externalMemoryFeatures = VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT | VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT;
return;
}
#endif
properties->compatibleHandleTypes = 0;
properties->exportFromImportedHandleTypes = 0;
properties->externalMemoryFeatures = 0;
}
void PhysicalDevice::getProperties(const VkPhysicalDeviceExternalFenceInfo *pExternalFenceInfo, VkExternalFenceProperties *pExternalFenceProperties) const
......@@ -630,7 +710,7 @@ bool PhysicalDevice::hasFeatures(const VkPhysicalDeviceFeatures &requestedFeatur
return true;
}
void PhysicalDevice::getFormatProperties(Format format, VkFormatProperties *pFormatProperties) const
void PhysicalDevice::GetFormatProperties(Format format, VkFormatProperties *pFormatProperties)
{
pFormatProperties->linearTilingFeatures = 0; // Unsupported format
pFormatProperties->optimalTilingFeatures = 0; // Unsupported format
......@@ -1047,7 +1127,7 @@ void PhysicalDevice::getImageFormatProperties(Format format, VkImageType type, V
pImageFormatProperties->maxExtent.height = 1 << (vk::MAX_IMAGE_LEVELS_2D - 1);
VkFormatProperties props;
getFormatProperties(format, &props);
GetFormatProperties(format, &props);
auto features = tiling == VK_IMAGE_TILING_LINEAR ? props.linearTilingFeatures : props.optimalTilingFeatures;
if(features & (VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))
{
......@@ -1122,7 +1202,7 @@ void PhysicalDevice::getQueueFamilyProperties(uint32_t pQueueFamilyPropertyCount
}
}
const VkPhysicalDeviceMemoryProperties &PhysicalDevice::getMemoryProperties() const
const VkPhysicalDeviceMemoryProperties &PhysicalDevice::GetMemoryProperties()
{
static const VkPhysicalDeviceMemoryProperties properties{
1, // memoryTypeCount
......
......@@ -46,9 +46,11 @@ public:
void getProperties(VkPhysicalDeviceProtectedMemoryProperties *properties) const;
void getProperties(VkPhysicalDeviceSubgroupProperties *properties) const;
void getProperties(const VkExternalMemoryHandleTypeFlagBits *handleType, VkExternalImageFormatProperties *properties) const;
void getProperties(const VkExternalMemoryHandleTypeFlagBits *handleType, VkExternalBufferProperties *properties) const;
void getProperties(VkSamplerYcbcrConversionImageFormatProperties *properties) const;
#ifdef __ANDROID__
void getProperties(VkPhysicalDevicePresentationPropertiesANDROID *properties) const;
void getProperties(VkAndroidHardwareBufferUsageANDROID *properties) const;
#endif
void getProperties(const VkPhysicalDeviceExternalBufferInfo *pExternalBufferInfo, VkExternalBufferProperties *pExternalBufferProperties) const;
void getProperties(const VkPhysicalDeviceExternalFenceInfo *pExternalFenceInfo, VkExternalFenceProperties *pExternalFenceProperties) const;
......@@ -58,7 +60,7 @@ public:
void getProperties(VkPhysicalDeviceLineRasterizationPropertiesEXT *properties) const;
void getProperties(VkPhysicalDeviceProvokingVertexPropertiesEXT *properties) const;
void getFormatProperties(Format format, VkFormatProperties *pFormatProperties) const;
static void GetFormatProperties(Format format, VkFormatProperties *pFormatProperties);
void getImageFormatProperties(Format format, VkImageType type, VkImageTiling tiling,
VkImageUsageFlags usage, VkImageCreateFlags flags,
VkImageFormatProperties *pImageFormatProperties) const;
......@@ -67,7 +69,7 @@ public:
VkQueueFamilyProperties *pQueueFamilyProperties) const;
void getQueueFamilyProperties(uint32_t pQueueFamilyPropertyCount,
VkQueueFamilyProperties2 *pQueueFamilyProperties) const;
const VkPhysicalDeviceMemoryProperties &getMemoryProperties() const;
static const VkPhysicalDeviceMemoryProperties &GetMemoryProperties();
private:
const VkPhysicalDeviceLimits &getLimits() const;
......
......@@ -75,6 +75,9 @@
# include <android/log.h>
# include <hardware/gralloc1.h>
# include <sync/sync.h>
# ifdef SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
# include "VkDeviceMemoryExternalAndroid.hpp"
# endif
#endif
#include "WSI/VkSwapchainKHR.hpp"
......@@ -518,7 +521,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties(VkPhysicalDevice
TRACE("GetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice = %p, VkFormat format = %d, VkFormatProperties* pFormatProperties = %p)",
physicalDevice, (int)format, pFormatProperties);
vk::Cast(physicalDevice)->getFormatProperties(format, pFormatProperties);
vk::PhysicalDevice::GetFormatProperties(format, pFormatProperties);
}
VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties)
......@@ -531,7 +534,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties(VkPhysic
memset(pImageFormatProperties, 0, sizeof(VkImageFormatProperties));
VkFormatProperties properties;
vk::Cast(physicalDevice)->getFormatProperties(format, &properties);
vk::PhysicalDevice::GetFormatProperties(format, &properties);
VkFormatFeatureFlags features;
switch(tiling)
......@@ -656,7 +659,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties(VkPhysicalDevice
{
TRACE("(VkPhysicalDevice physicalDevice = %p, VkPhysicalDeviceMemoryProperties* pMemoryProperties = %p)", physicalDevice, pMemoryProperties);
*pMemoryProperties = vk::Cast(physicalDevice)->getMemoryProperties();
*pMemoryProperties = vk::PhysicalDevice::GetMemoryProperties();
}
VK_EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *pName)
......@@ -1085,7 +1088,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkAllocateMemory(VkDevice device, const VkMemoryA
allocationInfo = allocationInfo->pNext;
}
VkResult result = vk::DeviceMemory::Create(pAllocator, pAllocateInfo, pMemory);
VkResult result = vk::DeviceMemory::Create(pAllocator, pAllocateInfo, pMemory, vk::Cast(device));
if(result != VK_SUCCESS)
{
return result;
......@@ -1141,7 +1144,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryFdPropertiesKHR(VkDevice device, VkExt
}
const VkPhysicalDeviceMemoryProperties &memoryProperties =
vk::Cast(device)->getPhysicalDevice()->getMemoryProperties();
vk::PhysicalDevice::GetMemoryProperties();
// All SwiftShader memory types support this!
pMemoryFdProperties->memoryTypeBits = (1U << memoryProperties.memoryTypeCount) - 1U;
......@@ -1180,7 +1183,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryZirconHandlePropertiesFUCHSIA(VkDevice
}
const VkPhysicalDeviceMemoryProperties &memoryProperties =
vk::Cast(device)->getPhysicalDevice()->getMemoryProperties();
vk::PhysicalDevice::GetMemoryProperties();
// All SwiftShader memory types support this!
pMemoryZirconHandleProperties->memoryTypeBits = (1U << memoryProperties.memoryTypeCount) - 1U;
......@@ -1210,7 +1213,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryAndroidHardwareBufferANDROID(VkDevice
TRACE("(VkDevice device = %p, const VkMemoryGetAndroidHardwareBufferInfoANDROID *pInfo = %p, struct AHardwareBuffer **pBuffer = %p)",
device, pInfo, pBuffer);
return vk::Cast(pInfo->memory)->exportAhb(pBuffer);
return vk::Cast(pInfo->memory)->exportAndroidHardwareBuffer(pBuffer);
}
VKAPI_ATTR VkResult VKAPI_CALL vkGetAndroidHardwareBufferPropertiesANDROID(VkDevice device, const struct AHardwareBuffer *buffer, VkAndroidHardwareBufferPropertiesANDROID *pProperties)
......@@ -1218,7 +1221,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetAndroidHardwareBufferPropertiesANDROID(VkDev
TRACE("(VkDevice device = %p, const struct AHardwareBuffer *buffer = %p, VkAndroidHardwareBufferPropertiesANDROID *pProperties = %p)",
device, buffer, pProperties);
return vk::DeviceMemory::getAhbProperties(buffer, pProperties);
return vk::DeviceMemory::GetAndroidHardwareBufferProperties(device, buffer, pProperties);
}
#endif // SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
......@@ -1271,7 +1274,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetDeviceMemoryCommitment(VkDevice pDevice, VkDevic
auto memory = vk::Cast(pMemory);
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
const auto &memoryProperties = vk::Cast(pDevice)->getPhysicalDevice()->getMemoryProperties();
const auto &memoryProperties = vk::PhysicalDevice::GetMemoryProperties();
uint32_t typeIndex = memory->getMemoryTypeIndex();
ASSERT(typeIndex < memoryProperties.memoryTypeCount);
ASSERT(memoryProperties.memoryTypes[typeIndex].propertyFlags & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT);
......@@ -1669,6 +1672,8 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateImage(VkDevice device, const VkImageCreat
swapchainImage = true;
}
break;
case VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_USAGE_ANDROID:
break;
#endif
case VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO:
// Do nothing. Should be handled by vk::Image::Create()
......@@ -2862,6 +2867,12 @@ VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements2(VkDevice device, const
{
auto requirements = reinterpret_cast<VkMemoryDedicatedRequirements *>(extensionRequirements);
vk::Cast(device)->getRequirements(requirements);
#if SWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER
if(vk::Cast(pInfo->image)->getSupportedExternalMemoryHandleTypes() == VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID)
{
requirements->requiresDedicatedAllocation = VK_TRUE;
}
#endif
}
break;
default:
......@@ -3120,6 +3131,14 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties2(VkPhysi
ASSERT(!hasDeviceExtension(VK_AMD_TEXTURE_GATHER_BIAS_LOD_EXTENSION_NAME));
}
break;
#ifdef __ANDROID__
case VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_USAGE_ANDROID:
{
auto properties = reinterpret_cast<VkAndroidHardwareBufferUsageANDROID *>(extensionProperties);
vk::Cast(physicalDevice)->getProperties(properties);
}
break;
#endif
default:
LOG_TRAP("pImageFormatProperties->pNext sType = %s", vk::Stringify(extensionProperties->sType).c_str());
break;
......
......@@ -73,7 +73,7 @@ public:
protected:
uint32_t getMemoryTypeIndex(uint32_t typeBits, vk::MemoryPropertyFlags properties)
{
vk::PhysicalDeviceMemoryProperties deviceMemoryProperties = physicalDevice.getMemoryProperties();
vk::PhysicalDeviceMemoryProperties deviceMemoryProperties = vk::PhysicalDevice::GetMemoryProperties();
for(uint32_t i = 0; i < deviceMemoryProperties.memoryTypeCount; i++)
{
if((typeBits & 1) == 1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment