2018-10-24 18:24:11 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2018-09-21 00:30:26 +00:00
|
|
|
From: Milan Burda <milan.burda@gmail.com>
|
|
|
|
Date: Thu, 20 Sep 2018 17:47:01 -0700
|
|
|
|
Subject: webgl_context_attributes.patch
|
|
|
|
|
|
|
|
|
2018-09-14 05:02:16 +00:00
|
|
|
diff --git a/content/renderer/renderer_blink_platform_impl.cc b/content/renderer/renderer_blink_platform_impl.cc
|
2019-01-24 09:42:21 +00:00
|
|
|
index 704ee01d0a30f68275653591428e9d16eeb5d5a0..2adc208e36b66fcf8cbdbf05abfa1cd877361745 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/content/renderer/renderer_blink_platform_impl.cc
|
|
|
|
+++ b/content/renderer/renderer_blink_platform_impl.cc
|
2019-01-24 09:42:21 +00:00
|
|
|
@@ -896,8 +896,10 @@ RendererBlinkPlatformImpl::CreateOffscreenGraphicsContext3DProvider(
|
2018-09-14 05:02:16 +00:00
|
|
|
attributes.sample_buffers = 0;
|
|
|
|
attributes.bind_generates_resource = false;
|
|
|
|
attributes.enable_raster_interface = web_attributes.enable_raster_interface;
|
|
|
|
- // Prefer discrete GPU for WebGL.
|
|
|
|
- attributes.gpu_preference = gl::PreferDiscreteGpu;
|
|
|
|
+
|
|
|
|
+ attributes.gpu_preference = web_attributes.prefer_integrated_gpu
|
|
|
|
+ ? gl::PreferIntegratedGpu
|
|
|
|
+ : gl::PreferDiscreteGpu;
|
|
|
|
|
|
|
|
attributes.fail_if_major_perf_caveat =
|
|
|
|
web_attributes.fail_if_major_performance_caveat;
|
2018-09-14 18:03:43 +00:00
|
|
|
diff --git a/third_party/blink/public/platform/platform.h b/third_party/blink/public/platform/platform.h
|
2019-01-16 18:07:52 +00:00
|
|
|
index bfc4a95febcf44249cd3793b883c03ab9bd1e3ec..03c6046fb6541f7864b504d8f1470b843579ae41 100644
|
2018-09-14 18:03:43 +00:00
|
|
|
--- a/third_party/blink/public/platform/platform.h
|
|
|
|
+++ b/third_party/blink/public/platform/platform.h
|
2019-01-16 18:07:52 +00:00
|
|
|
@@ -540,6 +540,7 @@ class BLINK_PLATFORM_EXPORT Platform {
|
2018-10-24 23:25:48 +00:00
|
|
|
kWebGPUContextType, // WebGPU context
|
2018-09-14 18:03:43 +00:00
|
|
|
};
|
|
|
|
struct ContextAttributes {
|
|
|
|
+ bool prefer_integrated_gpu = false;
|
|
|
|
bool fail_if_major_performance_caveat = false;
|
|
|
|
ContextType context_type = kGLES2ContextType;
|
|
|
|
// Offscreen contexts usually share a surface for the default frame buffer
|
2018-09-14 05:02:16 +00:00
|
|
|
diff --git a/third_party/blink/renderer/core/html/canvas/canvas_context_creation_attributes_core.h b/third_party/blink/renderer/core/html/canvas/canvas_context_creation_attributes_core.h
|
2019-01-16 18:07:52 +00:00
|
|
|
index 614e4e3a8737c1149baac1aedb985c6be62c9a84..3ae0b2a809532707ca9c8b3964737a1a5941e132 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/third_party/blink/renderer/core/html/canvas/canvas_context_creation_attributes_core.h
|
|
|
|
+++ b/third_party/blink/renderer/core/html/canvas/canvas_context_creation_attributes_core.h
|
|
|
|
@@ -30,6 +30,7 @@ class CORE_EXPORT CanvasContextCreationAttributesCore {
|
2019-01-12 01:00:43 +00:00
|
|
|
String pixel_format = "uint8";
|
2018-09-14 05:02:16 +00:00
|
|
|
bool premultiplied_alpha = true;
|
|
|
|
bool preserve_drawing_buffer = false;
|
|
|
|
+ String power_preference = "default";
|
|
|
|
bool stencil = false;
|
2019-01-16 18:07:52 +00:00
|
|
|
bool xr_compatible = false;
|
|
|
|
};
|
2018-09-14 05:02:16 +00:00
|
|
|
diff --git a/third_party/blink/renderer/modules/canvas/htmlcanvas/canvas_context_creation_attributes_module.idl b/third_party/blink/renderer/modules/canvas/htmlcanvas/canvas_context_creation_attributes_module.idl
|
2019-01-16 18:07:52 +00:00
|
|
|
index ad9f867f46be2c652da9fd328517de6d87de31a7..b4f97a0fdc658a23d5d021172e32d68f68a7c38f 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/third_party/blink/renderer/modules/canvas/htmlcanvas/canvas_context_creation_attributes_module.idl
|
|
|
|
+++ b/third_party/blink/renderer/modules/canvas/htmlcanvas/canvas_context_creation_attributes_module.idl
|
|
|
|
@@ -28,6 +28,12 @@ enum CanvasPixelFormat {
|
|
|
|
"float16",
|
|
|
|
};
|
|
|
|
|
|
|
|
+enum CanvasPowerPreference {
|
|
|
|
+ "default",
|
|
|
|
+ "low-power",
|
|
|
|
+ "high-performance",
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
[PermissiveDictionaryConversion]
|
|
|
|
dictionary CanvasContextCreationAttributesModule {
|
|
|
|
// This is an experimental feature, but it is not hidden behind a flag in
|
2018-09-14 18:03:43 +00:00
|
|
|
@@ -47,6 +53,7 @@ dictionary CanvasContextCreationAttributesModule {
|
2018-09-14 05:02:16 +00:00
|
|
|
boolean antialias = true;
|
|
|
|
boolean premultipliedAlpha = true;
|
|
|
|
boolean preserveDrawingBuffer = false;
|
|
|
|
+ CanvasPowerPreference powerPreference = "default";
|
|
|
|
boolean failIfMajorPerformanceCaveat = false;
|
2019-01-16 18:07:52 +00:00
|
|
|
[OriginTrialEnabled=WebXR] boolean xrCompatible = false;
|
2018-09-14 05:02:16 +00:00
|
|
|
};
|
|
|
|
diff --git a/third_party/blink/renderer/modules/webgl/webgl_context_attribute_helpers.cc b/third_party/blink/renderer/modules/webgl/webgl_context_attribute_helpers.cc
|
2019-01-16 18:07:52 +00:00
|
|
|
index 7a74942ab1f4495956d8e96ecd98b8028a20efa3..9a868cdb36ce468d3116379cfc04da28acfe010b 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/third_party/blink/renderer/modules/webgl/webgl_context_attribute_helpers.cc
|
|
|
|
+++ b/third_party/blink/renderer/modules/webgl/webgl_context_attribute_helpers.cc
|
2019-01-16 18:07:52 +00:00
|
|
|
@@ -17,6 +17,7 @@ WebGLContextAttributes* ToWebGLContextAttributes(
|
2019-01-08 23:59:47 +00:00
|
|
|
result->setAntialias(attrs.antialias);
|
|
|
|
result->setPremultipliedAlpha(attrs.premultiplied_alpha);
|
|
|
|
result->setPreserveDrawingBuffer(attrs.preserve_drawing_buffer);
|
|
|
|
+ result->setPowerPreference(attrs.power_preference);
|
|
|
|
result->setFailIfMajorPerformanceCaveat(
|
2018-09-14 05:02:16 +00:00
|
|
|
attrs.fail_if_major_performance_caveat);
|
2019-01-16 18:07:52 +00:00
|
|
|
result->setXrCompatible(attrs.xr_compatible);
|
|
|
|
@@ -29,6 +30,7 @@ Platform::ContextAttributes ToPlatformContextAttributes(
|
2018-09-21 00:30:26 +00:00
|
|
|
Platform::ContextType context_type,
|
2018-09-14 05:02:16 +00:00
|
|
|
bool support_own_offscreen_surface) {
|
|
|
|
Platform::ContextAttributes result;
|
|
|
|
+ result.prefer_integrated_gpu = attrs.power_preference == "low-power";
|
|
|
|
result.fail_if_major_performance_caveat =
|
|
|
|
attrs.fail_if_major_performance_caveat;
|
2018-09-21 00:30:26 +00:00
|
|
|
result.context_type = context_type;
|
2018-09-14 05:02:16 +00:00
|
|
|
diff --git a/third_party/blink/renderer/modules/webgl/webgl_context_attributes.idl b/third_party/blink/renderer/modules/webgl/webgl_context_attributes.idl
|
2019-01-16 18:07:52 +00:00
|
|
|
index 725dbfb351e7556e137750d95104648c879dffc1..2e4df15a8dfe1a8ea504205e951a3d270e23ed46 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/third_party/blink/renderer/modules/webgl/webgl_context_attributes.idl
|
|
|
|
+++ b/third_party/blink/renderer/modules/webgl/webgl_context_attributes.idl
|
|
|
|
@@ -26,6 +26,12 @@
|
|
|
|
|
|
|
|
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.2
|
|
|
|
|
|
|
|
+enum WebGLPowerPreference {
|
|
|
|
+ "default",
|
|
|
|
+ "low-power",
|
|
|
|
+ "high-performance",
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
dictionary WebGLContextAttributes {
|
|
|
|
boolean alpha = true;
|
|
|
|
boolean depth = true;
|
2018-09-14 18:03:43 +00:00
|
|
|
@@ -33,6 +39,7 @@ dictionary WebGLContextAttributes {
|
2018-09-14 05:02:16 +00:00
|
|
|
boolean antialias = true;
|
|
|
|
boolean premultipliedAlpha = true;
|
|
|
|
boolean preserveDrawingBuffer = false;
|
|
|
|
+ WebGLPowerPreference powerPreference = "default";
|
|
|
|
boolean failIfMajorPerformanceCaveat = false;
|
2019-01-16 18:07:52 +00:00
|
|
|
[OriginTrialEnabled=WebXR] boolean xrCompatible = false;
|
2019-01-12 01:00:43 +00:00
|
|
|
// TODO(crbug.com/788439): remove OriginTrialEnabled.
|