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

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

Issue 1717393002: Add "sample locations" feature to GrProcessor (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_getmultisamp
Patch Set: comments Created 4 years, 9 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrCaps.h" 9 #include "GrCaps.h"
10 #include "GrContextOptions.h" 10 #include "GrContextOptions.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return r; 73 return r;
74 } 74 }
75 75
76 void GrShaderCaps::applyOptionsOverrides(const GrContextOptions& options) { 76 void GrShaderCaps::applyOptionsOverrides(const GrContextOptions& options) {
77 fDualSourceBlendingSupport = fDualSourceBlendingSupport && !options.fSuppres sDualSourceBlending; 77 fDualSourceBlendingSupport = fDualSourceBlendingSupport && !options.fSuppres sDualSourceBlending;
78 this->onApplyOptionsOverrides(options); 78 this->onApplyOptionsOverrides(options);
79 } 79 }
80 80
81 /////////////////////////////////////////////////////////////////////////////// 81 ///////////////////////////////////////////////////////////////////////////////
82 82
83 GrCaps::GrCaps(const GrContextOptions& options) { 83 GrCaps::GrCaps(const GrContextOptions& options) : fMultisampleSpecsAllocator(1) {
84 fMipMapSupport = false; 84 fMipMapSupport = false;
85 fNPOTTextureTileSupport = false; 85 fNPOTTextureTileSupport = false;
86 fTwoSidedStencilSupport = false; 86 fTwoSidedStencilSupport = false;
87 fStencilWrapOpsSupport = false; 87 fStencilWrapOpsSupport = false;
88 fDiscardRenderTargetSupport = false; 88 fDiscardRenderTargetSupport = false;
89 fReuseScratchTextures = true; 89 fReuseScratchTextures = true;
90 fReuseScratchBuffers = true; 90 fReuseScratchBuffers = true;
91 fGpuTracingSupport = false; 91 fGpuTracingSupport = false;
92 fCompressedTexSubImageSupport = false; 92 fCompressedTexSubImageSupport = false;
93 fOversizedStencilSupport = false; 93 fOversizedStencilSupport = false;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 fMaxTextureSize = SkTMin(fMaxTextureSize, options.fMaxTextureSizeOverride); 125 fMaxTextureSize = SkTMin(fMaxTextureSize, options.fMaxTextureSizeOverride);
126 // If the max tile override is zero, it means we should use the max texture size. 126 // If the max tile override is zero, it means we should use the max texture size.
127 if (!options.fMaxTileSizeOverride || options.fMaxTileSizeOverride > fMaxText ureSize) { 127 if (!options.fMaxTileSizeOverride || options.fMaxTileSizeOverride > fMaxText ureSize) {
128 fMaxTileSize = fMaxTextureSize; 128 fMaxTileSize = fMaxTextureSize;
129 } else { 129 } else {
130 fMaxTileSize = options.fMaxTileSizeOverride; 130 fMaxTileSize = options.fMaxTileSizeOverride;
131 } 131 }
132 this->onApplyOptionsOverrides(options); 132 this->onApplyOptionsOverrides(options);
133 } 133 }
134 134
135 inline static uint8_t multisample_specs_id(uint8_t numSamples, GrSurfaceOrigin o rigin,
136 const GrCaps& caps) {
137 if (!caps.sampleLocationsSupport()) {
138 return numSamples;
139 }
140
141 SkASSERT(numSamples < 128);
142 SkASSERT(kTopLeft_GrSurfaceOrigin == origin || kBottomLeft_GrSurfaceOrigin = = origin);
143 return (numSamples << 1) | (origin - 1);
144
145 GR_STATIC_ASSERT(1 == kTopLeft_GrSurfaceOrigin);
146 GR_STATIC_ASSERT(2 == kBottomLeft_GrSurfaceOrigin);
147 }
148
149 const GrCaps::MultisampleSpecs&
150 GrCaps::getMultisampleSpecs(const GrSurfaceDesc& desc,
151 const QueryMultisampleFunctor& queryMultisample) con st {
152 uint8_t surfDescKey = multisample_specs_id(desc.fSampleCnt, desc.fOrigin, *t his);
153 if (fMultisampleSpecsMap.count() > surfDescKey && fMultisampleSpecsMap[surfD escKey]) {
154 #if !defined(SK_DEBUG)
155 // In debug mode we query the multisample info every time and verify the caching is correct.
156 return *fMultisampleSpecsMap[surfDescKey];
157 #endif
158 }
159 int effectiveSampleCnt;
160 SkAutoTDeleteArray<SkPoint> locations(nullptr);
161 queryMultisample(&effectiveSampleCnt, &locations);
162 SkASSERT(effectiveSampleCnt && effectiveSampleCnt >= desc.fSampleCnt);
163 uint8_t effectiveKey = multisample_specs_id(effectiveSampleCnt, desc.fOrigin , *this);
164 if (fMultisampleSpecsMap.count() > effectiveKey && fMultisampleSpecsMap[effe ctiveKey]) {
165 const MultisampleSpecs& specs = *fMultisampleSpecsMap[effectiveKey];
166 SkASSERT(effectiveKey == specs.fUniqueID);
167 SkASSERT(effectiveSampleCnt == specs.fEffectiveSampleCnt);
168 SkASSERT(!this->sampleLocationsSupport() || !memcmp(locations.get(),
169 specs.fSampleLocatio ns.get(),
170 effectiveSampleCnt * sizeof(SkPoint)));
171 SkASSERT(surfDescKey <= effectiveKey);
172 SkASSERT(!fMultisampleSpecsMap[surfDescKey] || fMultisampleSpecsMap[surf DescKey] == &specs);
173 fMultisampleSpecsMap[surfDescKey] = &specs;
174 return specs;
175 }
176 const MultisampleSpecs& specs = *new (&fMultisampleSpecsAllocator)
177 MultisampleSpecs{effectiveKey, effectiveSampleCnt, locations.detach()};
178 if (fMultisampleSpecsMap.count() <= effectiveKey) {
179 int n = 1 + effectiveKey - fMultisampleSpecsMap.count();
180 fMultisampleSpecsMap.push_back_n(n, (const MultisampleSpecs*) nullptr);
181 }
182 fMultisampleSpecsMap[effectiveKey] = &specs;
183 if (effectiveSampleCnt != desc.fSampleCnt) {
184 SkASSERT(surfDescKey < effectiveKey);
185 fMultisampleSpecsMap[surfDescKey] = &specs;
186 }
187 return specs;
188 }
189
190 const GrCaps::MultisampleSpecs& GrCaps::getMultisampleSpecs(uint8_t uniqueID) co nst {
191 SkASSERT(fMultisampleSpecsMap.count() > uniqueID && fMultisampleSpecsMap[uni queID]);
192 const MultisampleSpecs& specs = *fMultisampleSpecsMap[uniqueID];
193 SkASSERT(specs.fUniqueID == uniqueID);
194 return specs;
195 }
196
135 static SkString map_flags_to_string(uint32_t flags) { 197 static SkString map_flags_to_string(uint32_t flags) {
136 SkString str; 198 SkString str;
137 if (GrCaps::kNone_MapFlags == flags) { 199 if (GrCaps::kNone_MapFlags == flags) {
138 str = "none"; 200 str = "none";
139 } else { 201 } else {
140 SkASSERT(GrCaps::kCanMap_MapFlag & flags); 202 SkASSERT(GrCaps::kCanMap_MapFlag & flags);
141 SkDEBUGCODE(flags &= ~GrCaps::kCanMap_MapFlag); 203 SkDEBUGCODE(flags &= ~GrCaps::kCanMap_MapFlag);
142 str = "can_map"; 204 str = "can_map";
143 205
144 if (GrCaps::kSubset_MapFlag & flags) { 206 if (GrCaps::kSubset_MapFlag & flags) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 312
251 for (size_t i = 1; i < SK_ARRAY_COUNT(kConfigNames); ++i) { 313 for (size_t i = 1; i < SK_ARRAY_COUNT(kConfigNames); ++i) {
252 GrPixelConfig config = static_cast<GrPixelConfig>(i); 314 GrPixelConfig config = static_cast<GrPixelConfig>(i);
253 r.appendf("%s is uploadable to a texture: %s\n", 315 r.appendf("%s is uploadable to a texture: %s\n",
254 kConfigNames[i], 316 kConfigNames[i],
255 gNY[this->isConfigTexturable(config)]); 317 gNY[this->isConfigTexturable(config)]);
256 } 318 }
257 319
258 return r; 320 return r;
259 } 321 }
OLDNEW
« include/gpu/GrCaps.h ('K') | « include/private/SkTArray.h ('k') | src/gpu/GrGpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698