@@ -847,12 +847,17 @@ auto IGPUObjectFromAssetConverter::create(const asset::ICPUImage** const _begin,
847
847
}
848
848
}
849
849
850
- auto needToCompMipsForThisImg = [](const asset::ICPUImage* img) -> bool {
851
- if (img->getRegions ().size () == 0u )
850
+ auto needToCompMipsForThisImg = [](const asset::ICPUImage* img) -> bool
851
+ {
852
+ if (img->getRegions ().empty ())
852
853
return false ;
853
854
auto format = img->getCreationParameters ().format ;
854
855
if (asset::isIntegerFormat (format) || asset::isBlockCompressionFormat (format))
855
856
return false ;
857
+ // its enough to define a single mipmap region above the base level to prevent automatic computation
858
+ for (auto & region : img->getRegions ())
859
+ if (region.imageSubresource .mipLevel )
860
+ return false ;
856
861
return true ;
857
862
};
858
863
@@ -1025,8 +1030,8 @@ auto IGPUObjectFromAssetConverter::create(const asset::ICPUImage** const _begin,
1025
1030
promotionRequest.originalFormat = params.format ;
1026
1031
promotionRequest.usages = {};
1027
1032
1028
- const bool integerFmt = asset::isIntegerFormat (params. format );
1029
- if (!integerFmt )
1033
+ // override the mip-count if its not an integer format and there was no mip-pyramid specified
1034
+ if (params. mipLevels == 1u && ! asset::isIntegerFormat (params. format ) )
1030
1035
params.mipLevels = 1u + static_cast <uint32_t >(std::log2 (static_cast <float >(core::max<uint32_t >(core::max<uint32_t >(params.extent .width , params.extent .height ), params.extent .depth ))));
1031
1036
1032
1037
if (cpuimg->getRegions ().size ())
@@ -1036,7 +1041,10 @@ auto IGPUObjectFromAssetConverter::create(const asset::ICPUImage** const _begin,
1036
1041
1037
1042
if (needToCompMipsForThisImg (cpuimg))
1038
1043
{
1039
- params.usage |= asset::IImage::EUF_TRANSFER_SRC_BIT;
1044
+ params.usage |= asset::IImage::EUF_TRANSFER_SRC_BIT; // this is for blit
1045
+ // I'm already adding usage flags for mip-mapping compute shader
1046
+ params.usage |= asset::IImage::EUF_SAMPLED_BIT; // to read source mips
1047
+ params.usage |= asset::IImage::EUF_STORAGE_BIT; // to write dst mips
1040
1048
// TODO: will change when we do the blit on compute shader.
1041
1049
promotionRequest.usages .blitDst = true ;
1042
1050
promotionRequest.usages .blitSrc = true ;
@@ -1095,12 +1103,8 @@ auto IGPUObjectFromAssetConverter::create(const asset::ICPUImage** const _begin,
1095
1103
1096
1104
if (needToCompMipsForThisImg (cpuimg))
1097
1105
{
1098
- // Todo(achal): Remove this API check once OpenGL(ES) does its format usage reporting correctly
1099
- if (_params.device ->getAPIType () == EAT_VULKAN)
1100
- {
1101
- assert (_params.device ->getPhysicalDevice ()->getImageFormatUsagesOptimalTiling ()[gpuimg->getCreationParameters ().format ].sampledImage );
1102
- assert (asset::isFloatingPointFormat (gpuimg->getCreationParameters ().format ) || asset::isNormalizedFormat (gpuimg->getCreationParameters ().format )); // // for blits, can lift are polyphase compute
1103
- }
1106
+ assert (_params.device ->getPhysicalDevice ()->getImageFormatUsagesOptimalTiling ()[gpuimg->getCreationParameters ().format ].sampledImage );
1107
+ assert (asset::isFloatingPointFormat (gpuimg->getCreationParameters ().format ) || asset::isNormalizedFormat (gpuimg->getCreationParameters ().format ));
1104
1108
cmdComputeMip (cpuimg, gpuimg, newLayout);
1105
1109
}
1106
1110
else
0 commit comments