Don't assign MTLTextureUsageRenderTarget to linear textures
This commit is contained in:
parent
f967fb6aeb
commit
0b6a5db049
@ -312,7 +312,7 @@ public:
|
|||||||
* attempting to copy a depth image with a substituted format to and from a buffer.
|
* attempting to copy a depth image with a substituted format to and from a buffer.
|
||||||
*/
|
*/
|
||||||
inline bool hasExpectedTexelSize() { return _hasExpectedTexelSize; }
|
inline bool hasExpectedTexelSize() { return _hasExpectedTexelSize; }
|
||||||
|
|
||||||
/** Returns the Metal resource options for this image. */
|
/** Returns the Metal resource options for this image. */
|
||||||
MTLStorageMode getMTLStorageMode();
|
MTLStorageMode getMTLStorageMode();
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ MTLTextureDescriptor* MVKImagePlane::newMTLTextureDescriptor() {
|
|||||||
mtlTexDesc.mipmapLevelCount = _image->_mipLevels;
|
mtlTexDesc.mipmapLevelCount = _image->_mipLevels;
|
||||||
mtlTexDesc.sampleCount = mvkSampleCountFromVkSampleCountFlagBits(_image->_samples);
|
mtlTexDesc.sampleCount = mvkSampleCountFromVkSampleCountFlagBits(_image->_samples);
|
||||||
mtlTexDesc.arrayLength = _image->_arrayLayers;
|
mtlTexDesc.arrayLength = _image->_arrayLayers;
|
||||||
mtlTexDesc.usageMVK = _image->getPixelFormats()->getMTLTextureUsage(_image->_usage, mtlPixFmt, minUsage);
|
mtlTexDesc.usageMVK = _image->getPixelFormats()->getMTLTextureUsage(_image->_usage, mtlPixFmt, minUsage, _image->_isLinear);
|
||||||
mtlTexDesc.storageModeMVK = _image->getMTLStorageMode();
|
mtlTexDesc.storageModeMVK = _image->getMTLStorageMode();
|
||||||
mtlTexDesc.cpuCacheMode = _image->getMTLCPUCacheMode();
|
mtlTexDesc.cpuCacheMode = _image->getMTLCPUCacheMode();
|
||||||
|
|
||||||
|
@ -281,10 +281,12 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Returns the Metal texture usage from the Vulkan image usage and Metal format, ensuring that at least the
|
* Returns the Metal texture usage from the Vulkan image usage and Metal format, ensuring that at least the
|
||||||
* usages in minUsage are included, even if they wouldn't naturally be included based on the other two parameters.
|
* usages in minUsage are included, even if they wouldn't naturally be included based on the other two parameters.
|
||||||
|
* isLinear further restricts the allowed usage to those that are valid for linear textures.
|
||||||
*/
|
*/
|
||||||
MTLTextureUsage getMTLTextureUsage(VkImageUsageFlags vkImageUsageFlags,
|
MTLTextureUsage getMTLTextureUsage(VkImageUsageFlags vkImageUsageFlags,
|
||||||
MTLPixelFormat mtlFormat,
|
MTLPixelFormat mtlFormat,
|
||||||
MTLTextureUsage minUsage = MTLTextureUsageUnknown);
|
MTLTextureUsage minUsage = MTLTextureUsageUnknown,
|
||||||
|
bool isLinear = false);
|
||||||
|
|
||||||
/** Enumerates all formats that support the given features, calling a specified function for each one. */
|
/** Enumerates all formats that support the given features, calling a specified function for each one. */
|
||||||
void enumerateSupportedFormats(VkFormatProperties properties, bool any, std::function<bool(VkFormat)> func);
|
void enumerateSupportedFormats(VkFormatProperties properties, bool any, std::function<bool(VkFormat)> func);
|
||||||
|
@ -453,7 +453,8 @@ VkImageUsageFlags MVKPixelFormats::getVkImageUsageFlags(MTLTextureUsage mtlUsage
|
|||||||
|
|
||||||
MTLTextureUsage MVKPixelFormats::getMTLTextureUsage(VkImageUsageFlags vkImageUsageFlags,
|
MTLTextureUsage MVKPixelFormats::getMTLTextureUsage(VkImageUsageFlags vkImageUsageFlags,
|
||||||
MTLPixelFormat mtlFormat,
|
MTLPixelFormat mtlFormat,
|
||||||
MTLTextureUsage minUsage) {
|
MTLTextureUsage minUsage,
|
||||||
|
bool isLinear) {
|
||||||
bool isDepthFmt = isDepthFormat(mtlFormat);
|
bool isDepthFmt = isDepthFormat(mtlFormat);
|
||||||
bool isStencilFmt = isStencilFormat(mtlFormat);
|
bool isStencilFmt = isStencilFormat(mtlFormat);
|
||||||
bool isCombinedDepthStencilFmt = isDepthFmt && isStencilFmt;
|
bool isCombinedDepthStencilFmt = isDepthFmt && isStencilFmt;
|
||||||
@ -484,7 +485,13 @@ MTLTextureUsage MVKPixelFormats::getMTLTextureUsage(VkImageUsageFlags vkImageUsa
|
|||||||
VK_IMAGE_USAGE_TRANSFER_DST_BIT)) && // Scaling a BLIT may use rendering.
|
VK_IMAGE_USAGE_TRANSFER_DST_BIT)) && // Scaling a BLIT may use rendering.
|
||||||
mvkIsAnyFlagEnabled(mtlFmtCaps, (kMVKMTLFmtCapsColorAtt | kMVKMTLFmtCapsDSAtt))) {
|
mvkIsAnyFlagEnabled(mtlFmtCaps, (kMVKMTLFmtCapsColorAtt | kMVKMTLFmtCapsDSAtt))) {
|
||||||
|
|
||||||
mvkEnableFlags(mtlUsage, MTLTextureUsageRenderTarget);
|
#if MVK_MACOS
|
||||||
|
if(!isLinear) {
|
||||||
|
mvkEnableFlags(mtlUsage, MTLTextureUsageRenderTarget);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
mvkEnableFlags(mtlUsage, MTLTextureUsageRenderTarget);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create view on, but only on color formats, or combined depth-stencil formats if supported by the GPU...
|
// Create view on, but only on color formats, or combined depth-stencil formats if supported by the GPU...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user