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

Side by Side Diff: src/gpu/gl/GrGLCaps.h

Issue 1535153002: Move config table to GrGLCaps from GrGLGpu. (Closed) Base URL: https://skia.googlesource.com/skia.git@rmc2glf
Patch Set: more wraps Created 5 years 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 | « no previous file | src/gpu/gl/GrGLCaps.cpp » ('j') | src/gpu/gl/GrGLGpu.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 8
9 #ifndef GrGLCaps_DEFINED 9 #ifndef GrGLCaps_DEFINED
10 #define GrGLCaps_DEFINED 10 #define GrGLCaps_DEFINED
(...skipping 10 matching lines...) Expand all
21 21
22 /** 22 /**
23 * Stores some capabilities of a GL context. Most are determined by the GL 23 * Stores some capabilities of a GL context. Most are determined by the GL
24 * version and the extensions string. It also tracks formats that have passed 24 * version and the extensions string. It also tracks formats that have passed
25 * the FBO completeness test. 25 * the FBO completeness test.
26 */ 26 */
27 class GrGLCaps : public GrCaps { 27 class GrGLCaps : public GrCaps {
28 public: 28 public:
29 typedef GrGLStencilAttachment::Format StencilFormat; 29 typedef GrGLStencilAttachment::Format StencilFormat;
30 30
31 /** Provides information about the mappiing from GrPixelConfig to GL formats . */
32 struct ConfigFormats {
33 ConfigFormats() {
34 // Inits to known bad GL enum values.
35 memset(this, 0xAB, sizeof(ConfigFormats));
36 }
37 GrGLenum fBaseInternalFormat;
38 GrGLenum fSizedInternalFormat;
39 GrGLenum fExternalFormat;
40 GrGLenum fExternalType;
41
42 // The <format> parameter to use for glTexImage and glTexSubImage.
43 // This is usually the same as fExternalFormat except for kSRGBA on some GL contexts.
44 GrGLenum fExternalFormatForTexImage;
45 // Either the base or sized internal format depending on the GL and conf ig.
46 GrGLenum fInternalFormatTexImage;
47 };
48
31 /** 49 /**
32 * The type of MSAA for FBOs supported. Different extensions have different 50 * The type of MSAA for FBOs supported. Different extensions have different
33 * semantics of how / when a resolve is performed. 51 * semantics of how / when a resolve is performed.
34 */ 52 */
35 enum MSFBOType { 53 enum MSFBOType {
36 /** 54 /**
37 * no support for MSAA FBOs 55 * no support for MSAA FBOs
38 */ 56 */
39 kNone_MSFBOType = 0, 57 kNone_MSFBOType = 0,
40 /** 58 /**
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 kLast_TransferBufferType = kChromium_TransferBufferType, 116 kLast_TransferBufferType = kChromium_TransferBufferType,
99 }; 117 };
100 118
101 /** 119 /**
102 * Initializes the GrGLCaps to the set of features supported in the current 120 * Initializes the GrGLCaps to the set of features supported in the current
103 * OpenGL context accessible via ctxInfo. 121 * OpenGL context accessible via ctxInfo.
104 */ 122 */
105 GrGLCaps(const GrContextOptions& contextOptions, const GrGLContextInfo& ctxI nfo, 123 GrGLCaps(const GrContextOptions& contextOptions, const GrGLContextInfo& ctxI nfo,
106 const GrGLInterface* glInterface); 124 const GrGLInterface* glInterface);
107 125
126 /** Returns conversions to various GL format parameters for a GrPixelCfonig. */
127 const ConfigFormats& configGLFormats(GrPixelConfig config) const {
128 return fConfigTable[config].fFormats;
129 }
130
131
132 /**
133 * Gets an array of legal stencil formats. These formats are not guaranteed
134 * to be supported by the driver but are legal GLenum names given the GL
135 * version and extensions supported.
136 */
137 const SkTArray<StencilFormat, true>& stencilFormats() const {
138 return fStencilFormats;
139 }
140
141 /**
142 * Has a stencil format index been found for the config (or we've found that no format works).
143 */
144 bool hasStencilFormatBeenDeterminedForConfig(GrPixelConfig config) const {
145 return fConfigTable[config].fStencilFormatIndex != ConfigInfo::kUnknown_ StencilIndex;
146 }
147
148 /**
149 * Gets the stencil format index for the config. This assumes
150 * hasStencilFormatBeenDeterminedForConfig has already been checked. Returns false if
151 * no stencil format is supported with the config. The returned index refers to the array
152 * returned by stencilFormats().
153 */
154 bool getStencilFormatIndexForConfig(GrPixelConfig config, int* index) const {
155 SkASSERT(this->hasStencilFormatBeenDeterminedForConfig(config));
156 if (ConfigInfo::kUnsupported_StencilFormatIndex ==
157 fConfigTable[config].fStencilFormatIndex) {
158 return false;
159 } else {
160 *index = fConfigTable[config].fStencilFormatIndex;
egdaniel 2015/12/21 15:10:44 is it worth asserting that index > 0 here. Thus we
bsalomon 2015/12/21 15:59:43 Took your other suggestion to just return an int h
161 return true;
162 }
163 }
164
165 /**
166 * If index is >= 0 this records an index into stencilFormats() as the best stencil format for
167 * the config. If < 0 it records that the config has no supported stencil fo rmat index.
168 */
169 void setStencilFormatIndexForConfig(GrPixelConfig config, int index) {
170 SkASSERT(!this->hasStencilFormatBeenDeterminedForConfig(config));
171 if (index < 0) {
172 fConfigTable[config].fStencilFormatIndex = ConfigInfo::kUnsupported_ StencilFormatIndex;
173 } else {
174 fConfigTable[config].fStencilFormatIndex = index;
175 }
176 }
177
108 /** 178 /**
109 * Call to note that a color config has been verified as a valid color 179 * Call to note that a color config has been verified as a valid color
110 * attachment. This may save future calls to glCheckFramebufferStatus 180 * attachment. This may save future calls to glCheckFramebufferStatus
111 * using isConfigVerifiedColorAttachment(). 181 * using isConfigVerifiedColorAttachment().
112 */ 182 */
113 void markConfigAsValidColorAttachment(GrPixelConfig config) { 183 void markConfigAsValidColorAttachment(GrPixelConfig config) {
114 fVerifiedColorConfigs.markVerified(config); 184 fVerifiedColorConfigs.markVerified(config);
115 } 185 }
116 186
117 /** 187 /**
(...skipping 29 matching lines...) Expand all
147 } 217 }
148 218
149 InvalidateFBType invalidateFBType() const { return fInvalidateFBType; } 219 InvalidateFBType invalidateFBType() const { return fInvalidateFBType; }
150 220
151 /// What type of buffer mapping is supported? 221 /// What type of buffer mapping is supported?
152 MapBufferType mapBufferType() const { return fMapBufferType; } 222 MapBufferType mapBufferType() const { return fMapBufferType; }
153 223
154 /// What type of transfer buffer is supported? 224 /// What type of transfer buffer is supported?
155 TransferBufferType transferBufferType() const { return fTransferBufferType; } 225 TransferBufferType transferBufferType() const { return fTransferBufferType; }
156 226
157 /**
158 * Gets an array of legal stencil formats. These formats are not guaranteed
159 * to be supported by the driver but are legal GLenum names given the GL
160 * version and extensions supported.
161 */
162 const SkTArray<StencilFormat, true>& stencilFormats() const {
163 return fStencilFormats;
164 }
165
166 /// The maximum number of fragment uniform vectors (GLES has min. 16). 227 /// The maximum number of fragment uniform vectors (GLES has min. 16).
167 int maxFragmentUniformVectors() const { return fMaxFragmentUniformVectors; } 228 int maxFragmentUniformVectors() const { return fMaxFragmentUniformVectors; }
168 229
169 /// maximum number of attribute values per vertex 230 /// maximum number of attribute values per vertex
170 int maxVertexAttributes() const { return fMaxVertexAttributes; } 231 int maxVertexAttributes() const { return fMaxVertexAttributes; }
171 232
172 /// maximum number of texture units accessible in the fragment shader. 233 /// maximum number of texture units accessible in the fragment shader.
173 int maxFragmentTextureUnits() const { return fMaxFragmentTextureUnits; } 234 int maxFragmentTextureUnits() const { return fMaxFragmentTextureUnits; }
174 235
175 /// ES requires an extension to support RGBA8 in RenderBufferStorage 236 /// ES requires an extension to support RGBA8 in RenderBufferStorage
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 void initConfigTexturableTable(const GrGLContextInfo&, const GrGLInterface*, bool srgbSupport); 386 void initConfigTexturableTable(const GrGLContextInfo&, const GrGLInterface*, bool srgbSupport);
326 387
327 bool doReadPixelsSupported(const GrGLInterface* intf, GrGLenum format, GrGLe num type) const; 388 bool doReadPixelsSupported(const GrGLInterface* intf, GrGLenum format, GrGLe num type) const;
328 389
329 void initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, 390 void initShaderPrecisionTable(const GrGLContextInfo& ctxInfo,
330 const GrGLInterface* intf, 391 const GrGLInterface* intf,
331 GrGLSLCaps* glslCaps); 392 GrGLSLCaps* glslCaps);
332 393
333 void initConfigSwizzleTable(const GrGLContextInfo& ctxInfo, GrGLSLCaps* glsl Caps); 394 void initConfigSwizzleTable(const GrGLContextInfo& ctxInfo, GrGLSLCaps* glsl Caps);
334 395
396 void initConfigTable(const GrGLContextInfo&);
397
335 // tracks configs that have been verified to pass the FBO completeness when 398 // tracks configs that have been verified to pass the FBO completeness when
336 // used as a color attachment 399 // used as a color attachment
337 VerifiedColorConfigs fVerifiedColorConfigs; 400 VerifiedColorConfigs fVerifiedColorConfigs;
338 401
339 SkTArray<StencilFormat, true> fStencilFormats; 402 SkTArray<StencilFormat, true> fStencilFormats;
340 403
341 int fMaxFragmentUniformVectors; 404 int fMaxFragmentUniformVectors;
342 int fMaxVertexAttributes; 405 int fMaxVertexAttributes;
343 int fMaxFragmentTextureUnits; 406 int fMaxFragmentTextureUnits;
344 407
(...skipping 21 matching lines...) Expand all
366 bool fMultisampleDisableSupport : 1; 429 bool fMultisampleDisableSupport : 1;
367 bool fUseNonVBOVertexAndIndexDynamicData : 1; 430 bool fUseNonVBOVertexAndIndexDynamicData : 1;
368 bool fIsCoreProfile : 1; 431 bool fIsCoreProfile : 1;
369 bool fBindFragDataLocationSupport : 1; 432 bool fBindFragDataLocationSupport : 1;
370 bool fSRGBWriteControl : 1; 433 bool fSRGBWriteControl : 1;
371 bool fRGBA8888PixelsOpsAreSlow : 1; 434 bool fRGBA8888PixelsOpsAreSlow : 1;
372 bool fPartialFBOReadIsSlow : 1; 435 bool fPartialFBOReadIsSlow : 1;
373 bool fBindUniformLocationSupport : 1; 436 bool fBindUniformLocationSupport : 1;
374 bool fExternalTextureSupport : 1; 437 bool fExternalTextureSupport : 1;
375 438
439 struct ConfigInfo {
440 ConfigInfo() : fStencilFormatIndex(kUnknown_StencilIndex) {};
441
442 ConfigFormats fFormats;
443
444 // Index into GrGLCaps's list of stencil formats. Support is determined experimentally and
445 // lazily.
446 int fStencilFormatIndex;
447
448 enum {
449 // This indicates that a stencil format has not yet been determined for the config.
450 kUnknown_StencilIndex = -1,
451 // This indicates that there is no supported stencil format for the config.
452 kUnsupported_StencilFormatIndex = -2
453 };
454 };
455
456 ConfigInfo fConfigTable[kGrPixelConfigCnt];
457
376 struct ReadPixelsSupportedFormat { 458 struct ReadPixelsSupportedFormat {
377 GrGLenum fFormat; 459 GrGLenum fFormat;
378 GrGLenum fType; 460 GrGLenum fType;
379 GrGLenum fFboFormat; 461 GrGLenum fFboFormat;
380 462
381 bool operator==(const ReadPixelsSupportedFormat& rhs) const { 463 bool operator==(const ReadPixelsSupportedFormat& rhs) const {
382 return fFormat == rhs.fFormat 464 return fFormat == rhs.fFormat
383 && fType == rhs.fType 465 && fType == rhs.fType
384 && fFboFormat == rhs.fFboFormat; 466 && fFboFormat == rhs.fFboFormat;
385 } 467 }
386 }; 468 };
387 mutable SkTHashMap<ReadPixelsSupportedFormat, bool> fReadPixelsSupportedCach e; 469 mutable SkTHashMap<ReadPixelsSupportedFormat, bool> fReadPixelsSupportedCach e;
388 470
389 typedef GrCaps INHERITED; 471 typedef GrCaps INHERITED;
390 }; 472 };
391 473
392 #endif 474 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/gl/GrGLCaps.cpp » ('j') | src/gpu/gl/GrGLGpu.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698