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 static constexpr uint8_t kMaxVertexAttributes = 16u; 22 static constexpr uint8_t kMaxVertexBuffers = 8u; 23 static constexpr uint32_t kMaxVertexBufferArrayStride = 2048u; 24 static constexpr uint32_t kNumStages = 3; 25 static constexpr uint8_t kMaxColorAttachments = 8u; 26 static constexpr uint32_t kTextureBytesPerRowAlignment = 256u; 27 static constexpr uint32_t kMaxInterStageShaderComponents = 60u; 28 static constexpr uint32_t kMaxInterStageShaderVariables = kMaxInterStageShaderComponents / 4; 29 30 // Per stage limits 31 static constexpr uint32_t kMaxSampledTexturesPerShaderStage = 16; 32 static constexpr uint32_t kMaxSamplersPerShaderStage = 16; 33 static constexpr uint32_t kMaxStorageBuffersPerShaderStage = 8; 34 static constexpr uint32_t kMaxStorageTexturesPerShaderStage = 4; 35 static constexpr uint32_t kMaxUniformBuffersPerShaderStage = 12; 36 37 // Per pipeline layout limits 38 static constexpr uint32_t kMaxDynamicUniformBuffersPerPipelineLayout = 8u; 39 static constexpr uint32_t kMaxDynamicStorageBuffersPerPipelineLayout = 4u; 40 41 // Indirect command sizes 42 static constexpr uint64_t kDispatchIndirectSize = 3 * sizeof(uint32_t); 43 static constexpr uint64_t kDrawIndirectSize = 4 * sizeof(uint32_t); 44 static constexpr uint64_t kDrawIndexedIndirectSize = 5 * sizeof(uint32_t); 45 46 // Non spec defined constants. 47 static constexpr float kLodMin = 0.0; 48 static constexpr float kLodMax = 1000.0; 49 50 // Offset alignment for CopyB2B. Strictly speaking this alignment is required only 51 // on macOS, but we decide to do it on all platforms. 52 static constexpr uint64_t kCopyBufferToBufferOffsetAlignment = 4u; 53 54 // The maximum size of visibilityResultBuffer is 256KB on Metal, to fit the restriction, limit the 55 // maximum size of query set to 64KB. The size of a query is 8-bytes, the maximum query count is 64 56 // * 1024 / 8. 57 static constexpr uint32_t kMaxQueryCount = 8192u; 58 59 // An external texture occupies multiple binding slots. These are the per-external-texture bindings 60 // needed. 61 static constexpr uint8_t kSampledTexturesPerExternalTexture = 3u; 62 static constexpr uint8_t kSamplersPerExternalTexture = 1u; 63 static constexpr uint8_t kUniformsPerExternalTexture = 1u; 64 65 #endif // COMMON_CONSTANTS_H_ 66