mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
fix metal pvrtc upload issue (#15894)
This commit is contained in:
@@ -225,17 +225,21 @@ bool CCMTLTexture::createMTLTexture() {
|
||||
descriptor.mipmapLevelCount = _info.levelCount;
|
||||
descriptor.arrayLength = _info.type == TextureType::CUBE ? 1 : _info.layerCount;
|
||||
|
||||
descriptor.storageMode = MTLStorageModePrivate;
|
||||
bool memoryless = false;
|
||||
if (@available(macos 11.0, ios 10.0, *)) {
|
||||
bool memoryless = hasFlag(_info.flags, TextureFlagBit::LAZILY_ALLOCATED) &&
|
||||
hasFlag(_info.usage, TextureUsageBit::COLOR_ATTACHMENT) &&
|
||||
hasFlag(_info.usage, TextureUsageBit::DEPTH_STENCIL_ATTACHMENT);
|
||||
memoryless = hasFlag(_info.flags, TextureFlagBit::LAZILY_ALLOCATED) &&
|
||||
hasAllFlags(TextureUsageBit::COLOR_ATTACHMENT | TextureUsageBit::DEPTH_STENCIL_ATTACHMENT | TextureUsageBit::INPUT_ATTACHMENT, _info.usage);
|
||||
if (memoryless) {
|
||||
descriptor.storageMode = MTLStorageModeMemoryless;
|
||||
_allocateMemory = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!memoryless && !_isPVRTC) {
|
||||
// pvrtc can not use blit encoder to upload data.
|
||||
descriptor.storageMode = MTLStorageModePrivate;
|
||||
}
|
||||
|
||||
id<MTLDevice> mtlDevice = id<MTLDevice>(CCMTLDevice::getInstance()->getMTLDevice());
|
||||
_mtlTexture = [mtlDevice newTextureWithDescriptor:descriptor];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user