1cb93a386Sopenharmony_ci// Copyright 2017 The Dawn Authors
2cb93a386Sopenharmony_ci//
3cb93a386Sopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License");
4cb93a386Sopenharmony_ci// you may not use this file except in compliance with the License.
5cb93a386Sopenharmony_ci// You may obtain a copy of the License at
6cb93a386Sopenharmony_ci//
7cb93a386Sopenharmony_ci//     http://www.apache.org/licenses/LICENSE-2.0
8cb93a386Sopenharmony_ci//
9cb93a386Sopenharmony_ci// Unless required by applicable law or agreed to in writing, software
10cb93a386Sopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS,
11cb93a386Sopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12cb93a386Sopenharmony_ci// See the License for the specific language governing permissions and
13cb93a386Sopenharmony_ci// limitations under the License.
14cb93a386Sopenharmony_ci
15cb93a386Sopenharmony_ci#ifndef COMMON_CONSTANTS_H_
16cb93a386Sopenharmony_ci#define COMMON_CONSTANTS_H_
17cb93a386Sopenharmony_ci
18cb93a386Sopenharmony_ci#include <cstdint>
19cb93a386Sopenharmony_ci
20cb93a386Sopenharmony_cistatic constexpr uint32_t kMaxBindGroups = 4u;
21cb93a386Sopenharmony_cistatic constexpr uint8_t kMaxVertexAttributes = 16u;
22cb93a386Sopenharmony_cistatic constexpr uint8_t kMaxVertexBuffers = 8u;
23cb93a386Sopenharmony_cistatic constexpr uint32_t kMaxVertexBufferArrayStride = 2048u;
24cb93a386Sopenharmony_cistatic constexpr uint32_t kNumStages = 3;
25cb93a386Sopenharmony_cistatic constexpr uint8_t kMaxColorAttachments = 8u;
26cb93a386Sopenharmony_cistatic constexpr uint32_t kTextureBytesPerRowAlignment = 256u;
27cb93a386Sopenharmony_cistatic constexpr uint32_t kMaxInterStageShaderComponents = 60u;
28cb93a386Sopenharmony_cistatic constexpr uint32_t kMaxInterStageShaderVariables = kMaxInterStageShaderComponents / 4;
29cb93a386Sopenharmony_ci
30cb93a386Sopenharmony_ci// Per stage limits
31cb93a386Sopenharmony_cistatic constexpr uint32_t kMaxSampledTexturesPerShaderStage = 16;
32cb93a386Sopenharmony_cistatic constexpr uint32_t kMaxSamplersPerShaderStage = 16;
33cb93a386Sopenharmony_cistatic constexpr uint32_t kMaxStorageBuffersPerShaderStage = 8;
34cb93a386Sopenharmony_cistatic constexpr uint32_t kMaxStorageTexturesPerShaderStage = 4;
35cb93a386Sopenharmony_cistatic constexpr uint32_t kMaxUniformBuffersPerShaderStage = 12;
36cb93a386Sopenharmony_ci
37cb93a386Sopenharmony_ci// Per pipeline layout limits
38cb93a386Sopenharmony_cistatic constexpr uint32_t kMaxDynamicUniformBuffersPerPipelineLayout = 8u;
39cb93a386Sopenharmony_cistatic constexpr uint32_t kMaxDynamicStorageBuffersPerPipelineLayout = 4u;
40cb93a386Sopenharmony_ci
41cb93a386Sopenharmony_ci// Indirect command sizes
42cb93a386Sopenharmony_cistatic constexpr uint64_t kDispatchIndirectSize = 3 * sizeof(uint32_t);
43cb93a386Sopenharmony_cistatic constexpr uint64_t kDrawIndirectSize = 4 * sizeof(uint32_t);
44cb93a386Sopenharmony_cistatic constexpr uint64_t kDrawIndexedIndirectSize = 5 * sizeof(uint32_t);
45cb93a386Sopenharmony_ci
46cb93a386Sopenharmony_ci// Non spec defined constants.
47cb93a386Sopenharmony_cistatic constexpr float kLodMin = 0.0;
48cb93a386Sopenharmony_cistatic constexpr float kLodMax = 1000.0;
49cb93a386Sopenharmony_ci
50cb93a386Sopenharmony_ci// Offset alignment for CopyB2B. Strictly speaking this alignment is required only
51cb93a386Sopenharmony_ci// on macOS, but we decide to do it on all platforms.
52cb93a386Sopenharmony_cistatic constexpr uint64_t kCopyBufferToBufferOffsetAlignment = 4u;
53cb93a386Sopenharmony_ci
54cb93a386Sopenharmony_ci// The maximum size of visibilityResultBuffer is 256KB on Metal, to fit the restriction, limit the
55cb93a386Sopenharmony_ci// maximum size of query set to 64KB. The size of a query is 8-bytes, the maximum query count is 64
56cb93a386Sopenharmony_ci// * 1024 / 8.
57cb93a386Sopenharmony_cistatic constexpr uint32_t kMaxQueryCount = 8192u;
58cb93a386Sopenharmony_ci
59cb93a386Sopenharmony_ci// An external texture occupies multiple binding slots. These are the per-external-texture bindings
60cb93a386Sopenharmony_ci// needed.
61cb93a386Sopenharmony_cistatic constexpr uint8_t kSampledTexturesPerExternalTexture = 3u;
62cb93a386Sopenharmony_cistatic constexpr uint8_t kSamplersPerExternalTexture = 1u;
63cb93a386Sopenharmony_cistatic constexpr uint8_t kUniformsPerExternalTexture = 1u;
64cb93a386Sopenharmony_ci
65cb93a386Sopenharmony_ci#endif  // COMMON_CONSTANTS_H_
66