Merge pull request #373 from cdavis5e/bind-memory2
Support the VK_KHR_bind_memory2 extension.
This commit is contained in:
commit
ffb4406388
@ -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`
|
||||
|
@ -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);
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user