Robert Phillips | 865d8d6 | 2019-10-09 14:15:55 -0400 | [diff] [blame] | 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 | |
Robert Phillips | a87c529 | 2019-11-12 10:12:42 -0500 | [diff] [blame] | 10 | #include "src/gpu/GrStencilSettings.h" |
Robert Phillips | 550de7f | 2021-07-06 16:28:52 -0400 | [diff] [blame] | 11 | #include "src/gpu/effects/GrTextureEffect.h" |
Robert Phillips | a87c529 | 2019-11-12 10:12:42 -0500 | [diff] [blame] | 12 | |
| 13 | GrStencilSettings GrProgramInfo::nonGLStencilSettings() const { |
| 14 | GrStencilSettings stencil; |
| 15 | |
Chris Dalton | 1b6a43c | 2020-09-25 12:21:18 -0600 | [diff] [blame] | 16 | if (this->isStencilEnabled()) { |
| 17 | stencil.reset(*fUserStencilSettings, this->pipeline().hasStencilClip(), 8); |
Robert Phillips | a87c529 | 2019-11-12 10:12:42 -0500 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | return stencil; |
| 21 | } |
Robert Phillips | 865d8d6 | 2019-10-09 14:15:55 -0400 | [diff] [blame] | 22 | |
| 23 | #ifdef SK_DEBUG |
Brian Salomon | 4cfae3b | 2020-07-23 10:33:24 -0400 | [diff] [blame] | 24 | #include "src/gpu/GrTexture.h" |
Robert Phillips | 865d8d6 | 2019-10-09 14:15:55 -0400 | [diff] [blame] | 25 | |
Robert Phillips | 8053c97 | 2019-11-21 10:44:53 -0500 | [diff] [blame] | 26 | void GrProgramInfo::validate(bool flushTime) const { |
| 27 | if (flushTime) { |
| 28 | SkASSERT(fPipeline->allProxiesInstantiated()); |
| 29 | } |
Robert Phillips | 865d8d6 | 2019-10-09 14:15:55 -0400 | [diff] [blame] | 30 | } |
| 31 | |
Robert Phillips | 2d8a95e | 2019-10-10 12:50:22 -0400 | [diff] [blame] | 32 | void GrProgramInfo::checkAllInstantiated() const { |
Brian Salomon | 7e67dca | 2020-07-21 09:27:25 -0400 | [diff] [blame] | 33 | this->pipeline().visitProxies([](GrSurfaceProxy* proxy, GrMipmapped) { |
Brian Salomon | d90b3d3 | 2020-07-09 12:04:31 -0400 | [diff] [blame] | 34 | SkASSERT(proxy->isInstantiated()); |
| 35 | return true; |
| 36 | }); |
Robert Phillips | 2d8a95e | 2019-10-10 12:50:22 -0400 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | void GrProgramInfo::checkMSAAAndMIPSAreResolved() const { |
Brian Salomon | d90b3d3 | 2020-07-09 12:04:31 -0400 | [diff] [blame] | 40 | this->pipeline().visitTextureEffects([](const GrTextureEffect& te) { |
| 41 | GrTexture* tex = te.texture(); |
Robert Phillips | 865d8d6 | 2019-10-09 14:15:55 -0400 | [diff] [blame] | 42 | SkASSERT(tex); |
| 43 | |
| 44 | // Ensure mipmaps were all resolved ahead of time by the DAG. |
Brian Salomon | e69b9ef | 2020-07-22 11:18:06 -0400 | [diff] [blame] | 45 | if (te.samplerState().mipmapped() == GrMipmapped::kYes && |
Robert Phillips | 865d8d6 | 2019-10-09 14:15:55 -0400 | [diff] [blame] | 46 | (tex->width() != 1 || tex->height() != 1)) { |
Brian Salomon | d90b3d3 | 2020-07-09 12:04:31 -0400 | [diff] [blame] | 47 | // There are some cases where we might be given a non-mipmapped texture with a |
| 48 | // mipmap filter. See skbug.com/7094. |
Brian Salomon | 4cfae3b | 2020-07-23 10:33:24 -0400 | [diff] [blame] | 49 | SkASSERT(tex->mipmapped() != GrMipmapped::kYes || !tex->mipmapsAreDirty()); |
Robert Phillips | 865d8d6 | 2019-10-09 14:15:55 -0400 | [diff] [blame] | 50 | } |
Brian Salomon | d90b3d3 | 2020-07-09 12:04:31 -0400 | [diff] [blame] | 51 | }); |
Robert Phillips | 865d8d6 | 2019-10-09 14:15:55 -0400 | [diff] [blame] | 52 | } |
| 53 | |
Robert Phillips | 865d8d6 | 2019-10-09 14:15:55 -0400 | [diff] [blame] | 54 | #endif |