| OLD | NEW |
| 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 #include "gl/GLTestContext.h" | 10 #include "gl/GLTestContext.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #endif | 24 #endif |
| 25 #include "gl/null/NullGLTestContext.h" | 25 #include "gl/null/NullGLTestContext.h" |
| 26 #include "gl/GrGLGpu.h" | 26 #include "gl/GrGLGpu.h" |
| 27 #include "GrCaps.h" | 27 #include "GrCaps.h" |
| 28 | 28 |
| 29 namespace sk_gpu_test { | 29 namespace sk_gpu_test { |
| 30 GrContextFactory::GrContextFactory() { } | 30 GrContextFactory::GrContextFactory() { } |
| 31 | 31 |
| 32 GrContextFactory::GrContextFactory(const GrContextOptions& opts) | 32 GrContextFactory::GrContextFactory(const GrContextOptions& opts) |
| 33 : fGlobalOptions(opts) { | 33 : fGlobalOptions(opts) { |
| 34 // In this factory, instanced rendering is specified with kUseInstanced_Cont
extOptions. | 34 // In this factory, instanced rendering is specified with ContextOptions::kU
seInstanced. |
| 35 SkASSERT(!fGlobalOptions.fEnableInstancedRendering); | 35 SkASSERT(!fGlobalOptions.fEnableInstancedRendering); |
| 36 } | 36 } |
| 37 | 37 |
| 38 GrContextFactory::~GrContextFactory() { | 38 GrContextFactory::~GrContextFactory() { |
| 39 this->destroyContexts(); | 39 this->destroyContexts(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void GrContextFactory::destroyContexts() { | 42 void GrContextFactory::destroyContexts() { |
| 43 for (Context& context : fContexts) { | 43 for (Context& context : fContexts) { |
| 44 if (context.fTestContext) { | 44 if (context.fTestContext) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 case kCommandBuffer_ContextType: | 132 case kCommandBuffer_ContextType: |
| 133 glCtx = CommandBufferGLTestContext::Create(); | 133 glCtx = CommandBufferGLTestContext::Create(); |
| 134 break; | 134 break; |
| 135 #endif | 135 #endif |
| 136 #if SK_MESA | 136 #if SK_MESA |
| 137 case kMESA_ContextType: | 137 case kMESA_ContextType: |
| 138 glCtx = CreateMesaGLTestContext(); | 138 glCtx = CreateMesaGLTestContext(); |
| 139 break; | 139 break; |
| 140 #endif | 140 #endif |
| 141 case kNullGL_ContextType: | 141 case kNullGL_ContextType: |
| 142 glCtx = CreateNullGLTestContext(kEnableNVPR_ContextOptions &
options); | 142 glCtx = CreateNullGLTestContext(ContextOptions::kEnableNVPR
& options); |
| 143 break; | 143 break; |
| 144 case kDebugGL_ContextType: | 144 case kDebugGL_ContextType: |
| 145 glCtx = CreateDebugGLTestContext(); | 145 glCtx = CreateDebugGLTestContext(); |
| 146 break; | 146 break; |
| 147 default: | 147 default: |
| 148 return ContextInfo(); | 148 return ContextInfo(); |
| 149 } | 149 } |
| 150 if (!glCtx) { | 150 if (!glCtx) { |
| 151 return ContextInfo(); | 151 return ContextInfo(); |
| 152 } | 152 } |
| 153 testCtx.reset(glCtx); | 153 testCtx.reset(glCtx); |
| 154 glInterface.reset(SkRef(glCtx->gl())); | 154 glInterface.reset(SkRef(glCtx->gl())); |
| 155 // Block NVPR from non-NVPR types. We don't block NVPR from contexts
that will use | 155 // Block NVPR from non-NVPR types. We don't block NVPR from contexts
that will use |
| 156 // instanced rendering because that would prevent us from testing mi
xed samples. | 156 // instanced rendering because that would prevent us from testing mi
xed samples. |
| 157 if (!((kEnableNVPR_ContextOptions | kUseInstanced_ContextOptions) &
options)) { | 157 if (!((ContextOptions::kEnableNVPR | ContextOptions::kUseInstanced)
& options)) { |
| 158 glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface.get())); | 158 glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface.get())); |
| 159 if (!glInterface) { | 159 if (!glInterface) { |
| 160 return ContextInfo(); | 160 return ContextInfo(); |
| 161 } | 161 } |
| 162 } | 162 } |
| 163 backendContext = reinterpret_cast<GrBackendContext>(glInterface.get(
)); | 163 backendContext = reinterpret_cast<GrBackendContext>(glInterface.get(
)); |
| 164 break; | 164 break; |
| 165 } | 165 } |
| 166 #ifdef SK_VULKAN | 166 #ifdef SK_VULKAN |
| 167 case kVulkan_GrBackend: | 167 case kVulkan_GrBackend: |
| 168 SkASSERT(kVulkan_ContextType == type); | 168 SkASSERT(kVulkan_ContextType == type); |
| 169 if (kEnableNVPR_ContextOptions & options) { | 169 if (ContextOptions::kEnableNVPR & options) { |
| 170 return ContextInfo(); | 170 return ContextInfo(); |
| 171 } | 171 } |
| 172 testCtx.reset(CreatePlatformVkTestContext()); | 172 testCtx.reset(CreatePlatformVkTestContext()); |
| 173 if (!testCtx) { | 173 if (!testCtx) { |
| 174 return ContextInfo(); | 174 return ContextInfo(); |
| 175 } | 175 } |
| 176 | 176 |
| 177 // There is some bug (either in Skia or the NV Vulkan driver) where
VkDevice | 177 // There is some bug (either in Skia or the NV Vulkan driver) where
VkDevice |
| 178 // destruction will hang occaisonally. For some reason having an exi
sting GL | 178 // destruction will hang occaisonally. For some reason having an exi
sting GL |
| 179 // context fixes this. | 179 // context fixes this. |
| 180 if (!fSentinelGLContext) { | 180 if (!fSentinelGLContext) { |
| 181 fSentinelGLContext.reset(CreatePlatformGLTestContext(kGL_GrGLSta
ndard)); | 181 fSentinelGLContext.reset(CreatePlatformGLTestContext(kGL_GrGLSta
ndard)); |
| 182 if (!fSentinelGLContext) { | 182 if (!fSentinelGLContext) { |
| 183 fSentinelGLContext.reset(CreatePlatformGLTestContext(kGLES_G
rGLStandard)); | 183 fSentinelGLContext.reset(CreatePlatformGLTestContext(kGLES_G
rGLStandard)); |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 backendContext = testCtx->backendContext(); | 186 backendContext = testCtx->backendContext(); |
| 187 break; | 187 break; |
| 188 #endif | 188 #endif |
| 189 default: | 189 default: |
| 190 return ContextInfo(); | 190 return ContextInfo(); |
| 191 } | 191 } |
| 192 testCtx->makeCurrent(); | 192 testCtx->makeCurrent(); |
| 193 SkASSERT(testCtx && testCtx->backend() == backend); | 193 SkASSERT(testCtx && testCtx->backend() == backend); |
| 194 GrContextOptions grOptions = fGlobalOptions; | 194 GrContextOptions grOptions = fGlobalOptions; |
| 195 if (kUseInstanced_ContextOptions & options) { | 195 if (ContextOptions::kUseInstanced & options) { |
| 196 grOptions.fEnableInstancedRendering = true; | 196 grOptions.fEnableInstancedRendering = true; |
| 197 } | 197 } |
| 198 grCtx.reset(GrContext::Create(backend, backendContext, grOptions)); | 198 grCtx.reset(GrContext::Create(backend, backendContext, grOptions)); |
| 199 if (!grCtx.get()) { | 199 if (!grCtx.get()) { |
| 200 return ContextInfo(); | 200 return ContextInfo(); |
| 201 } | 201 } |
| 202 if (kEnableNVPR_ContextOptions & options) { | 202 if (ContextOptions::kEnableNVPR & options) { |
| 203 if (!grCtx->caps()->shaderCaps()->pathRenderingSupport()) { | 203 if (!grCtx->caps()->shaderCaps()->pathRenderingSupport()) { |
| 204 return ContextInfo(); | 204 return ContextInfo(); |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 if (kUseInstanced_ContextOptions & options) { | 207 if (ContextOptions::kUseInstanced & options) { |
| 208 if (GrCaps::InstancedSupport::kNone == grCtx->caps()->instancedSupport()
) { | 208 if (GrCaps::InstancedSupport::kNone == grCtx->caps()->instancedSupport()
) { |
| 209 return ContextInfo(); | 209 return ContextInfo(); |
| 210 } | 210 } |
| 211 } | 211 } |
| 212 if (kRequireSRGBSupport_ContextOptions & options) { | 212 if (ContextOptions::kRequireSRGBSupport & options) { |
| 213 if (!grCtx->caps()->srgbSupport()) { | 213 if (!grCtx->caps()->srgbSupport()) { |
| 214 return ContextInfo(); | 214 return ContextInfo(); |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 | 217 |
| 218 Context& context = fContexts.push_back(); | 218 Context& context = fContexts.push_back(); |
| 219 context.fBackend = backend; | 219 context.fBackend = backend; |
| 220 context.fTestContext = testCtx.release(); | 220 context.fTestContext = testCtx.release(); |
| 221 context.fGrContext = SkRef(grCtx.get()); | 221 context.fGrContext = SkRef(grCtx.get()); |
| 222 context.fType = type; | 222 context.fType = type; |
| 223 context.fOptions = options; | 223 context.fOptions = options; |
| 224 context.fAbandoned = false; | 224 context.fAbandoned = false; |
| 225 return ContextInfo(context.fBackend, context.fTestContext, context.fGrContex
t); | 225 return ContextInfo(context.fBackend, context.fTestContext, context.fGrContex
t); |
| 226 } | 226 } |
| 227 } // namespace sk_gpu_test | 227 } // namespace sk_gpu_test |
| OLD | NEW |