-----------------------------------------------------------------------------------
| 726 | } |
| 727 | //----------------------------------------------------------------------------------- |
| 728 | VkImageView VulkanTextureGpu::_createView( PixelFormatGpu pixelFormat, uint8 mipLevel, |
| 729 | uint8 numMipmaps, uint16 arraySlice, |
| 730 | bool cubemapsAs2DArrays, bool forUav, uint32 numSlices, |
| 731 | VkImage imageOverride ) const |
| 732 | { |
| 733 | OGRE_ASSERT_LOW( ( forUav || imageOverride || isTexture() ) && |
| 734 | "This texture is marked as 'TextureFlags::NotTexture', which " |
| 735 | "means it can't be used for reading as a regular texture." ); |
| 736 | |
| 737 | if( pixelFormat == PFG_UNKNOWN ) |
| 738 | { |
| 739 | pixelFormat = mPixelFormat; |
| 740 | if( forUav ) |
| 741 | pixelFormat = PixelFormatGpuUtils::getEquivalentLinear( pixelFormat ); |
| 742 | } |
| 743 | |
| 744 | pixelFormat = getWorkaroundedPixelFormat( pixelFormat ); |
| 745 | |
| 746 | VkImageViewType texType = this->getInternalVulkanTextureViewType(); |
| 747 | |
| 748 | if( ( cubemapsAs2DArrays || forUav || numSlices == 1u ) && |
| 749 | ( mTextureType == TextureTypes::TypeCube || mTextureType == TextureTypes::TypeCubeArray ) ) |
| 750 | { |
| 751 | texType = VK_IMAGE_VIEW_TYPE_2D_ARRAY; |
| 752 | } |
| 753 | |
| 754 | if( !numMipmaps ) |
| 755 | numMipmaps = mNumMipmaps - mipLevel; |
| 756 | |
| 757 | OGRE_ASSERT_LOW( numMipmaps <= mNumMipmaps - mipLevel && |
| 758 | "Asking for more mipmaps than the texture has!" ); |
| 759 | |
| 760 | VulkanTextureGpuManager *textureManager = |
| 761 | static_cast<VulkanTextureGpuManager *>( mTextureManager ); |
| 762 | VulkanDevice *device = textureManager->getDevice(); |
| 763 | |
| 764 | VkImageViewCreateInfo imageViewCi; |
| 765 | makeVkStruct( imageViewCi, VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO ); |
| 766 | imageViewCi.image = imageOverride ? imageOverride : mDisplayTextureName; |
| 767 | imageViewCi.viewType = texType; |
| 768 | imageViewCi.format = VulkanMappings::get( pixelFormat ); |
| 769 | |
| 770 | // Using both depth & stencil aspects in an image view for texture sampling is illegal |
| 771 | // Thus prefer depth over stencil. We only use both flags for FBOs |
| 772 | imageViewCi.subresourceRange.aspectMask = |
| 773 | VulkanMappings::getImageAspect( pixelFormat, imageOverride == 0 ); |
| 774 | imageViewCi.subresourceRange.baseMipLevel = mipLevel; |
| 775 | imageViewCi.subresourceRange.levelCount = numMipmaps; |
| 776 | imageViewCi.subresourceRange.baseArrayLayer = arraySlice; |
| 777 | if( numSlices == 0u ) |
| 778 | imageViewCi.subresourceRange.layerCount = VK_REMAINING_ARRAY_LAYERS; |
| 779 | else |
| 780 | imageViewCi.subresourceRange.layerCount = numSlices; |
| 781 | |
| 782 | VkImageViewUsageCreateInfo flagRestriction; |
| 783 | if( textureManager->canRestrictImageViewUsage() && isUav() && !forUav ) |
| 784 | { |
| 785 | // Some formats (e.g. *_SRGB formats) do not support USAGE_STORAGE_BIT at all |
no test coverage detected