mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 13:38:00 +00:00
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:
committed by
Dawn LUCI CQ
parent
4906b03963
commit
63b777b552
@@ -63,23 +63,23 @@ bool useRenderPass = device->IsToggleEnabled(Toggle::UseD3D12RenderPass);
|
||||
```
|
||||
|
||||
Toggles are defined in a table in [Toggles.cpp](../src/dawn/native/Toggles.cpp) that also includes their name and description.
|
||||
The name can be used to force enabling of a toggle or, at the contrary, force the disabling of a toogle.
|
||||
The name can be used to require enabling of a toggle or, at the contrary, require the disabling of a toogle.
|
||||
This is particularly useful in tests so that the two sides of a code path can be tested (for example using D3D12 render passes and not).
|
||||
|
||||
Here's an example of a test that is run in the D3D12 backend both with the D3D12 render passes forcibly disabled, and in the default configuration.
|
||||
Here's an example of a test that is run in the D3D12 backend both with the D3D12 render passes required to be disabled, and in the default configuration.
|
||||
```
|
||||
DAWN_INSTANTIATE_TEST(RenderPassTest,
|
||||
D3D12Backend(),
|
||||
D3D12Backend({}, {"use_d3d12_render_pass"}));
|
||||
// The {} is the list of force enabled toggles, {"..."} the force disabled ones.
|
||||
// The {} is the list of required enabled toggles, {"..."} the required disabled ones.
|
||||
```
|
||||
|
||||
The initialization order of toggles looks as follows:
|
||||
The toggles state of a device is decided by the adapter when creating it. The steps of device toggles state decision looks as follows:
|
||||
|
||||
- The toggles overrides from the device descriptor are applied.
|
||||
- The frontend device default toggles are applied (unless already overriden).
|
||||
- The backend device default toggles are applied (unless already overriden) using `DeviceBase::SetToggle`
|
||||
- The backend device can ignore overriden toggles if it can't support them by using `DeviceBase::ForceSetToggle`
|
||||
- The device toggles state initialized to required device toggles from the DawnTogglesDescriptor chained in device descriptor.
|
||||
- The frontend (i.e. not backend-specific) default toggles are set (unless already required) using `TogglesState::Default`.
|
||||
- Any backend device toggle that not supported is forced set to a proper state in `Adapter::SetupBackendDeviceToggles` using `TogglesState::ForceSet`.
|
||||
- The backend device default toggles are applied (unless already set) in `Adapter::SetupBackendDeviceToggles` using `TogglesState::Default`.
|
||||
|
||||
Forcing toggles should only be done when there is no "safe" option for the toggle.
|
||||
This is to avoid crashes during testing when the tests try to use both sides of a toggle.
|
||||
|
||||
Reference in New Issue
Block a user