Skip to content

Commit

Permalink
Merge pull request #815 from Cry-Mory/master
Browse files Browse the repository at this point in the history
Adds support for vkGetMTLBufferMVK
  • Loading branch information
billhollings authored Jan 21, 2020
2 parents 06e41fa + 0d8f27d commit 7eba92b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions MoltenVK/MoltenVK/API/vk_mvk_moltenvk.h
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ typedef void (VKAPI_PTR *PFN_vkGetVersionStringsMVK)(char* pMoltenVersionStringB
typedef void (VKAPI_PTR *PFN_vkGetMTLDeviceMVK)(VkPhysicalDevice physicalDevice, id<MTLDevice>* pMTLDevice);
typedef VkResult (VKAPI_PTR *PFN_vkSetMTLTextureMVK)(VkImage image, id<MTLTexture> mtlTexture);
typedef void (VKAPI_PTR *PFN_vkGetMTLTextureMVK)(VkImage image, id<MTLTexture>* pMTLTexture);
typedef void (VKAPI_PTR *PFN_vkGetMTLBufferMVK)(VkBuffer buffer, id<MTLBuffer>* pMTLBuffer);
typedef VkResult (VKAPI_PTR *PFN_vkUseIOSurfaceMVK)(VkImage image, IOSurfaceRef ioSurface);
typedef void (VKAPI_PTR *PFN_vkGetIOSurfaceMVK)(VkImage image, IOSurfaceRef* pIOSurface);
#endif // __OBJC__
Expand Down Expand Up @@ -927,6 +928,19 @@ VKAPI_ATTR void VKAPI_CALL vkGetMTLTextureMVK(
VkImage image,
id<MTLTexture>* pMTLTexture);

/**
* Returns, in the pMTLBuffer pointer, the MTLBuffer currently underlaying the VkBuffer.
*
* This function is not supported by the Vulkan SDK Loader and Layers framework.
* The VkBuffer object you provide here must have been retrieved directly from
* MoltenVK, and not through the Vulkan SDK Loader and Layers framework. Opaque Vulkan
* objects are often changed by layers, and passing them from one layer to another,
* or from a layer directly to MoltenVK, will result in undefined behaviour.
*/
VKAPI_ATTR void VKAPI_CALL vkGetMTLBufferMVK(
VkBuffer buffer,
id<MTLBuffer>* pMTLBuffer);

/**
* Indicates that a VkImage should use an IOSurface to underlay the Metal texture.
*
Expand Down
1 change: 1 addition & 0 deletions MoltenVK/MoltenVK/GPUObjects/MVKInstance.mm
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@
ADD_INST_EXT_ENTRY_POINT(vkGetMTLDeviceMVK, MVK_MOLTENVK);
ADD_INST_EXT_ENTRY_POINT(vkSetMTLTextureMVK, MVK_MOLTENVK);
ADD_INST_EXT_ENTRY_POINT(vkGetMTLTextureMVK, MVK_MOLTENVK);
ADD_INST_EXT_ENTRY_POINT(vkGetMTLBufferMVK, MVK_MOLTENVK);
ADD_INST_EXT_ENTRY_POINT(vkUseIOSurfaceMVK, MVK_MOLTENVK);
ADD_INST_EXT_ENTRY_POINT(vkGetIOSurfaceMVK, MVK_MOLTENVK);

Expand Down
9 changes: 9 additions & 0 deletions MoltenVK/MoltenVK/Vulkan/vk_mvk_moltenvk.mm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "MVKEnvironment.h"
#include "MVKSwapchain.h"
#include "MVKImage.h"
#include "MVKBuffer.h"
#include "MVKFoundation.h"
#include "MVKShaderModule.h"
#include <string>
Expand Down Expand Up @@ -133,6 +134,14 @@ MVK_PUBLIC_SYMBOL void vkGetMTLTextureMVK(
*pMTLTexture = mvkImg->getMTLTexture();
}

MVK_PUBLIC_SYMBOL void vkGetMTLBufferMVK(
VkBuffer buffer,
id<MTLBuffer>* pMTLBuffer) {

MVKBuffer* mvkBuffer = (MVKBuffer*)buffer;
*pMTLBuffer = mvkBuffer->getMTLBuffer();
}

MVK_PUBLIC_SYMBOL VkResult vkUseIOSurfaceMVK(
VkImage image,
IOSurfaceRef ioSurface) {
Expand Down

0 comments on commit 7eba92b

Please sign in to comment.