Hash :
f422f21a
Author :
Date :
2021-11-09T18:42:15
Reland "Metal: Reintroduce GPU power preference selection code." This reverts commit 67a8cf07a740c5ce3aafd2ad7fddd370451b3525. Reason for revert: Landed Chromium-side dependency: https://chromium-review.googlesource.com/c/chromium/src/+/3271170 Original change's description: > Revert "Metal: Reintroduce GPU power preference selection code." > > This reverts commit 017161701b7dbf70a13f3c180a39e1fa45c27d9f. > > Reason for revert: Blocking roller, please re-land with the fix. > > Original change's description: > > Metal: Reintroduce GPU power preference selection code. > > > > This CL re-introduces the GPU power preference code to > > the metal backend. It also reworks EGLDisplay caching > > in the frontend to cache based on the native display > > as well as the power preference attribute. > > A new extension, EGL_ANGLE_display_power_preference is > > added based on EGL_ANGLE_power_preference. This extension > > is a client extension that allows selection of GPU on > > display creation, similar to how GPUs are selected on > > context creation in EGL_ANGLE_power_preference. > > This CL adds EGLDisplayPowerPreferenceTest and enables it on > > the metal backend. > > > > Bug: angleproject:6143 > > Change-Id: I0a081dcd2e3f18ab365fdd3498ddcb6e2ba35212 > > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3231986 > > Reviewed-by: Kenneth Russell <kbr@chromium.org> > > Reviewed-by: Jamie Madill <jmadill@chromium.org> > > Reviewed-by: Gregg Tavares <gman@chromium.org> > > Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> > > TBR=kbr@chromium.org,gman@chromium.org,jonahr@google.com,jmadill@chromium.org,angle-scoped@luci-project-accounts.iam.gserviceaccount.com > > Change-Id: I4f775bf7139253a87b033a30e0da2100b3c1bb02 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: angleproject:6143 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3270749 > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Commit-Queue: Jamie Madill <jmadill@chromium.org> # Not skipping CQ checks because this is a reland. Bug: angleproject:6143 Change-Id: Id9b0a5cbb76e4dea9e2f2da2b1c47a0587dfdaf5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3270970 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Commit-Queue: Jonah Ryan-Davis <jonahr@google.com>
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
//
// Copyright 2014 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.
//
#ifndef ANGLE_TEST_CONFIGS_H_
#define ANGLE_TEST_CONFIGS_H_
// On Linux EGL/egl.h includes X.h which does defines for some very common
// names that are used by gtest (like None and Bool) and causes a lot of
// compilation errors. To work around this, even if this file doesn't use it,
// we include gtest before EGL so that it compiles fine in other files that
// want to use gtest.
#include <gtest/gtest.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include "angle_test_instantiate.h"
#include "util/EGLPlatformParameters.h"
namespace angle
{
struct PlatformParameters
{
PlatformParameters();
PlatformParameters(EGLint majorVersion,
EGLint minorVersion,
const EGLPlatformParameters &eglPlatformParameters);
PlatformParameters(EGLint majorVersion, EGLint minorVersion, GLESDriverType driver);
EGLint getRenderer() const;
EGLint getDeviceType() const;
bool isSwiftshader() const;
bool isVulkan() const;
bool isANGLE() const;
EGLint getAllocateNonZeroMemoryFeature() const;
void initDefaultParameters();
auto tie() const
{
return std::tie(driver, noFixture, eglParameters, majorVersion, minorVersion);
}
GLESDriverType driver;
bool noFixture;
EGLPlatformParameters eglParameters;
EGLint majorVersion;
EGLint minorVersion;
};
const char *GetRendererName(EGLint renderer);
bool operator<(const PlatformParameters &a, const PlatformParameters &b);
bool operator==(const PlatformParameters &a, const PlatformParameters &b);
std::ostream &operator<<(std::ostream &stream, const PlatformParameters &pp);
// EGL platforms
namespace egl_platform
{
EGLPlatformParameters DEFAULT();
EGLPlatformParameters DEFAULT_NULL();
EGLPlatformParameters D3D9();
EGLPlatformParameters D3D9_NULL();
EGLPlatformParameters D3D9_REFERENCE();
EGLPlatformParameters D3D11();
EGLPlatformParameters D3D11_PRESENT_PATH_FAST();
EGLPlatformParameters D3D11_FL11_1();
EGLPlatformParameters D3D11_FL11_0();
EGLPlatformParameters D3D11_FL10_1();
EGLPlatformParameters D3D11_FL10_0();
EGLPlatformParameters D3D11_NULL();
EGLPlatformParameters D3D11_WARP();
EGLPlatformParameters D3D11_FL11_1_WARP();
EGLPlatformParameters D3D11_FL11_0_WARP();
EGLPlatformParameters D3D11_FL10_1_WARP();
EGLPlatformParameters D3D11_FL10_0_WARP();
EGLPlatformParameters D3D11_REFERENCE();
EGLPlatformParameters D3D11_FL11_1_REFERENCE();
EGLPlatformParameters D3D11_FL11_0_REFERENCE();
EGLPlatformParameters D3D11_FL10_1_REFERENCE();
EGLPlatformParameters D3D11_FL10_0_REFERENCE();
EGLPlatformParameters OPENGL();
EGLPlatformParameters OPENGL(EGLint major, EGLint minor);
EGLPlatformParameters OPENGL_NULL();
EGLPlatformParameters OPENGLES();
EGLPlatformParameters OPENGLES(EGLint major, EGLint minor);
EGLPlatformParameters OPENGLES_NULL();
EGLPlatformParameters OPENGL_OR_GLES();
EGLPlatformParameters OPENGL_OR_GLES(EGLint major, EGLint minor);
EGLPlatformParameters OPENGL_OR_GLES_NULL();
EGLPlatformParameters VULKAN();
EGLPlatformParameters VULKAN_NULL();
EGLPlatformParameters VULKAN_SWIFTSHADER();
} // namespace egl_platform
// ANGLE tests platforms
PlatformParameters ES1_D3D9();
PlatformParameters ES2_D3D9();
PlatformParameters ES1_D3D11();
PlatformParameters ES2_D3D11();
PlatformParameters ES2_D3D11_PRESENT_PATH_FAST();
PlatformParameters ES2_D3D11_FL11_0();
PlatformParameters ES2_D3D11_FL10_1();
PlatformParameters ES2_D3D11_FL10_0();
PlatformParameters ES2_D3D11_WARP();
PlatformParameters ES2_D3D11_FL11_0_WARP();
PlatformParameters ES2_D3D11_FL10_1_WARP();
PlatformParameters ES2_D3D11_FL10_0_WARP();
PlatformParameters ES2_D3D11_REFERENCE();
PlatformParameters ES2_D3D11_FL11_0_REFERENCE();
PlatformParameters ES2_D3D11_FL10_1_REFERENCE();
PlatformParameters ES2_D3D11_FL10_0_REFERENCE();
PlatformParameters ES3_D3D11();
PlatformParameters ES3_D3D11_FL11_1();
PlatformParameters ES3_D3D11_FL11_0();
PlatformParameters ES3_D3D11_FL10_1();
PlatformParameters ES31_D3D11();
PlatformParameters ES31_D3D11_FL11_1();
PlatformParameters ES31_D3D11_FL11_0();
PlatformParameters ES3_D3D11_WARP();
PlatformParameters ES3_D3D11_FL11_1_WARP();
PlatformParameters ES3_D3D11_FL11_0_WARP();
PlatformParameters ES3_D3D11_FL10_1_WARP();
PlatformParameters ES1_OPENGL();
PlatformParameters ES2_OPENGL();
PlatformParameters ES2_OPENGL(EGLint major, EGLint minor);
PlatformParameters ES3_OPENGL();
PlatformParameters ES3_OPENGL(EGLint major, EGLint minor);
PlatformParameters ES31_OPENGL();
PlatformParameters ES31_OPENGL(EGLint major, EGLint minor);
PlatformParameters ES1_OPENGLES();
PlatformParameters ES2_OPENGLES();
PlatformParameters ES2_OPENGLES(EGLint major, EGLint minor);
PlatformParameters ES3_OPENGLES();
PlatformParameters ES3_OPENGLES(EGLint major, EGLint minor);
PlatformParameters ES31_OPENGLES();
PlatformParameters ES31_OPENGLES(EGLint major, EGLint minor);
PlatformParameters ES1_NULL();
PlatformParameters ES2_NULL();
PlatformParameters ES3_NULL();
PlatformParameters ES31_NULL();
PlatformParameters ES1_VULKAN();
PlatformParameters ES1_VULKAN_NULL();
PlatformParameters ES1_VULKAN_SWIFTSHADER();
PlatformParameters ES2_VULKAN();
PlatformParameters ES2_VULKAN_NULL();
PlatformParameters ES2_VULKAN_SWIFTSHADER();
PlatformParameters ES3_VULKAN();
PlatformParameters ES3_VULKAN_NULL();
PlatformParameters ES3_VULKAN_SWIFTSHADER();
PlatformParameters ES31_VULKAN();
PlatformParameters ES31_VULKAN_NULL();
PlatformParameters ES31_VULKAN_SWIFTSHADER();
PlatformParameters ES32_VULKAN();
PlatformParameters ES32_VULKAN_NULL();
PlatformParameters ES32_VULKAN_SWIFTSHADER();
PlatformParameters ES1_METAL();
PlatformParameters ES2_METAL();
PlatformParameters ES3_METAL();
PlatformParameters ES2_WGL();
PlatformParameters ES3_WGL();
PlatformParameters ES2_EGL();
PlatformParameters ES3_EGL();
const char *GetNativeEGLLibraryNameWithExtension();
inline PlatformParameters WithNoFixture(const PlatformParameters ¶ms)
{
PlatformParameters withNoFixture = params;
withNoFixture.noFixture = true;
return withNoFixture;
}
inline PlatformParameters WithNoTransformFeedback(const PlatformParameters ¶ms)
{
PlatformParameters withNoTransformFeedback = params;
withNoTransformFeedback.eglParameters.transformFeedbackFeature = EGL_FALSE;
return withNoTransformFeedback;
}
inline PlatformParameters WithAllocateNonZeroMemory(const PlatformParameters ¶ms)
{
PlatformParameters allocateNonZero = params;
allocateNonZero.eglParameters.allocateNonZeroMemoryFeature = EGL_TRUE;
return allocateNonZero;
}
inline PlatformParameters WithEmulateCopyTexImage2DFromRenderbuffers(
const PlatformParameters ¶ms)
{
PlatformParameters p = params;
p.eglParameters.emulateCopyTexImage2DFromRenderbuffers = EGL_TRUE;
return p;
}
inline PlatformParameters WithNoShaderStencilOutput(const PlatformParameters ¶ms)
{
PlatformParameters re = params;
re.eglParameters.shaderStencilOutputFeature = EGL_FALSE;
return re;
}
inline PlatformParameters WithNoGenMultipleMipsPerPass(const PlatformParameters ¶ms)
{
PlatformParameters re = params;
re.eglParameters.genMultipleMipsPerPassFeature = EGL_FALSE;
return re;
}
inline PlatformParameters WithMetalMemoryBarrierAndCheapRenderPass(const PlatformParameters ¶ms,
bool hasBarrier,
bool cheapRenderPass)
{
PlatformParameters re = params;
re.eglParameters.hasExplicitMemBarrierFeatureMtl = hasBarrier ? EGL_TRUE : EGL_FALSE;
re.eglParameters.hasCheapRenderPassFeatureMtl = cheapRenderPass ? EGL_TRUE : EGL_FALSE;
return re;
}
inline PlatformParameters WithMetalForcedBufferGPUStorage(const PlatformParameters ¶ms)
{
PlatformParameters re = params;
re.eglParameters.forceBufferGPUStorageFeatureMtl = EGL_TRUE;
return re;
}
inline PlatformParameters WithRobustness(const PlatformParameters ¶ms)
{
PlatformParameters withRobustness = params;
withRobustness.eglParameters.robustness = EGL_TRUE;
return withRobustness;
}
inline PlatformParameters WithEmulatedPrerotation(const PlatformParameters ¶ms, EGLint rotation)
{
PlatformParameters prerotation = params;
prerotation.eglParameters.emulatedPrerotation = rotation;
return prerotation;
}
inline PlatformParameters WithAsyncCommandQueueFeatureVulkan(const PlatformParameters ¶ms)
{
PlatformParameters withAsyncCommandQueue = params;
withAsyncCommandQueue.eglParameters.asyncCommandQueueFeatureVulkan = EGL_TRUE;
return withAsyncCommandQueue;
}
inline PlatformParameters WithNoVulkanViewportFlip(const PlatformParameters ¶ms)
{
PlatformParameters withoutVulkanViewportFlip = params;
withoutVulkanViewportFlip.eglParameters.supportsVulkanViewportFlip = EGL_FALSE;
return withoutVulkanViewportFlip;
}
inline PlatformParameters WithEmulatedVAOs(const PlatformParameters ¶ms)
{
PlatformParameters emualtedVAOParams = params;
emualtedVAOParams.eglParameters.emulatedVAOs = EGL_TRUE;
return emualtedVAOParams;
}
inline PlatformParameters WithGlslang(const PlatformParameters ¶ms)
{
PlatformParameters generateSPIRVThroughGlslang = params;
generateSPIRVThroughGlslang.eglParameters.generateSPIRVThroughGlslang = EGL_TRUE;
return generateSPIRVThroughGlslang;
}
inline PlatformParameters WithDirectMetalGeneration(const PlatformParameters ¶ms)
{
PlatformParameters directMetalGeneration = params;
directMetalGeneration.eglParameters.directMetalGeneration = EGL_TRUE;
return directMetalGeneration;
}
inline PlatformParameters WithInitShaderVariables(const PlatformParameters ¶ms)
{
PlatformParameters initShaderVariables = params;
initShaderVariables.eglParameters.forceInitShaderVariables = EGL_TRUE;
return initShaderVariables;
}
inline PlatformParameters WithForceVulkanFallbackFormat(const PlatformParameters ¶msIn)
{
PlatformParameters paramsOut = paramsIn;
paramsOut.eglParameters.forceVulkanFallbackFormat = EGL_TRUE;
return paramsOut;
}
inline PlatformParameters WithLowPowerGPU(const PlatformParameters ¶msIn)
{
PlatformParameters paramsOut = paramsIn;
paramsOut.eglParameters.displayPowerPreference = EGL_LOW_POWER_ANGLE;
return paramsOut;
}
inline PlatformParameters WithHighPowerGPU(const PlatformParameters ¶msIn)
{
PlatformParameters paramsOut = paramsIn;
paramsOut.eglParameters.displayPowerPreference = EGL_HIGH_POWER_ANGLE;
return paramsOut;
}
} // namespace angle
#endif // ANGLE_TEST_CONFIGS_H_