From 9bea7a325554de6b48a3f1b48e0a49bcb0f95961 Mon Sep 17 00:00:00 2001 From: coulsonwang Date: Wed, 5 Jun 2019 09:30:16 +0800 Subject: [PATCH] fix crash when using compressed pixel format (#19794) --- cocos/renderer/backend/metal/DeviceInfoMTL.mm | 3 --- cocos/renderer/backend/metal/TextureMTL.mm | 19 ++----------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/cocos/renderer/backend/metal/DeviceInfoMTL.mm b/cocos/renderer/backend/metal/DeviceInfoMTL.mm index 980eb33435..f0102c8f60 100644 --- a/cocos/renderer/backend/metal/DeviceInfoMTL.mm +++ b/cocos/renderer/backend/metal/DeviceInfoMTL.mm @@ -397,9 +397,6 @@ const char* DeviceInfoMTL::getExtension() const bool DeviceInfoMTL::checkForFeatureSupported(FeatureType feature) { - //TODO coulsonwang, removed it later. - return false; - bool featureSupported = false; switch (feature) { diff --git a/cocos/renderer/backend/metal/TextureMTL.mm b/cocos/renderer/backend/metal/TextureMTL.mm index 959ae815d1..ecfc27031e 100644 --- a/cocos/renderer/backend/metal/TextureMTL.mm +++ b/cocos/renderer/backend/metal/TextureMTL.mm @@ -41,21 +41,6 @@ namespace } } - MTLSamplerMipFilter toMTLSamplerMipFilter(SamplerFilter mode) { - switch (mode) { - case SamplerFilter::NEAREST: - case SamplerFilter::LINEAR_MIPMAP_NEAREST: - case SamplerFilter::NEAREST_MIPMAP_NEAREST: - return MTLSamplerMipFilterNearest; - case SamplerFilter::LINEAR: - case SamplerFilter::LINEAR_MIPMAP_LINEAR: - case SamplerFilter::NEAREST_MIPMAP_LINEAR: - return MTLSamplerMipFilterLinear; - case SamplerFilter::DONT_CARE: - return MTLSamplerMipFilterNearest; - } - } - void convertRGB2RGBA(uint8_t* src, uint8_t* dst, uint32_t length) { for (uint32_t i = 0; i < length; ++i) @@ -157,8 +142,8 @@ namespace MTLPixelFormat pixelFormat = Utils::toMTLPixelFormat(textureFormat); uint32_t bytesPerRow = 0; - if(textureFormat >= PixelFormat::PVRTC2 && - textureFormat <= PixelFormat::PVRTC4A) + if(textureFormat >= PixelFormat::PVRTC4 && + textureFormat <= PixelFormat::PVRTC2A) { bytesPerRow = 0; }