| 1 |
/* |
| 2 |
* Copyright 2021 Google Inc. |
| 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 |
#ifndef GrMtlPipeline_DEFINED |
| 9 |
#define GrMtlPipeline_DEFINED |
| 10 |
|
| 11 |
#include "src/gpu/ganesh/GrManagedResource.h" |
| 12 |
|
| 13 |
#import <Metal/Metal.h> |
| 14 |
|
| 15 |
/** |
| 16 |
* Wraps a MTLRenderPipelineState object |
| 17 |
*/ |
| 18 |
class GrMtlRenderPipeline : public GrManagedResource { |
| 19 |
public: |
| 20 |
static sk_sp<GrMtlRenderPipeline> Make(id<MTLRenderPipelineState> pso) { |
| 21 |
return sk_sp<GrMtlRenderPipeline>(new GrMtlRenderPipeline(pso)); |
| 22 |
} |
| 23 |
#ifdef SK_TRACE_MANAGED_RESOURCES |
| 24 |
/** output a human-readable dump of this resource's information |
| 25 |
*/ |
| 26 |
void dumpInfo() const override { |
| 27 |
SkDebugf("GrMtlRenderPipeline: %p (%ld refs)\n", fPipelineState, |
| 28 |
CFGetRetainCount((CFTypeRef)fPipelineState)); |
| 29 |
} |
| 30 |
#endif |
| 31 |
|
| 32 |
void freeGPUData() const override { |
| 33 |
fPipelineState = nil; |
| 34 |
} |
| 35 |
|
| 36 |
id<MTLRenderPipelineState> mtlPipelineState() const { return fPipelineState; } |
| 37 |
|
| 38 |
private: |
| 39 |
GrMtlRenderPipeline(id<MTLRenderPipelineState> pso) |
| 40 |
: GrManagedResource() |
| 41 |
, fPipelineState(pso) { |
| 42 |
} |
| 43 |
|
| 44 |
mutable id<MTLRenderPipelineState> fPipelineState; |
| 45 |
}; |
| 46 |
|
| 47 |
#endif |