Minor fixes

This commit is contained in:
Alexander Meißner 2020-06-11 13:41:42 +02:00
parent f2e8552caf
commit 7a0dcc07e6
5 changed files with 21 additions and 17 deletions

View File

@ -73,13 +73,15 @@ VkResult MVKCmdCopyImage<N>::setContent(MVKCommandBuffer* cmdBuff,
(pixFmts->getBytesPerBlock(_dstImage->getMTLPixelFormat(dstPlaneIndex)) != pixFmts->getBytesPerBlock(_srcImage->getMTLPixelFormat(srcPlaneIndex)))) {
return reportError(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdCopyImage(): Cannot copy between incompatible formats, such as formats of different pixel sizes, or between images with different sample counts.");
}
if ((_srcImage->getMTLTextureType() == MTLTextureType3D) != (_dstImage->getMTLTextureType() == MTLTextureType3D)) {
return reportError(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdCopyImage(): Metal does not support copying to or from slices of a 3D texture.");
}
_vkImageCopies.push_back(vkIR);
}
// Validate
if ((_srcImage->getMTLTextureType() == MTLTextureType3D) != (_dstImage->getMTLTextureType() == MTLTextureType3D)) {
return reportError(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdCopyImage(): Metal does not support copying to or from slices of a 3D texture.");
}
return VK_SUCCESS;
}
@ -1096,15 +1098,12 @@ VkResult MVKCmdClearImage<N>::setContent(MVKCommandBuffer* cmdBuff,
// Add subresource ranges
_subresourceRanges.clear(); // Clear for reuse
_subresourceRanges.reserve(rangeCount);
bool isDS = isDepthStencilClear();
for (uint32_t rangeIdx = 0; rangeIdx < rangeCount; rangeIdx++) {
auto& vkIR = pRanges[rangeIdx];
uint8_t planeIndex = MVKImage::getPlaneFromVkImageAspectFlags(vkIR.aspectMask);
// Validate
bool isDS = isDepthStencilClear();
if (_image->getImageType() == VK_IMAGE_TYPE_1D) {
return reportError(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdClear%sImage(): Native 1D images cannot be cleared on this device. Consider enabling MVK_CONFIG_TEXTURE_1D_AS_2D.", (isDS ? "DepthStencil" : "Color"));
}
MVKMTLFmtCaps mtlFmtCaps = cmdBuff->getPixelFormats()->getCapabilities(_image->getMTLPixelFormat(planeIndex));
if ((isDS && !mvkAreAllFlagsEnabled(mtlFmtCaps, kMVKMTLFmtCapsDSAtt)) ||
( !isDS && !mvkAreAllFlagsEnabled(mtlFmtCaps, kMVKMTLFmtCapsColorAtt))) {
@ -1114,6 +1113,11 @@ VkResult MVKCmdClearImage<N>::setContent(MVKCommandBuffer* cmdBuff,
_subresourceRanges.push_back(vkIR);
}
// Validate
if (_image->getImageType() == VK_IMAGE_TYPE_1D) {
return reportError(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdClear%sImage(): Native 1D images cannot be cleared on this device. Consider enabling MVK_CONFIG_TEXTURE_1D_AS_2D.", (isDS ? "DepthStencil" : "Color"));
}
return VK_SUCCESS;
}

View File

@ -192,7 +192,7 @@ void MVKDescriptorSetLayoutBinding::push(MVKCommandEncoder* cmdEncoder,
uint8_t planeCount = (imageView) ? imageView->getPlaneCount() : 1;
for (uint8_t planeIndex = 0; planeIndex < planeCount; planeIndex++) {
tb.mtlTexture = imageView->getMTLTexture(planeIndex);
tb.swizzle = (_info.descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ? imageView->getPackedSwizzle(0) : 0;
tb.swizzle = (_info.descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ? imageView->getPackedSwizzle() : 0;
if (_info.descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) {
id<MTLTexture> mtlTex = tb.mtlTexture;
if (mtlTex.parentTexture) { mtlTex = mtlTex.parentTexture; }
@ -282,7 +282,7 @@ void MVKDescriptorSetLayoutBinding::push(MVKCommandEncoder* cmdEncoder,
uint8_t planeCount = (imageView) ? imageView->getPlaneCount() : 1;
for (uint8_t planeIndex = 0; planeIndex < planeCount; planeIndex++) {
tb.mtlTexture = imageView->getMTLTexture(planeIndex);
tb.swizzle = (imageView) ? imageView->getPackedSwizzle(0) : 0;
tb.swizzle = (imageView) ? imageView->getPackedSwizzle() : 0;
MVKSampler* sampler;
if (_immutableSamplers.empty()) {
sampler = (MVKSampler*)imageInfo.sampler;
@ -719,7 +719,7 @@ void MVKImageDescriptor::bind(MVKCommandEncoder* cmdEncoder,
}
tb.swizzle = ((descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE ||
descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) &&
tb.mtlTexture) ? _mvkImageView->getPackedSwizzle(planeIndex) : 0;
tb.mtlTexture) ? _mvkImageView->getPackedSwizzle() : 0;
if (descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE && tb.mtlTexture) {
id<MTLTexture> mtlTex = tb.mtlTexture;
if (mtlTex.parentTexture) { mtlTex = mtlTex.parentTexture; }

View File

@ -2907,8 +2907,8 @@ void MVKDevice::enableFeatures(const VkDeviceCreateInfo* pCreateInfo) {
pdScalarLayoutFeatures.pNext = &pdTexelBuffAlignFeatures;
VkPhysicalDeviceSamplerYcbcrConversionFeatures pdSamplerYcbcrConversionFeatures;
pdScalarLayoutFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES;
pdScalarLayoutFeatures.pNext = &pdScalarLayoutFeatures;
pdSamplerYcbcrConversionFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES;
pdSamplerYcbcrConversionFeatures.pNext = &pdScalarLayoutFeatures;
VkPhysicalDeviceHostQueryResetFeaturesEXT pdHostQryResetFeatures;
pdHostQryResetFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES_EXT;

View File

@ -332,8 +332,8 @@ protected:
void initExternalMemory(VkExternalMemoryHandleTypeFlags handleTypes);
void releaseIOSurface();
std::vector<std::unique_ptr<MVKImageMemoryBinding>> _memoryBindings;
std::vector<std::unique_ptr<MVKImagePlane>> _planes;
MVKSmallVector<std::unique_ptr<MVKImageMemoryBinding>, 3> _memoryBindings;
MVKSmallVector<std::unique_ptr<MVKImagePlane>, 3> _planes;
VkExtent3D _extent;
uint32_t _mipLevels;
uint32_t _arrayLayers;
@ -531,7 +531,7 @@ public:
inline MTLPixelFormat getMTLPixelFormat(uint8_t planeIndex) { return _planes[planeIndex]->_mtlPixFmt; }
/** Returns the packed component swizzle of this image view. */
inline uint32_t getPackedSwizzle(uint8_t planeIndex) { return _planes[planeIndex]->_packedSwizzle; }
inline uint32_t getPackedSwizzle() { return _planes[0]->_packedSwizzle; }
/** Returns the number of planes of this image view. */
inline uint8_t getPlaneCount() { return _planes.size(); }
@ -587,7 +587,7 @@ protected:
void propagateDebugName() override;
MVKImage* _image;
std::vector<std::unique_ptr<MVKImageViewPlane>> _planes;
MVKSmallVector<std::unique_ptr<MVKImageViewPlane>, 3> _planes;
VkImageSubresourceRange _subresourceRange;
VkImageUsageFlags _usage;
std::mutex _lock;

View File

@ -359,8 +359,8 @@ void MVKImageMemoryBinding::propagateDebugName() {
bool MVKImageMemoryBinding::needsHostReadSync(VkPipelineStageFlags srcStageMask,
VkPipelineStageFlags dstStageMask,
VkMemoryBarrier* pMemoryBarrier) {
MVKPipelineBarrier& barrier = *(MVKPipelineBarrier*)pMemoryBarrier;
#if MVK_MACOS
MVKPipelineBarrier& barrier = *(MVKPipelineBarrier*)pMemoryBarrier;
return ((barrier.newLayout == VK_IMAGE_LAYOUT_GENERAL) &&
mvkIsAnyFlagEnabled(barrier.dstAccessMask, (VK_ACCESS_HOST_READ_BIT | VK_ACCESS_MEMORY_READ_BIT)) &&
isMemoryHostAccessible() && !isMemoryHostCoherent());