Flutter Engine
The Flutter Engine
GrProgramInfo.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2019 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
9
14
16 const GrSurfaceProxyView& targetView,
17 bool usesMSAASurface,
18 const GrPipeline* pipeline,
19 const GrUserStencilSettings* userStencilSettings,
20 const GrGeometryProcessor* geomProc,
21 GrPrimitiveType primitiveType,
22 GrXferBarrierFlags renderPassXferBarriers,
23 GrLoadOp colorLoadOp)
24 : fNeedsStencil(targetView.asRenderTargetProxy()->needsStencil())
25 , fBackendFormat(targetView.proxy()->backendFormat())
26 , fOrigin(targetView.origin())
27 , fTargetHasVkResolveAttachmentWithInput(
28 targetView.asRenderTargetProxy()->supportsVkInputAttachment() &&
29 ((targetView.asRenderTargetProxy()->numSamples() > 1 &&
30 targetView.asTextureProxy()) ||
31 targetView.asRenderTargetProxy()->numSamples() == 1))
32 , fTargetsNumSamples(targetView.asRenderTargetProxy()->numSamples())
33 , fPipeline(pipeline)
34 , fUserStencilSettings(userStencilSettings)
35 , fGeomProc(geomProc)
36 , fPrimitiveType(primitiveType)
37 , fRenderPassXferBarriers(renderPassXferBarriers)
38 , fColorLoadOp(colorLoadOp) {
39 SkASSERT(fTargetsNumSamples > 0);
40 fNumSamples = fTargetsNumSamples;
41 if (fNumSamples == 1 && usesMSAASurface) {
42 fNumSamples = caps.internalMultisampleCount(this->backendFormat());
43 }
44 SkDEBUGCODE(this->validate(false);)
45}
46
48 GrStencilSettings stencil;
49
50 if (this->isStencilEnabled()) {
51 stencil.reset(*fUserStencilSettings, this->pipeline().hasStencilClip(), 8);
52 }
53
54 return stencil;
55}
56
57#ifdef SK_DEBUG
59
60void GrProgramInfo::validate(bool flushTime) const {
61 if (flushTime) {
62 SkASSERT(fPipeline->allProxiesInstantiated());
63 }
64}
65
66void GrProgramInfo::checkAllInstantiated() const {
68 SkASSERT(proxy->isInstantiated());
69 return true;
70 });
71}
72
73void GrProgramInfo::checkMSAAAndMIPSAreResolved() const {
74 this->pipeline().visitTextureEffects([](const GrTextureEffect& te) {
75 GrTexture* tex = te.texture();
76 SkASSERT(tex);
77
78 // Ensure mipmaps were all resolved ahead of time by the DAG.
80 (tex->width() != 1 || tex->height() != 1)) {
81 // There are some cases where we might be given a non-mipmapped texture with a
82 // mipmap filter. See skbug.com/7094.
84 }
85 });
86}
87
88#endif
GrPrimitiveType
Definition: GrTypesPriv.h:43
GrLoadOp
Definition: GrTypesPriv.h:155
GrXferBarrierFlags
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
Definition: GrCaps.h:57
int internalMultisampleCount(const GrBackendFormat &format) const
Definition: GrCaps.h:271
void visitProxies(const GrVisitProxyFunc &) const
Definition: GrPipeline.cpp:105
void visitTextureEffects(const std::function< void(const GrTextureEffect &)> &) const
Definition: GrPipeline.cpp:98
const GrPipeline & pipeline() const
Definition: GrProgramInfo.h:39
GrProgramInfo(const GrCaps &caps, const GrSurfaceProxyView &targetView, bool usesMSAASurface, const GrPipeline *pipeline, const GrUserStencilSettings *userStencilSettings, const GrGeometryProcessor *geomProc, GrPrimitiveType primitiveType, GrXferBarrierFlags renderPassXferBarriers, GrLoadOp colorLoadOp)
bool isStencilEnabled() const
Definition: GrProgramInfo.h:31
const GrBackendFormat & backendFormat() const
Definition: GrProgramInfo.h:37
GrStencilSettings nonGLStencilSettings() const
constexpr skgpu::Mipmapped mipmapped() const
void reset(const GrUserStencilSettings &, bool hasStencilClip, int numStencilBits)
bool isInstantiated() const
int height() const
Definition: GrSurface.h:37
int width() const
Definition: GrSurface.h:32
GrTexture * texture() const
GrSamplerState samplerState() const
skgpu::Mipmapped mipmapped() const
Definition: GrTexture.h:62
bool mipmapsAreDirty() const
Definition: GrTexture.h:65
Mipmapped
Definition: GpuTypes.h:53