Merge pull request #373 from cdavis5e/bind-memory2

Support the VK_KHR_bind_memory2 extension.
This commit is contained in:
Bill Hollings 2018-12-06 15:05:54 -05:00 committed by GitHub
commit ffb4406388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 58 additions and 0 deletions

View File

@ -223,6 +223,7 @@ In addition to the core *Vulkan* API, **MoltenVK** also supports the following
- `VK_KHR_16bit_storage`
- `VK_KHR_8bit_storage`
- `VK_KHR_bind_memory2`
- `VK_KHR_dedicated_allocation`
- `VK_KHR_descriptor_update_template`
- `VK_KHR_get_memory_requirements2`

View File

@ -283,6 +283,8 @@ void MVKInstance::initProcAddrs() {
ADD_PROC_ADDR(vkCmdExecuteCommands);
// Supported extensions:
ADD_PROC_ADDR(vkBindBufferMemory2KHR);
ADD_PROC_ADDR(vkBindImageMemory2KHR);
ADD_PROC_ADDR(vkCreateDescriptorUpdateTemplateKHR);
ADD_PROC_ADDR(vkDestroyDescriptorUpdateTemplateKHR);
ADD_PROC_ADDR(vkUpdateDescriptorSetWithTemplateKHR);

View File

@ -47,6 +47,9 @@ public:
/** Binds this resource to the specified offset within the specified memory allocation. */
virtual VkResult bindDeviceMemory(MVKDeviceMemory* mvkMem, VkDeviceSize memOffset);
/** Binds this resource according to the specified bind information. */
virtual VkResult bindDeviceMemory2(const void* pBindInfo);
/** Returns the device memory underlying this resource. */
inline MVKDeviceMemory* getDeviceMemory() { return _deviceMemory; }

View File

@ -20,6 +20,18 @@
#include "MVKCommandBuffer.h"
struct MVKBindDeviceMemoryInfo {
VkStructureType sType;
void* pNext;
union {
VkBuffer buffer;
VkImage image;
};
VkDeviceMemory memory;
VkDeviceSize memoryOffset;
};
#pragma mark MVKResource
VkResult MVKResource::bindDeviceMemory(MVKDeviceMemory* mvkMem, VkDeviceSize memOffset) {
@ -33,6 +45,11 @@ VkResult MVKResource::bindDeviceMemory(MVKDeviceMemory* mvkMem, VkDeviceSize mem
return VK_SUCCESS;
}
VkResult MVKResource::bindDeviceMemory2(const void* pBindInfo) {
auto* mvkBindInfo = (const MVKBindDeviceMemoryInfo*)pBindInfo;
return bindDeviceMemory((MVKDeviceMemory*)mvkBindInfo->memory, mvkBindInfo->memoryOffset);
}
// Returns whether the specified global memory barrier requires a sync between this
// texture and host memory for the purpose of the host reading texture memory.
bool MVKResource::needsHostReadSync(VkPipelineStageFlags srcStageMask,

View File

@ -32,6 +32,7 @@
MVK_EXTENSION(KHR_16bit_storage, KHR_16BIT_STORAGE)
MVK_EXTENSION(KHR_8bit_storage, KHR_8BIT_STORAGE)
MVK_EXTENSION(KHR_bind_memory2, KHR_BIND_MEMORY_2)
MVK_EXTENSION(KHR_dedicated_allocation, KHR_DEDICATED_ALLOCATION)
MVK_EXTENSION(KHR_descriptor_update_template, KHR_DESCRIPTOR_UPDATE_TEMPLATE)
MVK_EXTENSION(KHR_get_memory_requirements2, KHR_GET_MEMORY_REQUIREMENTS_2)

View File

@ -1474,6 +1474,40 @@ MVK_PUBLIC_SYMBOL void vkCmdExecuteCommands(
}
#pragma mark -
#pragma mark VK_KHR_bind_memory2 extension
MVK_PUBLIC_SYMBOL VkResult vkBindBufferMemory2KHR(
VkDevice device,
uint32_t bindInfoCount,
const VkBindBufferMemoryInfoKHR* pBindInfos) {
VkResult res;
for (uint32_t i = 0; i < bindInfoCount; ++i) {
MVKBuffer* mvkBuff = (MVKBuffer*)pBindInfos[i].buffer;
res = mvkBuff->bindDeviceMemory2(&pBindInfos[i]);
if (res != VK_SUCCESS) {
break;
}
}
return res;
}
MVK_PUBLIC_SYMBOL VkResult vkBindImageMemory2KHR(
VkDevice device,
uint32_t bindInfoCount,
const VkBindImageMemoryInfoKHR* pBindInfos) {
VkResult res;
for (uint32_t i = 0; i < bindInfoCount; ++i) {
MVKImage* mvkImg = (MVKImage*)pBindInfos[i].image;
res = mvkImg->bindDeviceMemory2(&pBindInfos[i]);
if (res != VK_SUCCESS) {
break;
}
}
return res;
}
#pragma mark -
#pragma mark VK_KHR_descriptor_update_template extension