// SPDX-FileCopyrightText: 2023 Unity Technologies and the glTFast authors // SPDX-License-Identifier: Apache-2.0 #if KTX_IS_RECENT #define KTX_IS_ENABLED #endif #if KTX_IS_ENABLED using System.Threading.Tasks; using KtxUnity; using Unity.Collections; namespace GLTFast { class KtxLoadNativeContext : KtxLoadContextBase { ReadOnlyNativeArray m_Data; public KtxLoadNativeContext(int index,ReadOnlyNativeArray data) { imageIndex = index; m_Data = data; m_KtxTexture = new KtxTexture(); } public override async Task LoadTexture2D(bool linear) { var errorCode = m_KtxTexture.Open(m_Data.AsNativeArrayReadOnly()); if (errorCode != ErrorCode.Success) { return new TextureResult(errorCode); } var result = await m_KtxTexture.LoadTexture2D(linear); m_KtxTexture.Dispose(); return result; } } } #endif // KTX_IS_INSTALLED