1 // Copyright 2017 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 COMMON_CONSTANTS_H_ 16 #define COMMON_CONSTANTS_H_ 17 18 #include <cstdint> 19 20 static constexpr uint32_t kMaxBindGroups = 4u; 21 // TODO(cwallez@chromium.org): investigate bindgroup limits 22 static constexpr uint32_t kMaxBindingsPerGroup = 16u; 23 static constexpr uint32_t kMaxVertexAttributes = 16u; 24 // Vulkan has a standalone limit named maxVertexInputAttributeOffset (2047u at least) for vertex 25 // attribute offset. The limit might be meaningless because Vulkan has another limit named 26 // maxVertexInputBindingStride (2048u at least). We use maxVertexAttributeEnd (2048u) here to 27 // verify vertex attribute offset, which equals to maxOffset + smallest size of vertex format 28 // (char). We may use maxVertexInputBindingStride (maxVertexBufferStride below) instead to replace 29 // maxVertexAttributeEnd in future. 30 static constexpr uint32_t kMaxVertexAttributeEnd = 2048u; 31 static constexpr uint32_t kMaxVertexBuffers = 16u; 32 static constexpr uint32_t kMaxVertexBufferStride = 2048u; 33 static constexpr uint32_t kNumStages = 3; 34 static constexpr uint32_t kMaxColorAttachments = 4u; 35 static constexpr uint32_t kTextureRowPitchAlignment = 256u; 36 // Dynamic buffer offsets require offset to be divisible by 256 37 static constexpr uint64_t kMinDynamicBufferOffsetAlignment = 256u; 38 // Indirect command sizes 39 static constexpr uint64_t kDispatchIndirectSize = 3 * sizeof(uint32_t); 40 static constexpr uint64_t kDrawIndirectSize = 4 * sizeof(uint32_t); 41 static constexpr uint64_t kDrawIndexedIndirectSize = 5 * sizeof(uint32_t); 42 43 // Non spec defined constants. 44 static constexpr float kLodMin = 0.0; 45 static constexpr float kLodMax = 1000.0; 46 47 static constexpr uint32_t kVendorID_AMD = 0x1002; 48 static constexpr uint32_t kVendorID_ARM = 0x13B5; 49 static constexpr uint32_t kVendorID_ImgTec = 0x1010; 50 static constexpr uint32_t kVendorID_Intel = 0x8086; 51 static constexpr uint32_t kVendorID_Nvidia = 0x10DE; 52 static constexpr uint32_t kVendorID_Qualcomm = 0x5143; 53 54 // Max texture size constants 55 static constexpr uint32_t kMaxTextureSize = 8192u; 56 static constexpr uint32_t kMaxTexture2DArrayLayers = 256u; 57 static constexpr uint32_t kMaxTexture2DMipLevels = 14u; 58 static_assert(1 << (kMaxTexture2DMipLevels - 1) == kMaxTextureSize, 59 "kMaxTexture2DMipLevels and kMaxTextureSize size mismatch"); 60 61 #endif // COMMON_CONSTANTS_H_ 62