Skip to content

Commit

Permalink
Merge pull request #845 from billhollings/master
Browse files Browse the repository at this point in the history
Do not create depth/stencil MTLTextures from MTLHeap.
  • Loading branch information
billhollings authored Mar 30, 2020
2 parents d04dc46 + b882161 commit d256991
Show file tree
Hide file tree
Showing 17 changed files with 310 additions and 338 deletions.
5 changes: 4 additions & 1 deletion Common/MVKOSExtensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ typedef float MVKOSVersion;
* - (10.12.3) => 10.1203
* - (8.0.2) => 8.0002
*/
MVKOSVersion mvkOSVersion(void);
MVKOSVersion mvkOSVersion();

/** Returns whether the operating system version is at least minVer. */
inline bool mvkOSVersionIsAtLeast(MVKOSVersion minVer) { return mvkOSVersion() >= minVer; }

/**
* Returns a monotonic timestamp value for use in Vulkan and performance timestamping.
Expand Down
2 changes: 1 addition & 1 deletion Common/MVKOSExtensions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ uint64_t mvkGetSystemMemorySize() {

uint64_t mvkGetAvailableMemorySize() {
#if MVK_IOS
if (mvkOSVersion() >= 13.0) { return os_proc_available_memory(); }
if (mvkOSVersionIsAtLeast(13.0)) { return os_proc_available_memory(); }
#endif
mach_port_t host_port;
mach_msg_type_number_t host_size;
Expand Down
6 changes: 3 additions & 3 deletions MoltenVK/MoltenVK/API/mvk_datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ VkImageType mvkVkImageTypeFromMTLTextureType(MTLTextureType mtlTextureType);
/** Returns the Metal MTLTextureType corresponding to the Vulkan VkImageViewType. */
MTLTextureType mvkMTLTextureTypeFromVkImageViewType(VkImageViewType vkImageViewType, bool isMultisample);

/** Returns the Metal texture usage from the Vulkan image usage. */
MTLTextureUsage mvkMTLTextureUsageFromVkImageUsageFlags(VkImageUsageFlags vkImageUsageFlags);
/** Returns the Metal texture usage from the Vulkan image usage taking into considertion usage limits for the pixel format. */
MTLTextureUsage mvkMTLTextureUsageFromVkImageUsageFlags(VkImageUsageFlags vkImageUsageFlags, MTLPixelFormat mtlPixFmt);

/** Returns the Vulkan image usage from the Metal texture usage and format. */
VkImageUsageFlags mvkVkImageUsageFlagsFromMTLTextureUsage(MTLTextureUsage mtlUsage, MTLPixelFormat mtlFormat);
Expand Down Expand Up @@ -357,7 +357,7 @@ MTLTriangleFillMode mvkMTLTriangleFillModeFromVkPolygonMode(VkPolygonMode vkFill
MTLLoadAction mvkMTLLoadActionFromVkAttachmentLoadOp(VkAttachmentLoadOp vkLoadOp);

/** Returns the Metal MTLStoreAction corresponding to the specified Vulkan VkAttachmentStoreOp. */
MTLStoreAction mvkMTLStoreActionFromVkAttachmentStoreOp(VkAttachmentStoreOp vkStoreOp, bool hasResolveAttachment = false);
MTLStoreAction mvkMTLStoreActionFromVkAttachmentStoreOp(VkAttachmentStoreOp vkStoreOp, bool hasResolveAttachment);

/** Returns the Metal MTLViewport corresponding to the specified Vulkan VkViewport. */
MTLViewport mvkMTLViewportFromVkViewport(VkViewport vkViewport);
Expand Down
5 changes: 3 additions & 2 deletions MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1095,8 +1095,9 @@ static inline MTLSize mvkClampMTLSize(MTLSize size, MTLOrigin origin, MTLSize ma
if (_image->getImageType() == VK_IMAGE_TYPE_1D) {
setConfigurationResult(reportError(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdClearImage(): Native 1D images cannot be cleared on this device. Consider enabling MVK_CONFIG_TEXTURE_1D_AS_2D."));
}
if ((_isDepthStencilClear && !_image->getSupportsAllFormatFeatures(VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) ||
(!_isDepthStencilClear && !_image->getSupportsAllFormatFeatures(VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))) {
MVKMTLFmtCaps mtlFmtCaps = getPixelFormats()->getMTLPixelFormatCapabilities(_image->getMTLPixelFormat());
if ((_isDepthStencilClear && !mvkAreAllFlagsEnabled(mtlFmtCaps, kMVKMTLFmtCapsDSAtt)) ||
( !_isDepthStencilClear && !mvkAreAllFlagsEnabled(mtlFmtCaps, kMVKMTLFmtCapsColorAtt))) {
setConfigurationResult(reportError(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdClearImage(): Format %s cannot be cleared on this device.", getPixelFormats()->getVkFormatName(_image->getVkFormat())));
}
}
Expand Down
3 changes: 0 additions & 3 deletions MoltenVK/MoltenVK/GPUObjects/MVKDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,6 @@ class MVKPhysicalDevice : public MVKDispatchableVulkanAPIObject {

#pragma mark Metal

/** Returns whether the underlying MTLDevice supports the GPU family. */
bool getSupportsGPUFamily(MTLGPUFamily gpuFamily);

/** Populates the specified structure with the Metal-specific features of this device. */
inline const MVKPhysicalDeviceMetalFeatures* getMetalFeatures() { return &_metalFeatures; }

Expand Down
Loading

0 comments on commit d256991

Please sign in to comment.