diff options
author | Timothy Liang <timliang@google.com> | 2018-07-02 17:36:20 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-11 16:27:28 +0000 |
commit | 58f153db313033289ce4a0a7f68bdf6c66238460 (patch) | |
tree | 8c3a4cbde7d6d38680756ff2144fc3b88aaab3c7 /src/gpu/mtl/GrMtlTexture.mm | |
parent | 0421083a447a8ab105d20c786f7d8377f30a6d5d (diff) |
refactored where texture descriptors are made for metal gpu backend
Bug: skia:
Change-Id: Ic90660b5ad5c1e795cd768bb7471e9ac80a59f47
Reviewed-on: https://skia-review.googlesource.com/138999
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Timothy Liang <timliang@google.com>
Diffstat (limited to 'src/gpu/mtl/GrMtlTexture.mm')
-rw-r--r-- | src/gpu/mtl/GrMtlTexture.mm | 37 |
1 files changed, 10 insertions, 27 deletions
diff --git a/src/gpu/mtl/GrMtlTexture.mm b/src/gpu/mtl/GrMtlTexture.mm index 87ee28b206..0511df29a8 100644 --- a/src/gpu/mtl/GrMtlTexture.mm +++ b/src/gpu/mtl/GrMtlTexture.mm @@ -54,43 +54,26 @@ GrMtlTexture::GrMtlTexture(GrMtlGpu* gpu, } sk_sp<GrMtlTexture> GrMtlTexture::CreateNewTexture(GrMtlGpu* gpu, SkBudgeted budgeted, - const GrSurfaceDesc& desc, int mipLevels) { - MTLPixelFormat format; - if (!GrPixelConfigToMTLFormat(desc.fConfig, &format)) { - return nullptr; - } - + const GrSurfaceDesc& desc, + MTLTextureDescriptor* texDesc, + GrMipMapsStatus mipMapsStatus) { if (desc.fSampleCnt > 1) { SkASSERT(false); // Currently we don't support msaa return nullptr; } - - MTLTextureDescriptor* descriptor = [[MTLTextureDescriptor alloc] init]; - descriptor.textureType = MTLTextureType2D; - descriptor.pixelFormat = format; - descriptor.width = desc.fWidth; - descriptor.height = desc.fHeight; - descriptor.depth = 1; - descriptor.mipmapLevelCount = mipLevels; - descriptor.sampleCount = 1; - descriptor.arrayLength = 1; - // descriptor.resourceOptions This looks to be set by setting cpuCacheMode and storageModes - descriptor.cpuCacheMode = MTLCPUCacheModeWriteCombined; - // Make all textures have private gpu only access. We can use transfer buffers to copy to them. - descriptor.storageMode = MTLStorageModePrivate; - descriptor.usage = MTLTextureUsageShaderRead; - - id<MTLTexture> texture = [gpu->device() newTextureWithDescriptor:descriptor]; - - GrMipMapsStatus mipMapsStatus = mipLevels > 1 ? GrMipMapsStatus::kValid - : GrMipMapsStatus::kNotAllocated; - + id<MTLTexture> texture = [gpu->device() newTextureWithDescriptor:texDesc]; + SkASSERT(nil != texture); + SkASSERT(MTLTextureUsageShaderRead & texture.usage); return sk_sp<GrMtlTexture>(new GrMtlTexture(gpu, budgeted, desc, texture, mipMapsStatus)); } sk_sp<GrMtlTexture> GrMtlTexture::MakeWrappedTexture(GrMtlGpu* gpu, const GrSurfaceDesc& desc, id<MTLTexture> texture) { + if (desc.fSampleCnt > 1) { + SkASSERT(false); // Currently we don't support msaa + return nullptr; + } SkASSERT(nil != texture); SkASSERT(MTLTextureUsageShaderRead & texture.usage); GrMipMapsStatus mipMapsStatus = texture.mipmapLevelCount > 1 ? GrMipMapsStatus::kValid |