Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/KhronosGroup/MoltenVK
Browse files Browse the repository at this point in the history
  • Loading branch information
billhollings committed Nov 6, 2018
2 parents 38160b3 + 8a807b7 commit 759bb6d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
7 changes: 7 additions & 0 deletions MoltenVK/MoltenVK/GPUObjects/MVKDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ class MVKPhysicalDevice : public MVKDispatchableObject {
*/
inline uint32_t getHostVisibleMemoryTypes() { return _hostVisibleMemoryTypes; }

/**
* Returns a bit mask of all memory type indices that are coherent between host and device.
* Each bit [0..31] in the returned bit mask indicates a distinct memory type.
*/
inline uint32_t getHostCoherentMemoryTypes() { return _hostCoherentMemoryTypes; }

/**
* Returns a bit mask of all memory type indices that do NOT allow host visibility to the memory.
* Each bit [0..31] in the returned bit mask indicates a distinct memory type.
Expand Down Expand Up @@ -277,6 +283,7 @@ class MVKPhysicalDevice : public MVKDispatchableObject {
std::vector<MVKQueueFamily*> _queueFamilies;
uint32_t _allMemoryTypes;
uint32_t _hostVisibleMemoryTypes;
uint32_t _hostCoherentMemoryTypes;
uint32_t _privateMemoryTypes;
};

Expand Down
14 changes: 8 additions & 6 deletions MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1091,15 +1091,17 @@

#if MVK_MACOS
_memoryProperties.memoryTypeCount = 3;
_privateMemoryTypes = 0x1; // Private only
_hostVisibleMemoryTypes = 0x6; // Shared & managed
_allMemoryTypes = 0x7; // Private, shared, & managed
_privateMemoryTypes = 0x1; // Private only
_hostCoherentMemoryTypes = 0x4; // Shared only
_hostVisibleMemoryTypes = 0x6; // Shared & managed
_allMemoryTypes = 0x7; // Private, shared, & managed
#endif
#if MVK_IOS
_memoryProperties.memoryTypeCount = 2; // Managed storage not available on iOS
_privateMemoryTypes = 0x1; // Private only
_hostVisibleMemoryTypes = 0x2; // Shared only
_allMemoryTypes = 0x3; // Private & shared
_privateMemoryTypes = 0x1; // Private only
_hostCoherentMemoryTypes = 0x2; // Shared only
_hostVisibleMemoryTypes = 0x2; // Shared only
_allMemoryTypes = 0x3; // Private & shared
#endif
}

Expand Down
5 changes: 5 additions & 0 deletions MoltenVK/MoltenVK/GPUObjects/MVKImage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@
pMemoryRequirements->memoryTypeBits = (_isDepthStencilAttachment
? _device->getPhysicalDevice()->getPrivateMemoryTypes()
: _device->getPhysicalDevice()->getAllMemoryTypes());
#if MVK_MACOS
if (!_isLinear) { // XXX Linear images must support host-coherent memory
mvkDisableFlag(pMemoryRequirements->memoryTypeBits, _device->getPhysicalDevice()->getHostCoherentMemoryTypes());
}
#endif
return VK_SUCCESS;
}

Expand Down

0 comments on commit 759bb6d

Please sign in to comment.