blob: 091d1133ee68377f8f419328d8aa004958653fe6 [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"
Robert Phillips550de7f2021-07-06 16:28:52 -040011#include "src/gpu/effects/GrTextureEffect.h"
Robert Phillipsa87c5292019-11-12 10:12:42 -050012
13GrStencilSettings GrProgramInfo::nonGLStencilSettings() const {
14 GrStencilSettings stencil;
15
Chris Dalton1b6a43c2020-09-25 12:21:18 -060016 if (this->isStencilEnabled()) {
17 stencil.reset(*fUserStencilSettings, this->pipeline().hasStencilClip(), 8);
Robert Phillipsa87c5292019-11-12 10:12:42 -050018 }
19
20 return stencil;
21}
Robert Phillips865d8d62019-10-09 14:15:55 -040022
23#ifdef SK_DEBUG
Brian Salomon4cfae3b2020-07-23 10:33:24 -040024#include "src/gpu/GrTexture.h"
Robert Phillips865d8d62019-10-09 14:15:55 -040025
Robert Phillips8053c972019-11-21 10:44:53 -050026void GrProgramInfo::validate(bool flushTime) const {
27 if (flushTime) {
28 SkASSERT(fPipeline->allProxiesInstantiated());
29 }
Robert Phillips865d8d62019-10-09 14:15:55 -040030}
31
Robert Phillips2d8a95e2019-10-10 12:50:22 -040032void GrProgramInfo::checkAllInstantiated() const {
Brian Salomon7e67dca2020-07-21 09:27:25 -040033 this->pipeline().visitProxies([](GrSurfaceProxy* proxy, GrMipmapped) {
Brian Salomond90b3d32020-07-09 12:04:31 -040034 SkASSERT(proxy->isInstantiated());
35 return true;
36 });
Robert Phillips2d8a95e2019-10-10 12:50:22 -040037}
38
39void GrProgramInfo::checkMSAAAndMIPSAreResolved() const {
Brian Salomond90b3d32020-07-09 12:04:31 -040040 this->pipeline().visitTextureEffects([](const GrTextureEffect& te) {
41 GrTexture* tex = te.texture();
Robert Phillips865d8d62019-10-09 14:15:55 -040042 SkASSERT(tex);
43
44 // Ensure mipmaps were all resolved ahead of time by the DAG.
Brian Salomone69b9ef2020-07-22 11:18:06 -040045 if (te.samplerState().mipmapped() == GrMipmapped::kYes &&
Robert Phillips865d8d62019-10-09 14:15:55 -040046 (tex->width() != 1 || tex->height() != 1)) {
Brian Salomond90b3d32020-07-09 12:04:31 -040047 // There are some cases where we might be given a non-mipmapped texture with a
48 // mipmap filter. See skbug.com/7094.
Brian Salomon4cfae3b2020-07-23 10:33:24 -040049 SkASSERT(tex->mipmapped() != GrMipmapped::kYes || !tex->mipmapsAreDirty());
Robert Phillips865d8d62019-10-09 14:15:55 -040050 }
Brian Salomond90b3d32020-07-09 12:04:31 -040051 });
Robert Phillips865d8d62019-10-09 14:15:55 -040052}
53
Robert Phillips865d8d62019-10-09 14:15:55 -040054#endif