Hash :
51386f4a
Author :
Date :
2019-04-11T21:55:20
Reland "Define and expose EGL_ANGLE_power_preference extension." This is a reland of ac58e63295f093b7518535bdd060ff832025b0c5 The original CL was reverted in a rush because I thought there was an uninitialized variable bug, but upon later re-review this turned out to not be the case. Original change's description: > Define and expose EGL_ANGLE_power_preference extension. > > Allows application to select the integrated or discrete GPU on > dual-GPU macOS systems. > > Tested by modifying the example program at: > https://github.com/grorg/ANGLEIOSurfaceTest > > and verifying that both integrated and discrete GPUs can be selected. > (The changes to that program will be upstreamed once some build issues > are resolved.) > > Bug: 2813 > Change-Id: Ibeb17778512896456d220e9bc4cf8f222aa57057 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1570081 > Commit-Queue: Kenneth Russell <kbr@chromium.org> > Reviewed-by: Geoff Lang <geofflang@chromium.org> Bug: 2813 Tbr: geofflang@chromium.org Tbr: cwallez@chromium.org Change-Id: Iea000dd718f4f4b4f57237adb1dc44381b10106b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1575419 Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Kenneth Russell <kbr@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
//
// Copyright 2019 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ContextCGL:
// Mac-specific subclass of ContextGL.
//
#include "libANGLE/renderer/gl/cgl/ContextCGL.h"
#include "libANGLE/Context.h"
#include "libANGLE/Display.h"
#include "libANGLE/renderer/gl/cgl/DisplayCGL.h"
namespace rx
{
ContextCGL::ContextCGL(const gl::State &state,
gl::ErrorSet *errorSet,
const std::shared_ptr<RendererGL> &renderer,
bool usesDiscreteGPU)
: ContextGL(state, errorSet, renderer), mUsesDiscreteGpu(usesDiscreteGPU)
{}
void ContextCGL::onDestroy(const gl::Context *context)
{
if (mUsesDiscreteGpu)
{
egl::Display *display = context->getDisplay();
// TODO(kbr): if the context is created and destroyed without ever
// making it current, it is possible to leak retentions of the
// discrete GPU.
if (display)
{
GetImplAs<DisplayCGL>(display)->unreferenceDiscreteGPU();
}
}
}
} // namespace rx