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" |
| 11 | |
| 12 | GrStencilSettings 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 Phillips | 865d8d6 | 2019-10-09 14:15:55 -0400 | [diff] [blame] | 23 | |
| 24 | #ifdef SK_DEBUG |
| 25 | #include "src/gpu/GrTexturePriv.h" |
| 26 | |
Robert Phillips | 8053c97 | 2019-11-21 10:44:53 -0500 | [diff] [blame] | 27 | void GrProgramInfo::validate(bool flushTime) const { |
| 28 | if (flushTime) { |
| 29 | SkASSERT(fPipeline->allProxiesInstantiated()); |
| 30 | } |
Robert Phillips | 865d8d6 | 2019-10-09 14:15:55 -0400 | [diff] [blame] | 31 | } |
| 32 | |
Robert Phillips | 2d8a95e | 2019-10-10 12:50:22 -0400 | [diff] [blame] | 33 | void GrProgramInfo::checkAllInstantiated() const { |
Brian Salomon | d90b3d3 | 2020-07-09 12:04:31 -0400 | [diff] [blame^] | 34 | this->pipeline().visitProxies([](GrSurfaceProxy* proxy, GrMipMapped) { |
| 35 | SkASSERT(proxy->isInstantiated()); |
| 36 | return true; |
| 37 | }); |
Robert Phillips | 2d8a95e | 2019-10-10 12:50:22 -0400 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | void GrProgramInfo::checkMSAAAndMIPSAreResolved() const { |
Brian Salomon | d90b3d3 | 2020-07-09 12:04:31 -0400 | [diff] [blame^] | 41 | this->pipeline().visitTextureEffects([](const GrTextureEffect& te) { |
| 42 | GrTexture* tex = te.texture(); |
Robert Phillips | 865d8d6 | 2019-10-09 14:15:55 -0400 | [diff] [blame] | 43 | SkASSERT(tex); |
| 44 | |
| 45 | // Ensure mipmaps were all resolved ahead of time by the DAG. |
Brian Salomon | d90b3d3 | 2020-07-09 12:04:31 -0400 | [diff] [blame^] | 46 | if (GrSamplerState::Filter::kMipMap == te.samplerState().filter() && |
Robert Phillips | 865d8d6 | 2019-10-09 14:15:55 -0400 | [diff] [blame] | 47 | (tex->width() != 1 || tex->height() != 1)) { |
Brian Salomon | d90b3d3 | 2020-07-09 12:04:31 -0400 | [diff] [blame^] | 48 | // There are some cases where we might be given a non-mipmapped texture with a |
| 49 | // mipmap filter. See skbug.com/7094. |
Robert Phillips | 865d8d6 | 2019-10-09 14:15:55 -0400 | [diff] [blame] | 50 | SkASSERT(tex->texturePriv().mipMapped() != GrMipMapped::kYes || |
| 51 | !tex->texturePriv().mipMapsAreDirty()); |
| 52 | } |
Brian Salomon | d90b3d3 | 2020-07-09 12:04:31 -0400 | [diff] [blame^] | 53 | }); |
Robert Phillips | 865d8d6 | 2019-10-09 14:15:55 -0400 | [diff] [blame] | 54 | } |
| 55 | |
Robert Phillips | 865d8d6 | 2019-10-09 14:15:55 -0400 | [diff] [blame] | 56 | #endif |