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

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

Issue 1037123003: Implement support for KHR_blend_equation_advanced (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_zzz2_barriers
Patch Set: Rebase, blend_support_all_equations Created 5 years, 7 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 * 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 fTwoSidedStencilSupport = (ctxInfo.version() >= GR_GL_VER(2,0)); 262 fTwoSidedStencilSupport = (ctxInfo.version() >= GR_GL_VER(2,0));
263 // supported on GL 1.4 and higher or by extension 263 // supported on GL 1.4 and higher or by extension
264 fStencilWrapOpsSupport = (ctxInfo.version() >= GR_GL_VER(1,4)) || 264 fStencilWrapOpsSupport = (ctxInfo.version() >= GR_GL_VER(1,4)) ||
265 ctxInfo.hasExtension("GL_EXT_stencil_wrap"); 265 ctxInfo.hasExtension("GL_EXT_stencil_wrap");
266 } else { 266 } else {
267 // ES 2 has two sided stencil and stencil wrap 267 // ES 2 has two sided stencil and stencil wrap
268 fTwoSidedStencilSupport = true; 268 fTwoSidedStencilSupport = true;
269 fStencilWrapOpsSupport = true; 269 fStencilWrapOpsSupport = true;
270 } 270 }
271 271
272 if (kIntel_GrGLVendor != ctxInfo.vendor()) {
273 if (ctxInfo.hasExtension("GL_KHR_blend_equation_advanced_coherent") ||
274 ctxInfo.hasExtension("GL_NV_blend_equation_advanced_coherent")) {
275 fBlendEquationSupport = kAdvancedCoherent_BlendEquationSupport;
276 } else if (ctxInfo.hasExtension("GL_KHR_blend_equation_advanced") ||
277 ctxInfo.hasExtension("GL_NV_blend_equation_advanced")) {
278 fBlendEquationSupport = kAdvanced_BlendEquationSupport;
279 } else {
280 fBlendEquationSupport = kBasic_BlendEquationSupport;
281 }
282 } else {
283 // On Intel platforms, KHR_blend_equation_advanced is not conformant.
284 fBlendEquationSupport = kBasic_BlendEquationSupport;
285 }
286
272 if (kGL_GrGLStandard == standard) { 287 if (kGL_GrGLStandard == standard) {
273 fMapBufferFlags = kCanMap_MapFlag; // we require VBO support and the des ktop VBO 288 fMapBufferFlags = kCanMap_MapFlag; // we require VBO support and the des ktop VBO
274 // extension includes glMapBuffer. 289 // extension includes glMapBuffer.
275 if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_ARB_map_buffe r_range")) { 290 if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_ARB_map_buffe r_range")) {
276 fMapBufferFlags |= kSubset_MapFlag; 291 fMapBufferFlags |= kSubset_MapFlag;
277 fMapBufferType = kMapBufferRange_MapBufferType; 292 fMapBufferType = kMapBufferRange_MapBufferType;
278 } else { 293 } else {
279 fMapBufferType = kMapBuffer_MapBufferType; 294 fMapBufferType = kMapBuffer_MapBufferType;
280 } 295 }
281 } else { 296 } else {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 SkASSERT(ctxInfo.hasExtension("GL_EXT_framebuffer_object")); 360 SkASSERT(ctxInfo.hasExtension("GL_EXT_framebuffer_object"));
346 } 361 }
347 } else { 362 } else {
348 // ES 3.0 supports mixed size FBO attachments, 2.0 does not. 363 // ES 3.0 supports mixed size FBO attachments, 2.0 does not.
349 fOversizedStencilSupport = ctxInfo.version() >= GR_GL_VER(3, 0); 364 fOversizedStencilSupport = ctxInfo.version() >= GR_GL_VER(3, 0);
350 } 365 }
351 366
352 this->initConfigTexturableTable(ctxInfo, gli); 367 this->initConfigTexturableTable(ctxInfo, gli);
353 this->initConfigRenderableTable(ctxInfo); 368 this->initConfigRenderableTable(ctxInfo);
354 369
355 reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get())->init(ctxInfo, gli); 370 reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get())->init(ctxInfo, gli, *this);
356 371
357 return true; 372 return true;
358 } 373 }
359 374
360 void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) { 375 void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) {
361 // OpenGL < 3.0 376 // OpenGL < 3.0
362 // no support for render targets unless the GL_ARB_framebuffer_object 377 // no support for render targets unless the GL_ARB_framebuffer_object
363 // extension is supported (in which case we get ALPHA, RED, RG, RGB, 378 // extension is supported (in which case we get ALPHA, RED, RG, RGB,
364 // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we 379 // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we
365 // probably don't get R8 in this case. 380 // probably don't get R8 in this case.
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 this->reset(); 922 this->reset();
908 } 923 }
909 924
910 925
911 void GrGLSLCaps::reset() { 926 void GrGLSLCaps::reset() {
912 INHERITED::reset(); 927 INHERITED::reset();
913 928
914 fDropsTileOnZeroDivide = false; 929 fDropsTileOnZeroDivide = false;
915 fFBFetchSupport = false; 930 fFBFetchSupport = false;
916 fFBFetchNeedsCustomOutput = false; 931 fFBFetchNeedsCustomOutput = false;
932 fAdvancedBlendEqnInteraction = kNotSupported_AdvancedBlendEqnInteraction;
917 fFBFetchColorName = NULL; 933 fFBFetchColorName = NULL;
918 fFBFetchExtensionString = NULL; 934 fFBFetchExtensionString = NULL;
919 } 935 }
920 936
921 GrGLSLCaps::GrGLSLCaps(const GrGLSLCaps& caps) : GrShaderCaps() { 937 GrGLSLCaps::GrGLSLCaps(const GrGLSLCaps& caps) : GrShaderCaps() {
922 *this = caps; 938 *this = caps;
923 } 939 }
924 940
925 GrGLSLCaps& GrGLSLCaps::operator= (const GrGLSLCaps& caps) { 941 GrGLSLCaps& GrGLSLCaps::operator= (const GrGLSLCaps& caps) {
926 INHERITED::operator=(caps); 942 INHERITED::operator=(caps);
927 fDropsTileOnZeroDivide = caps.fDropsTileOnZeroDivide; 943 fDropsTileOnZeroDivide = caps.fDropsTileOnZeroDivide;
928 fFBFetchSupport = caps.fFBFetchSupport; 944 fFBFetchSupport = caps.fFBFetchSupport;
929 fFBFetchNeedsCustomOutput = caps.fFBFetchNeedsCustomOutput; 945 fFBFetchNeedsCustomOutput = caps.fFBFetchNeedsCustomOutput;
946 fAdvancedBlendEqnInteraction = caps.fAdvancedBlendEqnInteraction;
930 fFBFetchColorName = caps.fFBFetchColorName; 947 fFBFetchColorName = caps.fFBFetchColorName;
931 fFBFetchExtensionString = caps.fFBFetchExtensionString; 948 fFBFetchExtensionString = caps.fFBFetchExtensionString;
932 949
933 return *this; 950 return *this;
934 } 951 }
935 952
936 bool GrGLSLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { 953 bool GrGLSLCaps::init(const GrGLContextInfo& ctxInfo,
954 const GrGLInterface* gli,
955 const GrGLCaps& glCaps) {
937 this->reset(); 956 this->reset();
938 if (!ctxInfo.isInitialized()) { 957 if (!ctxInfo.isInitialized()) {
939 return false; 958 return false;
940 } 959 }
941 960
942 GrGLStandard standard = ctxInfo.standard(); 961 GrGLStandard standard = ctxInfo.standard();
943 GrGLVersion version = ctxInfo.version(); 962 GrGLVersion version = ctxInfo.version();
944 963
945 /************************************************************************** 964 /**************************************************************************
946 * Caps specific to GrGLSLCaps 965 * Caps specific to GrGLSLCaps
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 fShaderDerivativeSupport = true; 1022 fShaderDerivativeSupport = true;
1004 // we don't support GL_ARB_geometry_shader4, just GL 3.2+ GS 1023 // we don't support GL_ARB_geometry_shader4, just GL 3.2+ GS
1005 fGeometryShaderSupport = ctxInfo.version() >= GR_GL_VER(3, 2) && 1024 fGeometryShaderSupport = ctxInfo.version() >= GR_GL_VER(3, 2) &&
1006 ctxInfo.glslGeneration() >= k150_GrGLSLGeneration; 1025 ctxInfo.glslGeneration() >= k150_GrGLSLGeneration;
1007 } 1026 }
1008 else { 1027 else {
1009 fShaderDerivativeSupport = ctxInfo.version() >= GR_GL_VER(3, 0) || 1028 fShaderDerivativeSupport = ctxInfo.version() >= GR_GL_VER(3, 0) ||
1010 ctxInfo.hasExtension("GL_OES_standard_derivatives"); 1029 ctxInfo.hasExtension("GL_OES_standard_derivatives");
1011 } 1030 }
1012 1031
1032 if (glCaps.advancedBlendEquationSupport()) {
1033 bool coherent =
1034 GrDrawTargetCaps::kAdvancedCoherent_BlendEquationSupport == glCaps.ble ndEquationSupport();
1035
1036 if (ctxInfo.hasExtension(coherent ? "GL_NV_blend_equation_advanced_coher ent"
1037 : "GL_NV_blend_equation_advanced")) {
1038 fAdvancedBlendEqnInteraction = kAutomatic_AdvancedBlendEqnInteractio n;
1039 } else {
1040 fAdvancedBlendEqnInteraction = kMustEnable_AdvancedBlendEqnInteracti on;
1041 // TODO: Use the following on any platform where "blend_support_all_ equations" is slow.
1042 //fAdvancedBlendEqnInteraction = kMustEnableSeparately_AdvancedBlend EqnInteraction;
1043 }
1044 }
1045
1013 this->initShaderPrecisionTable(ctxInfo, gli); 1046 this->initShaderPrecisionTable(ctxInfo, gli);
1014 1047
1015 return true; 1048 return true;
1016 } 1049 }
1017 1050
1018 SkString GrGLSLCaps::dump() const { 1051 SkString GrGLSLCaps::dump() const {
1019 SkString r = INHERITED::dump(); 1052 SkString r = INHERITED::dump();
1020 1053
1054 static const char* kAdvancedBlendEqnInteractionStr[] = {
1055 "Not Supported",
1056 "Automatic",
1057 "Must Enable",
1058 "Must Enable Separately",
1059 };
1060 GR_STATIC_ASSERT(0 == kNotSupported_AdvancedBlendEqnInteraction);
1061 GR_STATIC_ASSERT(1 == kAutomatic_AdvancedBlendEqnInteraction);
1062 GR_STATIC_ASSERT(2 == kMustEnable_AdvancedBlendEqnInteraction);
1063 GR_STATIC_ASSERT(3 == kMustEnableSeparately_AdvancedBlendEqnInteraction);
1064 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kAdvancedBlendEqnInteractionStr) ==
1065 kLast_AdvancedBlendEqnInteraction + 1);
1066
1021 r.appendf("--- GLSL-Specific ---\n"); 1067 r.appendf("--- GLSL-Specific ---\n");
1022 1068
1023 r.appendf("FB Fetch Support: %s\n", (fFBFetchSupport ? "YES" : "NO")); 1069 r.appendf("FB Fetch Support: %s\n", (fFBFetchSupport ? "YES" : "NO"));
1024 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO")); 1070 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO"));
1071 r.appendf("Advanced blend equation interaction: %s\n",
1072 kAdvancedBlendEqnInteractionStr[fAdvancedBlendEqnInteraction]);
1025 return r; 1073 return r;
1026 } 1074 }
1027 1075
1028 static GrGLenum precision_to_gl_float_type(GrSLPrecision p) { 1076 static GrGLenum precision_to_gl_float_type(GrSLPrecision p) {
1029 switch (p) { 1077 switch (p) {
1030 case kLow_GrSLPrecision: 1078 case kLow_GrSLPrecision:
1031 return GR_GL_LOW_FLOAT; 1079 return GR_GL_LOW_FLOAT;
1032 case kMedium_GrSLPrecision: 1080 case kMedium_GrSLPrecision:
1033 return GR_GL_MEDIUM_FLOAT; 1081 return GR_GL_MEDIUM_FLOAT;
1034 case kHigh_GrSLPrecision: 1082 case kHigh_GrSLPrecision:
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 if (fGeometryShaderSupport) { 1150 if (fGeometryShaderSupport) {
1103 for (int p = 0; p < kGrSLPrecisionCount; ++p) { 1151 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
1104 fFloatPrecisions[kGeometry_GrShaderType][p] = fFloatPrecisions[kVert ex_GrShaderType][p]; 1152 fFloatPrecisions[kGeometry_GrShaderType][p] = fFloatPrecisions[kVert ex_GrShaderType][p];
1105 } 1153 }
1106 } 1154 }
1107 } 1155 }
1108 1156
1109 1157
1110 1158
1111 1159
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698