Add support for VK_KHR_get_memory_requirements2 & dedicated_allocation

* Unverified as yet, but the former is relatively straightforward and
  not serialised, and the latter is quite similar to the NV dedicated
  allocation extension.
This commit is contained in:
baldurk
2017-07-21 18:33:46 +01:00
parent 001b6b4e92
commit d539fed918
6 changed files with 133 additions and 24 deletions
+2 -1
View File
@@ -3170,7 +3170,8 @@ static void SerialiseNext(Serialiser *ser, VkStructureType &sType, const void *&
// it might be helpful to serialise this for informational purposes.
else if(next->sType == VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV ||
next->sType == VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_IMAGE_CREATE_INFO_NV ||
next->sType == VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_BUFFER_CREATE_INFO_NV)
next->sType == VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_BUFFER_CREATE_INFO_NV ||
next->sType == VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR)
{
// do nothing
}
+6
View File
@@ -765,6 +765,9 @@ static const VkExtensionProperties supportedExtensions[] = {
VK_KHR_ANDROID_SURFACE_EXTENSION_NAME, VK_KHR_ANDROID_SURFACE_SPEC_VERSION,
},
#endif
{
VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME, VK_KHR_DEDICATED_ALLOCATION_SPEC_VERSION,
},
#ifdef VK_KHR_display
{
VK_KHR_DISPLAY_EXTENSION_NAME, VK_KHR_DISPLAY_SPEC_VERSION,
@@ -805,6 +808,9 @@ static const VkExtensionProperties supportedExtensions[] = {
VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME, VK_KHR_EXTERNAL_SEMAPHORE_WIN32_SPEC_VERSION,
},
#endif
{
VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME, VK_KHR_GET_MEMORY_REQUIREMENTS_2_SPEC_VERSION,
},
{
VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME,
VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_SPEC_VERSION,
+12
View File
@@ -1524,4 +1524,16 @@ public:
VkResult vkImportSemaphoreFdKHR(VkDevice device,
const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo);
VkResult vkGetSemaphoreFdKHR(VkDevice device, const VkSemaphoreGetFdInfoKHR *pGetFdInfo, int *pFd);
// VK_KHR_get_memory_requirements2
void vkGetImageMemoryRequirements2KHR(VkDevice device,
const VkImageMemoryRequirementsInfo2KHR *pInfo,
VkMemoryRequirements2KHR *pMemoryRequirements);
void vkGetBufferMemoryRequirements2KHR(VkDevice device,
const VkBufferMemoryRequirementsInfo2KHR *pInfo,
VkMemoryRequirements2KHR *pMemoryRequirements);
void vkGetImageSparseMemoryRequirements2KHR(
VkDevice device, const VkImageSparseMemoryRequirementsInfo2KHR *pInfo,
uint32_t *pSparseMemoryRequirementCount,
VkSparseImageMemoryRequirements2KHR *pSparseMemoryRequirements);
};
+36 -22
View File
@@ -282,7 +282,8 @@
CheckExt(VK_EXT_direct_mode_display); \
CheckExt(VK_EXT_acquire_xlib_display); \
CheckExt(VK_KHR_external_memory_capabilities); \
CheckExt(VK_KHR_external_semaphore_capabilities);
CheckExt(VK_KHR_external_semaphore_capabilities); \
CheckExt(VK_KHR_get_memory_requirements2);
#define CheckDeviceExts() \
CheckExt(VK_EXT_debug_marker); \
@@ -336,27 +337,30 @@
GetPhysicalDeviceExternalSemaphorePropertiesKHR); \
HookInitInstance_PlatformSpecific()
#define HookInitVulkanDeviceExts() \
HookInitExtension(VK_EXT_debug_marker, DebugMarkerSetObjectTagEXT); \
HookInitExtension(VK_EXT_debug_marker, DebugMarkerSetObjectNameEXT); \
HookInitExtension(VK_EXT_debug_marker, CmdDebugMarkerBeginEXT); \
HookInitExtension(VK_EXT_debug_marker, CmdDebugMarkerEndEXT); \
HookInitExtension(VK_EXT_debug_marker, CmdDebugMarkerInsertEXT); \
HookInitExtension(VK_KHR_swapchain, CreateSwapchainKHR); \
HookInitExtension(VK_KHR_swapchain, DestroySwapchainKHR); \
HookInitExtension(VK_KHR_swapchain, GetSwapchainImagesKHR); \
HookInitExtension(VK_KHR_swapchain, AcquireNextImageKHR); \
HookInitExtension(VK_KHR_swapchain, QueuePresentKHR); \
HookInitExtension(VK_KHR_display_swapchain, CreateSharedSwapchainsKHR); \
HookInitExtension(VK_KHR_maintenance1, TrimCommandPoolKHR); \
HookInitExtension(VK_EXT_display_control, DisplayPowerControlEXT); \
HookInitExtension(VK_EXT_display_control, RegisterDeviceEventEXT); \
HookInitExtension(VK_EXT_display_control, RegisterDisplayEventEXT); \
HookInitExtension(VK_EXT_display_control, GetSwapchainCounterEXT); \
HookInitExtension(VK_KHR_external_memory_fd, GetMemoryFdKHR); \
HookInitExtension(VK_KHR_external_memory_fd, GetMemoryFdPropertiesKHR); \
HookInitExtension(VK_KHR_external_semaphore_fd, ImportSemaphoreFdKHR); \
HookInitExtension(VK_KHR_external_semaphore_fd, GetSemaphoreFdKHR); \
#define HookInitVulkanDeviceExts() \
HookInitExtension(VK_EXT_debug_marker, DebugMarkerSetObjectTagEXT); \
HookInitExtension(VK_EXT_debug_marker, DebugMarkerSetObjectNameEXT); \
HookInitExtension(VK_EXT_debug_marker, CmdDebugMarkerBeginEXT); \
HookInitExtension(VK_EXT_debug_marker, CmdDebugMarkerEndEXT); \
HookInitExtension(VK_EXT_debug_marker, CmdDebugMarkerInsertEXT); \
HookInitExtension(VK_KHR_swapchain, CreateSwapchainKHR); \
HookInitExtension(VK_KHR_swapchain, DestroySwapchainKHR); \
HookInitExtension(VK_KHR_swapchain, GetSwapchainImagesKHR); \
HookInitExtension(VK_KHR_swapchain, AcquireNextImageKHR); \
HookInitExtension(VK_KHR_swapchain, QueuePresentKHR); \
HookInitExtension(VK_KHR_display_swapchain, CreateSharedSwapchainsKHR); \
HookInitExtension(VK_KHR_maintenance1, TrimCommandPoolKHR); \
HookInitExtension(VK_EXT_display_control, DisplayPowerControlEXT); \
HookInitExtension(VK_EXT_display_control, RegisterDeviceEventEXT); \
HookInitExtension(VK_EXT_display_control, RegisterDisplayEventEXT); \
HookInitExtension(VK_EXT_display_control, GetSwapchainCounterEXT); \
HookInitExtension(VK_KHR_external_memory_fd, GetMemoryFdKHR); \
HookInitExtension(VK_KHR_external_memory_fd, GetMemoryFdPropertiesKHR); \
HookInitExtension(VK_KHR_external_semaphore_fd, ImportSemaphoreFdKHR); \
HookInitExtension(VK_KHR_external_semaphore_fd, GetSemaphoreFdKHR); \
HookInitExtension(VK_KHR_get_memory_requirements2, GetBufferMemoryRequirements2KHR); \
HookInitExtension(VK_KHR_get_memory_requirements2, GetImageMemoryRequirements2KHR); \
HookInitExtension(VK_KHR_get_memory_requirements2, GetImageSparseMemoryRequirements2KHR); \
HookInitDevice_PlatformSpecific()
#define DefineHooks() \
@@ -757,6 +761,16 @@
const VkImportSemaphoreFdInfoKHR *, pImportSemaphoreFdInfo); \
HookDefine3(VkResult, vkGetSemaphoreFdKHR, VkDevice, device, const VkSemaphoreGetFdInfoKHR *, \
pGetFdInfo, int *, pFd); \
HookDefine3(void, vkGetImageMemoryRequirements2KHR, VkDevice, device, \
const VkImageMemoryRequirementsInfo2KHR *, pInfo, VkMemoryRequirements2KHR *, \
pMemoryRequirements); \
HookDefine3(void, vkGetBufferMemoryRequirements2KHR, VkDevice, device, \
const VkBufferMemoryRequirementsInfo2KHR *, pInfo, VkMemoryRequirements2KHR *, \
pMemoryRequirements); \
HookDefine4(void, vkGetImageSparseMemoryRequirements2KHR, VkDevice, device, \
const VkImageSparseMemoryRequirementsInfo2KHR *, pInfo, uint32_t *, \
pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements2KHR *, \
pSparseMemoryRequirements); \
HookDefine_PlatformSpecific()
struct VkLayerInstanceDispatchTableExtended : VkLayerInstanceDispatchTable
@@ -170,6 +170,67 @@ void WrappedVulkan::vkGetImageSparseMemoryRequirements(
pSparseMemoryRequirements);
}
void WrappedVulkan::vkGetBufferMemoryRequirements2KHR(VkDevice device,
const VkBufferMemoryRequirementsInfo2KHR *pInfo,
VkMemoryRequirements2KHR *pMemoryRequirements)
{
VkBufferMemoryRequirementsInfo2KHR unwrappedInfo = *pInfo;
unwrappedInfo.buffer = Unwrap(unwrappedInfo.buffer);
ObjDisp(device)->GetBufferMemoryRequirements2KHR(Unwrap(device), &unwrappedInfo,
pMemoryRequirements);
// don't do remapping here on replay.
if(m_State < WRITING)
return;
uint32_t bits = pMemoryRequirements->memoryRequirements.memoryTypeBits;
uint32_t *memIdxMap = GetRecord(device)->memIdxMap;
pMemoryRequirements->memoryRequirements.memoryTypeBits = 0;
// for each of our fake memory indices, check if the real
// memory type it points to is set - if so, set our fake bit
for(uint32_t i = 0; i < VK_MAX_MEMORY_TYPES; i++)
if(memIdxMap[i] < 32U && (bits & (1U << memIdxMap[i])))
pMemoryRequirements->memoryRequirements.memoryTypeBits |= (1U << i);
}
void WrappedVulkan::vkGetImageMemoryRequirements2KHR(VkDevice device,
const VkImageMemoryRequirementsInfo2KHR *pInfo,
VkMemoryRequirements2KHR *pMemoryRequirements)
{
VkImageMemoryRequirementsInfo2KHR unwrappedInfo = *pInfo;
unwrappedInfo.image = Unwrap(unwrappedInfo.image);
ObjDisp(device)->GetImageMemoryRequirements2KHR(Unwrap(device), &unwrappedInfo,
pMemoryRequirements);
// don't do remapping here on replay.
if(m_State < WRITING)
return;
uint32_t bits = pMemoryRequirements->memoryRequirements.memoryTypeBits;
uint32_t *memIdxMap = GetRecord(device)->memIdxMap;
pMemoryRequirements->memoryRequirements.memoryTypeBits = 0;
// for each of our fake memory indices, check if the real
// memory type it points to is set - if so, set our fake bit
for(uint32_t i = 0; i < VK_MAX_MEMORY_TYPES; i++)
if(memIdxMap[i] < 32U && (bits & (1U << memIdxMap[i])))
pMemoryRequirements->memoryRequirements.memoryTypeBits |= (1U << i);
}
void WrappedVulkan::vkGetImageSparseMemoryRequirements2KHR(
VkDevice device, const VkImageSparseMemoryRequirementsInfo2KHR *pInfo,
uint32_t *pSparseMemoryRequirementCount,
VkSparseImageMemoryRequirements2KHR *pSparseMemoryRequirements)
{
VkImageSparseMemoryRequirementsInfo2KHR unwrappedInfo = *pInfo;
unwrappedInfo.image = Unwrap(unwrappedInfo.image);
ObjDisp(device)->GetImageSparseMemoryRequirements2KHR(
Unwrap(device), &unwrappedInfo, pSparseMemoryRequirementCount, pSparseMemoryRequirements);
}
void WrappedVulkan::vkGetDeviceMemoryCommitment(VkDevice device, VkDeviceMemory memory,
VkDeviceSize *pCommittedMemoryInBytes)
{
@@ -270,9 +270,11 @@ VkResult WrappedVulkan::vkAllocateMemory(VkDevice device, const VkMemoryAllocate
const VkGenericStruct *next = (const VkGenericStruct *)info.pNext;
while(next)
{
// we need to unwrap this struct
// we need to unwrap these structs
if(next->sType == VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV)
memSize += sizeof(VkDedicatedAllocationMemoryAllocateInfoNV);
else if(next->sType == VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR)
memSize += sizeof(VkMemoryDedicatedAllocateInfoKHR);
// the rest we don't need to unwrap, but we need to copy locally for chaining
else if(next->sType == VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_NV)
memSize += sizeof(VkExportMemoryAllocateInfoNV);
@@ -331,6 +333,19 @@ VkResult WrappedVulkan::vkAllocateMemory(VkDevice device, const VkMemoryAllocate
AppendModifiedChainedStruct(tempMem, dedicatedOut, nextChainTail);
}
else if(nextInput->sType == VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR)
{
const VkMemoryDedicatedAllocateInfoKHR *dedicatedIn =
(const VkMemoryDedicatedAllocateInfoKHR *)nextInput;
VkMemoryDedicatedAllocateInfoKHR *dedicatedOut = (VkMemoryDedicatedAllocateInfoKHR *)tempMem;
// copy and unwrap the struct
dedicatedOut->sType = dedicatedIn->sType;
dedicatedOut->buffer = Unwrap(dedicatedIn->buffer);
dedicatedOut->image = Unwrap(dedicatedIn->image);
AppendModifiedChainedStruct(tempMem, dedicatedOut, nextChainTail);
}
else if(nextInput->sType == VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_NV)
{
CopyNextChainedStruct<VkExportMemoryAllocateInfoNV>(tempMem, nextInput, nextChainTail);