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
8#include "src/gpu/GrProgramInfo.h"
9
10#include "src/gpu/GrStencilSettings.h"
11
12GrStencilSettings GrProgramInfo::nonGLStencilSettings() const {
13 GrStencilSettings stencil;
14
15 if (this->pipeline().isStencilEnabled()) {
16 stencil.reset(*this->pipeline().getUserStencil(),
17 this->pipeline().hasStencilClip(),
18 8);
19 }
20
21 return stencil;
22}
23
24#ifdef SK_DEBUG
25#include "src/gpu/GrTexturePriv.h"
26
27void GrProgramInfo::validate(bool flushTime) const {
28 if (flushTime) {
29 SkASSERT(fPipeline->allProxiesInstantiated());
30 }
31}
32
33void GrProgramInfo::checkAllInstantiated() const {
34 for (auto [sampler, fp] : GrFragmentProcessor::PipelineTextureSamplerRange(this->pipeline())) {
35 SkASSERT(sampler.proxy()->isInstantiated());
36 }
37}
38
39void GrProgramInfo::checkMSAAAndMIPSAreResolved() const {
40 for (auto [sampler, fp] : GrFragmentProcessor::PipelineTextureSamplerRange(this->pipeline())) {
41 GrTexture* tex = sampler.peekTexture();
42 SkASSERT(tex);
43
44 // Ensure mipmaps were all resolved ahead of time by the DAG.
45 if (GrSamplerState::Filter::kMipMap == sampler.samplerState().filter() &&
46 (tex->width() != 1 || tex->height() != 1)) {
47 // There are some cases where we might be given a non-mipmapped texture with a mipmap
48 // filter. See skbug.com/7094.
49 SkASSERT(tex->texturePriv().mipMapped() != GrMipMapped::kYes ||
50 !tex->texturePriv().mipMapsAreDirty());
51 }
52 }
53}
54
55#endif
56