Dawn: Refactor device toggles

This CL refactor the logic adapter creating device toggles set when
creating device and the way device holding its toggles. This CL also
introduce the concept "toggle stage", currently "device stage" only but
in future will add "instance stage" and "adapter stage" for instance and
adapter toggles. No changes on Dawn API.
More details:
1. Introduce `TogglesState` objects that represent the complete toggles
   state of a device (and will used for instance and adapter in future).
2. When creating a device, adapter set up a TogglesState object for it
   in `AdapterBase::CreateDeviceInternal` and
   `Adapter::SetupBackendDeviceToggles`, no other place would change
   the device's toggles state. This change simplify the logic.
3. Introduce the `ToggleStage` enum for every toggle and `TogglesState`
   object. Currently we only have `Device` toggle stage, but in future
   will have `Instance` and `Adapter` for instance and adapter toggles.

Bug: dawn:1495
Change-Id: Ifafac6a6a075b5b9a733159574ae5b6d4f3ebde9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118030
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
This commit is contained in:
Zhaoming Jiang
2023-02-10 01:43:55 +00:00
committed by Dawn LUCI CQ
parent 4906b03963
commit 63b777b552
27 changed files with 695 additions and 642 deletions

View File

@@ -49,6 +49,12 @@ struct DAWN_NATIVE_EXPORT DawnDeviceDescriptor {
const WGPURequiredLimits* requiredLimits = nullptr;
};
// Each toggle is assigned with a TogglesStage, indicating the validation and earliest usage
// time of the toggle.
// TODO(dawn:1495): Currently all toggles are device toggles, i.e. of Device toggle stage. Add
// instance and adapter stages after instance and adapter toggles implemented.
enum class ToggleStage { Device };
// A struct to record the information of a toggle. A toggle is a code path in Dawn device that
// can be manually configured to run or not outside Dawn, including workarounds, special
// features and optimizations.
@@ -56,6 +62,7 @@ struct ToggleInfo {
const char* name;
const char* description;
const char* url;
ToggleStage stage;
};
// A struct to record the information of a feature. A feature is a GPU feature that is not