• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 The Dawn Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef DAWNNATIVE_TOGGLES_H_
16 #define DAWNNATIVE_TOGGLES_H_
17 
18 #include <bitset>
19 #include <unordered_map>
20 #include <vector>
21 
22 #include "dawn_native/DawnNative.h"
23 
24 namespace dawn_native {
25 
26     enum class Toggle {
27         EmulateStoreAndMSAAResolve,
28         NonzeroClearResourcesOnCreationForTesting,
29         AlwaysResolveIntoZeroLevelAndLayer,
30         LazyClearResourceOnFirstUse,
31         TurnOffVsync,
32         UseTemporaryBufferInCompressedTextureToTextureCopy,
33         UseD3D12ResourceHeapTier2,
34         UseD3D12RenderPass,
35         UseD3D12ResidencyManagement,
36         SkipValidation,
37         VulkanUseD32S8,
38         MetalDisableSamplerCompare,
39         MetalUseSharedModeForCounterSampleBuffer,
40         DisableBaseVertex,
41         DisableBaseInstance,
42         DisableIndexedDrawBuffers,
43         DisableSnormRead,
44         DisableDepthStencilRead,
45         DisableSampleVariables,
46         UseD3D12SmallShaderVisibleHeapForTesting,
47         UseDXC,
48         DisableRobustness,
49         MetalEnableVertexPulling,
50         DisallowUnsafeAPIs,
51         FlushBeforeClientWaitSync,
52         UseTempBufferInSmallFormatTextureToTextureCopyFromGreaterToLessMipLevel,
53         EmitHLSLDebugSymbols,
54         DisallowSpirv,
55         DumpShaders,
56         DEPRECATED_DumpTranslatedShaders,  // Use DumpShaders
57         ForceWGSLStep,
58         DisableWorkgroupInit,
59         DisableSymbolRenaming,
60         UseUserDefinedLabelsInBackend,
61         DisableR8RG8Mipmaps,
62         UseDummyFragmentInVertexOnlyPipeline,
63         FxcOptimizations,
64 
65         EnumCount,
66         InvalidEnum = EnumCount,
67     };
68 
69     // A wrapper of the bitset to store if a toggle is present or not. This wrapper provides the
70     // convenience to convert the enums of enum class Toggle to the indices of a bitset.
71     struct TogglesSet {
72         std::bitset<static_cast<size_t>(Toggle::EnumCount)> toggleBitset;
73 
74         void Set(Toggle toggle, bool enabled);
75         bool Has(Toggle toggle) const;
76         std::vector<const char*> GetContainedToggleNames() const;
77     };
78 
79     const char* ToggleEnumToName(Toggle toggle);
80 
81     class TogglesInfo {
82       public:
83         // Used to query the details of a toggle. Return nullptr if toggleName is not a valid name
84         // of a toggle supported in Dawn.
85         const ToggleInfo* GetToggleInfo(const char* toggleName);
86         Toggle ToggleNameToEnum(const char* toggleName);
87 
88       private:
89         void EnsureToggleNameToEnumMapInitialized();
90 
91         bool mToggleNameToEnumMapInitialized = false;
92         std::unordered_map<std::string, Toggle> mToggleNameToEnumMap;
93     };
94 
95 }  // namespace dawn_native
96 
97 #endif  // DAWNNATIVE_TOGGLES_H_
98