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 DisableResourceSuballocation, 37 SkipValidation, 38 VulkanUseD32S8, 39 MetalDisableSamplerCompare, 40 MetalUseSharedModeForCounterSampleBuffer, 41 DisableBaseVertex, 42 DisableBaseInstance, 43 DisableIndexedDrawBuffers, 44 DisableSnormRead, 45 DisableDepthStencilRead, 46 DisableSampleVariables, 47 UseD3D12SmallShaderVisibleHeapForTesting, 48 UseDXC, 49 DisableRobustness, 50 MetalEnableVertexPulling, 51 DisallowUnsafeAPIs, 52 FlushBeforeClientWaitSync, 53 UseTempBufferInSmallFormatTextureToTextureCopyFromGreaterToLessMipLevel, 54 EmitHLSLDebugSymbols, 55 DisallowSpirv, 56 DumpShaders, 57 DEPRECATED_DumpTranslatedShaders, // Use DumpShaders 58 ForceWGSLStep, 59 DisableWorkgroupInit, 60 DisableSymbolRenaming, 61 UseUserDefinedLabelsInBackend, 62 DisableR8RG8Mipmaps, 63 UseDummyFragmentInVertexOnlyPipeline, 64 FxcOptimizations, 65 66 EnumCount, 67 InvalidEnum = EnumCount, 68 }; 69 70 // A wrapper of the bitset to store if a toggle is present or not. This wrapper provides the 71 // convenience to convert the enums of enum class Toggle to the indices of a bitset. 72 struct TogglesSet { 73 std::bitset<static_cast<size_t>(Toggle::EnumCount)> toggleBitset; 74 75 void Set(Toggle toggle, bool enabled); 76 bool Has(Toggle toggle) const; 77 std::vector<const char*> GetContainedToggleNames() const; 78 }; 79 80 const char* ToggleEnumToName(Toggle toggle); 81 82 class TogglesInfo { 83 public: 84 // Used to query the details of a toggle. Return nullptr if toggleName is not a valid name 85 // of a toggle supported in Dawn. 86 const ToggleInfo* GetToggleInfo(const char* toggleName); 87 Toggle ToggleNameToEnum(const char* toggleName); 88 89 private: 90 void EnsureToggleNameToEnumMapInitialized(); 91 92 bool mToggleNameToEnumMapInitialized = false; 93 std::unordered_map<std::string, Toggle> mToggleNameToEnumMap; 94 }; 95 96 } // namespace dawn_native 97 98 #endif // DAWNNATIVE_TOGGLES_H_ 99