1 // Copyright 2018 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_DAWNPLATFORM_H_ 16 #define DAWNNATIVE_DAWNPLATFORM_H_ 17 18 // Use webgpu_cpp to have the enum and bitfield definitions 19 #include <dawn/webgpu_cpp.h> 20 21 #include <dawn_native/dawn_platform_autogen.h> 22 23 namespace dawn_native { 24 25 // kEnumCount is a constant specifying the number of enums in a WebGPU enum type, 26 // if the enums are contiguous, making it suitable for iteration. 27 // It is defined in dawn_platform_autogen.h 28 template <typename T> 29 constexpr uint32_t kEnumCount = EnumCount<T>::value; 30 31 // Extra buffer usages 32 // Add an extra buffer usage and an extra binding type for binding the buffers with QueryResolve 33 // usage as storage buffer in the internal pipeline. 34 static constexpr wgpu::BufferUsage kInternalStorageBuffer = 35 static_cast<wgpu::BufferUsage>(0x40000000); 36 37 // Add an extra buffer usage (readonly storage buffer usage) for render pass resource tracking 38 static constexpr wgpu::BufferUsage kReadOnlyStorageBuffer = 39 static_cast<wgpu::BufferUsage>(0x80000000); 40 41 // Extra texture usages 42 // Add an extra texture usage (readonly render attachment usage) for render pass resource 43 // tracking 44 static constexpr wgpu::TextureUsage kReadOnlyRenderAttachment = 45 static_cast<wgpu::TextureUsage>(0x40000000); 46 47 // Internal usage to help tracking when a subresource is used as render attachment usage 48 // more than once in a render pass. 49 static constexpr wgpu::TextureUsage kAgainAsRenderAttachment = 50 static_cast<wgpu::TextureUsage>(0x80000001); 51 52 // Add an extra texture usage for textures that will be presented, for use in backends 53 // that needs to transition to present usage. 54 // This currently aliases wgpu::TextureUsage::Present, we would assign it 55 // some bit when wgpu::TextureUsage::Present is removed. 56 static constexpr wgpu::TextureUsage kPresentTextureUsage = wgpu::TextureUsage::Present; 57 58 static constexpr wgpu::BufferBindingType kInternalStorageBufferBinding = 59 static_cast<wgpu::BufferBindingType>(0xFFFFFFFF); 60 } // namespace dawn_native 61 62 #endif // DAWNNATIVE_DAWNPLATFORM_H_ 63