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

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: Compiler warning 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
« no previous file with comments | « src/gpu/gl/GrGLCaps.h ('k') | src/gpu/gl/GrGLGpu.h » ('j') | 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 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 fAdvBlendEqInteraction = kNotSupported_AdvBlendEqInteraction;
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 fAdvBlendEqInteraction = caps.fAdvBlendEqInteraction;
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 = glCaps.advancedCoherentBlendEquationSupport();
1034 if (ctxInfo.hasExtension(coherent ? "GL_NV_blend_equation_advanced_coher ent"
1035 : "GL_NV_blend_equation_advanced")) {
1036 fAdvBlendEqInteraction = kAutomatic_AdvBlendEqInteraction;
1037 } else {
1038 fAdvBlendEqInteraction = kGeneralEnable_AdvBlendEqInteraction;
1039 // TODO: Use the following on any platform where "blend_support_all_ equations" is slow.
1040 //fAdvBlendEqInteraction = kSpecificEnables_AdvBlendEqInteraction;
1041 }
1042 }
1043
1013 this->initShaderPrecisionTable(ctxInfo, gli); 1044 this->initShaderPrecisionTable(ctxInfo, gli);
1014 1045
1015 return true; 1046 return true;
1016 } 1047 }
1017 1048
1018 SkString GrGLSLCaps::dump() const { 1049 SkString GrGLSLCaps::dump() const {
1019 SkString r = INHERITED::dump(); 1050 SkString r = INHERITED::dump();
1020 1051
1052 static const char* kAdvBlendEqInteractionStr[] = {
1053 "Not Supported",
1054 "Automatic",
1055 "General Enable",
1056 "Specific Enables",
1057 };
1058 GR_STATIC_ASSERT(0 == kNotSupported_AdvBlendEqInteraction);
1059 GR_STATIC_ASSERT(1 == kAutomatic_AdvBlendEqInteraction);
1060 GR_STATIC_ASSERT(2 == kGeneralEnable_AdvBlendEqInteraction);
1061 GR_STATIC_ASSERT(3 == kSpecificEnables_AdvBlendEqInteraction);
1062 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kAdvBlendEqInteractionStr) == kLast_AdvBlend EqInteraction + 1);
1063
1021 r.appendf("--- GLSL-Specific ---\n"); 1064 r.appendf("--- GLSL-Specific ---\n");
1022 1065
1023 r.appendf("FB Fetch Support: %s\n", (fFBFetchSupport ? "YES" : "NO")); 1066 r.appendf("FB Fetch Support: %s\n", (fFBFetchSupport ? "YES" : "NO"));
1024 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO")); 1067 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO"));
1068 r.appendf("Advanced blend equation interaction: %s\n",
1069 kAdvBlendEqInteractionStr[fAdvBlendEqInteraction]);
1025 return r; 1070 return r;
1026 } 1071 }
1027 1072
1028 static GrGLenum precision_to_gl_float_type(GrSLPrecision p) { 1073 static GrGLenum precision_to_gl_float_type(GrSLPrecision p) {
1029 switch (p) { 1074 switch (p) {
1030 case kLow_GrSLPrecision: 1075 case kLow_GrSLPrecision:
1031 return GR_GL_LOW_FLOAT; 1076 return GR_GL_LOW_FLOAT;
1032 case kMedium_GrSLPrecision: 1077 case kMedium_GrSLPrecision:
1033 return GR_GL_MEDIUM_FLOAT; 1078 return GR_GL_MEDIUM_FLOAT;
1034 case kHigh_GrSLPrecision: 1079 case kHigh_GrSLPrecision:
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 if (fGeometryShaderSupport) { 1147 if (fGeometryShaderSupport) {
1103 for (int p = 0; p < kGrSLPrecisionCount; ++p) { 1148 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
1104 fFloatPrecisions[kGeometry_GrShaderType][p] = fFloatPrecisions[kVert ex_GrShaderType][p]; 1149 fFloatPrecisions[kGeometry_GrShaderType][p] = fFloatPrecisions[kVert ex_GrShaderType][p];
1105 } 1150 }
1106 } 1151 }
1107 } 1152 }
1108 1153
1109 1154
1110 1155
1111 1156
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLCaps.h ('k') | src/gpu/gl/GrGLGpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698