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

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

Issue 1420423002: Fix gl caps for mixed sample support (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add more comments. Created 5 years, 1 month 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/gl/GrGLCaps.h ('k') | no next file » | 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 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 #include "GrGLCaps.h" 9 #include "GrGLCaps.h"
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 this->init(contextOptions, ctxInfo, glInterface); 58 this->init(contextOptions, ctxInfo, glInterface);
59 } 59 }
60 60
61 void GrGLCaps::init(const GrContextOptions& contextOptions, 61 void GrGLCaps::init(const GrContextOptions& contextOptions,
62 const GrGLContextInfo& ctxInfo, 62 const GrGLContextInfo& ctxInfo,
63 const GrGLInterface* gli) { 63 const GrGLInterface* gli) {
64 GrGLStandard standard = ctxInfo.standard(); 64 GrGLStandard standard = ctxInfo.standard();
65 GrGLVersion version = ctxInfo.version(); 65 GrGLVersion version = ctxInfo.version();
66 66
67 this->initGLSL(ctxInfo);
68 GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get());
69
67 /************************************************************************** 70 /**************************************************************************
68 * Caps specific to GrGLCaps 71 * Caps specific to GrGLCaps
69 **************************************************************************/ 72 **************************************************************************/
70 73
71 if (kGLES_GrGLStandard == standard) { 74 if (kGLES_GrGLStandard == standard) {
72 GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS, 75 GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS,
73 &fMaxFragmentUniformVectors); 76 &fMaxFragmentUniformVectors);
74 } else { 77 } else {
75 SkASSERT(kGL_GrGLStandard == standard); 78 SkASSERT(kGL_GrGLStandard == standard);
76 GrGLint max; 79 GrGLint max;
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 bool isANGLE = kANGLE_GrGLDriver == ctxInfo.driver() || 279 bool isANGLE = kANGLE_GrGLDriver == ctxInfo.driver() ||
277 kChromium_GrGLDriver == ctxInfo.driver(); 280 kChromium_GrGLDriver == ctxInfo.driver();
278 // Angle has slow read/write pixel paths for 32bit RGBA (but fast for BGRA). 281 // Angle has slow read/write pixel paths for 32bit RGBA (but fast for BGRA).
279 fRGBA8888PixelsOpsAreSlow = isANGLE; 282 fRGBA8888PixelsOpsAreSlow = isANGLE;
280 // On DX9 ANGLE reading a partial FBO is slow. TODO: Check whether this is s till true and 283 // On DX9 ANGLE reading a partial FBO is slow. TODO: Check whether this is s till true and
281 // check DX11 ANGLE. 284 // check DX11 ANGLE.
282 fPartialFBOReadIsSlow = isANGLE; 285 fPartialFBOReadIsSlow = isANGLE;
283 #endif 286 #endif
284 287
285 /************************************************************************** 288 /**************************************************************************
289 * GrShaderCaps fields
290 **************************************************************************/
291
292 glslCaps->fPathRenderingSupport = this->hasPathRenderingSupport(ctxInfo, gli );
293
294 // For now these two are equivalent but we could have dst read in shader via some other method.
295 // Before setting this, initGLSL() must have been called.
296 glslCaps->fDstReadInShaderSupport = glslCaps->fFBFetchSupport;
297
298 // Enable supported shader-related caps
299 if (kGL_GrGLStandard == standard) {
300 glslCaps->fDualSourceBlendingSupport = (ctxInfo.version() >= GR_GL_VER(3 , 3) ||
301 ctxInfo.hasExtension("GL_ARB_blend_func_extended")) &&
302 GrGLSLSupportsNamedFragmentShaderOutputs(ctxInfo.glslGeneration());
303 glslCaps->fShaderDerivativeSupport = true;
304 // we don't support GL_ARB_geometry_shader4, just GL 3.2+ GS
305 glslCaps->fGeometryShaderSupport = ctxInfo.version() >= GR_GL_VER(3, 2) &&
306 ctxInfo.glslGeneration() >= k150_GrGLSLGeneration;
307 }
308 else {
309 glslCaps->fDualSourceBlendingSupport = ctxInfo.hasExtension("GL_EXT_blen d_func_extended");
310
311 glslCaps->fShaderDerivativeSupport = ctxInfo.version() >= GR_GL_VER(3, 0 ) ||
312 ctxInfo.hasExtension("GL_OES_standard_derivatives");
313 }
314
315 // We need dual source blending and the ability to disable multisample in or der to support mixed
316 // samples in every corner case.
317 if (fMultisampleDisableSupport && glslCaps->fDualSourceBlendingSupport) {
318 // We understand "mixed samples" to mean the collective capability of 3 different extensions
319 glslCaps->fMixedSamplesSupport =
320 ctxInfo.hasExtension("GL_NV_framebuffer_mixed_samples") &&
321 ctxInfo.hasExtension("GL_NV_sample_mask_override_coverage") &&
322 ctxInfo.hasExtension("GL_EXT_raster_multisample");
323 }
324 // Workaround NVIDIA bug related to glInvalidateFramebuffer and mixed sample s.
325 if (kNVIDIA_GrGLDriver == ctxInfo.driver() && fShaderCaps->mixedSamplesSuppo rt()) {
326 fDiscardRenderTargetSupport = false;
327 fInvalidateFBType = kNone_InvalidateFBType;
328 }
329 glslCaps->fProgrammableSampleLocationsSupport =
330 ctxInfo.hasExtension("GL_NV_sample_locations") ||
331 ctxInfo.hasExtension("GL_ARB_sample_locations");
332
333 /**************************************************************************
286 * GrCaps fields 334 * GrCaps fields
287 **************************************************************************/ 335 **************************************************************************/
288 336
337 // fPathRenderingSupport and fMixedSampleSupport must be set before calling initFSAASupport.
338 // Both of these are set in the GrShaderCaps.
289 this->initFSAASupport(ctxInfo, gli); 339 this->initFSAASupport(ctxInfo, gli);
290 this->initBlendEqationSupport(ctxInfo); 340 this->initBlendEqationSupport(ctxInfo);
291 this->initStencilFormats(ctxInfo); 341 this->initStencilFormats(ctxInfo);
292 342
293 if (kGL_GrGLStandard == standard) { 343 if (kGL_GrGLStandard == standard) {
294 // we could also look for GL_ATI_separate_stencil extension or 344 // we could also look for GL_ATI_separate_stencil extension or
295 // GL_EXT_stencil_two_side but they use different function signatures 345 // GL_EXT_stencil_two_side but they use different function signatures
296 // than GL2.0+ (and than each other). 346 // than GL2.0+ (and than each other).
297 fTwoSidedStencilSupport = (ctxInfo.version() >= GR_GL_VER(2,0)); 347 fTwoSidedStencilSupport = (ctxInfo.version() >= GR_GL_VER(2,0));
298 // supported on GL 1.4 and higher or by extension 348 // supported on GL 1.4 and higher or by extension
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 423
374 // Disable scratch texture reuse on Mali and Adreno devices 424 // Disable scratch texture reuse on Mali and Adreno devices
375 fReuseScratchTextures = kARM_GrGLVendor != ctxInfo.vendor() && 425 fReuseScratchTextures = kARM_GrGLVendor != ctxInfo.vendor() &&
376 kQualcomm_GrGLVendor != ctxInfo.vendor(); 426 kQualcomm_GrGLVendor != ctxInfo.vendor();
377 427
378 #if 0 428 #if 0
379 fReuseScratchBuffers = kARM_GrGLVendor != ctxInfo.vendor() && 429 fReuseScratchBuffers = kARM_GrGLVendor != ctxInfo.vendor() &&
380 kQualcomm_GrGLVendor != ctxInfo.vendor(); 430 kQualcomm_GrGLVendor != ctxInfo.vendor();
381 #endif 431 #endif
382 432
433 // initFSAASupport() must have been called before this point
383 if (GrGLCaps::kES_IMG_MsToTexture_MSFBOType == fMSFBOType) { 434 if (GrGLCaps::kES_IMG_MsToTexture_MSFBOType == fMSFBOType) {
384 GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES_IMG, &fMaxSampleCount); 435 GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES_IMG, &fMaxSampleCount);
385 } else if (GrGLCaps::kNone_MSFBOType != fMSFBOType) { 436 } else if (GrGLCaps::kNone_MSFBOType != fMSFBOType) {
386 GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES, &fMaxSampleCount); 437 GR_GL_GetIntegerv(gli, GR_GL_MAX_SAMPLES, &fMaxSampleCount);
387 } 438 }
388 439
389 if (kPowerVR54x_GrGLRenderer == ctxInfo.renderer() || 440 if (kPowerVR54x_GrGLRenderer == ctxInfo.renderer() ||
390 kPowerVRRogue_GrGLRenderer == ctxInfo.renderer() || 441 kPowerVRRogue_GrGLRenderer == ctxInfo.renderer() ||
391 kAdreno3xx_GrGLRenderer == ctxInfo.renderer()) { 442 kAdreno3xx_GrGLRenderer == ctxInfo.renderer()) {
392 fUseDrawInsteadOfClear = true; 443 fUseDrawInsteadOfClear = true;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 version >= GR_GL_VER(3, 2) || 476 version >= GR_GL_VER(3, 2) ||
426 (ctxInfo.hasExtension("GL_ARB_draw_instanced") && 477 (ctxInfo.hasExtension("GL_ARB_draw_instanced") &&
427 ctxInfo.hasExtension("GL_ARB_instanced_arrays")); 478 ctxInfo.hasExtension("GL_ARB_instanced_arrays"));
428 } else { 479 } else {
429 fSupportsInstancedDraws = 480 fSupportsInstancedDraws =
430 version >= GR_GL_VER(3, 0) || 481 version >= GR_GL_VER(3, 0) ||
431 (ctxInfo.hasExtension("GL_EXT_draw_instanced") && 482 (ctxInfo.hasExtension("GL_EXT_draw_instanced") &&
432 ctxInfo.hasExtension("GL_EXT_instanced_arrays")); 483 ctxInfo.hasExtension("GL_EXT_instanced_arrays"));
433 } 484 }
434 485
435 // Must init GLSLCaps after setting GLCaps
436 this->initGLSL(contextOptions, ctxInfo, gli);
437 GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get());
438
439 this->initConfigTexturableTable(ctxInfo, gli, srgbSupport); 486 this->initConfigTexturableTable(ctxInfo, gli, srgbSupport);
440 this->initConfigRenderableTable(ctxInfo, srgbSupport); 487 this->initConfigRenderableTable(ctxInfo, srgbSupport);
441 this->initShaderPrecisionTable(ctxInfo, gli, glslCaps); 488 this->initShaderPrecisionTable(ctxInfo, gli, glslCaps);
442 489
443 this->applyOptionsOverrides(contextOptions); 490 this->applyOptionsOverrides(contextOptions);
444 glslCaps->applyOptionsOverrides(contextOptions); 491 glslCaps->applyOptionsOverrides(contextOptions);
445 } 492 }
446 493
447 const char* get_glsl_version_decl_string(GrGLStandard standard, GrGLSLGeneration generation, 494 const char* get_glsl_version_decl_string(GrGLStandard standard, GrGLSLGeneration generation,
448 bool isCoreProfile) { 495 bool isCoreProfile) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 return "#version 330 compatibility\n"; 527 return "#version 330 compatibility\n";
481 } 528 }
482 } 529 }
483 case k310es_GrGLSLGeneration: 530 case k310es_GrGLSLGeneration:
484 SkASSERT(kGLES_GrGLStandard == standard); 531 SkASSERT(kGLES_GrGLStandard == standard);
485 return "#version 310 es\n"; 532 return "#version 310 es\n";
486 } 533 }
487 return "<no version>"; 534 return "<no version>";
488 } 535 }
489 536
490 void GrGLCaps::initGLSL(const GrContextOptions& contextOptions, 537 void GrGLCaps::initGLSL(const GrGLContextInfo& ctxInfo) {
491 const GrGLContextInfo& ctxInfo,
492 const GrGLInterface* gli) {
493 GrGLStandard standard = ctxInfo.standard(); 538 GrGLStandard standard = ctxInfo.standard();
494 GrGLVersion version = ctxInfo.version(); 539 GrGLVersion version = ctxInfo.version();
495 540
496 /************************************************************************** 541 /**************************************************************************
497 * Caps specific to GrGLSLCaps 542 * Caps specific to GrGLSLCaps
498 **************************************************************************/ 543 **************************************************************************/
499 544
500 GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get()); 545 GrGLSLCaps* glslCaps = static_cast<GrGLSLCaps*>(fShaderCaps.get());
501 glslCaps->fGLSLGeneration = ctxInfo.glslGeneration(); 546 glslCaps->fGLSLGeneration = ctxInfo.glslGeneration();
502 547
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 // undefined results". This appears to be an issue with the 'any' call since even the simple 579 // undefined results". This appears to be an issue with the 'any' call since even the simple
535 // "result=black; if (any()) result=white;" code fails to compile. This issu e comes into play 580 // "result=black; if (any()) result=white;" code fails to compile. This issu e comes into play
536 // from our GrTextureDomain processor. 581 // from our GrTextureDomain processor.
537 glslCaps->fCanUseAnyFunctionInShader = kImagination_GrGLVendor != ctxInfo.ve ndor(); 582 glslCaps->fCanUseAnyFunctionInShader = kImagination_GrGLVendor != ctxInfo.ve ndor();
538 583
539 glslCaps->fForceHighPrecisionNDSTransform = kARM_GrGLVendor == ctxInfo.vendo r() || 584 glslCaps->fForceHighPrecisionNDSTransform = kARM_GrGLVendor == ctxInfo.vendo r() ||
540 kPowerVR54x_GrGLRenderer == ctxI nfo.renderer(); 585 kPowerVR54x_GrGLRenderer == ctxI nfo.renderer();
541 586
542 glslCaps->fVersionDeclString = get_glsl_version_decl_string(standard, glslCa ps->fGLSLGeneration, 587 glslCaps->fVersionDeclString = get_glsl_version_decl_string(standard, glslCa ps->fGLSLGeneration,
543 fIsCoreProfile); 588 fIsCoreProfile);
544
545 /**************************************************************************
546 * GrShaderCaps fields
547 **************************************************************************/
548
549 glslCaps->fPathRenderingSupport = this->hasPathRenderingSupport(ctxInfo, gli );
550
551 // For now these two are equivalent but we could have dst read in shader via some other method
552 glslCaps->fDstReadInShaderSupport = glslCaps->fFBFetchSupport;
553
554 // Enable supported shader-related caps
555 if (kGL_GrGLStandard == standard) {
556 glslCaps->fDualSourceBlendingSupport = (ctxInfo.version() >= GR_GL_VER(3 , 3) ||
557 ctxInfo.hasExtension("GL_ARB_blend_func_extended")) &&
558 GrGLSLSupportsNamedFragmentShaderOutputs(ctxInfo.glslGeneration());
559 glslCaps->fShaderDerivativeSupport = true;
560 // we don't support GL_ARB_geometry_shader4, just GL 3.2+ GS
561 glslCaps->fGeometryShaderSupport = ctxInfo.version() >= GR_GL_VER(3, 2) &&
562 ctxInfo.glslGeneration() >= k150_GrGLSLGeneration;
563 }
564 else {
565 glslCaps->fDualSourceBlendingSupport = ctxInfo.hasExtension("GL_EXT_blen d_func_extended");
566
567 glslCaps->fShaderDerivativeSupport = ctxInfo.version() >= GR_GL_VER(3, 0 ) ||
568 ctxInfo.hasExtension("GL_OES_standard_derivatives");
569 }
570
571 // We need dual source blending and the ability to disable multisample in or der to support mixed
572 // samples in every corner case.
573 if (fMultisampleDisableSupport && glslCaps->fDualSourceBlendingSupport) {
574 // We understand "mixed samples" to mean the collective capability of 3 different extensions
575 glslCaps->fMixedSamplesSupport =
576 ctxInfo.hasExtension("GL_NV_framebuffer_mixed_samples") &&
577 ctxInfo.hasExtension("GL_NV_sample_mask_override_coverage") &&
578 ctxInfo.hasExtension("GL_EXT_raster_multisample");
579 }
580 // Workaround NVIDIA bug related to glInvalidateFramebuffer and mixed sample s.
581 if (kNVIDIA_GrGLDriver == ctxInfo.driver() && fShaderCaps->mixedSamplesSuppo rt()) {
582 fDiscardRenderTargetSupport = false;
583 fInvalidateFBType = kNone_InvalidateFBType;
584 }
585 glslCaps->fProgrammableSampleLocationsSupport =
586 ctxInfo.hasExtension("GL_NV_sample_locations") ||
587 ctxInfo.hasExtension("GL_ARB_sample_locations");
588 } 589 }
589 590
590 bool GrGLCaps::hasPathRenderingSupport(const GrGLContextInfo& ctxInfo, const GrG LInterface* gli) { 591 bool GrGLCaps::hasPathRenderingSupport(const GrGLContextInfo& ctxInfo, const GrG LInterface* gli) {
591 bool hasChromiumPathRendering = ctxInfo.hasExtension("GL_CHROMIUM_path_rende ring"); 592 bool hasChromiumPathRendering = ctxInfo.hasExtension("GL_CHROMIUM_path_rende ring");
592 593
593 if (!(ctxInfo.hasExtension("GL_NV_path_rendering") || hasChromiumPathRenderi ng)) { 594 if (!(ctxInfo.hasExtension("GL_NV_path_rendering") || hasChromiumPathRenderi ng)) {
594 return false; 595 return false;
595 } 596 }
596 597
597 if (kGL_GrGLStandard == ctxInfo.standard()) { 598 if (kGL_GrGLStandard == ctxInfo.standard()) {
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 for (int p = 0; p < kGrSLPrecisionCount; ++p) { 1267 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
1267 glslCaps->fFloatPrecisions[kGeometry_GrShaderType][p] = 1268 glslCaps->fFloatPrecisions[kGeometry_GrShaderType][p] =
1268 glslCaps->fFloatPrecisions[kVerte x_GrShaderType][p]; 1269 glslCaps->fFloatPrecisions[kVerte x_GrShaderType][p];
1269 } 1270 }
1270 } 1271 }
1271 } 1272 }
1272 1273
1273 1274
1274 1275
1275 1276
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLCaps.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698