blob: 85f5121c352085b4566c1293c66dab5b561e2af2 [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
Chris Dalton1b6a43c2020-09-25 12:21:18 -060015 if (this->isStencilEnabled()) {
16 stencil.reset(*fUserStencilSettings, this->pipeline().hasStencilClip(), 8);
Robert Phillipsa87c5292019-11-12 10:12:42 -050017 }
18
19 return stencil;
20}
Robert Phillips865d8d62019-10-09 14:15:55 -040021
22#ifdef SK_DEBUG
Brian Salomon4cfae3b2020-07-23 10:33:24 -040023#include "src/gpu/GrTexture.h"
Robert Phillips865d8d62019-10-09 14:15:55 -040024
Robert Phillips8053c972019-11-21 10:44:53 -050025void GrProgramInfo::validate(bool flushTime) const {
26 if (flushTime) {
27 SkASSERT(fPipeline->allProxiesInstantiated());
28 }
Robert Phillips865d8d62019-10-09 14:15:55 -040029}
30
Robert Phillips2d8a95e2019-10-10 12:50:22 -040031void GrProgramInfo::checkAllInstantiated() const {
Brian Salomon7e67dca2020-07-21 09:27:25 -040032 this->pipeline().visitProxies([](GrSurfaceProxy* proxy, GrMipmapped) {
Brian Salomond90b3d32020-07-09 12:04:31 -040033 SkASSERT(proxy->isInstantiated());
34 return true;
35 });
Robert Phillips2d8a95e2019-10-10 12:50:22 -040036}
37
38void GrProgramInfo::checkMSAAAndMIPSAreResolved() const {
Brian Salomond90b3d32020-07-09 12:04:31 -040039 this->pipeline().visitTextureEffects([](const GrTextureEffect& te) {
40 GrTexture* tex = te.texture();
Robert Phillips865d8d62019-10-09 14:15:55 -040041 SkASSERT(tex);
42
43 // Ensure mipmaps were all resolved ahead of time by the DAG.
Brian Salomone69b9ef2020-07-22 11:18:06 -040044 if (te.samplerState().mipmapped() == GrMipmapped::kYes &&
Robert Phillips865d8d62019-10-09 14:15:55 -040045 (tex->width() != 1 || tex->height() != 1)) {
Brian Salomond90b3d32020-07-09 12:04:31 -040046 // There are some cases where we might be given a non-mipmapped texture with a
47 // mipmap filter. See skbug.com/7094.
Brian Salomon4cfae3b2020-07-23 10:33:24 -040048 SkASSERT(tex->mipmapped() != GrMipmapped::kYes || !tex->mipmapsAreDirty());
Robert Phillips865d8d62019-10-09 14:15:55 -040049 }
Brian Salomond90b3d32020-07-09 12:04:31 -040050 });
Robert Phillips865d8d62019-10-09 14:15:55 -040051}
52
Robert Phillips865d8d62019-10-09 14:15:55 -040053#endif