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

Side by Side Diff: src/gpu/GrContextFactory.cpp

Issue 1448883002: Make NVPR a GL context option instead of a GL context (Closed) Base URL: https://skia.googlesource.com/skia.git@commandbuffer-as-api-02-other-tests-refactor
Patch Set: Created 5 years 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/GrContextFactory.h ('k') | tests/GLInterfaceValidationTest.cpp » ('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 /* 2 /*
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrContextFactory.h" 9 #include "GrContextFactory.h"
10 10
11 #if SK_ANGLE 11 #if SK_ANGLE
12 #include "gl/angle/SkANGLEGLContext.h" 12 #include "gl/angle/SkANGLEGLContext.h"
13 #endif 13 #endif
14 #if SK_COMMAND_BUFFER 14 #if SK_COMMAND_BUFFER
15 #include "gl/command_buffer/SkCommandBufferGLContext.h" 15 #include "gl/command_buffer/SkCommandBufferGLContext.h"
16 #endif 16 #endif
17 #include "gl/debug/SkDebugGLContext.h" 17 #include "gl/debug/SkDebugGLContext.h"
18 #if SK_MESA 18 #if SK_MESA
19 #include "gl/mesa/SkMesaGLContext.h" 19 #include "gl/mesa/SkMesaGLContext.h"
20 #endif 20 #endif
21 #include "gl/SkGLContext.h" 21 #include "gl/SkGLContext.h"
22 #include "gl/SkNullGLContext.h" 22 #include "gl/SkNullGLContext.h"
23 #include "gl/GrGLGpu.h" 23 #include "gl/GrGLGpu.h"
24 #include "GrCaps.h" 24 #include "GrCaps.h"
25 25
26 GrContextFactory::ContextInfo* GrContextFactory::getContextInfo(GLContextType ty pe, 26 GrContextFactory::ContextInfo* GrContextFactory::getContextInfo(GLContextType ty pe,
27 GrGLStandard for cedGpuAPI) { 27 GrGLStandard for cedGpuAPI,
28 GLContextOptions options) {
28 for (int i = 0; i < fContexts.count(); ++i) { 29 for (int i = 0; i < fContexts.count(); ++i) {
29 if (forcedGpuAPI != kNone_GrGLStandard && 30 if (fContexts[i]->fType == type &&
30 forcedGpuAPI != fContexts[i]->fGLContext->gl()->fStandard) 31 fContexts[i]->fOptions == options &&
31 continue; 32 (forcedGpuAPI == kNone_GrGLStandard ||
32 33 forcedGpuAPI == fContexts[i]->fGLContext->gl()->fStandard)) {
33 if (fContexts[i]->fType == type) {
34 fContexts[i]->fGLContext->makeCurrent(); 34 fContexts[i]->fGLContext->makeCurrent();
35 return fContexts[i]; 35 return fContexts[i];
36 } 36 }
37 } 37 }
38
38 SkAutoTUnref<SkGLContext> glCtx; 39 SkAutoTUnref<SkGLContext> glCtx;
39 SkAutoTUnref<GrContext> grCtx; 40 SkAutoTUnref<GrContext> grCtx;
40 switch (type) { 41 switch (type) {
41 case kNVPR_GLContextType: // fallthru
42 case kNative_GLContextType: 42 case kNative_GLContextType:
43 glCtx.reset(SkCreatePlatformGLContext(forcedGpuAPI)); 43 glCtx.reset(SkCreatePlatformGLContext(forcedGpuAPI));
44 break; 44 break;
45 #ifdef SK_ANGLE 45 #ifdef SK_ANGLE
46 case kANGLE_GLContextType: 46 case kANGLE_GLContextType:
47 glCtx.reset(SkANGLEGLContext::Create(forcedGpuAPI, false)); 47 glCtx.reset(SkANGLEGLContext::Create(forcedGpuAPI, false));
48 break; 48 break;
49 case kANGLE_GL_GLContextType: 49 case kANGLE_GL_GLContextType:
50 glCtx.reset(SkANGLEGLContext::Create(forcedGpuAPI, true)); 50 glCtx.reset(SkANGLEGLContext::Create(forcedGpuAPI, true));
51 break; 51 break;
(...skipping 16 matching lines...) Expand all
68 break; 68 break;
69 } 69 }
70 if (nullptr == glCtx.get()) { 70 if (nullptr == glCtx.get()) {
71 return nullptr; 71 return nullptr;
72 } 72 }
73 73
74 SkASSERT(glCtx->isValid()); 74 SkASSERT(glCtx->isValid());
75 75
76 // Block NVPR from non-NVPR types. 76 // Block NVPR from non-NVPR types.
77 SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl())); 77 SkAutoTUnref<const GrGLInterface> glInterface(SkRef(glCtx->gl()));
78 if (kNVPR_GLContextType != type) { 78 if (!(kEnableNVPR_GLContextOptions & options)) {
79 glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface)); 79 glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface));
80 if (!glInterface) { 80 if (!glInterface) {
81 return nullptr; 81 return nullptr;
82 } 82 }
83 } else {
84 if (!glInterface->hasExtension("GL_NV_path_rendering")) {
85 return nullptr;
86 }
87 } 83 }
88 84
89 glCtx->makeCurrent(); 85 glCtx->makeCurrent();
90 GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(glInterface.get ()); 86 GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(glInterface.get ());
91 #ifdef SK_VULKAN 87 #ifdef SK_VULKAN
92 grCtx.reset(GrContext::Create(kVulkan_GrBackend, p3dctx, fGlobalOptions)); 88 grCtx.reset(GrContext::Create(kVulkan_GrBackend, p3dctx, fGlobalOptions));
93 #else 89 #else
94 grCtx.reset(GrContext::Create(kOpenGL_GrBackend, p3dctx, fGlobalOptions)); 90 grCtx.reset(GrContext::Create(kOpenGL_GrBackend, p3dctx, fGlobalOptions));
95 #endif 91 #endif
96 if (!grCtx.get()) { 92 if (!grCtx.get()) {
97 return nullptr; 93 return nullptr;
98 } 94 }
99 // Warn if path rendering support is not available for the NVPR type. 95
100 if (kNVPR_GLContextType == type) { 96 if (kEnableNVPR_GLContextOptions & options) {
101 if (!grCtx->caps()->shaderCaps()->pathRenderingSupport()) { 97 if (!grCtx->caps()->shaderCaps()->pathRenderingSupport()) {
102 GrGpu* gpu = grCtx->getGpu(); 98 return nullptr;
Kimmo Kinnunen 2015/12/02 14:03:57 IIRC this hunk was interesting when NVPR was run b
bsalomon 2015/12/02 14:30:28 Does DM really fail or does it just print that it
103 const GrGLContext* ctx = gpu->glContextForTesting();
104 if (ctx) {
105 const GrGLubyte* verUByte;
106 GR_GL_CALL_RET(ctx->interface(), verUByte, GetString(GR_GL_VERSI ON));
107 const char* ver = reinterpret_cast<const char*>(verUByte);
108 SkDebugf("\nWARNING: nvprmsaa config requested, but driver path rendering "
109 "support not available. Maybe update the driver? Your d river version "
110 "string: \"%s\"\n", ver);
111 } else {
112 SkDebugf("\nWARNING: nvprmsaa config requested, but driver path rendering "
113 "support not available.\n");
114 }
115 } 99 }
116 } 100 }
117 101
118 ContextInfo* ctx = fContexts.emplace_back(new ContextInfo); 102 ContextInfo* ctx = fContexts.emplace_back(new ContextInfo);
119 ctx->fGLContext = SkRef(glCtx.get()); 103 ctx->fGLContext = SkRef(glCtx.get());
120 ctx->fGrContext = SkRef(grCtx.get()); 104 ctx->fGrContext = SkRef(grCtx.get());
121 ctx->fType = type; 105 ctx->fType = type;
106 ctx->fOptions = options;
122 return ctx; 107 return ctx;
123 } 108 }
OLDNEW
« no previous file with comments | « src/gpu/GrContextFactory.h ('k') | tests/GLInterfaceValidationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698