vkGetPhysicalDeviceFormatProperties() return VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT if supported, even if other format properties are not.

This commit is contained in:
Bill Hollings 2018-08-15 13:14:43 -04:00
parent 0cbc5b086f
commit 97df931b43
4 changed files with 15 additions and 16 deletions

View File

@ -165,17 +165,18 @@ size_t mvkMTLPixelFormatBytesPerLayer(MTLPixelFormat mtlFormat, size_t bytesPerR
/**
* Returns the default properties for the specified Vulkan format.
*
* Not all MTLPixelFormats returned by this function are supported by all GPU's,
* and, as a result, MoltenVK may return a different value from the
* vkGetPhysicalDeviceFormatProperties() function than is returned here.
* Not all MTLPixelFormats returned by this function are supported by all GPU's, and, as a
* result, MoltenVK may return a different value from the vkGetPhysicalDeviceFormatProperties()
* function than is returned here. Use the vkGetPhysicalDeviceFormatProperties() function to
* return the properties for a particular GPU.
*
* Not all macOS GPU's support the MTLPixelFormatDepth24Unorm_Stencil8
* (VK_FORMAT_D24_UNORM_S8_UINT) pixel format. On an macOS device that has more
* than one GPU, one of the GPU's may support that format, while another may not.
* Use the vkGetPhysicalDeviceFormatProperties() function to return the properties
* for a particular GPU.
* Setting assumeGPUSupportsDefault to true allows the default format properties to be returned.
* The assumeGPUSupportsDefault flag can be set to false if it is already known that the format
* is not supported by a particular GPU for images, in which case all of the returned properties
* will be disabled, except possibly VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT, which may be supported
* for the format even without image support.
*/
VkFormatProperties mvkVkFormatProperties(VkFormat vkFormat);
VkFormatProperties mvkVkFormatProperties(VkFormat vkFormat, bool assumeGPUSupportsDefault = true);
/** Returns the name of the specified Vulkan format. */
const char* mvkVkFormatName(VkFormat vkFormat);

View File

@ -81,7 +81,7 @@ public:
/** Populates the specified structure with the properties of this device. */
void getProperties(VkPhysicalDeviceProperties* properties);
/** Returns whether the specified format is supported. */
/** Returns whether the specified format is supported on this device. */
bool getFormatIsSupported(VkFormat format);
/** Populates the specified structure with the format properties of this device. */

View File

@ -85,11 +85,9 @@ bool MVKPhysicalDevice::getFormatIsSupported(VkFormat format) {
return true;
}
void MVKPhysicalDevice::getFormatProperties(VkFormat format,
VkFormatProperties* pFormatProperties) {
static VkFormatProperties noFmtFeats = { 0, 0, 0 };
void MVKPhysicalDevice::getFormatProperties(VkFormat format, VkFormatProperties* pFormatProperties) {
if (pFormatProperties) {
*pFormatProperties = getFormatIsSupported(format) ? mvkVkFormatProperties(format) : noFmtFeats;
*pFormatProperties = mvkVkFormatProperties(format, getFormatIsSupported(format));
}
}

View File

@ -594,9 +594,9 @@ MVK_PUBLIC_SYMBOL size_t mvkMTLPixelFormatBytesPerLayer(MTLPixelFormat mtlFormat
return mvkCeilingDivide(texelRowsPerLayer, formatDescForMTLPixelFormat(mtlFormat).blockTexelSize.height) * bytesPerRow;
}
MVK_PUBLIC_SYMBOL VkFormatProperties mvkVkFormatProperties(VkFormat vkFormat) {
MVK_PUBLIC_SYMBOL VkFormatProperties mvkVkFormatProperties(VkFormat vkFormat, bool assumeGPUSupportsDefault) {
const MVKFormatDesc& fmtDesc = formatDescForVkFormat(vkFormat);
if (fmtDesc.isSupported()) {
if (assumeGPUSupportsDefault && fmtDesc.isSupported()) {
return fmtDesc.properties;
} else {
// If texture format is unsupported, vertex buffer format may still be.