Flutter Engine
The Flutter Engine
third_party
skia
src
gpu
ganesh
mtl
GrMtlResourceProvider.h
Go to the documentation of this file.
1
/*
2
* Copyright 2018 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 GrMtlResourceProvider_DEFINED
9
#define GrMtlResourceProvider_DEFINED
10
11
#include "
include/private/base/SkTArray.h
"
12
#include "
src/base/SkSpinlock.h
"
13
#include "
src/core/SkChecksum.h
"
14
#include "
src/core/SkLRUCache.h
"
15
#include "
src/core/SkTDynamicHash.h
"
16
#include "
src/gpu/ganesh/GrProgramDesc.h
"
17
#include "
src/gpu/ganesh/GrThreadSafePipelineBuilder.h
"
18
#include "
src/gpu/ganesh/mtl/GrMtlDepthStencil.h
"
19
#include "
src/gpu/ganesh/mtl/GrMtlPipeline.h
"
20
#include "
src/gpu/ganesh/mtl/GrMtlPipelineStateBuilder.h
"
21
#include "
src/gpu/ganesh/mtl/GrMtlSampler.h
"
22
23
#import <Metal/Metal.h>
24
25
class
GrMtlGpu
;
26
class
GrMtlCommandBuffer
;
27
28
class
GrMtlResourceProvider
{
29
public
:
30
GrMtlResourceProvider
(
GrMtlGpu
* gpu);
31
32
GrMtlPipelineState
*
findOrCreateCompatiblePipelineState
(
33
const
GrProgramDesc
&,
const
GrProgramInfo
&,
34
GrThreadSafePipelineBuilder::Stats::ProgramCacheResult
* stat =
nullptr
);
35
bool
precompileShader
(
const
SkData
&
key
,
const
SkData
&
data
);
36
37
// Finds or creates a compatible MTLDepthStencilState based on the GrStencilSettings.
38
GrMtlDepthStencil
*
findOrCreateCompatibleDepthStencilState
(
const
GrStencilSettings
&,
39
GrSurfaceOrigin
);
40
41
// Finds or creates a compatible MTLSamplerState based on the GrSamplerState.
42
GrMtlSampler
*
findOrCreateCompatibleSampler
(
GrSamplerState
);
43
44
const
GrMtlRenderPipeline
*
findOrCreateMSAALoadPipeline
(MTLPixelFormat colorFormat,
45
int
sampleCount,
46
MTLPixelFormat stencilFormat);
47
48
// Destroy any cached resources. To be called before releasing the MtlDevice.
49
void
destroyResources
();
50
51
#if defined(GR_TEST_UTILS)
52
void
resetShaderCacheForTesting()
const
{ fPipelineStateCache->release(); }
53
#endif
54
55
private
:
56
#ifdef SK_DEBUG
57
#define GR_PIPELINE_STATE_CACHE_STATS
58
#endif
59
60
class
PipelineStateCache :
public
GrThreadSafePipelineBuilder
{
61
public
:
62
PipelineStateCache(
GrMtlGpu
* gpu);
63
~PipelineStateCache()
override
;
64
65
void
release();
66
GrMtlPipelineState
* refPipelineState(
const
GrProgramDesc
&,
const
GrProgramInfo
&,
67
Stats::ProgramCacheResult
*);
68
bool
precompileShader
(
const
SkData
&
key
,
const
SkData
&
data
);
69
70
private
:
71
GrMtlPipelineState
* onRefPipelineState(
const
GrProgramDesc
&,
const
GrProgramInfo
&,
72
Stats::ProgramCacheResult
*);
73
74
struct
Entry
;
75
76
struct
DescHash {
77
uint32_t operator()(
const
GrProgramDesc
&
desc
)
const
{
78
return
SkChecksum::Hash32
(
desc
.asKey(),
desc
.keyLength());
79
}
80
};
81
82
SkLRUCache<const GrProgramDesc, std::unique_ptr<Entry>
, DescHash> fMap;
83
84
GrMtlGpu
* fGpu;
85
};
86
87
GrMtlGpu
* fGpu;
88
89
// Cache of GrMtlPipelineStates
90
std::unique_ptr<PipelineStateCache> fPipelineStateCache;
91
92
SkTDynamicHash<GrMtlSampler, GrMtlSampler::Key>
fSamplers;
93
SkTDynamicHash<GrMtlDepthStencil, GrMtlDepthStencil::Key>
fDepthStencilStates;
94
95
struct
MSAALoadPipelineEntry {
96
sk_sp<const GrMtlRenderPipeline>
fPipeline;
97
MTLPixelFormat fColorFormat;
98
int
fSampleCount;
99
MTLPixelFormat fStencilFormat;
100
};
101
id<MTLLibrary> fMSAALoadLibrary;
102
skia_private::TArray<MSAALoadPipelineEntry>
fMSAALoadPipelines;
103
};
104
105
#endif
GrMtlDepthStencil.h
GrMtlPipelineStateBuilder.h
GrMtlPipeline.h
GrMtlSampler.h
GrProgramDesc.h
GrThreadSafePipelineBuilder.h
GrSurfaceOrigin
GrSurfaceOrigin
Definition:
GrTypes.h:147
SkChecksum.h
SkLRUCache.h
SkSpinlock.h
SkTArray.h
SkTDynamicHash.h
GrMtlCommandBuffer
Definition:
GrMtlCommandBuffer.h:30
GrMtlDepthStencil
Definition:
GrMtlDepthStencil.h:22
GrMtlGpu
Definition:
GrMtlGpu.h:35
GrMtlPipelineState
Definition:
GrMtlPipelineState.h:33
GrMtlRenderPipeline
Definition:
GrMtlPipeline.h:18
GrMtlResourceProvider
Definition:
GrMtlResourceProvider.h:28
GrMtlResourceProvider::findOrCreateMSAALoadPipeline
const GrMtlRenderPipeline * findOrCreateMSAALoadPipeline(MTLPixelFormat colorFormat, int sampleCount, MTLPixelFormat stencilFormat)
Definition:
GrMtlResourceProvider.mm:70
GrMtlResourceProvider::findOrCreateCompatiblePipelineState
GrMtlPipelineState * findOrCreateCompatiblePipelineState(const GrProgramDesc &, const GrProgramInfo &, GrThreadSafePipelineBuilder::Stats::ProgramCacheResult *stat=nullptr)
Definition:
GrMtlResourceProvider.mm:33
GrMtlResourceProvider::precompileShader
bool precompileShader(const SkData &key, const SkData &data)
Definition:
GrMtlResourceProvider.mm:40
GrMtlResourceProvider::findOrCreateCompatibleDepthStencilState
GrMtlDepthStencil * findOrCreateCompatibleDepthStencilState(const GrStencilSettings &, GrSurfaceOrigin)
Definition:
GrMtlResourceProvider.mm:46
GrMtlResourceProvider::destroyResources
void destroyResources()
Definition:
GrMtlResourceProvider.mm:157
GrMtlResourceProvider::GrMtlResourceProvider
GrMtlResourceProvider(GrMtlGpu *gpu)
Definition:
GrMtlResourceProvider.mm:28
GrMtlResourceProvider::findOrCreateCompatibleSampler
GrMtlSampler * findOrCreateCompatibleSampler(GrSamplerState)
Definition:
GrMtlResourceProvider.mm:59
GrMtlSampler
Definition:
GrMtlSampler.h:21
GrProgramDesc
Definition:
GrProgramDesc.h:26
GrProgramInfo
Definition:
GrProgramInfo.h:17
GrSamplerState
Definition:
GrSamplerState.h:22
GrStencilSettings
Definition:
GrStencilSettings.h:51
GrThreadSafePipelineBuilder::Stats::ProgramCacheResult
ProgramCacheResult
Definition:
GrThreadSafePipelineBuilder.h:26
GrThreadSafePipelineBuilder
Definition:
GrThreadSafePipelineBuilder.h:20
SkData
Definition:
SkData.h:25
SkLRUCache
Definition:
SkLRUCache.h:19
SkTDynamicHash< GrMtlSampler, GrMtlSampler::Key >
sk_sp< const GrMtlRenderPipeline >
skia_private::TArray< MSAALoadPipelineEntry >
key
int key
Definition:
keyboard_key_handler_unittests.cc:114
SkChecksum::Hash32
uint32_t Hash32(const void *data, size_t bytes, uint32_t seed)
Definition:
SkChecksum.cpp:113
convert_manifest_to_json.Entry
Entry
Definition:
convert_manifest_to_json.py:16
import_conformance_tests.desc
desc
Definition:
import_conformance_tests.py:63
data
std::shared_ptr< const fml::Mapping > data
Definition:
texture_gles.cc:63
Generated on Sun Jun 23 2024 21:56:22 for Flutter Engine by
1.9.4