2017-10-27 22:55:37 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2017-10-27 23:10:06 +00:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2016-08-04 18:33:42 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef mozilla_gfx_config_gfxVars_h
|
|
|
|
#define mozilla_gfx_config_gfxVars_h
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "mozilla/Assertions.h"
|
|
|
|
#include "mozilla/StaticPtr.h"
|
|
|
|
#include "mozilla/gfx/GraphicsMessages.h"
|
|
|
|
#include "mozilla/gfx/Point.h"
|
|
|
|
#include "mozilla/gfx/Types.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsXULAppAPI.h"
|
|
|
|
|
2023-05-11 09:59:53 +00:00
|
|
|
namespace mozilla::gfx {
|
2016-08-04 18:33:42 +00:00
|
|
|
|
|
|
|
class gfxVarReceiver;
|
|
|
|
|
|
|
|
// Generator for graphics vars.
|
|
|
|
#define GFX_VARS_LIST(_) \
|
|
|
|
/* C++ Name, Data Type, Default Value */ \
|
2020-10-06 05:43:33 +00:00
|
|
|
_(AllowEglRbab, bool, true) \
|
2020-09-27 22:18:23 +00:00
|
|
|
_(AllowWebgl2, bool, true) \
|
2020-10-06 05:43:33 +00:00
|
|
|
_(AllowWebglAccelAngle, bool, true) \
|
2020-10-01 08:14:12 +00:00
|
|
|
_(AllowWebglOop, bool, true) \
|
2016-08-04 18:33:44 +00:00
|
|
|
_(BrowserTabsRemoteAutostart, bool, false) \
|
2016-08-04 18:33:44 +00:00
|
|
|
_(ContentBackend, BackendType, BackendType::NONE) \
|
2017-03-28 14:35:55 +00:00
|
|
|
_(SoftwareBackend, BackendType, BackendType::NONE) \
|
2016-08-24 18:02:00 +00:00
|
|
|
_(OffscreenFormat, gfxImageFormat, \
|
|
|
|
mozilla::gfx::SurfaceFormat::X8R8G8B8_UINT32) \
|
2016-08-24 18:03:00 +00:00
|
|
|
_(RequiresAcceleratedGLContextForCompositorOGL, bool, false) \
|
2016-08-25 03:48:35 +00:00
|
|
|
_(CanUseHardwareVideoDecoding, bool, false) \
|
2016-11-14 22:13:40 +00:00
|
|
|
_(DXInterop2Blocked, bool, false) \
|
2018-05-17 03:07:20 +00:00
|
|
|
_(DXNV12Blocked, bool, false) \
|
2018-10-11 07:32:35 +00:00
|
|
|
_(DXP010Blocked, bool, false) \
|
|
|
|
_(DXP016Blocked, bool, false) \
|
2017-03-29 14:14:19 +00:00
|
|
|
_(UseWebRenderANGLE, bool, false) \
|
2019-07-19 09:26:03 +00:00
|
|
|
_(UseWebRenderFlipSequentialWin, bool, false) \
|
2018-03-29 02:23:31 +00:00
|
|
|
_(UseWebRenderDCompWin, bool, false) \
|
2023-06-22 00:21:07 +00:00
|
|
|
_(UseWebRenderDCompVideoHwOverlayWin, bool, false) \
|
|
|
|
_(UseWebRenderDCompVideoSwOverlayWin, bool, false) \
|
2019-07-19 09:26:03 +00:00
|
|
|
_(UseWebRenderTripleBufferingWin, bool, false) \
|
2019-12-10 19:16:13 +00:00
|
|
|
_(UseWebRenderCompositor, bool, false) \
|
2018-05-31 06:07:34 +00:00
|
|
|
_(UseWebRenderProgramBinaryDisk, bool, false) \
|
2020-04-21 10:32:15 +00:00
|
|
|
_(UseWebRenderOptimizedShaders, bool, false) \
|
2020-06-08 21:05:03 +00:00
|
|
|
_(UseWebRenderScissoredCacheClears, bool, true) \
|
Bug 1671289 - Improve WebRender's integrated profiler. r=gw
In a (large-ish) nutshell:
- Consolidate all counters under a single type.
- Counters are all arranged in an array and referred to via index.
- All counters can be displayed as average+max (float/int), graph, and change indicator.
- Specify what to show and in what form via a pref.
- All counters and visualizations support not having values every frame.
- GPU time queries visualization is easier to read relative to the frame budget:
- If the maximum value is under 16ms, the right side of the graph is fixed at 16ms.
- If the maximum value is above 16ms, draw a vertical bar at 16ms.
- Added a few new profile counters:
- Total frame CPU time (from API send to the end of GPU command submission).
- Visibility, Prepare, Batching and Glyph resolve times.
The main change is how profile counters are represented. Instead of having different types for different visualizations, every counter is represented the same way, tracking average/max values over half a ms and optionally recording a graph over a number of frames. Counters are stored in a vector and referred to via index (See constants at the top of profiler.rs).
The main motivation for this storage is to facilitate adding counters without having to think too much about where to store them and how to pass them to the renderer.
The profiler's UI is defined by a string with with a single syntax:
- Comma separated list of tokens (leading and trailing spaces ignored), which can be:
- A counter name:
- If prefixed with a '#' character, the counter is shown as a graph.
- If prefixed with a '*' character, the counter is shown as a change indicator
- By default (counter name without prefix), the counter is shown as average and max over half a second.
- A preset name:
- A preset is a builtin UI string in the same syntax that can be nested in the main UI string.
- Presets are defined towards the top of profiler.rs and can also refer to other presets.
- An empty token adds a bit of vertical space.
- A '|' token begins a new column.
- A '_' token begins a new row.
Differential Revision: https://phabricator.services.mozilla.com/D93603
2020-10-20 08:54:04 +00:00
|
|
|
_(WebRenderProfilerUI, nsCString, nsCString()) \
|
2020-09-27 22:18:23 +00:00
|
|
|
_(WebglAllowCoreProfile, bool, true) \
|
|
|
|
_(WebglAllowWindowsNativeGl, bool, false) \
|
2019-12-17 05:05:30 +00:00
|
|
|
_(WebRenderMaxPartialPresentRects, int32_t, 0) \
|
2017-08-23 10:00:37 +00:00
|
|
|
_(WebRenderDebugFlags, int32_t, 0) \
|
2021-09-23 15:17:46 +00:00
|
|
|
_(WebRenderBoolParameters, int32_t, 0) \
|
2020-02-20 03:45:17 +00:00
|
|
|
_(WebRenderBatchingLookback, int32_t, 10) \
|
2021-09-08 12:41:51 +00:00
|
|
|
_(WebRenderBlobTileSize, int32_t, 256) \
|
2021-11-03 16:42:42 +00:00
|
|
|
_(WebRenderBatchedUploadThreshold, int32_t, 512 * 512) \
|
2024-06-11 10:33:44 +00:00
|
|
|
_(WebRenderSlowCpuFrameThreshold, float, 10.0) \
|
2020-03-13 18:18:14 +00:00
|
|
|
_(UseSoftwareWebRender, bool, false) \
|
2021-03-10 05:22:45 +00:00
|
|
|
_(AllowSoftwareWebRenderD3D11, bool, false) \
|
2024-03-22 00:55:48 +00:00
|
|
|
_(PrimaryScreenDepth, int32_t, 0) \
|
2017-12-16 15:13:30 +00:00
|
|
|
_(GREDirectory, nsString, nsString()) \
|
2018-05-31 06:07:34 +00:00
|
|
|
_(ProfDirectory, nsString, nsString()) \
|
2017-07-25 18:02:36 +00:00
|
|
|
_(AllowD3D11KeyedMutex, bool, false) \
|
2021-10-19 15:04:08 +00:00
|
|
|
_(SwapIntervalGLX, bool, false) \
|
|
|
|
_(SwapIntervalEGL, bool, false) \
|
2019-05-26 14:30:57 +00:00
|
|
|
_(SystemTextQuality, int32_t, 5 /* CLEARTYPE_QUALITY */) \
|
2021-08-05 09:13:09 +00:00
|
|
|
_(SystemTextClearTypeLevel, float, 1.0f) \
|
|
|
|
_(SystemTextEnhancedContrast, float, 1.0f) \
|
|
|
|
_(SystemTextGamma, float, 2.2f) \
|
|
|
|
_(SystemTextPixelGeometry, int32_t, 1 /* pixel geometry RGB */) \
|
|
|
|
_(SystemTextRenderingMode, int32_t, 0) \
|
|
|
|
_(SystemGDIGamma, float, 1.4f) \
|
2018-11-28 20:44:27 +00:00
|
|
|
_(LayersWindowRecordingPath, nsCString, nsCString()) \
|
2019-07-09 06:37:45 +00:00
|
|
|
_(RemoteCanvasEnabled, bool, false) \
|
2019-08-09 18:57:35 +00:00
|
|
|
_(UseDoubleBufferingWithCompositor, bool, false) \
|
2020-01-10 16:57:55 +00:00
|
|
|
_(UseGLSwizzle, bool, true) \
|
2020-05-16 03:09:57 +00:00
|
|
|
_(ForceSubpixelAAWherePossible, bool, false) \
|
2020-07-02 13:43:19 +00:00
|
|
|
_(FxREmbedded, bool, false) \
|
2023-01-27 21:35:26 +00:00
|
|
|
_(UseAHardwareBufferSharedSurfaceWebglOop, bool, false) \
|
2021-01-18 09:26:21 +00:00
|
|
|
_(UseEGL, bool, false) \
|
2021-03-16 20:14:51 +00:00
|
|
|
_(DrmRenderDevice, nsCString, nsCString()) \
|
2021-06-11 13:15:17 +00:00
|
|
|
_(UseDMABuf, bool, false) \
|
2024-11-02 03:50:17 +00:00
|
|
|
_(UseDMABufWebGL, bool, true) \
|
2023-05-11 09:59:53 +00:00
|
|
|
_(DMABufModifiersXRGB, ArrayOfuint64_t, nsTArray<uint64_t>()) \
|
|
|
|
_(DMABufModifiersARGB, ArrayOfuint64_t, nsTArray<uint64_t>()) \
|
2022-07-22 23:08:08 +00:00
|
|
|
_(CodecSupportInfo, nsCString, nsCString()) \
|
2021-11-09 17:33:46 +00:00
|
|
|
_(WebRenderRequiresHardwareDriver, bool, false) \
|
2022-01-24 16:12:02 +00:00
|
|
|
_(SupportsThreadsafeGL, bool, false) \
|
2022-03-23 19:28:57 +00:00
|
|
|
_(AllowWebGPU, bool, false) \
|
|
|
|
_(UseVP8HwDecode, bool, false) \
|
2022-04-05 14:26:42 +00:00
|
|
|
_(UseVP9HwDecode, bool, false) \
|
2023-05-11 09:58:21 +00:00
|
|
|
_(UseAV1HwDecode, bool, false) \
|
|
|
|
_(UseH264HwDecode, bool, false) \
|
2022-06-20 10:14:41 +00:00
|
|
|
_(HwDecodedVideoZeroCopy, bool, false) \
|
2022-06-28 21:54:36 +00:00
|
|
|
_(UseDMABufSurfaceExport, bool, true) \
|
2022-07-08 04:02:41 +00:00
|
|
|
_(ReuseDecoderDevice, bool, false) \
|
2022-08-18 12:29:20 +00:00
|
|
|
_(UseCanvasRenderThread, bool, false) \
|
2022-12-07 02:24:57 +00:00
|
|
|
_(AllowBackdropFilter, bool, true) \
|
2022-12-16 20:15:49 +00:00
|
|
|
_(WebglOopAsyncPresentForceSync, bool, true) \
|
2022-12-20 08:29:47 +00:00
|
|
|
_(UseAcceleratedCanvas2D, bool, false) \
|
2023-11-29 21:45:27 +00:00
|
|
|
_(AllowSoftwareWebRenderOGL, bool, false) \
|
2024-03-08 01:38:56 +00:00
|
|
|
_(WebglUseHardware, bool, true) \
|
2024-03-13 01:34:05 +00:00
|
|
|
_(WebRenderOverlayVpAutoHDR, bool, false) \
|
2024-03-22 04:13:28 +00:00
|
|
|
_(WebRenderOverlayVpSuperResolution, bool, false) \
|
2024-05-16 00:06:33 +00:00
|
|
|
_(AllowWebGPUPresentWithoutReadback, bool, false) \
|
|
|
|
_(GPUProcessEnabled, bool, false)
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2016-08-04 18:33:42 +00:00
|
|
|
/* Add new entries above this line. */
|
|
|
|
|
|
|
|
// Some graphics settings are computed on the UI process and must be
|
|
|
|
// communicated to content and GPU processes. gfxVars helps facilitate
|
2019-05-26 14:31:53 +00:00
|
|
|
// this. Its function is similar to StaticPrefs, except rather than hold
|
2016-08-04 18:33:42 +00:00
|
|
|
// user preferences, it holds dynamically computed values.
|
|
|
|
//
|
|
|
|
// Each variable in GFX_VARS_LIST exposes the following static methods:
|
|
|
|
//
|
|
|
|
// const DataType& CxxName();
|
|
|
|
// void SetCxxName(const DataType& aValue);
|
|
|
|
//
|
|
|
|
// Note that the setter may only be called in the UI process; a gfxVar must be
|
|
|
|
// a variable that is determined in the UI process and pushed to child
|
|
|
|
// processes.
|
|
|
|
class gfxVars final {
|
|
|
|
public:
|
2017-06-27 21:04:17 +00:00
|
|
|
// These values will be used during the Initialize() call if set. Any
|
|
|
|
// updates that come before initialization will get added to this array.
|
|
|
|
static void SetValuesForInitialize(
|
|
|
|
const nsTArray<GfxVarUpdate>& aInitUpdates);
|
|
|
|
|
2017-04-14 03:13:31 +00:00
|
|
|
static void Initialize();
|
2016-08-04 18:33:42 +00:00
|
|
|
static void Shutdown();
|
|
|
|
|
|
|
|
static void ApplyUpdate(const GfxVarUpdate& aUpdate);
|
|
|
|
static void AddReceiver(gfxVarReceiver* aReceiver);
|
|
|
|
static void RemoveReceiver(gfxVarReceiver* aReceiver);
|
|
|
|
|
|
|
|
// Return a list of updates for all variables with non-default values.
|
|
|
|
static nsTArray<GfxVarUpdate> FetchNonDefaultVars();
|
|
|
|
|
2023-05-11 09:59:53 +00:00
|
|
|
private:
|
|
|
|
template <typename U>
|
|
|
|
static U CloneVarValue(const U& aValue) {
|
|
|
|
return aValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename U>
|
|
|
|
static nsTArray<U> CloneVarValue(const nsTArray<U>& aValue) {
|
|
|
|
return aValue.Clone();
|
|
|
|
}
|
|
|
|
|
2016-08-04 18:33:42 +00:00
|
|
|
public:
|
|
|
|
// Each variable must expose Set and Get methods for IPDL.
|
|
|
|
class VarBase {
|
|
|
|
public:
|
|
|
|
VarBase();
|
|
|
|
virtual void SetValue(const GfxVarValue& aValue) = 0;
|
|
|
|
virtual void GetValue(GfxVarValue* aOutValue) = 0;
|
|
|
|
virtual bool HasDefaultValue() const = 0;
|
|
|
|
size_t Index() const { return mIndex; }
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2016-08-04 18:33:42 +00:00
|
|
|
private:
|
|
|
|
size_t mIndex;
|
|
|
|
};
|
|
|
|
|
2023-10-05 10:53:52 +00:00
|
|
|
// Whether the gfxVars singleton instance has been initialized. Most gfx code
|
|
|
|
// doesn't need to check this, but code that can potentially run before
|
|
|
|
// gfxPlatform initialization can use this to check whether gfxVars are
|
|
|
|
// available yet.
|
|
|
|
static bool IsInitialized() { return sInstance != nullptr; }
|
|
|
|
|
2016-08-04 18:33:42 +00:00
|
|
|
private:
|
|
|
|
static StaticAutoPtr<gfxVars> sInstance;
|
|
|
|
static StaticAutoPtr<nsTArray<VarBase*>> sVarList;
|
|
|
|
|
2020-05-15 00:12:58 +00:00
|
|
|
template <typename T, T Default(), T GetFrom(const GfxVarValue& aValue)>
|
2016-08-04 18:33:42 +00:00
|
|
|
class VarImpl final : public VarBase {
|
|
|
|
public:
|
|
|
|
VarImpl() : mValue(Default()) {}
|
|
|
|
void SetValue(const GfxVarValue& aValue) override {
|
2020-05-15 00:12:58 +00:00
|
|
|
mValue = GetFrom(aValue);
|
2018-09-13 18:59:27 +00:00
|
|
|
if (mListener) {
|
|
|
|
mListener();
|
|
|
|
}
|
2016-08-04 18:33:42 +00:00
|
|
|
}
|
|
|
|
void GetValue(GfxVarValue* aOutValue) override {
|
|
|
|
*aOutValue = GfxVarValue(mValue);
|
|
|
|
}
|
|
|
|
bool HasDefaultValue() const override { return mValue == Default(); }
|
|
|
|
const T& Get() const { return mValue; }
|
2023-05-11 09:59:53 +00:00
|
|
|
|
2016-08-04 18:33:42 +00:00
|
|
|
// Return true if the value changed, false otherwise.
|
|
|
|
bool Set(const T& aValue) {
|
|
|
|
MOZ_ASSERT(XRE_IsParentProcess());
|
|
|
|
if (mValue == aValue) {
|
|
|
|
return false;
|
|
|
|
}
|
2023-05-11 09:59:53 +00:00
|
|
|
mValue = CloneVarValue(aValue);
|
2018-09-13 18:59:27 +00:00
|
|
|
if (mListener) {
|
|
|
|
mListener();
|
|
|
|
}
|
2016-08-04 18:33:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
2018-09-13 18:59:27 +00:00
|
|
|
|
|
|
|
void SetListener(const std::function<void()>& aListener) {
|
|
|
|
mListener = aListener;
|
|
|
|
}
|
2018-11-30 10:46:48 +00:00
|
|
|
|
2016-08-04 18:33:42 +00:00
|
|
|
private:
|
|
|
|
T mValue;
|
2018-09-13 18:59:27 +00:00
|
|
|
std::function<void()> mListener;
|
2016-08-04 18:33:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define GFX_VAR_DECL(CxxName, DataType, DefaultValue) \
|
|
|
|
private: \
|
|
|
|
static DataType Get##CxxName##Default() { return DefaultValue; } \
|
2020-05-15 00:12:58 +00:00
|
|
|
static DataType Get##CxxName##From(const GfxVarValue& aValue) { \
|
2023-05-11 09:59:53 +00:00
|
|
|
return CloneVarValue(aValue.get_##DataType()); \
|
2020-05-15 00:12:58 +00:00
|
|
|
} \
|
|
|
|
VarImpl<DataType, Get##CxxName##Default, Get##CxxName##From> mVar##CxxName; \
|
2018-11-30 10:46:48 +00:00
|
|
|
\
|
2016-08-04 18:33:42 +00:00
|
|
|
public: \
|
|
|
|
static const DataType& CxxName() { return sInstance->mVar##CxxName.Get(); } \
|
2018-02-16 14:50:40 +00:00
|
|
|
static DataType Get##CxxName##OrDefault() { \
|
|
|
|
if (!sInstance) { \
|
|
|
|
return DefaultValue; \
|
|
|
|
} \
|
2023-05-11 09:59:53 +00:00
|
|
|
return CloneVarValue(sInstance->mVar##CxxName.Get()); \
|
2018-02-16 14:50:40 +00:00
|
|
|
} \
|
2016-08-04 18:33:42 +00:00
|
|
|
static void Set##CxxName(const DataType& aValue) { \
|
|
|
|
if (sInstance->mVar##CxxName.Set(aValue)) { \
|
|
|
|
sInstance->NotifyReceivers(&sInstance->mVar##CxxName); \
|
2018-09-13 18:59:27 +00:00
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
static void Set##CxxName##Listener(const std::function<void()>& aListener) { \
|
|
|
|
sInstance->mVar##CxxName.SetListener(aListener); \
|
2016-08-04 18:33:42 +00:00
|
|
|
}
|
|
|
|
|
2023-05-11 09:59:53 +00:00
|
|
|
using ArrayOfuint64_t = nsTArray<uint64_t>;
|
|
|
|
|
2016-08-04 18:33:42 +00:00
|
|
|
GFX_VARS_LIST(GFX_VAR_DECL)
|
|
|
|
#undef GFX_VAR_DECL
|
|
|
|
|
|
|
|
private:
|
|
|
|
gfxVars();
|
|
|
|
|
|
|
|
void NotifyReceivers(VarBase* aVar);
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsTArray<gfxVarReceiver*> mReceivers;
|
|
|
|
};
|
|
|
|
|
|
|
|
#undef GFX_VARS_LIST
|
|
|
|
|
2023-05-11 09:59:53 +00:00
|
|
|
} // namespace mozilla::gfx
|
2016-08-04 18:33:42 +00:00
|
|
|
|
|
|
|
#endif // mozilla_gfx_config_gfxVars_h
|