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 | |
Chris Dalton | 3bf2f3a | 2020-03-17 11:48:23 -0600 | [diff] [blame^] | 32 | if (this->hasFixedPrimProcTextures()) { |
Robert Phillips | 67a625e | 2019-11-15 15:37:07 -0500 | [diff] [blame] | 33 | SkASSERT(fPrimProc->numTextureSamplers()); |
Robert Phillips | 865d8d6 | 2019-10-09 14:15:55 -0400 | [diff] [blame] | 34 | } |
| 35 | |
Chris Dalton | 012f849 | 2020-03-05 11:49:15 -0700 | [diff] [blame] | 36 | if (!fPipeline->isScissorTestEnabled()) { |
Chris Dalton | 3bf2f3a | 2020-03-17 11:48:23 -0600 | [diff] [blame^] | 37 | SkASSERT(!this->hasFixedScissor()); |
Robert Phillips | 865d8d6 | 2019-10-09 14:15:55 -0400 | [diff] [blame] | 38 | } |
| 39 | } |
| 40 | |
Robert Phillips | 2d8a95e | 2019-10-10 12:50:22 -0400 | [diff] [blame] | 41 | void GrProgramInfo::checkAllInstantiated() const { |
| 42 | if (this->hasFixedPrimProcTextures()) { |
| 43 | auto fixedPrimProcTextures = this->fixedPrimProcTextures(); |
| 44 | for (int s = 0; s < this->primProc().numTextureSamplers(); ++s) { |
| 45 | SkASSERT(fixedPrimProcTextures[s]->isInstantiated()); |
| 46 | } |
| 47 | } |
Chris Dalton | 3bf2f3a | 2020-03-17 11:48:23 -0600 | [diff] [blame^] | 48 | for (auto [sampler, fp] : GrFragmentProcessor::PipelineTextureSamplerRange(this->pipeline())) { |
| 49 | SkASSERT(sampler.proxy()->isInstantiated()); |
Robert Phillips | 2d8a95e | 2019-10-10 12:50:22 -0400 | [diff] [blame] | 50 | } |
| 51 | } |
| 52 | |
| 53 | void GrProgramInfo::checkMSAAAndMIPSAreResolved() const { |
Brian Salomon | ccb6142 | 2020-01-09 10:46:36 -0500 | [diff] [blame] | 54 | auto assertResolved = [](GrTexture* tex, GrSamplerState sampler) { |
Robert Phillips | 865d8d6 | 2019-10-09 14:15:55 -0400 | [diff] [blame] | 55 | SkASSERT(tex); |
| 56 | |
| 57 | // Ensure mipmaps were all resolved ahead of time by the DAG. |
| 58 | if (GrSamplerState::Filter::kMipMap == sampler.filter() && |
| 59 | (tex->width() != 1 || tex->height() != 1)) { |
| 60 | // There are some cases where we might be given a non-mipmapped texture with a mipmap |
| 61 | // filter. See skbug.com/7094. |
| 62 | SkASSERT(tex->texturePriv().mipMapped() != GrMipMapped::kYes || |
| 63 | !tex->texturePriv().mipMapsAreDirty()); |
| 64 | } |
| 65 | }; |
| 66 | |
Chris Dalton | 3bf2f3a | 2020-03-17 11:48:23 -0600 | [diff] [blame^] | 67 | if (this->hasFixedPrimProcTextures()) { |
Robert Phillips | 865d8d6 | 2019-10-09 14:15:55 -0400 | [diff] [blame] | 68 | auto fixedPrimProcTextures = this->fixedPrimProcTextures(); |
| 69 | |
| 70 | for (int s = 0; s < this->primProc().numTextureSamplers(); ++s) { |
| 71 | auto* tex = fixedPrimProcTextures[s]->peekTexture(); |
| 72 | assertResolved(tex, this->primProc().textureSampler(s).samplerState()); |
| 73 | } |
| 74 | } |
| 75 | |
Brian Salomon | c241b58 | 2019-11-27 08:57:17 -0500 | [diff] [blame] | 76 | for (auto [sampler, fp] : GrFragmentProcessor::PipelineTextureSamplerRange(this->pipeline())) { |
| 77 | assertResolved(sampler.peekTexture(), sampler.samplerState()); |
Robert Phillips | 865d8d6 | 2019-10-09 14:15:55 -0400 | [diff] [blame] | 78 | } |
| 79 | } |
| 80 | |
Robert Phillips | 865d8d6 | 2019-10-09 14:15:55 -0400 | [diff] [blame] | 81 | #endif |