Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(524)

Side by Side Diff: src/gpu/GrXferProcessor.cpp

Issue 1164973002: Add mixed samples support to XPs (Closed) Base URL: https://skia.googlesource.com/skia.git@upload2_reenablebea
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrPipelineBuilder.cpp ('k') | src/gpu/effects/GrCoverageSetOpXP.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrXferProcessor.h" 8 #include "GrXferProcessor.h"
9 #include "GrPipelineBuilder.h"
9 #include "GrProcOptInfo.h" 10 #include "GrProcOptInfo.h"
10 #include "gl/GrGLCaps.h" 11 #include "gl/GrGLCaps.h"
11 12
12 GrXferProcessor::GrXferProcessor() 13 GrXferProcessor::GrXferProcessor()
13 : fWillReadDstColor(false), fReadsCoverage(true), fDstTextureOffset() { 14 : fWillReadDstColor(false)
15 , fDstReadUsesMixedSamples(false)
16 , fReadsCoverage(true)
17 , fDstTextureOffset() {
14 } 18 }
15 19
16 GrXferProcessor::GrXferProcessor(const DstTexture* dstTexture, bool willReadDstC olor) 20 GrXferProcessor::GrXferProcessor(const DstTexture* dstTexture,
21 bool willReadDstColor,
22 bool hasMixedSamples)
17 : fWillReadDstColor(willReadDstColor) 23 : fWillReadDstColor(willReadDstColor)
24 , fDstReadUsesMixedSamples(willReadDstColor && hasMixedSamples)
18 , fReadsCoverage(true) 25 , fReadsCoverage(true)
19 , fDstTextureOffset() { 26 , fDstTextureOffset() {
20 if (dstTexture && dstTexture->texture()) { 27 if (dstTexture && dstTexture->texture()) {
21 SkASSERT(willReadDstColor); 28 SkASSERT(willReadDstColor);
22 fDstTexture.reset(dstTexture->texture()); 29 fDstTexture.reset(dstTexture->texture());
23 fDstTextureOffset = dstTexture->offset(); 30 fDstTextureOffset = dstTexture->offset();
24 this->addTextureAccess(&fDstTexture); 31 this->addTextureAccess(&fDstTexture);
25 this->setWillReadFragmentPosition(); 32 this->setWillReadFragmentPosition();
26 } 33 }
27 } 34 }
(...skipping 19 matching lines...) Expand all
47 if (flags & GrXferProcessor::kIgnoreCoverage_OptFlag) { 54 if (flags & GrXferProcessor::kIgnoreCoverage_OptFlag) {
48 fReadsCoverage = false; 55 fReadsCoverage = false;
49 } 56 }
50 return flags; 57 return flags;
51 } 58 }
52 59
53 bool GrXferProcessor::hasSecondaryOutput() const { 60 bool GrXferProcessor::hasSecondaryOutput() const {
54 if (!this->willReadDstColor()) { 61 if (!this->willReadDstColor()) {
55 return this->onHasSecondaryOutput(); 62 return this->onHasSecondaryOutput();
56 } 63 }
57 return false; 64 return this->dstReadUsesMixedSamples();
58 } 65 }
59 66
60 void GrXferProcessor::getBlendInfo(BlendInfo* blendInfo) const { 67 void GrXferProcessor::getBlendInfo(BlendInfo* blendInfo) const {
61 blendInfo->reset(); 68 blendInfo->reset();
62 if (!this->willReadDstColor()) { 69 if (!this->willReadDstColor()) {
63 this->onGetBlendInfo(blendInfo); 70 this->onGetBlendInfo(blendInfo);
71 } else if (this->dstReadUsesMixedSamples()) {
72 blendInfo->fDstBlend = kIS2A_GrBlendCoeff;
64 } 73 }
65 } 74 }
66 75
67 void GrXferProcessor::getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBu ilder* b) const { 76 void GrXferProcessor::getGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBu ilder* b) const {
68 uint32_t key = this->willReadDstColor() ? 0x1 : 0x0; 77 uint32_t key = this->willReadDstColor() ? 0x1 : 0x0;
69 if (key) { 78 if (key) {
70 if (const GrTexture* dstTexture = this->getDstTexture()) { 79 if (const GrTexture* dstTexture = this->getDstTexture()) {
71 key |= 0x2; 80 key |= 0x2;
72 if (kTopLeft_GrSurfaceOrigin == dstTexture->origin()) { 81 if (kTopLeft_GrSurfaceOrigin == dstTexture->origin()) {
73 key |= 0x4; 82 key |= 0x4;
74 } 83 }
75 } 84 }
76 if (this->readsCoverage()) { 85 if (this->readsCoverage()) {
77 key |= 0x8; 86 key |= 0x8;
78 } 87 }
88 if (this->dstReadUsesMixedSamples()) {
89 key |= 0x10;
90 }
79 } 91 }
80 b->add32(key); 92 b->add32(key);
81 this->onGetGLProcessorKey(caps, b); 93 this->onGetGLProcessorKey(caps, b);
82 } 94 }
83 95
84 bool GrXferProcessor::willNeedXferBarrier(const GrRenderTarget* rt, 96 bool GrXferProcessor::willNeedXferBarrier(const GrRenderTarget* rt,
85 const GrCaps& caps, 97 const GrCaps& caps,
86 GrXferBarrierType* outBarrierType) con st { 98 GrXferBarrierType* outBarrierType) con st {
87 if (static_cast<const GrSurface*>(rt) == this->getDstTexture()) { 99 if (static_cast<const GrSurface*>(rt) == this->getDstTexture()) {
88 // Texture barriers are required when a shader reads and renders to the same texture. 100 // Texture barriers are required when a shader reads and renders to the same texture.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 fWriteColor, equation_string(fEquation), coeff_string(fSrcBlend), 197 fWriteColor, equation_string(fEquation), coeff_string(fSrcBlend),
186 coeff_string(fDstBlend), fBlendConstant); 198 coeff_string(fDstBlend), fBlendConstant);
187 return out; 199 return out;
188 } 200 }
189 #endif 201 #endif
190 202
191 /////////////////////////////////////////////////////////////////////////////// 203 ///////////////////////////////////////////////////////////////////////////////
192 204
193 GrXferProcessor* GrXPFactory::createXferProcessor(const GrProcOptInfo& colorPOI, 205 GrXferProcessor* GrXPFactory::createXferProcessor(const GrProcOptInfo& colorPOI,
194 const GrProcOptInfo& coverageP OI, 206 const GrProcOptInfo& coverageP OI,
207 bool hasMixedSamples,
195 const DstTexture* dstTexture, 208 const DstTexture* dstTexture,
196 const GrCaps& caps) const { 209 const GrCaps& caps) const {
197 #ifdef SK_DEBUG 210 #ifdef SK_DEBUG
198 if (this->willReadDstColor(caps, colorPOI, coveragePOI)) { 211 if (this->willReadDstColor(caps, colorPOI, coveragePOI, hasMixedSamples)) {
199 if (!caps.shaderCaps()->dstReadInShaderSupport()) { 212 if (!caps.shaderCaps()->dstReadInShaderSupport()) {
200 SkASSERT(dstTexture && dstTexture->texture()); 213 SkASSERT(dstTexture && dstTexture->texture());
201 } else { 214 } else {
202 SkASSERT(!dstTexture || !dstTexture->texture()); 215 SkASSERT(!dstTexture || !dstTexture->texture());
203 } 216 }
204 } else { 217 } else {
205 SkASSERT(!dstTexture || !dstTexture->texture()); 218 SkASSERT(!dstTexture || !dstTexture->texture());
206 } 219 }
220 SkASSERT(!hasMixedSamples || caps.shaderCaps()->dualSourceBlendingSupport()) ;
207 #endif 221 #endif
208 return this->onCreateXferProcessor(caps, colorPOI, coveragePOI, dstTexture); 222 return this->onCreateXferProcessor(caps, colorPOI, coveragePOI, hasMixedSamp les, dstTexture);
209 } 223 }
210 224
211 bool GrXPFactory::willNeedDstTexture(const GrCaps& caps, const GrProcOptInfo& co lorPOI, 225 bool GrXPFactory::willNeedDstTexture(const GrCaps& caps,
212 const GrProcOptInfo& coveragePOI) const { 226 const GrProcOptInfo& colorPOI,
213 return (this->willReadDstColor(caps, colorPOI, coveragePOI) 227 const GrProcOptInfo& coveragePOI,
214 && !caps.shaderCaps()->dstReadInShaderSupport()); 228 bool hasMixedSamples) const {
229 return (this->willReadDstColor(caps, colorPOI, coveragePOI, hasMixedSamples) &&
230 !caps.shaderCaps()->dstReadInShaderSupport());
215 } 231 }
OLDNEW
« no previous file with comments | « src/gpu/GrPipelineBuilder.cpp ('k') | src/gpu/effects/GrCoverageSetOpXP.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698