mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 13:20:14 +01:00
gfxstream: Remove internal vk_util.h and vk_struct_id.h entirely
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Reviewed-by: Aaron Ruby <None> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33006>
This commit is contained in:
parent
e9663276f4
commit
e862bb52bd
7 changed files with 104 additions and 455 deletions
|
|
@ -138,7 +138,7 @@ SNAPSHOT_HANDLE_DEPENDENCIES = [
|
|||
handleDependenciesDict = dict(SNAPSHOT_HANDLE_DEPENDENCIES)
|
||||
|
||||
def extract_deps_vkAllocateMemory(param, access, lenExpr, api, cgen):
|
||||
cgen.stmt("const VkMemoryDedicatedAllocateInfo* dedicatedAllocateInfo = vk_find_struct<VkMemoryDedicatedAllocateInfo>(pAllocateInfo)");
|
||||
cgen.stmt("const VkMemoryDedicatedAllocateInfo* dedicatedAllocateInfo = vk_find_struct_const(pAllocateInfo, MEMORY_DEDICATED_ALLOCATE_INFO)");
|
||||
cgen.beginIf("dedicatedAllocateInfo");
|
||||
cgen.beginIf("dedicatedAllocateInfo->image")
|
||||
cgen.stmt("mReconstruction.addHandleDependency((const uint64_t*)%s, %s, (uint64_t)(uintptr_t)%s)" % \
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ class DeepcopyCodegen(VulkanTypeIterator):
|
|||
self.cgen.stmt("const void* %s = %s" % (nextVar, self.inputVars[0]))
|
||||
self.cgen.stmt("size_t %s = 0u" % sizeVar)
|
||||
self.cgen.beginWhile("!%s && %s" % (sizeVar, nextVar))
|
||||
self.cgen.stmt("%s = static_cast<const vk_struct_common*>(%s)->%s" % (
|
||||
self.cgen.stmt("%s = static_cast<const VkBaseOutStructure*>(%s)->%s" % (
|
||||
nextVar, nextVar, vulkanType.paramName
|
||||
))
|
||||
self.cgen.stmt("%s = %s(%s, %s)" % (
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../vulkan_enc/vk_util.h"
|
||||
#include "GfxStreamConnectionManager.h"
|
||||
#include "GfxStreamRenderControl.h"
|
||||
#include "GfxStreamVulkanConnection.h"
|
||||
|
|
@ -14,12 +13,10 @@
|
|||
#include "VkEncoder.h"
|
||||
#include "gfxstream_vk_entrypoints.h"
|
||||
#include "gfxstream_vk_private.h"
|
||||
#include "util/perf/cpu_trace.h"
|
||||
#include "vk_alloc.h"
|
||||
#include "vk_device.h"
|
||||
#include "vk_instance.h"
|
||||
#include "vk_sync_dummy.h"
|
||||
#include "util/detect_os.h"
|
||||
#include "util/perf/cpu_trace.h"
|
||||
#include "vk_sync_dummy.h"
|
||||
#include "vk_util.h"
|
||||
|
||||
uint32_t gSeqno = 0;
|
||||
uint32_t gNoRenderControlEnc = 0;
|
||||
|
|
@ -448,7 +445,8 @@ VkResult gfxstream_vk_CreateDevice(VkPhysicalDevice physicalDevice,
|
|||
* reaches it.
|
||||
*/
|
||||
VkPhysicalDeviceSwapchainMaintenance1FeaturesEXT* swapchainMaintenance1Features =
|
||||
(VkPhysicalDeviceSwapchainMaintenance1FeaturesEXT*)vk_find_struct<VkPhysicalDeviceSwapchainMaintenance1FeaturesEXT>(pCreateInfo);
|
||||
vk_find_struct(const_cast<VkDeviceCreateInfo*>(pCreateInfo),
|
||||
PHYSICAL_DEVICE_SWAPCHAIN_MAINTENANCE_1_FEATURES_EXT);
|
||||
if (swapchainMaintenance1Features) {
|
||||
swapchainMaintenance1Features->swapchainMaintenance1 = VK_FALSE;
|
||||
}
|
||||
|
|
@ -470,9 +468,8 @@ VkResult gfxstream_vk_CreateDevice(VkPhysicalDevice physicalDevice,
|
|||
|
||||
/* pNext = VkPhysicalDeviceGroupProperties */
|
||||
std::vector<VkPhysicalDevice> initialPhysicalDeviceList;
|
||||
VkPhysicalDeviceGroupProperties* mutablePhysicalDeviceGroupProperties =
|
||||
(VkPhysicalDeviceGroupProperties*)vk_find_struct<VkPhysicalDeviceGroupProperties>(
|
||||
pCreateInfo);
|
||||
VkPhysicalDeviceGroupProperties* mutablePhysicalDeviceGroupProperties = vk_find_struct(
|
||||
const_cast<VkDeviceCreateInfo*>(pCreateInfo), PHYSICAL_DEVICE_GROUP_PROPERTIES);
|
||||
if (mutablePhysicalDeviceGroupProperties) {
|
||||
// Temporarily modify the VkPhysicalDeviceGroupProperties structure to use translated
|
||||
// VkPhysicalDevice references for the encoder call
|
||||
|
|
@ -640,9 +637,8 @@ VkResult gfxstream_vk_AllocateMemory(VkDevice device, const VkMemoryAllocateInfo
|
|||
VK_FROM_HANDLE(gfxstream_vk_device, gfxstream_device, device);
|
||||
VkResult vkAllocateMemory_VkResult_return = (VkResult)0;
|
||||
/* VkMemoryDedicatedAllocateInfo */
|
||||
VkMemoryDedicatedAllocateInfo* dedicatedAllocInfoPtr =
|
||||
(VkMemoryDedicatedAllocateInfo*)vk_find_struct<VkMemoryDedicatedAllocateInfo>(
|
||||
pAllocateInfo);
|
||||
VkMemoryDedicatedAllocateInfo* dedicatedAllocInfoPtr = vk_find_struct(
|
||||
const_cast<VkMemoryAllocateInfo*>(pAllocateInfo), MEMORY_DEDICATED_ALLOCATE_INFO);
|
||||
if (dedicatedAllocInfoPtr) {
|
||||
if (dedicatedAllocInfoPtr->buffer) {
|
||||
VK_FROM_HANDLE(gfxstream_vk_buffer, gfxstream_buffer, dedicatedAllocInfoPtr->buffer);
|
||||
|
|
@ -693,6 +689,18 @@ VkResult gfxstream_vk_EnumerateInstanceVersion(uint32_t* pApiVersion) {
|
|||
return vkEnumerateInstanceVersion_VkResult_return;
|
||||
}
|
||||
|
||||
static bool vk_descriptor_type_has_descriptor_buffer(VkDescriptorType type) {
|
||||
switch (type) {
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static std::vector<VkWriteDescriptorSet> transformDescriptorSetList(
|
||||
const VkWriteDescriptorSet* pDescriptorSets, uint32_t descriptorSetCount,
|
||||
std::vector<std::vector<VkDescriptorBufferInfo>>& bufferInfos) {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ VkResult getAndroidHardwareBufferPropertiesANDROID(
|
|||
gfxstream::Gralloc* grallocHelper, const AHardwareBuffer* buffer,
|
||||
VkAndroidHardwareBufferPropertiesANDROID* pProperties) {
|
||||
VkAndroidHardwareBufferFormatPropertiesANDROID* ahbFormatProps =
|
||||
vk_find_struct<VkAndroidHardwareBufferFormatPropertiesANDROID>(pProperties);
|
||||
vk_find_struct(pProperties, ANDROID_HARDWARE_BUFFER_FORMAT_PROPERTIES_ANDROID);
|
||||
|
||||
const auto format = grallocHelper->getFormat(buffer);
|
||||
if (ahbFormatProps) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
#include "vk_struct_id.h"
|
||||
#include "vk_util.h"
|
||||
|
||||
#if DETECT_OS_LINUX
|
||||
|
|
@ -46,6 +45,36 @@ void zx_event_create(int, zx_handle_t*) {}
|
|||
|
||||
static constexpr uint32_t kDefaultApiVersion = VK_MAKE_VERSION(1, 1, 0);
|
||||
|
||||
struct vk_struct_chain_iterator {
|
||||
VkBaseOutStructure* value;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
static vk_struct_chain_iterator vk_make_chain_iterator(T* vk_struct) {
|
||||
vk_struct_chain_iterator result = {reinterpret_cast<VkBaseOutStructure*>(vk_struct)};
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static void vk_append_struct(vk_struct_chain_iterator* i, T* vk_struct) {
|
||||
VkBaseOutStructure* p = i->value;
|
||||
if (p->pNext) {
|
||||
::abort();
|
||||
}
|
||||
|
||||
p->pNext = reinterpret_cast<VkBaseOutStructure*>(vk_struct);
|
||||
vk_struct->pNext = NULL;
|
||||
|
||||
*i = vk_make_chain_iterator(vk_struct);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static T vk_make_orphan_copy(const T& vk_struct) {
|
||||
T copy = vk_struct;
|
||||
copy.pNext = NULL;
|
||||
return copy;
|
||||
}
|
||||
|
||||
namespace gfxstream {
|
||||
namespace vk {
|
||||
|
||||
|
|
@ -2054,7 +2083,7 @@ void ResourceTracker::on_vkGetPhysicalDeviceFeatures2(void*, VkPhysicalDevice,
|
|||
VkPhysicalDeviceFeatures2* pFeatures) {
|
||||
if (pFeatures) {
|
||||
VkPhysicalDeviceDeviceMemoryReportFeaturesEXT* memoryReportFeaturesEXT =
|
||||
vk_find_struct<VkPhysicalDeviceDeviceMemoryReportFeaturesEXT>(pFeatures);
|
||||
vk_find_struct(pFeatures, PHYSICAL_DEVICE_DEVICE_MEMORY_REPORT_FEATURES_EXT);
|
||||
if (memoryReportFeaturesEXT) {
|
||||
memoryReportFeaturesEXT->deviceMemoryReport = VK_TRUE;
|
||||
}
|
||||
|
|
@ -2071,11 +2100,6 @@ void ResourceTracker::on_vkGetPhysicalDeviceProperties2(void* context,
|
|||
VkPhysicalDevice physicalDevice,
|
||||
VkPhysicalDeviceProperties2* pProperties) {
|
||||
if (pProperties) {
|
||||
VkPhysicalDeviceDeviceMemoryReportFeaturesEXT* memoryReportFeaturesEXT =
|
||||
vk_find_struct<VkPhysicalDeviceDeviceMemoryReportFeaturesEXT>(pProperties);
|
||||
if (memoryReportFeaturesEXT) {
|
||||
memoryReportFeaturesEXT->deviceMemoryReport = VK_TRUE;
|
||||
}
|
||||
on_vkGetPhysicalDeviceProperties(context, physicalDevice, &pProperties->properties);
|
||||
}
|
||||
}
|
||||
|
|
@ -2988,9 +3012,9 @@ VkResult ResourceTracker::allocateCoherentMemory(VkDevice device,
|
|||
createBlobInfo.sType = VK_STRUCTURE_TYPE_CREATE_BLOB_GOOGLE;
|
||||
|
||||
const VkMemoryAllocateFlagsInfo* allocFlagsInfoPtr =
|
||||
vk_find_struct<VkMemoryAllocateFlagsInfo>(pAllocateInfo);
|
||||
vk_find_struct_const(pAllocateInfo, MEMORY_ALLOCATE_FLAGS_INFO);
|
||||
const VkMemoryOpaqueCaptureAddressAllocateInfo* opaqueCaptureAddressAllocInfoPtr =
|
||||
vk_find_struct<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo);
|
||||
vk_find_struct_const(pAllocateInfo, MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO);
|
||||
|
||||
bool deviceAddressMemoryAllocation =
|
||||
allocFlagsInfoPtr &&
|
||||
|
|
@ -3142,7 +3166,7 @@ VkResult ResourceTracker::getCoherentMemory(const VkMemoryAllocateInfo* pAllocat
|
|||
VkDeviceMemory* pMemory) {
|
||||
// Add buffer device address capture structs
|
||||
const VkMemoryAllocateFlagsInfo* allocFlagsInfoPtr =
|
||||
vk_find_struct<VkMemoryAllocateFlagsInfo>(pAllocateInfo);
|
||||
vk_find_struct_const(pAllocateInfo, MEMORY_ALLOCATE_FLAGS_INFO);
|
||||
|
||||
bool dedicated =
|
||||
allocFlagsInfoPtr &&
|
||||
|
|
@ -3223,9 +3247,9 @@ VkResult ResourceTracker::on_vkAllocateMemory(void* context, VkResult input_resu
|
|||
|
||||
// Add buffer device address capture structs
|
||||
const VkMemoryAllocateFlagsInfo* allocFlagsInfoPtr =
|
||||
vk_find_struct<VkMemoryAllocateFlagsInfo>(pAllocateInfo);
|
||||
vk_find_struct_const(pAllocateInfo, MEMORY_ALLOCATE_FLAGS_INFO);
|
||||
const VkMemoryOpaqueCaptureAddressAllocateInfo* opaqueCaptureAddressAllocInfoPtr =
|
||||
vk_find_struct<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo);
|
||||
vk_find_struct_const(pAllocateInfo, MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO);
|
||||
|
||||
if (allocFlagsInfoPtr) {
|
||||
mesa_logd("%s: has alloc flags\n", __func__);
|
||||
|
|
@ -3253,11 +3277,11 @@ VkResult ResourceTracker::on_vkAllocateMemory(void* context, VkResult input_resu
|
|||
// };
|
||||
|
||||
const VkExportMemoryAllocateInfo* exportAllocateInfoPtr =
|
||||
vk_find_struct<VkExportMemoryAllocateInfo>(pAllocateInfo);
|
||||
vk_find_struct_const(pAllocateInfo, EXPORT_MEMORY_ALLOCATE_INFO);
|
||||
|
||||
#ifdef VK_USE_PLATFORM_ANDROID_KHR
|
||||
const VkImportAndroidHardwareBufferInfoANDROID* importAhbInfoPtr =
|
||||
vk_find_struct<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo);
|
||||
vk_find_struct_const(pAllocateInfo, IMPORT_ANDROID_HARDWARE_BUFFER_INFO_ANDROID);
|
||||
// Even if we export allocate, the underlying operation
|
||||
// for the host is always going to be an import operation.
|
||||
// This is also how Intel's implementation works,
|
||||
|
|
@ -3275,24 +3299,24 @@ VkResult ResourceTracker::on_vkAllocateMemory(void* context, VkResult input_resu
|
|||
|
||||
#if DETECT_OS_LINUX && !defined(VK_USE_PLATFORM_ANDROID_KHR)
|
||||
const VkImportMemoryFdInfoKHR* importFdInfoPtr =
|
||||
vk_find_struct<VkImportMemoryFdInfoKHR>(pAllocateInfo);
|
||||
vk_find_struct_const(pAllocateInfo, IMPORT_MEMORY_FD_INFO_KHR);
|
||||
#else
|
||||
const VkImportMemoryFdInfoKHR* importFdInfoPtr = nullptr;
|
||||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_FUCHSIA
|
||||
const VkImportMemoryBufferCollectionFUCHSIA* importBufferCollectionInfoPtr =
|
||||
vk_find_struct<VkImportMemoryBufferCollectionFUCHSIA>(pAllocateInfo);
|
||||
vk_find_struct_const(pAllocateInfo, IMPORT_MEMORY_BUFFER_COLLECTION_FUCHSIA);
|
||||
|
||||
const VkImportMemoryZirconHandleInfoFUCHSIA* importVmoInfoPtr =
|
||||
vk_find_struct<VkImportMemoryZirconHandleInfoFUCHSIA>(pAllocateInfo);
|
||||
vk_find_struct_const(pAllocateInfo, IMPORT_MEMORY_ZIRCON_HANDLE_INFO_FUCHSIA);
|
||||
#else
|
||||
const void* importBufferCollectionInfoPtr = nullptr;
|
||||
const void* importVmoInfoPtr = nullptr;
|
||||
#endif // VK_USE_PLATFORM_FUCHSIA
|
||||
|
||||
const VkMemoryDedicatedAllocateInfo* dedicatedAllocInfoPtr =
|
||||
vk_find_struct<VkMemoryDedicatedAllocateInfo>(pAllocateInfo);
|
||||
vk_find_struct_const(pAllocateInfo, MEMORY_DEDICATED_ALLOCATE_INFO);
|
||||
|
||||
// Note for AHardwareBuffers, the Vulkan spec states:
|
||||
//
|
||||
|
|
@ -4146,7 +4170,7 @@ void ResourceTracker::transformImageMemoryRequirements2ForGuest(VkImage image,
|
|||
transformImageMemoryRequirementsForGuestLocked(image, &reqs2->memoryRequirements);
|
||||
|
||||
VkMemoryDedicatedRequirements* dedicatedReqs =
|
||||
vk_find_struct<VkMemoryDedicatedRequirements>(reqs2);
|
||||
vk_find_struct(reqs2, MEMORY_DEDICATED_REQUIREMENTS);
|
||||
|
||||
if (!dedicatedReqs) return;
|
||||
|
||||
|
|
@ -4167,7 +4191,7 @@ void ResourceTracker::transformBufferMemoryRequirements2ForGuest(VkBuffer buffer
|
|||
}
|
||||
|
||||
VkMemoryDedicatedRequirements* dedicatedReqs =
|
||||
vk_find_struct<VkMemoryDedicatedRequirements>(reqs2);
|
||||
vk_find_struct(reqs2, MEMORY_DEDICATED_REQUIREMENTS);
|
||||
|
||||
if (!dedicatedReqs) return;
|
||||
|
||||
|
|
@ -4190,7 +4214,7 @@ VkResult ResourceTracker::on_vkCreateImage(void* context, VkResult, VkDevice dev
|
|||
VkExternalMemoryImageCreateInfo localExtImgCi;
|
||||
|
||||
const VkExternalMemoryImageCreateInfo* extImgCiPtr =
|
||||
vk_find_struct<VkExternalMemoryImageCreateInfo>(pCreateInfo);
|
||||
vk_find_struct_const(pCreateInfo, EXTERNAL_MEMORY_IMAGE_CREATE_INFO);
|
||||
|
||||
if (extImgCiPtr) {
|
||||
localExtImgCi = vk_make_orphan_copy(*extImgCiPtr);
|
||||
|
|
@ -4205,7 +4229,7 @@ VkResult ResourceTracker::on_vkCreateImage(void* context, VkResult, VkDevice dev
|
|||
if (extImgCiPtr &&
|
||||
(extImgCiPtr->handleTypes & VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT)) {
|
||||
const wsi_image_create_info* wsiImageCi =
|
||||
vk_find_struct<wsi_image_create_info>(pCreateInfo);
|
||||
vk_find_struct_const(pCreateInfo, WSI_IMAGE_CREATE_INFO_MESA);
|
||||
if (wsiImageCi && wsiImageCi->scanout) {
|
||||
// Linux WSI creates swapchain images with VK_IMAGE_CREATE_ALIAS_BIT. Vulkan spec
|
||||
// states: "If the pNext chain includes a VkExternalMemoryImageCreateInfo or
|
||||
|
|
@ -4216,9 +4240,9 @@ VkResult ResourceTracker::on_vkCreateImage(void* context, VkResult, VkDevice dev
|
|||
}
|
||||
|
||||
const VkImageDrmFormatModifierExplicitCreateInfoEXT* drmFmtMod =
|
||||
vk_find_struct<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo);
|
||||
vk_find_struct_const(pCreateInfo, IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT);
|
||||
const VkImageDrmFormatModifierListCreateInfoEXT* drmFmtModList =
|
||||
vk_find_struct<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo);
|
||||
vk_find_struct_const(pCreateInfo, IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT);
|
||||
if (drmFmtMod || drmFmtModList) {
|
||||
if (getHostDeviceExtensionIndex(VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME) !=
|
||||
-1) {
|
||||
|
|
@ -4254,7 +4278,7 @@ VkResult ResourceTracker::on_vkCreateImage(void* context, VkResult, VkDevice dev
|
|||
|
||||
#ifdef VK_USE_PLATFORM_ANDROID_KHR
|
||||
VkNativeBufferANDROID localAnb;
|
||||
const VkNativeBufferANDROID* anbInfoPtr = vk_find_struct<VkNativeBufferANDROID>(pCreateInfo);
|
||||
const VkNativeBufferANDROID* anbInfoPtr = vk_find_struct_const(pCreateInfo, NATIVE_BUFFER_ANDROID);
|
||||
if (anbInfoPtr) {
|
||||
localAnb = vk_make_orphan_copy(*anbInfoPtr);
|
||||
vk_append_struct(&structChainIter, &localAnb);
|
||||
|
|
@ -4262,7 +4286,7 @@ VkResult ResourceTracker::on_vkCreateImage(void* context, VkResult, VkDevice dev
|
|||
|
||||
VkExternalFormatANDROID localExtFormatAndroid;
|
||||
const VkExternalFormatANDROID* extFormatAndroidPtr =
|
||||
vk_find_struct<VkExternalFormatANDROID>(pCreateInfo);
|
||||
vk_find_struct_const(pCreateInfo, EXTERNAL_FORMAT_ANDROID);
|
||||
if (extFormatAndroidPtr) {
|
||||
localExtFormatAndroid = vk_make_orphan_copy(*extFormatAndroidPtr);
|
||||
|
||||
|
|
@ -4279,7 +4303,7 @@ VkResult ResourceTracker::on_vkCreateImage(void* context, VkResult, VkDevice dev
|
|||
|
||||
#ifdef VK_USE_PLATFORM_FUCHSIA
|
||||
const VkBufferCollectionImageCreateInfoFUCHSIA* extBufferCollectionPtr =
|
||||
vk_find_struct<VkBufferCollectionImageCreateInfoFUCHSIA>(pCreateInfo);
|
||||
vk_find_struct_const(pCreateInfo, BUFFER_COLLECTION_IMAGE_CREATE_INFO_FUCHSIA);
|
||||
|
||||
bool isSysmemBackedMemory = false;
|
||||
|
||||
|
|
@ -4485,7 +4509,7 @@ VkResult ResourceTracker::on_vkCreateSamplerYcbcrConversion(
|
|||
|
||||
#ifdef VK_USE_PLATFORM_ANDROID_KHR
|
||||
const VkExternalFormatANDROID* extFormatAndroidPtr =
|
||||
vk_find_struct<VkExternalFormatANDROID>(pCreateInfo);
|
||||
vk_find_struct_const(pCreateInfo, EXTERNAL_FORMAT_ANDROID);
|
||||
if (extFormatAndroidPtr) {
|
||||
if (extFormatAndroidPtr->externalFormat == DRM_FORMAT_RGB565) {
|
||||
// We don't support external formats on host and it causes RGB565
|
||||
|
|
@ -4531,7 +4555,7 @@ VkResult ResourceTracker::on_vkCreateSamplerYcbcrConversionKHR(
|
|||
|
||||
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
|
||||
const VkExternalFormatANDROID* extFormatAndroidPtr =
|
||||
vk_find_struct<VkExternalFormatANDROID>(pCreateInfo);
|
||||
vk_find_struct_const(pCreateInfo, EXTERNAL_FORMAT_ANDROID);
|
||||
if (extFormatAndroidPtr) {
|
||||
if (extFormatAndroidPtr->externalFormat == DRM_FORMAT_RGB565) {
|
||||
// We don't support external formats on host and it causes RGB565
|
||||
|
|
@ -4580,7 +4604,7 @@ VkResult ResourceTracker::on_vkCreateSampler(void* context, VkResult, VkDevice d
|
|||
vk_struct_chain_iterator structChainIter = vk_make_chain_iterator(&localCreateInfo);
|
||||
VkSamplerYcbcrConversionInfo localVkSamplerYcbcrConversionInfo;
|
||||
const VkSamplerYcbcrConversionInfo* samplerYcbcrConversionInfo =
|
||||
vk_find_struct<VkSamplerYcbcrConversionInfo>(pCreateInfo);
|
||||
vk_find_struct_const(pCreateInfo, SAMPLER_YCBCR_CONVERSION_INFO);
|
||||
if (samplerYcbcrConversionInfo) {
|
||||
if (samplerYcbcrConversionInfo->conversion != VK_YCBCR_CONVERSION_DO_NOTHING) {
|
||||
localVkSamplerYcbcrConversionInfo = vk_make_orphan_copy(*samplerYcbcrConversionInfo);
|
||||
|
|
@ -4590,7 +4614,7 @@ VkResult ResourceTracker::on_vkCreateSampler(void* context, VkResult, VkDevice d
|
|||
|
||||
VkSamplerCustomBorderColorCreateInfoEXT localVkSamplerCustomBorderColorCreateInfo;
|
||||
const VkSamplerCustomBorderColorCreateInfoEXT* samplerCustomBorderColorCreateInfo =
|
||||
vk_find_struct<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo);
|
||||
vk_find_struct_const(pCreateInfo, SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT);
|
||||
if (samplerCustomBorderColorCreateInfo) {
|
||||
localVkSamplerCustomBorderColorCreateInfo =
|
||||
vk_make_orphan_copy(*samplerCustomBorderColorCreateInfo);
|
||||
|
|
@ -4644,7 +4668,7 @@ VkResult ResourceTracker::on_vkCreateFence(void* context, VkResult input_result,
|
|||
VkFenceCreateInfo finalCreateInfo = *pCreateInfo;
|
||||
|
||||
const VkExportFenceCreateInfo* exportFenceInfoPtr =
|
||||
vk_find_struct<VkExportFenceCreateInfo>(pCreateInfo);
|
||||
vk_find_struct_const(pCreateInfo, EXPORT_FENCE_CREATE_INFO);
|
||||
|
||||
#if defined(VK_USE_PLATFORM_ANDROID_KHR) || DETECT_OS_LINUX
|
||||
bool exportSyncFd = exportFenceInfoPtr && (exportFenceInfoPtr->handleTypes &
|
||||
|
|
@ -5398,7 +5422,7 @@ VkResult ResourceTracker::on_vkCreateBuffer(void* context, VkResult, VkDevice de
|
|||
VkExternalMemoryBufferCreateInfo localExtBufCi;
|
||||
|
||||
const VkExternalMemoryBufferCreateInfo* extBufCiPtr =
|
||||
vk_find_struct<VkExternalMemoryBufferCreateInfo>(pCreateInfo);
|
||||
vk_find_struct_const(pCreateInfo, EXTERNAL_MEMORY_BUFFER_CREATE_INFO);
|
||||
if (extBufCiPtr) {
|
||||
localExtBufCi = vk_make_orphan_copy(*extBufCiPtr);
|
||||
vk_append_struct(&structChainIter, &localExtBufCi);
|
||||
|
|
@ -5406,7 +5430,7 @@ VkResult ResourceTracker::on_vkCreateBuffer(void* context, VkResult, VkDevice de
|
|||
|
||||
VkBufferOpaqueCaptureAddressCreateInfo localCapAddrCi;
|
||||
const VkBufferOpaqueCaptureAddressCreateInfo* pCapAddrCi =
|
||||
vk_find_struct<VkBufferOpaqueCaptureAddressCreateInfo>(pCreateInfo);
|
||||
vk_find_struct_const(pCreateInfo, BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO);
|
||||
if (pCapAddrCi) {
|
||||
localCapAddrCi = vk_make_orphan_copy(*pCapAddrCi);
|
||||
vk_append_struct(&structChainIter, &localCapAddrCi);
|
||||
|
|
@ -5414,7 +5438,7 @@ VkResult ResourceTracker::on_vkCreateBuffer(void* context, VkResult, VkDevice de
|
|||
|
||||
VkBufferDeviceAddressCreateInfoEXT localDevAddrCi;
|
||||
const VkBufferDeviceAddressCreateInfoEXT* pDevAddrCi =
|
||||
vk_find_struct<VkBufferDeviceAddressCreateInfoEXT>(pCreateInfo);
|
||||
vk_find_struct_const(pCreateInfo, BUFFER_DEVICE_ADDRESS_CREATE_INFO_EXT);
|
||||
if (pDevAddrCi) {
|
||||
localDevAddrCi = vk_make_orphan_copy(*pDevAddrCi);
|
||||
vk_append_struct(&structChainIter, &localDevAddrCi);
|
||||
|
|
@ -5429,8 +5453,8 @@ VkResult ResourceTracker::on_vkCreateBuffer(void* context, VkResult, VkDevice de
|
|||
isSysmemBackedMemory = true;
|
||||
}
|
||||
|
||||
const auto* extBufferCollectionPtr =
|
||||
vk_find_struct<VkBufferCollectionBufferCreateInfoFUCHSIA>(pCreateInfo);
|
||||
const VkBufferCollectionBufferCreateInfoFUCHSIA* extBufferCollectionPtr =
|
||||
vk_find_struct_const(pCreateInfo, BUFFER_COLLECTION_BUFFER_CREATE_INFO_FUCHSIA);
|
||||
|
||||
if (extBufferCollectionPtr) {
|
||||
const auto& collection =
|
||||
|
|
@ -5600,7 +5624,7 @@ VkResult ResourceTracker::on_vkCreateSemaphore(void* context, VkResult input_res
|
|||
VkSemaphoreCreateInfo finalCreateInfo = *pCreateInfo;
|
||||
|
||||
const VkExportSemaphoreCreateInfoKHR* exportSemaphoreInfoPtr =
|
||||
vk_find_struct<VkExportSemaphoreCreateInfoKHR>(pCreateInfo);
|
||||
vk_find_struct_const(pCreateInfo, EXPORT_SEMAPHORE_CREATE_INFO);
|
||||
|
||||
#ifdef VK_USE_PLATFORM_FUCHSIA
|
||||
bool exportEvent =
|
||||
|
|
@ -5611,7 +5635,7 @@ VkResult ResourceTracker::on_vkCreateSemaphore(void* context, VkResult input_res
|
|||
finalCreateInfo.pNext = nullptr;
|
||||
// If we have timeline semaphores externally, leave it there.
|
||||
const VkSemaphoreTypeCreateInfo* typeCi =
|
||||
vk_find_struct<VkSemaphoreTypeCreateInfo>(pCreateInfo);
|
||||
vk_find_struct_const(pCreateInfo, SEMAPHORE_TYPE_CREATE_INFO);
|
||||
if (typeCi) finalCreateInfo.pNext = typeCi;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -5624,7 +5648,7 @@ VkResult ResourceTracker::on_vkCreateSemaphore(void* context, VkResult input_res
|
|||
finalCreateInfo.pNext = nullptr;
|
||||
// If we have timeline semaphores externally, leave it there.
|
||||
const VkSemaphoreTypeCreateInfo* typeCi =
|
||||
vk_find_struct<VkSemaphoreTypeCreateInfo>(pCreateInfo);
|
||||
vk_find_struct_const(pCreateInfo, SEMAPHORE_TYPE_CREATE_INFO);
|
||||
if (typeCi) finalCreateInfo.pNext = typeCi;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -6021,8 +6045,8 @@ VkResult ResourceTracker::on_vkQueueSubmit(void* context, VkResult input_result,
|
|||
* this check.
|
||||
*/
|
||||
for (uint32_t i = 0; i < submitCount; i++) {
|
||||
VkTimelineSemaphoreSubmitInfo* tssi = const_cast<VkTimelineSemaphoreSubmitInfo*>(
|
||||
vk_find_struct<VkTimelineSemaphoreSubmitInfo>(&pSubmits[i]));
|
||||
VkTimelineSemaphoreSubmitInfo* tssi =
|
||||
vk_find_struct(const_cast<VkSubmitInfo*>(&pSubmits[i]), TIMELINE_SEMAPHORE_SUBMIT_INFO);
|
||||
|
||||
if (tssi) {
|
||||
uint32_t count = getSignalSemaphoreCount(pSubmits[i]);
|
||||
|
|
@ -6261,10 +6285,9 @@ void ResourceTracker::unwrap_vkCreateImage_pCreateInfo(const VkImageCreateInfo*
|
|||
VkImageCreateInfo* local_pCreateInfo) {
|
||||
#ifdef VK_USE_PLATFORM_ANDROID_KHR
|
||||
const VkNativeBufferANDROID* inputNativeInfo =
|
||||
vk_find_struct<VkNativeBufferANDROID>(pCreateInfo);
|
||||
vk_find_struct_const(pCreateInfo, NATIVE_BUFFER_ANDROID);
|
||||
|
||||
VkNativeBufferANDROID* outputNativeInfo = const_cast<VkNativeBufferANDROID*>(
|
||||
vk_find_struct<VkNativeBufferANDROID>(local_pCreateInfo));
|
||||
VkNativeBufferANDROID* outputNativeInfo = vk_find_struct(local_pCreateInfo, NATIVE_BUFFER_ANDROID);
|
||||
|
||||
unwrap_VkNativeBufferANDROID(inputNativeInfo, outputNativeInfo);
|
||||
#endif
|
||||
|
|
@ -6306,19 +6329,16 @@ void ResourceTracker::unwrap_VkBindImageMemory2_pBindInfos(
|
|||
VkBindImageMemoryInfo* outputBindInfo = &outputBindInfos[i];
|
||||
|
||||
const VkNativeBufferANDROID* inputNativeInfo =
|
||||
vk_find_struct<VkNativeBufferANDROID>(inputBindInfo);
|
||||
vk_find_struct_const(inputBindInfo, NATIVE_BUFFER_ANDROID);
|
||||
|
||||
VkNativeBufferANDROID* outputNativeInfo = const_cast<VkNativeBufferANDROID*>(
|
||||
vk_find_struct<VkNativeBufferANDROID>(outputBindInfo));
|
||||
VkNativeBufferANDROID* outputNativeInfo = vk_find_struct(outputBindInfo, NATIVE_BUFFER_ANDROID);
|
||||
|
||||
unwrap_VkNativeBufferANDROID(inputNativeInfo, outputNativeInfo);
|
||||
|
||||
const VkBindImageMemorySwapchainInfoKHR* inputBimsi =
|
||||
vk_find_struct<VkBindImageMemorySwapchainInfoKHR>(inputBindInfo);
|
||||
vk_find_struct_const(inputBindInfo, BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR);
|
||||
|
||||
VkBindImageMemorySwapchainInfoKHR* outputBimsi =
|
||||
const_cast<VkBindImageMemorySwapchainInfoKHR*>(
|
||||
vk_find_struct<VkBindImageMemorySwapchainInfoKHR>(outputBindInfo));
|
||||
VkBindImageMemorySwapchainInfoKHR* outputBimsi = vk_find_struct(outputBindInfo, BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR);
|
||||
|
||||
unwrap_VkBindImageMemorySwapchainInfoKHR(inputBimsi, outputBimsi);
|
||||
}
|
||||
|
|
@ -6672,7 +6692,7 @@ VkResult ResourceTracker::on_vkGetPhysicalDeviceImageFormatProperties2_common(
|
|||
|
||||
uint32_t supportedHandleType = 0;
|
||||
VkExternalImageFormatProperties* ext_img_properties =
|
||||
vk_find_struct<VkExternalImageFormatProperties>(pImageFormatProperties);
|
||||
vk_find_struct(pImageFormatProperties, EXTERNAL_IMAGE_FORMAT_PROPERTIES);
|
||||
|
||||
#ifdef VK_USE_PLATFORM_FUCHSIA
|
||||
|
||||
|
|
@ -6699,13 +6719,12 @@ VkResult ResourceTracker::on_vkGetPhysicalDeviceImageFormatProperties2_common(
|
|||
#endif
|
||||
|
||||
#ifdef VK_USE_PLATFORM_ANDROID_KHR
|
||||
VkAndroidHardwareBufferUsageANDROID* output_ahw_usage =
|
||||
vk_find_struct<VkAndroidHardwareBufferUsageANDROID>(pImageFormatProperties);
|
||||
VkAndroidHardwareBufferUsageANDROID* output_ahw_usage = vk_find_struct(pImageFormatProperties, ANDROID_HARDWARE_BUFFER_USAGE_ANDROID);
|
||||
supportedHandleType |= VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT |
|
||||
VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID;
|
||||
#endif
|
||||
const VkPhysicalDeviceExternalImageFormatInfo* ext_img_info =
|
||||
vk_find_struct<VkPhysicalDeviceExternalImageFormatInfo>(pImageFormatInfo);
|
||||
vk_find_struct_const(pImageFormatInfo, PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO);
|
||||
if (supportedHandleType && ext_img_info) {
|
||||
// 0 is a valid handleType so we don't check against 0
|
||||
if (ext_img_info->handleType != (ext_img_info->handleType & supportedHandleType)) {
|
||||
|
|
@ -6715,7 +6734,7 @@ VkResult ResourceTracker::on_vkGetPhysicalDeviceImageFormatProperties2_common(
|
|||
|
||||
#ifdef LINUX_GUEST_BUILD
|
||||
const VkPhysicalDeviceImageDrmFormatModifierInfoEXT* drmFmtMod =
|
||||
vk_find_struct<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo);
|
||||
vk_find_struct_const(pImageFormatInfo, PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT);
|
||||
VkDrmFormatModifierPropertiesListEXT* emulatedDrmFmtModPropsList = nullptr;
|
||||
if (drmFmtMod) {
|
||||
if (getHostDeviceExtensionIndex(VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME) != -1) {
|
||||
|
|
@ -6723,7 +6742,7 @@ VkResult ResourceTracker::on_vkGetPhysicalDeviceImageFormatProperties2_common(
|
|||
} else {
|
||||
mesa_logd("emulating DRM_FORMAT_MOD_LINEAR with VK_IMAGE_TILING_LINEAR");
|
||||
emulatedDrmFmtModPropsList =
|
||||
vk_find_struct<VkDrmFormatModifierPropertiesListEXT>(pImageFormatProperties);
|
||||
vk_find_struct(pImageFormatProperties, DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT);
|
||||
|
||||
// Host doesn't support DRM format modifiers, try emulating.
|
||||
if (drmFmtMod) {
|
||||
|
|
@ -6898,7 +6917,7 @@ void ResourceTracker::on_vkGetPhysicalDeviceExternalSemaphoreProperties(
|
|||
}
|
||||
#else
|
||||
const VkSemaphoreTypeCreateInfo* semaphoreTypeCi =
|
||||
vk_find_struct<VkSemaphoreTypeCreateInfo>(pExternalSemaphoreInfo);
|
||||
vk_find_struct_const(pExternalSemaphoreInfo, SEMAPHORE_TYPE_CREATE_INFO);
|
||||
bool isSemaphoreTimeline =
|
||||
semaphoreTypeCi != nullptr && semaphoreTypeCi->semaphoreType == VK_SEMAPHORE_TYPE_TIMELINE;
|
||||
if (isSemaphoreTimeline) {
|
||||
|
|
@ -7102,8 +7121,7 @@ VkResult ResourceTracker::on_vkCreateImageView(void* context, VkResult input_res
|
|||
}
|
||||
}
|
||||
VkSamplerYcbcrConversionInfo localVkSamplerYcbcrConversionInfo;
|
||||
const VkSamplerYcbcrConversionInfo* samplerYcbcrConversionInfo =
|
||||
vk_find_struct<VkSamplerYcbcrConversionInfo>(pCreateInfo);
|
||||
const VkSamplerYcbcrConversionInfo* samplerYcbcrConversionInfo = vk_find_struct_const(pCreateInfo, SAMPLER_YCBCR_CONVERSION_INFO);
|
||||
if (samplerYcbcrConversionInfo) {
|
||||
if (samplerYcbcrConversionInfo->conversion != VK_YCBCR_CONVERSION_DO_NOTHING) {
|
||||
localVkSamplerYcbcrConversionInfo = vk_make_orphan_copy(*samplerYcbcrConversionInfo);
|
||||
|
|
@ -7377,7 +7395,7 @@ VkResult ResourceTracker::on_vkCreateGraphicsPipelines(
|
|||
bool forceColorBlendState = false;
|
||||
|
||||
const VkPipelineRenderingCreateInfo* pipelineRenderingInfo =
|
||||
vk_find_struct<VkPipelineRenderingCreateInfo>(&graphicsPipelineCreateInfo);
|
||||
vk_find_struct_const(&graphicsPipelineCreateInfo, PIPELINE_RENDERING_CREATE_INFO);
|
||||
|
||||
if (pipelineRenderingInfo) {
|
||||
forceDepthStencilState |=
|
||||
|
|
|
|||
|
|
@ -1,140 +0,0 @@
|
|||
/*
|
||||
* Copyright 2018 Google LLC
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#include "goldfish_vk_private_defs.h"
|
||||
#include "vk_android_native_buffer_gfxstream.h"
|
||||
#include "vulkan_gfxstream.h"
|
||||
|
||||
#if defined(LINUX_GUEST_BUILD)
|
||||
#include "vulkan/wsi/wsi_common.h"
|
||||
#endif
|
||||
|
||||
// anonymous
|
||||
namespace {
|
||||
|
||||
template <class T>
|
||||
struct vk_get_vk_struct_id;
|
||||
|
||||
#define REGISTER_VK_STRUCT_ID(T, ID) \
|
||||
template <> \
|
||||
struct vk_get_vk_struct_id<T> { \
|
||||
static constexpr VkStructureType id = ID; \
|
||||
}
|
||||
|
||||
#ifdef VK_USE_PLATFORM_ANDROID_KHR
|
||||
REGISTER_VK_STRUCT_ID(VkAndroidHardwareBufferPropertiesANDROID,
|
||||
VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_PROPERTIES_ANDROID);
|
||||
REGISTER_VK_STRUCT_ID(VkAndroidHardwareBufferFormatPropertiesANDROID,
|
||||
VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_FORMAT_PROPERTIES_ANDROID);
|
||||
REGISTER_VK_STRUCT_ID(VkAndroidHardwareBufferUsageANDROID,
|
||||
VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_USAGE_ANDROID);
|
||||
#endif
|
||||
REGISTER_VK_STRUCT_ID(VkBufferCreateInfo, VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkImageCreateInfo, VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkImageFormatProperties2, VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2);
|
||||
#ifdef VK_USE_PLATFORM_ANDROID_KHR
|
||||
REGISTER_VK_STRUCT_ID(VkNativeBufferANDROID, VK_STRUCTURE_TYPE_NATIVE_BUFFER_ANDROID);
|
||||
REGISTER_VK_STRUCT_ID(VkExternalFormatANDROID, VK_STRUCTURE_TYPE_EXTERNAL_FORMAT_ANDROID);
|
||||
#endif
|
||||
REGISTER_VK_STRUCT_ID(VkExternalMemoryBufferCreateInfo,
|
||||
VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkExternalMemoryImageCreateInfo,
|
||||
VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkMemoryAllocateInfo, VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkMemoryDedicatedAllocateInfo,
|
||||
VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkMemoryDedicatedRequirements,
|
||||
VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS);
|
||||
#ifdef VK_USE_PLATFORM_ANDROID_KHR
|
||||
REGISTER_VK_STRUCT_ID(VkImportAndroidHardwareBufferInfoANDROID,
|
||||
VK_STRUCTURE_TYPE_IMPORT_ANDROID_HARDWARE_BUFFER_INFO_ANDROID);
|
||||
#endif
|
||||
REGISTER_VK_STRUCT_ID(VkImportMemoryFdInfoKHR, VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR);
|
||||
REGISTER_VK_STRUCT_ID(VkExportMemoryAllocateInfo, VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkMemoryRequirements2, VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2);
|
||||
REGISTER_VK_STRUCT_ID(VkSemaphoreCreateInfo, VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkExportSemaphoreCreateInfoKHR,
|
||||
VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO_KHR);
|
||||
REGISTER_VK_STRUCT_ID(VkSamplerYcbcrConversionCreateInfo,
|
||||
VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkImportColorBufferGOOGLE, VK_STRUCTURE_TYPE_IMPORT_COLOR_BUFFER_GOOGLE);
|
||||
REGISTER_VK_STRUCT_ID(VkImageViewCreateInfo, VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO);
|
||||
#ifdef VK_USE_PLATFORM_FUCHSIA
|
||||
REGISTER_VK_STRUCT_ID(VkImportMemoryBufferCollectionFUCHSIA,
|
||||
VK_STRUCTURE_TYPE_IMPORT_MEMORY_BUFFER_COLLECTION_FUCHSIA);
|
||||
REGISTER_VK_STRUCT_ID(VkImportMemoryZirconHandleInfoFUCHSIA,
|
||||
VK_STRUCTURE_TYPE_IMPORT_MEMORY_ZIRCON_HANDLE_INFO_FUCHSIA);
|
||||
REGISTER_VK_STRUCT_ID(VkBufferCollectionImageCreateInfoFUCHSIA,
|
||||
VK_STRUCTURE_TYPE_BUFFER_COLLECTION_IMAGE_CREATE_INFO_FUCHSIA);
|
||||
REGISTER_VK_STRUCT_ID(VkBufferCollectionBufferCreateInfoFUCHSIA,
|
||||
VK_STRUCTURE_TYPE_BUFFER_COLLECTION_BUFFER_CREATE_INFO_FUCHSIA);
|
||||
#endif // VK_USE_PLATFORM_FUCHSIA
|
||||
REGISTER_VK_STRUCT_ID(VkSamplerCreateInfo, VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkSamplerCustomBorderColorCreateInfoEXT,
|
||||
VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT);
|
||||
REGISTER_VK_STRUCT_ID(VkSamplerYcbcrConversionInfo,
|
||||
VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkFenceCreateInfo, VK_STRUCTURE_TYPE_FENCE_CREATE_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkExportFenceCreateInfo, VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkImportBufferGOOGLE, VK_STRUCTURE_TYPE_IMPORT_BUFFER_GOOGLE);
|
||||
REGISTER_VK_STRUCT_ID(VkCreateBlobGOOGLE, VK_STRUCTURE_TYPE_CREATE_BLOB_GOOGLE);
|
||||
REGISTER_VK_STRUCT_ID(VkExternalImageFormatProperties,
|
||||
VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES);
|
||||
REGISTER_VK_STRUCT_ID(VkPhysicalDeviceImageFormatInfo2,
|
||||
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2);
|
||||
REGISTER_VK_STRUCT_ID(VkPhysicalDeviceExternalImageFormatInfo,
|
||||
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkSemaphoreTypeCreateInfo, VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkPhysicalDeviceFeatures2, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2);
|
||||
REGISTER_VK_STRUCT_ID(VkPhysicalDeviceProperties2, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2);
|
||||
REGISTER_VK_STRUCT_ID(VkPhysicalDeviceDeviceMemoryReportFeaturesEXT,
|
||||
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_MEMORY_REPORT_FEATURES_EXT);
|
||||
REGISTER_VK_STRUCT_ID(VkMemoryAllocateFlagsInfo, VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkMemoryOpaqueCaptureAddressAllocateInfo,
|
||||
VK_STRUCTURE_TYPE_MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkBindImageMemoryInfo, VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkBindImageMemorySwapchainInfoKHR,
|
||||
VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR);
|
||||
REGISTER_VK_STRUCT_ID(VkBufferOpaqueCaptureAddressCreateInfo,
|
||||
VK_STRUCTURE_TYPE_BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkBufferDeviceAddressCreateInfoEXT,
|
||||
VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_CREATE_INFO_EXT);
|
||||
REGISTER_VK_STRUCT_ID(VkGraphicsPipelineCreateInfo,
|
||||
VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkPipelineRenderingCreateInfo,
|
||||
VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkPhysicalDeviceExternalSemaphoreInfo,
|
||||
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkRenderPassBeginInfo, VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkRenderPassAttachmentBeginInfo,
|
||||
VK_STRUCTURE_TYPE_RENDER_PASS_ATTACHMENT_BEGIN_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkImportMemoryHostPointerInfoEXT,
|
||||
VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT);
|
||||
REGISTER_VK_STRUCT_ID(VkDeviceCreateInfo, VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkPhysicalDeviceGroupProperties,
|
||||
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES);
|
||||
REGISTER_VK_STRUCT_ID(VkPhysicalDeviceSwapchainMaintenance1FeaturesEXT, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SWAPCHAIN_MAINTENANCE_1_FEATURES_EXT);
|
||||
REGISTER_VK_STRUCT_ID(VkSubmitInfo, VK_STRUCTURE_TYPE_SUBMIT_INFO);
|
||||
REGISTER_VK_STRUCT_ID(VkTimelineSemaphoreSubmitInfo,
|
||||
VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO);
|
||||
#if defined(LINUX_GUEST_BUILD)
|
||||
REGISTER_VK_STRUCT_ID(wsi_image_create_info, VK_STRUCTURE_TYPE_WSI_IMAGE_CREATE_INFO_MESA);
|
||||
#endif
|
||||
REGISTER_VK_STRUCT_ID(VkImageDrmFormatModifierExplicitCreateInfoEXT,
|
||||
VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT);
|
||||
REGISTER_VK_STRUCT_ID(VkFormatProperties2, VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2);
|
||||
REGISTER_VK_STRUCT_ID(VkPhysicalDeviceImageDrmFormatModifierInfoEXT,
|
||||
VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT);
|
||||
REGISTER_VK_STRUCT_ID(VkDrmFormatModifierPropertiesListEXT,
|
||||
VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT);
|
||||
REGISTER_VK_STRUCT_ID(VkImageDrmFormatModifierListCreateInfoEXT,
|
||||
VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT);
|
||||
|
||||
#undef REGISTER_VK_STRUCT_ID
|
||||
|
||||
} // namespace
|
||||
|
|
@ -1,237 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 Intel
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
#ifndef VK_UTIL_H
|
||||
#define VK_UTIL_H
|
||||
|
||||
/* common inlines and macros for vulkan drivers */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#include "vk_struct_id.h"
|
||||
|
||||
namespace { // anonymous
|
||||
|
||||
struct vk_struct_common {
|
||||
VkStructureType sType;
|
||||
struct vk_struct_common* pNext;
|
||||
};
|
||||
|
||||
struct vk_struct_chain_iterator {
|
||||
vk_struct_common* value;
|
||||
};
|
||||
|
||||
#define vk_foreach_struct(__iter, __start) \
|
||||
for (struct vk_struct_common* __iter = (struct vk_struct_common*)(__start); __iter; \
|
||||
__iter = __iter->pNext)
|
||||
|
||||
#define vk_foreach_struct_const(__iter, __start) \
|
||||
for (const struct vk_struct_common* __iter = (const struct vk_struct_common*)(__start); \
|
||||
__iter; __iter = __iter->pNext)
|
||||
|
||||
/**
|
||||
* A wrapper for a Vulkan output array. A Vulkan output array is one that
|
||||
* follows the convention of the parameters to
|
||||
* vkGetPhysicalDeviceQueueFamilyProperties().
|
||||
*
|
||||
* Example Usage:
|
||||
*
|
||||
* VkResult
|
||||
* vkGetPhysicalDeviceQueueFamilyProperties(
|
||||
* VkPhysicalDevice physicalDevice,
|
||||
* uint32_t* pQueueFamilyPropertyCount,
|
||||
* VkQueueFamilyProperties* pQueueFamilyProperties)
|
||||
* {
|
||||
* VK_OUTARRAY_MAKE(props, pQueueFamilyProperties,
|
||||
* pQueueFamilyPropertyCount);
|
||||
*
|
||||
* vk_outarray_append(&props, p) {
|
||||
* p->queueFlags = ...;
|
||||
* p->queueCount = ...;
|
||||
* }
|
||||
*
|
||||
* vk_outarray_append(&props, p) {
|
||||
* p->queueFlags = ...;
|
||||
* p->queueCount = ...;
|
||||
* }
|
||||
*
|
||||
* return vk_outarray_status(&props);
|
||||
* }
|
||||
*/
|
||||
struct __vk_outarray {
|
||||
/** May be null. */
|
||||
void* data;
|
||||
|
||||
/**
|
||||
* Capacity, in number of elements. Capacity is unlimited (UINT32_MAX) if
|
||||
* data is null.
|
||||
*/
|
||||
uint32_t cap;
|
||||
|
||||
/**
|
||||
* Count of elements successfully written to the array. Every write is
|
||||
* considered successful if data is null.
|
||||
*/
|
||||
uint32_t* filled_len;
|
||||
|
||||
/**
|
||||
* Count of elements that would have been written to the array if its
|
||||
* capacity were sufficient. Vulkan functions often return VK_INCOMPLETE
|
||||
* when `*filled_len < wanted_len`.
|
||||
*/
|
||||
uint32_t wanted_len;
|
||||
};
|
||||
|
||||
static inline void __vk_outarray_init(struct __vk_outarray* a, void* data, uint32_t* len) {
|
||||
a->data = data;
|
||||
a->cap = *len;
|
||||
a->filled_len = len;
|
||||
*a->filled_len = 0;
|
||||
a->wanted_len = 0;
|
||||
|
||||
if (a->data == NULL) a->cap = UINT32_MAX;
|
||||
}
|
||||
|
||||
static inline VkResult __vk_outarray_status(const struct __vk_outarray* a) {
|
||||
if (*a->filled_len < a->wanted_len)
|
||||
return VK_INCOMPLETE;
|
||||
else
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
static inline void* __vk_outarray_next(struct __vk_outarray* a, size_t elem_size) {
|
||||
void* p = NULL;
|
||||
|
||||
a->wanted_len += 1;
|
||||
|
||||
if (*a->filled_len >= a->cap) return NULL;
|
||||
|
||||
if (a->data != NULL) p = ((uint8_t*)a->data) + (*a->filled_len) * elem_size;
|
||||
|
||||
*a->filled_len += 1;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
#define vk_outarray(elem_t) \
|
||||
struct { \
|
||||
struct __vk_outarray base; \
|
||||
elem_t meta[]; \
|
||||
}
|
||||
|
||||
#define vk_outarray_typeof_elem(a) __typeof__((a)->meta[0])
|
||||
#define vk_outarray_sizeof_elem(a) sizeof((a)->meta[0])
|
||||
|
||||
#define vk_outarray_init(a, data, len) __vk_outarray_init(&(a)->base, (data), (len))
|
||||
|
||||
#define VK_OUTARRAY_MAKE(name, data, len) \
|
||||
vk_outarray(__typeof__((data)[0])) name; \
|
||||
vk_outarray_init(&name, (data), (len))
|
||||
|
||||
#define VK_OUTARRAY_MAKE_TYPED(type, name, data, len) \
|
||||
vk_outarray(type) name; \
|
||||
vk_outarray_init(&name, (data), (len))
|
||||
|
||||
#define vk_outarray_status(a) __vk_outarray_status(&(a)->base)
|
||||
|
||||
#define vk_outarray_next(a) vk_outarray_next_typed(vk_outarray_typeof_elem(a), a)
|
||||
#define vk_outarray_next_typed(type, a) \
|
||||
((type*)__vk_outarray_next(&(a)->base, vk_outarray_sizeof_elem(a)))
|
||||
|
||||
/**
|
||||
* Append to a Vulkan output array.
|
||||
*
|
||||
* This is a block-based macro. For example:
|
||||
*
|
||||
* vk_outarray_append(&a, elem) {
|
||||
* elem->foo = ...;
|
||||
* elem->bar = ...;
|
||||
* }
|
||||
*
|
||||
* The array `a` has type `vk_outarray(elem_t) *`. It is usually declared with
|
||||
* VK_OUTARRAY_MAKE(). The variable `elem` is block-scoped and has type
|
||||
* `elem_t *`.
|
||||
*
|
||||
* The macro unconditionally increments the array's `wanted_len`. If the array
|
||||
* is not full, then the macro also increment its `filled_len` and then
|
||||
* executes the block. When the block is executed, `elem` is non-null and
|
||||
* points to the newly appended element.
|
||||
*/
|
||||
#define vk_outarray_append(a, elem) \
|
||||
for (vk_outarray_typeof_elem(a)* elem = vk_outarray_next(a); elem != NULL; elem = NULL)
|
||||
|
||||
#define vk_outarray_append_typed(type, a, elem) \
|
||||
for (type* elem = vk_outarray_next_typed(type, a); elem != NULL; elem = NULL)
|
||||
|
||||
static inline void* __vk_find_struct(void* start, VkStructureType sType) {
|
||||
vk_foreach_struct(s, start) {
|
||||
if (s->sType == sType) return s;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
template <class T, class H>
|
||||
T* vk_find_struct(H* head) {
|
||||
(void)vk_get_vk_struct_id<H>::id;
|
||||
return static_cast<T*>(__vk_find_struct(static_cast<void*>(head), vk_get_vk_struct_id<T>::id));
|
||||
}
|
||||
|
||||
template <class T, class H>
|
||||
const T* vk_find_struct(const H* head) {
|
||||
(void)vk_get_vk_struct_id<H>::id;
|
||||
return static_cast<const T*>(__vk_find_struct(const_cast<void*>(static_cast<const void*>(head)),
|
||||
vk_get_vk_struct_id<T>::id));
|
||||
}
|
||||
|
||||
#define VK_EXT_OFFSET (1000000000UL)
|
||||
#define VK_ENUM_EXTENSION(__enum) \
|
||||
((__enum) >= VK_EXT_OFFSET ? ((((__enum)-VK_EXT_OFFSET) / 1000UL) + 1) : 0)
|
||||
#define VK_ENUM_OFFSET(__enum) ((__enum) >= VK_EXT_OFFSET ? ((__enum) % 1000) : (__enum))
|
||||
|
||||
template <class T>
|
||||
T vk_make_orphan_copy(const T& vk_struct) {
|
||||
T copy = vk_struct;
|
||||
copy.pNext = NULL;
|
||||
return copy;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
vk_struct_chain_iterator vk_make_chain_iterator(T* vk_struct) {
|
||||
(void)vk_get_vk_struct_id<T>::id;
|
||||
vk_struct_chain_iterator result = {reinterpret_cast<vk_struct_common*>(vk_struct)};
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void vk_append_struct(vk_struct_chain_iterator* i, T* vk_struct) {
|
||||
(void)vk_get_vk_struct_id<T>::id;
|
||||
|
||||
vk_struct_common* p = i->value;
|
||||
if (p->pNext) {
|
||||
::abort();
|
||||
}
|
||||
|
||||
p->pNext = reinterpret_cast<vk_struct_common*>(vk_struct);
|
||||
vk_struct->pNext = NULL;
|
||||
|
||||
*i = vk_make_chain_iterator(vk_struct);
|
||||
}
|
||||
|
||||
bool vk_descriptor_type_has_descriptor_buffer(VkDescriptorType type) {
|
||||
switch (type) {
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif /* VK_UTIL_H */
|
||||
Loading…
Add table
Reference in a new issue