• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 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_INTEGERTYPES_H_
16 #define DAWNNATIVE_INTEGERTYPES_H_
17 
18 #include "common/Constants.h"
19 #include "common/TypedInteger.h"
20 
21 #include <cstdint>
22 
23 namespace dawn_native {
24     // Binding numbers in the shader and BindGroup/BindGroupLayoutDescriptors
25     using BindingNumber = TypedInteger<struct BindingNumberT, uint32_t>;
26 
27     // Binding numbers get mapped to a packed range of indices
28     using BindingIndex = TypedInteger<struct BindingIndexT, uint32_t>;
29 
30     using BindGroupIndex = TypedInteger<struct BindGroupIndexT, uint32_t>;
31 
32     static constexpr BindGroupIndex kMaxBindGroupsTyped = BindGroupIndex(kMaxBindGroups);
33 
34     using ColorAttachmentIndex = TypedInteger<struct ColorAttachmentIndexT, uint8_t>;
35 
36     constexpr ColorAttachmentIndex kMaxColorAttachmentsTyped =
37         ColorAttachmentIndex(kMaxColorAttachments);
38 
39     using VertexBufferSlot = TypedInteger<struct VertexBufferSlotT, uint8_t>;
40     using VertexAttributeLocation = TypedInteger<struct VertexAttributeLocationT, uint8_t>;
41 
42     constexpr VertexBufferSlot kMaxVertexBuffersTyped = VertexBufferSlot(kMaxVertexBuffers);
43     constexpr VertexAttributeLocation kMaxVertexAttributesTyped =
44         VertexAttributeLocation(kMaxVertexAttributes);
45 
46     // Serials are 64bit integers that are incremented by one each time to produce unique values.
47     // Some serials (like queue serials) are compared numerically to know which one is before
48     // another, while some serials are only checked for equality. We call serials only checked
49     // for equality IDs.
50 
51     // Buffer mapping requests are stored outside of the buffer while they are being processed and
52     // cannot be invalidated. Instead they are associated with an ID, and when a map request is
53     // finished, the mapping callback is fired only if its ID matches the ID if the last request
54     // that was sent.
55     using MapRequestID = TypedInteger<struct MapRequestIDT, uint64_t>;
56 
57     // The type for the WebGPU API fence serial values.
58     using FenceAPISerial = TypedInteger<struct FenceAPISerialT, uint64_t>;
59 
60     // A serial used to watch the progression of GPU execution on a queue, each time operations
61     // that need to be followed individually are scheduled for execution on a queue, the serial
62     // is incremented by one. This way to know if something is done executing, we just need to
63     // compare its serial with the currently completed serial.
64     using ExecutionSerial = TypedInteger<struct QueueSerialT, uint64_t>;
65     constexpr ExecutionSerial kMaxExecutionSerial = ExecutionSerial(~uint64_t(0));
66 
67     // An identifier that indicates which Pipeline a BindGroupLayout is compatible with. Pipelines
68     // created with a default layout will produce BindGroupLayouts with a non-zero compatibility
69     // token, which prevents them (and any BindGroups created with them) from being used with any
70     // other pipelines.
71     using PipelineCompatibilityToken = TypedInteger<struct PipelineCompatibilityTokenT, uint64_t>;
72 
73 }  // namespace dawn_native
74 
75 #endif  // DAWNNATIVE_INTEGERTYPES_H_
76