31#if defined(SK_BUILD_FOR_WIN) && defined(SK_ENABLE_DISCRETE_GPU)
37 _declspec(dllexport)
unsigned long NvOptimusEnablement = 0x00000001;
41 __declspec(dllexport)
int AmdPowerXpressRequestHighPerformance = 1;
51 : fGlobalOptions(opts) {}
62 for (
int i = fContexts.
size() - 1;
i >= 0; --
i) {
63 Context& context = fContexts[
i];
65 if (context.fTestContext) {
66 restore = context.fTestContext->makeCurrentAndAutoRestore();
68 if (!context.fGrContext->unique()) {
69 context.fGrContext->releaseResourcesAndAbandonContext();
70 context.fAbandoned =
true;
72 context.fGrContext->unref();
73 delete context.fTestContext;
83 for (
int i = fContexts.
size() - 1;
i >= 0; --
i) {
84 Context& context = fContexts[
i];
85 if (!context.fAbandoned) {
86 if (context.fTestContext) {
87 auto restore = context.fTestContext->makeCurrentAndAutoRestore();
88 context.fTestContext->testAbandon();
92 if (requiresEarlyAbandon) {
93 context.fGrContext->abandonContext();
95 if (context.fTestContext) {
96 delete(context.fTestContext);
97 context.fTestContext =
nullptr;
99 if (!requiresEarlyAbandon) {
100 context.fGrContext->abandonContext();
102 context.fAbandoned =
true;
112 for (
int i = fContexts.
size() - 1;
i >= 0; --
i) {
113 Context& context = fContexts[
i];
115 if (!context.fAbandoned) {
116 if (context.fTestContext) {
117 restore = context.fTestContext->makeCurrentAndAutoRestore();
119 context.fGrContext->releaseResourcesAndAbandonContext();
120 if (context.fTestContext) {
121 delete context.fTestContext;
122 context.fTestContext =
nullptr;
124 context.fAbandoned =
true;
135 uint32_t shareIndex) {
137 SkASSERT((shareIndex == 0) || (shareContext !=
nullptr));
139 for (
int i = 0;
i < fContexts.
size(); ++
i) {
141 if (context.fType ==
type &&
142 context.fOverrides == overrides &&
143 context.fShareContext == shareContext &&
144 context.fShareIndex == shareIndex &&
145 !context.fAbandoned) {
146 context.fTestContext->makeCurrent();
147 return ContextInfo(context.fType, context.fTestContext, context.fGrContext,
153 Context* primaryContext =
nullptr;
155 for (
int i = 0;
i < fContexts.
size(); ++
i) {
156 if (!fContexts[
i].fAbandoned && fContexts[
i].fGrContext == shareContext) {
157 primaryContext = &fContexts[
i];
161 SkASSERT(primaryContext && primaryContext->fType ==
type);
164 std::unique_ptr<TestContext> testCtx;
169 GLTestContext* glShareContext = primaryContext
170 ?
static_cast<GLTestContext*
>(primaryContext->fTestContext) :
nullptr;
171 GLTestContext* glCtx;
173 case ContextType::kGL:
176 case ContextType::kGLES:
180 case ContextType::kANGLE_D3D9_ES2:
182 glShareContext).release();
190 return ContextInfo();
194 case ContextType::kANGLE_D3D11_ES2:
196 glShareContext).release();
198 case ContextType::kANGLE_D3D11_ES3:
200 glShareContext).release();
202 case ContextType::kANGLE_GL_ES2:
204 glShareContext).release();
206 case ContextType::kANGLE_GL_ES3:
208 glShareContext).release();
210 case ContextType::kANGLE_Metal_ES2:
212 glShareContext).release();
214 case ContextType::kANGLE_Metal_ES3:
216 glShareContext).release();
220 return ContextInfo();
223 return ContextInfo();
227 glCtx->overrideVersion(
"OpenGL ES 2.0",
"OpenGL ES GLSL ES 1.00");
229 testCtx.reset(glCtx);
235 VkTestContext* vkSharedContext = primaryContext
236 ?
static_cast<VkTestContext*
>(primaryContext->fTestContext) :
nullptr;
238 testCtx.reset(CreatePlatformVkTestContext(vkSharedContext));
240 return ContextInfo();
248 if (!fSentinelGLContext) {
250 if (!fSentinelGLContext) {
260 MtlTestContext* mtlSharedContext = primaryContext
261 ?
static_cast<MtlTestContext*
>(primaryContext->fTestContext) :
nullptr;
265 return ContextInfo();
272 D3DTestContext* d3dSharedContext = primaryContext
273 ?
static_cast<D3DTestContext*
>(primaryContext->fTestContext) :
nullptr;
275 testCtx.reset(CreatePlatformD3DTestContext(d3dSharedContext));
277 return ContextInfo();
283 TestContext* sharedContext = primaryContext ? primaryContext->fTestContext :
nullptr;
287 return ContextInfo();
292 return ContextInfo();
305 auto restore = testCtx->makeCurrentAndAutoRestore();
306 grCtx = testCtx->makeContext(grOptions);
309 return ContextInfo();
320 context.fTestContext = testCtx.release();
321 context.fGrContext =
SkRef(grCtx.
get());
322 context.fType =
type;
323 context.fOverrides = overrides;
324 context.fAbandoned =
false;
325 context.fShareContext = shareContext;
326 context.fShareIndex = shareIndex;
327 context.fOptions = grOptions;
328 context.fTestContext->makeCurrent();
329 return ContextInfo(context.fType, context.fTestContext, context.fGrContext, context.fOptions);
333 return this->getContextInfoInternal(
type, overrides,
nullptr, 0);
337 uint32_t shareIndex) {
339 for (
int i = 0;
i < fContexts.
size(); ++
i) {
340 if (!fContexts[
i].fAbandoned && fContexts[
i].fGrContext == shareContext) {
341 return this->getContextInfoInternal(fContexts[
i].fType, fContexts[
i].fOverrides,
342 shareContext, shareIndex);
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
bool gCreateProtectedContext
GrGLDriverInfo GrGLGetDriverInfo(const GrGLInterface *interface)
DirectContextID directContextID() const
GrDirectContext * directContext() const
ContextInfo getContextInfo(ContextType type, ContextOverrides=ContextOverrides::kNone)
ContextInfo getSharedContextInfo(GrDirectContext *shareContext, uint32_t shareIndex=0)
GrDirectContext * get(ContextType type, ContextOverrides overrides=ContextOverrides::kNone)
void releaseResourcesAndAbandonContexts()
std::unique_ptr< GLTestContext > MakeANGLETestContext(ANGLEBackend type, ANGLEContextVersion version, GLTestContext *shareContext, void *display)
TestContext * CreateMockTestContext(TestContext *)
GLTestContext * CreatePlatformGLTestContext(GrGLStandard forcedGpuAPI, GLTestContext *shareContext)
MtlTestContext * CreatePlatformMtlTestContext(MtlTestContext *sharedContext)
GrBackendApi ContextTypeBackend(skgpu::ContextType type)
@ kVulkan
ANGLE on Metal ES 3 context.
bool fReducedShaderVariations
bool fAvoidStencilBuffers