1/* 2 * Copyright 2021 Google LLC 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8#include "src/gpu/graphite/mtl/MtlGraphiteTypesPriv.h" 9 10#import <Metal/Metal.h> 11 12namespace skgpu::graphite { 13 14MtlTextureInfo::MtlTextureInfo(CFTypeRef texture) { 15 SkASSERT(texture); 16 id<MTLTexture> mtlTex = (id<MTLTexture>)texture; 17 18 fSampleCount = mtlTex.sampleCount; 19 fMipmapped = mtlTex.mipmapLevelCount > 1 ? Mipmapped::kYes : Mipmapped::kNo; 20 21 fFormat = mtlTex.pixelFormat; 22 fUsage = mtlTex.usage; 23 fStorageMode = mtlTex.storageMode; 24 fFramebufferOnly = mtlTex.framebufferOnly; 25} 26 27MtlTextureInfo MtlTextureSpecToTextureInfo(const MtlTextureSpec& mtlSpec, 28 uint32_t sampleCount, 29 Mipmapped mipmapped) { 30 MtlTextureInfo info; 31 // Shared info 32 info.fSampleCount = sampleCount; 33 info.fMipmapped = mipmapped; 34 35 // Mtl info 36 info.fFormat = mtlSpec.fFormat; 37 info.fUsage = mtlSpec.fUsage; 38 info.fStorageMode = mtlSpec.fStorageMode; 39 info.fFramebufferOnly = mtlSpec.fFramebufferOnly; 40 41 return info; 42} 43 44} // namespace skgpu::graphite 45