OLD | NEW |
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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 fConfigTable[config].fStencilFormatIndex = index; | 174 fConfigTable[config].fStencilFormatIndex = index; |
175 } | 175 } |
176 } | 176 } |
177 | 177 |
178 /** | 178 /** |
179 * 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 |
180 * attachment. This may save future calls to glCheckFramebufferStatus | 180 * attachment. This may save future calls to glCheckFramebufferStatus |
181 * using isConfigVerifiedColorAttachment(). | 181 * using isConfigVerifiedColorAttachment(). |
182 */ | 182 */ |
183 void markConfigAsValidColorAttachment(GrPixelConfig config) { | 183 void markConfigAsValidColorAttachment(GrPixelConfig config) { |
184 fVerifiedColorConfigs.markVerified(config); | 184 fConfigTable[config].fFlags |= ConfigInfo::kVerifiedColorAttachment_Flag
; |
185 } | 185 } |
186 | 186 |
187 /** | 187 /** |
188 * Call to check whether a config has been verified as a valid color | 188 * Call to check whether a config has been verified as a valid color |
189 * attachment. | 189 * attachment. |
190 */ | 190 */ |
191 bool isConfigVerifiedColorAttachment(GrPixelConfig config) const { | 191 bool isConfigVerifiedColorAttachment(GrPixelConfig config) const { |
192 return fVerifiedColorConfigs.isVerified(config); | 192 return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kVerifiedColor
Attachment_Flag); |
193 } | 193 } |
194 | 194 |
195 /** | 195 /** |
196 * Reports the type of MSAA FBO support. | 196 * Reports the type of MSAA FBO support. |
197 */ | 197 */ |
198 MSFBOType msFBOType() const { return fMSFBOType; } | 198 MSFBOType msFBOType() const { return fMSFBOType; } |
199 | 199 |
200 /** | 200 /** |
201 * Does the supported MSAA FBO extension have MSAA renderbuffers? | 201 * Does the supported MSAA FBO extension have MSAA renderbuffers? |
202 */ | 202 */ |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 | 334 |
335 const GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fS
haderCaps.get()); } | 335 const GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fS
haderCaps.get()); } |
336 | 336 |
337 private: | 337 private: |
338 void init(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterfa
ce*); | 338 void init(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterfa
ce*); |
339 void initGLSL(const GrGLContextInfo&); | 339 void initGLSL(const GrGLContextInfo&); |
340 bool hasPathRenderingSupport(const GrGLContextInfo&, const GrGLInterface*); | 340 bool hasPathRenderingSupport(const GrGLContextInfo&, const GrGLInterface*); |
341 | 341 |
342 void onApplyOptionsOverrides(const GrContextOptions& options) override; | 342 void onApplyOptionsOverrides(const GrContextOptions& options) override; |
343 | 343 |
344 /** | |
345 * Maintains a bit per GrPixelConfig. It is used to avoid redundantly | |
346 * performing glCheckFrameBufferStatus for the same config. | |
347 */ | |
348 struct VerifiedColorConfigs { | |
349 VerifiedColorConfigs() { | |
350 this->reset(); | |
351 } | |
352 | |
353 void reset() { | |
354 for (int i = 0; i < kNumUints; ++i) { | |
355 fVerifiedColorConfigs[i] = 0; | |
356 } | |
357 } | |
358 | |
359 static const int kNumUints = (kGrPixelConfigCnt + 31) / 32; | |
360 uint32_t fVerifiedColorConfigs[kNumUints]; | |
361 | |
362 void markVerified(GrPixelConfig config) { | |
363 #if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT | |
364 return; | |
365 #endif | |
366 int u32Idx = config / 32; | |
367 int bitIdx = config % 32; | |
368 fVerifiedColorConfigs[u32Idx] |= 1 << bitIdx; | |
369 } | |
370 | |
371 bool isVerified(GrPixelConfig config) const { | |
372 #if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT | |
373 return false; | |
374 #endif | |
375 int u32Idx = config / 32; | |
376 int bitIdx = config % 32; | |
377 return SkToBool(fVerifiedColorConfigs[u32Idx] & (1 << bitIdx)); | |
378 } | |
379 }; | |
380 | |
381 void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*); | 344 void initFSAASupport(const GrGLContextInfo&, const GrGLInterface*); |
382 void initBlendEqationSupport(const GrGLContextInfo&); | 345 void initBlendEqationSupport(const GrGLContextInfo&); |
383 void initStencilFormats(const GrGLContextInfo&); | 346 void initStencilFormats(const GrGLContextInfo&); |
384 // This must be called after initFSAASupport(). | 347 // This must be called after initFSAASupport(). |
385 void initConfigRenderableTable(const GrGLContextInfo&, bool srgbSupport); | 348 void initConfigRenderableTable(const GrGLContextInfo&, bool srgbSupport); |
386 void initConfigTexturableTable(const GrGLContextInfo&, const GrGLInterface*,
bool srgbSupport); | 349 void initConfigTexturableTable(const GrGLContextInfo&, const GrGLInterface*,
bool srgbSupport); |
387 | 350 |
388 bool doReadPixelsSupported(const GrGLInterface* intf, GrGLenum format, GrGLe
num type) const; | 351 bool doReadPixelsSupported(const GrGLInterface* intf, GrGLenum format, GrGLe
num type) const; |
389 | 352 |
390 void initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, | 353 void initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, |
391 const GrGLInterface* intf, | 354 const GrGLInterface* intf, |
392 GrGLSLCaps* glslCaps); | 355 GrGLSLCaps* glslCaps); |
393 | 356 |
394 void initConfigSwizzleTable(const GrGLContextInfo& ctxInfo, GrGLSLCaps* glsl
Caps); | 357 void initConfigSwizzleTable(const GrGLContextInfo& ctxInfo, GrGLSLCaps* glsl
Caps); |
395 | 358 |
396 void initConfigTable(const GrGLContextInfo&); | 359 void initConfigTable(const GrGLContextInfo&); |
397 | 360 |
398 // tracks configs that have been verified to pass the FBO completeness when | |
399 // used as a color attachment | |
400 VerifiedColorConfigs fVerifiedColorConfigs; | |
401 | |
402 SkTArray<StencilFormat, true> fStencilFormats; | 361 SkTArray<StencilFormat, true> fStencilFormats; |
403 | 362 |
404 int fMaxFragmentUniformVectors; | 363 int fMaxFragmentUniformVectors; |
405 int fMaxVertexAttributes; | 364 int fMaxVertexAttributes; |
406 int fMaxFragmentTextureUnits; | 365 int fMaxFragmentTextureUnits; |
407 | 366 |
408 MSFBOType fMSFBOType; | 367 MSFBOType fMSFBOType; |
409 InvalidateFBType fInvalidateFBType; | 368 InvalidateFBType fInvalidateFBType; |
410 MapBufferType fMapBufferType; | 369 MapBufferType fMapBufferType; |
411 TransferBufferType fTransferBufferType; | 370 TransferBufferType fTransferBufferType; |
(...skipping 18 matching lines...) Expand all Loading... |
430 bool fUseNonVBOVertexAndIndexDynamicData : 1; | 389 bool fUseNonVBOVertexAndIndexDynamicData : 1; |
431 bool fIsCoreProfile : 1; | 390 bool fIsCoreProfile : 1; |
432 bool fBindFragDataLocationSupport : 1; | 391 bool fBindFragDataLocationSupport : 1; |
433 bool fSRGBWriteControl : 1; | 392 bool fSRGBWriteControl : 1; |
434 bool fRGBA8888PixelsOpsAreSlow : 1; | 393 bool fRGBA8888PixelsOpsAreSlow : 1; |
435 bool fPartialFBOReadIsSlow : 1; | 394 bool fPartialFBOReadIsSlow : 1; |
436 bool fBindUniformLocationSupport : 1; | 395 bool fBindUniformLocationSupport : 1; |
437 bool fExternalTextureSupport : 1; | 396 bool fExternalTextureSupport : 1; |
438 | 397 |
439 struct ConfigInfo { | 398 struct ConfigInfo { |
440 ConfigInfo() : fStencilFormatIndex(kUnknown_StencilIndex) {}; | 399 ConfigInfo() : fStencilFormatIndex(kUnknown_StencilIndex), fFlags(0) {}; |
441 | 400 |
442 ConfigFormats fFormats; | 401 ConfigFormats fFormats; |
443 | 402 |
444 // Index into GrGLCaps's list of stencil formats. Support is determined
experimentally and | |
445 // lazily. | |
446 int fStencilFormatIndex; | |
447 | |
448 enum { | 403 enum { |
449 // This indicates that a stencil format has not yet been determined
for the config. | 404 // This indicates that a stencil format has not yet been determined
for the config. |
450 kUnknown_StencilIndex = -1, | 405 kUnknown_StencilIndex = -1, |
451 // This indicates that there is no supported stencil format for the
config. | 406 // This indicates that there is no supported stencil format for the
config. |
452 kUnsupported_StencilFormatIndex = -2 | 407 kUnsupported_StencilFormatIndex = -2 |
453 }; | 408 }; |
| 409 |
| 410 // Index fStencilFormats. |
| 411 int fStencilFormatIndex; |
| 412 |
| 413 enum { |
| 414 kVerifiedColorAttachment_Flag = 0x1 |
| 415 }; |
| 416 uint32_t fFlags; |
454 }; | 417 }; |
455 | 418 |
456 ConfigInfo fConfigTable[kGrPixelConfigCnt]; | 419 ConfigInfo fConfigTable[kGrPixelConfigCnt]; |
457 | 420 |
458 struct ReadPixelsSupportedFormat { | 421 struct ReadPixelsSupportedFormat { |
459 GrGLenum fFormat; | 422 GrGLenum fFormat; |
460 GrGLenum fType; | 423 GrGLenum fType; |
461 GrGLenum fFboFormat; | 424 GrGLenum fFboFormat; |
462 | 425 |
463 bool operator==(const ReadPixelsSupportedFormat& rhs) const { | 426 bool operator==(const ReadPixelsSupportedFormat& rhs) const { |
464 return fFormat == rhs.fFormat | 427 return fFormat == rhs.fFormat |
465 && fType == rhs.fType | 428 && fType == rhs.fType |
466 && fFboFormat == rhs.fFboFormat; | 429 && fFboFormat == rhs.fFboFormat; |
467 } | 430 } |
468 }; | 431 }; |
469 mutable SkTHashMap<ReadPixelsSupportedFormat, bool> fReadPixelsSupportedCach
e; | 432 mutable SkTHashMap<ReadPixelsSupportedFormat, bool> fReadPixelsSupportedCach
e; |
470 | 433 |
471 typedef GrCaps INHERITED; | 434 typedef GrCaps INHERITED; |
472 }; | 435 }; |
473 | 436 |
474 #endif | 437 #endif |
OLD | NEW |