Skip to content

Commit

Permalink
Merge pull request #166 from billhollings/master
Browse files Browse the repository at this point in the history
vkGetPhysicalDeviceImageFormatProperties returns VK_ERROR_FORMAT_NOT_SUPPORTED.
  • Loading branch information
billhollings authored May 23, 2018
2 parents 9e5e1ee + 442dd2d commit fff5ec9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
6 changes: 6 additions & 0 deletions MoltenVK/MoltenVK/API/mvk_datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ typedef enum {
kMVKFormatDepthStencil, /**< A depth and stencil value. */
} MVKFormatType;

/** Returns whether the VkFormat is supported by this implementation. */
bool mvkVkFormatIsSupported(VkFormat vkFormat);

/** Returns whether the MTLPixelFormat is supported by this implementation. */
bool mvkMTLPixelFormatIsSupported(MTLPixelFormat mtlFormat);

/** Returns the format type corresponding to the specified Vulkan VkFormat, */
MVKFormatType mvkFormatTypeFromVkFormat(VkFormat vkFormat);

Expand Down
2 changes: 1 addition & 1 deletion MoltenVK/MoltenVK/API/vk_mvk_moltenvk.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ typedef struct {
VkBool32 displayWatermark; /**< If enabled, a MoltenVK logo watermark will be rendered on top of the scene. This can be enabled for publicity during demos. Default value is true if the MVK_DISPLAY_WATERMARK build setting is defined when MoltenVK is compiled, and false otherwise. By default the MVK_DISPLAY_WATERMARK build setting is not defined. */
VkBool32 performanceTracking; /**< If enabled, per-frame performance statistics are tracked, optionally logged, and can be retrieved via the vkGetSwapchainPerformanceMVK() function, and various performance statistics are tracked, logged, and can be retrieved via the vkGetPerformanceStatisticsMVK() function. Default value is true in the presence of the DEBUG build setting, and false otherwise. */
uint32_t performanceLoggingFrameCount; /**< If non-zero, performance statistics will be periodically logged to the console, on a repeating cycle of this many frames per swapchain. The performanceTracking capability must also be enabled. Default value is 300 in the presence of the DEBUG build setting, and zero otherwise. */
uint64_t metalCompileTimeout; /**< The maximum amount of time, in nanoseconds, to wait for a Metal library, function or pipeline state object to be compiled and created. If an internal error occurs with the Metal compiler, it can stall the thread for up to 30 seconds. Setting this value limits the delay to that amount of time. Default value is infinite in the presence of the DEBUG build setting, and 125,000,000 (125 ms) otherwise. */
uint64_t metalCompileTimeout; /**< The maximum amount of time, in nanoseconds, to wait for a Metal library, function or pipeline state object to be compiled and created. If an internal error occurs with the Metal compiler, it can stall the thread for up to 30 seconds. Setting this value limits the delay to that amount of time. Default value is infinite. */
} MVKDeviceConfiguration;

/** Features provided by the current implementation of Metal on the current device. */
Expand Down
7 changes: 5 additions & 2 deletions MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@
VkImageUsageFlags usage,
VkImageCreateFlags flags,
VkImageFormatProperties* pImageFormatProperties) {
if (!pImageFormatProperties) { return VK_SUCCESS; }

if ( !mvkVkFormatIsSupported(format) ) { return VK_ERROR_FORMAT_NOT_SUPPORTED; }

if ( !pImageFormatProperties ) { return VK_SUCCESS; }

VkPhysicalDeviceLimits* pLimits = &_properties.limits;
VkExtent3D maxExt;
Expand Down Expand Up @@ -1451,7 +1454,7 @@
pCfg->displayWatermark = MVK_DISPLAY_WATERMARK_BOOL;
pCfg->performanceTracking = MVK_DEBUG;
pCfg->performanceLoggingFrameCount = MVK_DEBUG ? 300 : 0;
pCfg->metalCompileTimeout = MVK_DEBUG ? UINT64_MAX : (125 * 1000 * 1000);
pCfg->metalCompileTimeout = numeric_limits<int64_t>::max();

_globalVisibilityResultMTLBuffer = nil;
_globalVisibilityQueryCount = 0;
Expand Down
26 changes: 17 additions & 9 deletions MoltenVK/MoltenVK/Vulkan/mvk_datatypes.mm
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,26 @@ static void MVKInitFormatMaps() {

// Return a reference to the format description corresponding to the MTLPixelFormat.
inline const MVKFormatDesc& formatDescForMTLPixelFormat(MTLPixelFormat mtlFormat) {
uint16_t fmtIdx = _fmtDescIndicesByMTLPixelFormats[mtlFormat];
uint16_t fmtIdx = (mtlFormat < _mtlFormatCount) ? _fmtDescIndicesByMTLPixelFormats[mtlFormat] : 0;
return _formatDescriptions[fmtIdx];
}

MVK_PUBLIC_SYMBOL bool mvkVkFormatIsSupported(VkFormat vkFormat) {
return formatDescForVkFormat(vkFormat).isSupported();
}

MVK_PUBLIC_SYMBOL bool mvkMTLPixelFormatIsSupported(MTLPixelFormat mtlFormat) {
return formatDescForMTLPixelFormat(mtlFormat).isSupported();
}

MVK_PUBLIC_SYMBOL MVKFormatType mvkFormatTypeFromVkFormat(VkFormat vkFormat) {
return formatDescForVkFormat(vkFormat).formatType;
}

MVK_PUBLIC_SYMBOL MVKFormatType mvkFormatTypeFromMTLPixelFormat(MTLPixelFormat mtlFormat) {
return formatDescForMTLPixelFormat(mtlFormat).formatType;
}

MVK_PUBLIC_SYMBOL MTLPixelFormat mvkMTLPixelFormatFromVkFormat(VkFormat vkFormat) {
MTLPixelFormat mtlPixFmt = MTLPixelFormatInvalid;

Expand Down Expand Up @@ -530,14 +546,6 @@ MVK_PUBLIC_SYMBOL MTLPixelFormat mvkMTLPixelFormatFromVkFormat(VkFormat vkFormat
return mtlPixFmt;
}

MVK_PUBLIC_SYMBOL MVKFormatType mvkFormatTypeFromVkFormat(VkFormat vkFormat) {
return formatDescForVkFormat(vkFormat).formatType;
}

MVK_PUBLIC_SYMBOL MVKFormatType mvkFormatTypeFromMTLPixelFormat(MTLPixelFormat mtlFormat) {
return formatDescForMTLPixelFormat(mtlFormat).formatType;
}

MVK_PUBLIC_SYMBOL VkFormat mvkVkFormatFromMTLPixelFormat(MTLPixelFormat mtlFormat) {
return formatDescForMTLPixelFormat(mtlFormat).vk;
}
Expand Down

0 comments on commit fff5ec9

Please sign in to comment.