blob: 34e645985337210306c6de1ebc68d70a9c35a7cd [file] [log] [blame]
Robert Phillips865d8d62019-10-09 14:15:55 -04001/*
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
Robert Phillipsa87c5292019-11-12 10:12:42 -050010#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}
Robert Phillips865d8d62019-10-09 14:15:55 -040023
24#ifdef SK_DEBUG
25#include "src/gpu/GrTexturePriv.h"
26
Robert Phillips8053c972019-11-21 10:44:53 -050027void GrProgramInfo::validate(bool flushTime) const {
28 if (flushTime) {
29 SkASSERT(fPipeline->allProxiesInstantiated());
30 }
Robert Phillips865d8d62019-10-09 14:15:55 -040031}
32
Robert Phillips2d8a95e2019-10-10 12:50:22 -040033void GrProgramInfo::checkAllInstantiated() const {
Brian Salomond90b3d32020-07-09 12:04:31 -040034 this->pipeline().visitProxies([](GrSurfaceProxy* proxy, GrMipMapped) {
35 SkASSERT(proxy->isInstantiated());
36 return true;
37 });
Robert Phillips2d8a95e2019-10-10 12:50:22 -040038}
39
40void GrProgramInfo::checkMSAAAndMIPSAreResolved() const {
Brian Salomond90b3d32020-07-09 12:04:31 -040041 this->pipeline().visitTextureEffects([](const GrTextureEffect& te) {
42 GrTexture* tex = te.texture();
Robert Phillips865d8d62019-10-09 14:15:55 -040043 SkASSERT(tex);
44
45 // Ensure mipmaps were all resolved ahead of time by the DAG.
Brian Salomond90b3d32020-07-09 12:04:31 -040046 if (GrSamplerState::Filter::kMipMap == te.samplerState().filter() &&
Robert Phillips865d8d62019-10-09 14:15:55 -040047 (tex->width() != 1 || tex->height() != 1)) {
Brian Salomond90b3d32020-07-09 12:04:31 -040048 // There are some cases where we might be given a non-mipmapped texture with a
49 // mipmap filter. See skbug.com/7094.
Robert Phillips865d8d62019-10-09 14:15:55 -040050 SkASSERT(tex->texturePriv().mipMapped() != GrMipMapped::kYes ||
51 !tex->texturePriv().mipMapsAreDirty());
52 }
Brian Salomond90b3d32020-07-09 12:04:31 -040053 });
Robert Phillips865d8d62019-10-09 14:15:55 -040054}
55
Robert Phillips865d8d62019-10-09 14:15:55 -040056#endif