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

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

Issue 433603002: FBFetch refactor + arm support (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: comment cleanup Created 6 years, 4 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/GrGLDefines.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 #include "GrGLContext.h" 10 #include "GrGLContext.h"
11 #include "SkTSearch.h" 11 #include "SkTSearch.h"
12 #include "SkTSort.h" 12 #include "SkTSort.h"
13 13
14 GrGLCaps::GrGLCaps() { 14 GrGLCaps::GrGLCaps() {
15 this->reset(); 15 this->reset();
16 } 16 }
17 17
18 void GrGLCaps::reset() { 18 void GrGLCaps::reset() {
19 INHERITED::reset(); 19 INHERITED::reset();
20 20
21 fVerifiedColorConfigs.reset(); 21 fVerifiedColorConfigs.reset();
22 fStencilFormats.reset(); 22 fStencilFormats.reset();
23 fStencilVerifiedColorConfigs.reset(); 23 fStencilVerifiedColorConfigs.reset();
24 fMSFBOType = kNone_MSFBOType; 24 fMSFBOType = kNone_MSFBOType;
25 fFBFetchType = kNone_FBFetchType;
26 fInvalidateFBType = kNone_InvalidateFBType; 25 fInvalidateFBType = kNone_InvalidateFBType;
27 fLATCAlias = kLATC_LATCAlias; 26 fLATCAlias = kLATC_LATCAlias;
28 fMapBufferType = kNone_MapBufferType; 27 fMapBufferType = kNone_MapBufferType;
29 fMaxFragmentUniformVectors = 0; 28 fMaxFragmentUniformVectors = 0;
30 fMaxVertexAttributes = 0; 29 fMaxVertexAttributes = 0;
31 fMaxFragmentTextureUnits = 0; 30 fMaxFragmentTextureUnits = 0;
32 fMaxFixedFunctionTextureCoords = 0; 31 fMaxFixedFunctionTextureCoords = 0;
33 fRGBA8RenderbufferSupport = false; 32 fRGBA8RenderbufferSupport = false;
34 fBGRAIsInternalFormat = false; 33 fBGRAIsInternalFormat = false;
35 fTextureSwizzleSupport = false; 34 fTextureSwizzleSupport = false;
36 fUnpackRowLengthSupport = false; 35 fUnpackRowLengthSupport = false;
37 fUnpackFlipYSupport = false; 36 fUnpackFlipYSupport = false;
38 fPackRowLengthSupport = false; 37 fPackRowLengthSupport = false;
39 fPackFlipYSupport = false; 38 fPackFlipYSupport = false;
40 fTextureUsageSupport = false; 39 fTextureUsageSupport = false;
41 fTexStorageSupport = false; 40 fTexStorageSupport = false;
42 fTextureRedSupport = false; 41 fTextureRedSupport = false;
43 fImagingSupport = false; 42 fImagingSupport = false;
44 fTwoFormatLimit = false; 43 fTwoFormatLimit = false;
45 fFragCoordsConventionSupport = false; 44 fFragCoordsConventionSupport = false;
46 fVertexArrayObjectSupport = false; 45 fVertexArrayObjectSupport = false;
47 fUseNonVBOVertexAndIndexDynamicData = false; 46 fUseNonVBOVertexAndIndexDynamicData = false;
48 fIsCoreProfile = false; 47 fIsCoreProfile = false;
49 fFullClearIsFree = false; 48 fFullClearIsFree = false;
50 fDropsTileOnZeroDivide = false; 49 fDropsTileOnZeroDivide = false;
50 fFBFetchSupport = false;
51 fFBFetchColorName = NULL;
52 fFBFetchExtensionString = NULL;
51 } 53 }
52 54
53 GrGLCaps::GrGLCaps(const GrGLCaps& caps) : GrDrawTargetCaps() { 55 GrGLCaps::GrGLCaps(const GrGLCaps& caps) : GrDrawTargetCaps() {
54 *this = caps; 56 *this = caps;
55 } 57 }
56 58
57 GrGLCaps& GrGLCaps::operator= (const GrGLCaps& caps) { 59 GrGLCaps& GrGLCaps::operator= (const GrGLCaps& caps) {
58 INHERITED::operator=(caps); 60 INHERITED::operator=(caps);
59 fVerifiedColorConfigs = caps.fVerifiedColorConfigs; 61 fVerifiedColorConfigs = caps.fVerifiedColorConfigs;
60 fStencilFormats = caps.fStencilFormats; 62 fStencilFormats = caps.fStencilFormats;
61 fStencilVerifiedColorConfigs = caps.fStencilVerifiedColorConfigs; 63 fStencilVerifiedColorConfigs = caps.fStencilVerifiedColorConfigs;
62 fLATCAlias = caps.fLATCAlias; 64 fLATCAlias = caps.fLATCAlias;
63 fMaxFragmentUniformVectors = caps.fMaxFragmentUniformVectors; 65 fMaxFragmentUniformVectors = caps.fMaxFragmentUniformVectors;
64 fMaxVertexAttributes = caps.fMaxVertexAttributes; 66 fMaxVertexAttributes = caps.fMaxVertexAttributes;
65 fMaxFragmentTextureUnits = caps.fMaxFragmentTextureUnits; 67 fMaxFragmentTextureUnits = caps.fMaxFragmentTextureUnits;
66 fMaxFixedFunctionTextureCoords = caps.fMaxFixedFunctionTextureCoords; 68 fMaxFixedFunctionTextureCoords = caps.fMaxFixedFunctionTextureCoords;
67 fMSFBOType = caps.fMSFBOType; 69 fMSFBOType = caps.fMSFBOType;
68 fFBFetchType = caps.fFBFetchType;
69 fInvalidateFBType = caps.fInvalidateFBType; 70 fInvalidateFBType = caps.fInvalidateFBType;
70 fMapBufferType = caps.fMapBufferType; 71 fMapBufferType = caps.fMapBufferType;
71 fRGBA8RenderbufferSupport = caps.fRGBA8RenderbufferSupport; 72 fRGBA8RenderbufferSupport = caps.fRGBA8RenderbufferSupport;
72 fBGRAIsInternalFormat = caps.fBGRAIsInternalFormat; 73 fBGRAIsInternalFormat = caps.fBGRAIsInternalFormat;
73 fTextureSwizzleSupport = caps.fTextureSwizzleSupport; 74 fTextureSwizzleSupport = caps.fTextureSwizzleSupport;
74 fUnpackRowLengthSupport = caps.fUnpackRowLengthSupport; 75 fUnpackRowLengthSupport = caps.fUnpackRowLengthSupport;
75 fUnpackFlipYSupport = caps.fUnpackFlipYSupport; 76 fUnpackFlipYSupport = caps.fUnpackFlipYSupport;
76 fPackRowLengthSupport = caps.fPackRowLengthSupport; 77 fPackRowLengthSupport = caps.fPackRowLengthSupport;
77 fPackFlipYSupport = caps.fPackFlipYSupport; 78 fPackFlipYSupport = caps.fPackFlipYSupport;
78 fTextureUsageSupport = caps.fTextureUsageSupport; 79 fTextureUsageSupport = caps.fTextureUsageSupport;
79 fTexStorageSupport = caps.fTexStorageSupport; 80 fTexStorageSupport = caps.fTexStorageSupport;
80 fTextureRedSupport = caps.fTextureRedSupport; 81 fTextureRedSupport = caps.fTextureRedSupport;
81 fImagingSupport = caps.fImagingSupport; 82 fImagingSupport = caps.fImagingSupport;
82 fTwoFormatLimit = caps.fTwoFormatLimit; 83 fTwoFormatLimit = caps.fTwoFormatLimit;
83 fFragCoordsConventionSupport = caps.fFragCoordsConventionSupport; 84 fFragCoordsConventionSupport = caps.fFragCoordsConventionSupport;
84 fVertexArrayObjectSupport = caps.fVertexArrayObjectSupport; 85 fVertexArrayObjectSupport = caps.fVertexArrayObjectSupport;
85 fUseNonVBOVertexAndIndexDynamicData = caps.fUseNonVBOVertexAndIndexDynamicDa ta; 86 fUseNonVBOVertexAndIndexDynamicData = caps.fUseNonVBOVertexAndIndexDynamicDa ta;
86 fIsCoreProfile = caps.fIsCoreProfile; 87 fIsCoreProfile = caps.fIsCoreProfile;
87 fFullClearIsFree = caps.fFullClearIsFree; 88 fFullClearIsFree = caps.fFullClearIsFree;
88 fDropsTileOnZeroDivide = caps.fDropsTileOnZeroDivide; 89 fDropsTileOnZeroDivide = caps.fDropsTileOnZeroDivide;
90 fFBFetchSupport = caps.fFBFetchSupport;
91 fFBFetchColorName = caps.fFBFetchColorName;
92 fFBFetchExtensionString = caps.fFBFetchExtensionString;
89 93
90 return *this; 94 return *this;
91 } 95 }
92 96
93 bool GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { 97 bool GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
94 98
95 this->reset(); 99 this->reset();
96 if (!ctxInfo.isInitialized()) { 100 if (!ctxInfo.isInitialized()) {
97 return false; 101 return false;
98 } 102 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 if (kGL_GrGLStandard == standard) { 230 if (kGL_GrGLStandard == standard) {
227 fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) || 231 fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) ||
228 ctxInfo.hasExtension("GL_ARB_vertex_array_ob ject"); 232 ctxInfo.hasExtension("GL_ARB_vertex_array_ob ject");
229 } else { 233 } else {
230 fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) || 234 fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) ||
231 ctxInfo.hasExtension("GL_OES_vertex_array_ob ject"); 235 ctxInfo.hasExtension("GL_OES_vertex_array_ob ject");
232 } 236 }
233 237
234 if (kGLES_GrGLStandard == standard) { 238 if (kGLES_GrGLStandard == standard) {
235 if (ctxInfo.hasExtension("GL_EXT_shader_framebuffer_fetch")) { 239 if (ctxInfo.hasExtension("GL_EXT_shader_framebuffer_fetch")) {
236 fFBFetchType = kEXT_FBFetchType; 240 fFBFetchSupport = true;
241 fFBFetchColorName = "gl_LastFragData[0]";
242 fFBFetchExtensionString = "GL_EXT_shader_framebuffer_fetch";
237 } else if (ctxInfo.hasExtension("GL_NV_shader_framebuffer_fetch")) { 243 } else if (ctxInfo.hasExtension("GL_NV_shader_framebuffer_fetch")) {
238 fFBFetchType = kNV_FBFetchType; 244 fFBFetchSupport = true;
245 fFBFetchColorName = "gl_LastFragData[0]";
246 fFBFetchExtensionString = "GL_NV_shader_framebuffer_fetch";
247 } else if (ctxInfo.hasExtension("GL_ARM_shader_framebuffer_fetch")) {
248 // The arm extension also requires an additional flag which we will set onResetContext
249 // This is all temporary.
250 fFBFetchSupport = true;
251 fFBFetchColorName = "gl_LastFragColorARM";
252 fFBFetchExtensionString = "GL_ARM_shader_framebuffer_fetch";
239 } 253 }
240 } 254 }
241 255
242 // Adreno GPUs have a tendency to drop tiles when there is a divide-by-zero in a shader 256 // Adreno GPUs have a tendency to drop tiles when there is a divide-by-zero in a shader
243 fDropsTileOnZeroDivide = kQualcomm_GrGLVendor == ctxInfo.vendor(); 257 fDropsTileOnZeroDivide = kQualcomm_GrGLVendor == ctxInfo.vendor();
244 258
245 this->initFSAASupport(ctxInfo, gli); 259 this->initFSAASupport(ctxInfo, gli);
246 this->initStencilFormats(ctxInfo); 260 this->initStencilFormats(ctxInfo);
247 261
248 /************************************************************************** 262 /**************************************************************************
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 ctxInfo.hasExtension("GL_ARB_program_interface_query")) && 342 ctxInfo.hasExtension("GL_ARB_program_interface_query")) &&
329 NULL != gli->fFunctions.fProgramPathFragmentInputGen)); 343 NULL != gli->fFunctions.fProgramPathFragmentInputGen));
330 } else { 344 } else {
331 // Note: path rendering is not yet implemented for GLES. 345 // Note: path rendering is not yet implemented for GLES.
332 fPathRenderingSupport = ctxInfo.version() >= GR_GL_VER(3,1) && false ; 346 fPathRenderingSupport = ctxInfo.version() >= GR_GL_VER(3,1) && false ;
333 } 347 }
334 } 348 }
335 349
336 fGpuTracingSupport = ctxInfo.hasExtension("GL_EXT_debug_marker"); 350 fGpuTracingSupport = ctxInfo.hasExtension("GL_EXT_debug_marker");
337 351
338 fDstReadInShaderSupport = kNone_FBFetchType != fFBFetchType; 352 // For now these two are equivalent but we could have dst read in shader via some other method
353 fDstReadInShaderSupport = fFBFetchSupport;
339 354
340 // Disable scratch texture reuse on Mali and Adreno devices 355 // Disable scratch texture reuse on Mali and Adreno devices
341 fReuseScratchTextures = kARM_GrGLVendor != ctxInfo.vendor() && 356 fReuseScratchTextures = kARM_GrGLVendor != ctxInfo.vendor() &&
342 kQualcomm_GrGLVendor != ctxInfo.vendor(); 357 kQualcomm_GrGLVendor != ctxInfo.vendor();
343 358
344 // Enable supported shader-related caps 359 // Enable supported shader-related caps
345 if (kGL_GrGLStandard == standard) { 360 if (kGL_GrGLStandard == standard) {
346 fDualSourceBlendingSupport = ctxInfo.version() >= GR_GL_VER(3,3) || 361 fDualSourceBlendingSupport = ctxInfo.version() >= GR_GL_VER(3,3) ||
347 ctxInfo.hasExtension("GL_ARB_blend_func_ext ended"); 362 ctxInfo.hasExtension("GL_ARB_blend_func_ext ended");
348 fShaderDerivativeSupport = true; 363 fShaderDerivativeSupport = true;
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 }; 783 };
769 GR_STATIC_ASSERT(0 == kNone_MSFBOType); 784 GR_STATIC_ASSERT(0 == kNone_MSFBOType);
770 GR_STATIC_ASSERT(1 == kDesktop_ARB_MSFBOType); 785 GR_STATIC_ASSERT(1 == kDesktop_ARB_MSFBOType);
771 GR_STATIC_ASSERT(2 == kDesktop_EXT_MSFBOType); 786 GR_STATIC_ASSERT(2 == kDesktop_EXT_MSFBOType);
772 GR_STATIC_ASSERT(3 == kES_3_0_MSFBOType); 787 GR_STATIC_ASSERT(3 == kES_3_0_MSFBOType);
773 GR_STATIC_ASSERT(4 == kES_Apple_MSFBOType); 788 GR_STATIC_ASSERT(4 == kES_Apple_MSFBOType);
774 GR_STATIC_ASSERT(5 == kES_IMG_MsToTexture_MSFBOType); 789 GR_STATIC_ASSERT(5 == kES_IMG_MsToTexture_MSFBOType);
775 GR_STATIC_ASSERT(6 == kES_EXT_MsToTexture_MSFBOType); 790 GR_STATIC_ASSERT(6 == kES_EXT_MsToTexture_MSFBOType);
776 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMSFBOExtStr) == kLast_MSFBOType + 1); 791 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMSFBOExtStr) == kLast_MSFBOType + 1);
777 792
778 static const char* kFBFetchTypeStr[] = {
779 "None",
780 "EXT",
781 "NV",
782 };
783 GR_STATIC_ASSERT(0 == kNone_FBFetchType);
784 GR_STATIC_ASSERT(1 == kEXT_FBFetchType);
785 GR_STATIC_ASSERT(2 == kNV_FBFetchType);
786 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kFBFetchTypeStr) == kLast_FBFetchType + 1);
787
788 static const char* kInvalidateFBTypeStr[] = { 793 static const char* kInvalidateFBTypeStr[] = {
789 "None", 794 "None",
790 "Discard", 795 "Discard",
791 "Invalidate", 796 "Invalidate",
792 }; 797 };
793 GR_STATIC_ASSERT(0 == kNone_InvalidateFBType); 798 GR_STATIC_ASSERT(0 == kNone_InvalidateFBType);
794 GR_STATIC_ASSERT(1 == kDiscard_InvalidateFBType); 799 GR_STATIC_ASSERT(1 == kDiscard_InvalidateFBType);
795 GR_STATIC_ASSERT(2 == kInvalidate_InvalidateFBType); 800 GR_STATIC_ASSERT(2 == kInvalidate_InvalidateFBType);
796 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kInvalidateFBTypeStr) == kLast_InvalidateFBT ype + 1); 801 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kInvalidateFBTypeStr) == kLast_InvalidateFBT ype + 1);
797 802
798 static const char* kMapBufferTypeStr[] = { 803 static const char* kMapBufferTypeStr[] = {
799 "None", 804 "None",
800 "MapBuffer", 805 "MapBuffer",
801 "MapBufferRange", 806 "MapBufferRange",
802 "Chromium", 807 "Chromium",
803 }; 808 };
804 GR_STATIC_ASSERT(0 == kNone_MapBufferType); 809 GR_STATIC_ASSERT(0 == kNone_MapBufferType);
805 GR_STATIC_ASSERT(1 == kMapBuffer_MapBufferType); 810 GR_STATIC_ASSERT(1 == kMapBuffer_MapBufferType);
806 GR_STATIC_ASSERT(2 == kMapBufferRange_MapBufferType); 811 GR_STATIC_ASSERT(2 == kMapBufferRange_MapBufferType);
807 GR_STATIC_ASSERT(3 == kChromium_MapBufferType); 812 GR_STATIC_ASSERT(3 == kChromium_MapBufferType);
808 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMapBufferTypeStr) == kLast_MapBufferType + 1); 813 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMapBufferTypeStr) == kLast_MapBufferType + 1);
809 814
810 r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); 815 r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO"));
811 r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]); 816 r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]);
812 r.appendf("FB Fetch Type: %s\n", kFBFetchTypeStr[fFBFetchType]); 817 r.appendf("FB Fetch Support: %s\n", (fFBFetchSupport ? "YES" : "NO"));
813 r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType ]); 818 r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType ]);
814 r.appendf("Map Buffer Type: %s\n", kMapBufferTypeStr[fMapBufferType]); 819 r.appendf("Map Buffer Type: %s\n", kMapBufferTypeStr[fMapBufferType]);
815 r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors); 820 r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors);
816 r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits); 821 r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits);
817 if (!fIsCoreProfile) { 822 if (!fIsCoreProfile) {
818 r.appendf("Max Fixed Function Texture Coords: %d\n", fMaxFixedFunctionTe xtureCoords); 823 r.appendf("Max Fixed Function Texture Coords: %d\n", fMaxFixedFunctionTe xtureCoords);
819 } 824 }
820 r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes); 825 r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes);
821 r.appendf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ? "YES": "NO")); 826 r.appendf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ? "YES": "NO"));
822 r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES" : "NO")); 827 r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES" : "NO"));
(...skipping 10 matching lines...) Expand all
833 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); 838 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO"));
834 r.appendf("Fragment coord conventions support: %s\n", 839 r.appendf("Fragment coord conventions support: %s\n",
835 (fFragCoordsConventionSupport ? "YES": "NO")); 840 (fFragCoordsConventionSupport ? "YES": "NO"));
836 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO")); 841 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO"));
837 r.appendf("Use non-VBO for dynamic data: %s\n", 842 r.appendf("Use non-VBO for dynamic data: %s\n",
838 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); 843 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO"));
839 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO ")); 844 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO "));
840 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO")); 845 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES" : "NO"));
841 return r; 846 return r;
842 } 847 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLCaps.h ('k') | src/gpu/gl/GrGLDefines.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698