• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 Google LLC
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef skgpu_DrawTypes_DEFINED
9 #define skgpu_DrawTypes_DEFINED
10 
11 #include "experimental/graphite/include/GraphiteTypes.h"
12 
13 namespace skgpu {
14 
15 class Buffer;
16 
17 /**
18  * Types of shader-language-specific boxed variables we can create.
19  */
20 enum class SLType {
21     kVoid,
22     kBool,
23     kBool2,
24     kBool3,
25     kBool4,
26     kShort,
27     kShort2,
28     kShort3,
29     kShort4,
30     kUShort,
31     kUShort2,
32     kUShort3,
33     kUShort4,
34     kFloat,
35     kFloat2,
36     kFloat3,
37     kFloat4,
38     kFloat2x2,
39     kFloat3x3,
40     kFloat4x4,
41     kHalf,
42     kHalf2,
43     kHalf3,
44     kHalf4,
45     kHalf2x2,
46     kHalf3x3,
47     kHalf4x4,
48     kInt,
49     kInt2,
50     kInt3,
51     kInt4,
52     kUInt,
53     kUInt2,
54     kUInt3,
55     kUInt4,
56     kTexture2DSampler,
57     kTextureExternalSampler,
58     kTexture2DRectSampler,
59     kTexture2D,
60     kSampler,
61     kInput,
62 
63     kLast = kInput
64 };
65 static const int kSLTypeCount = static_cast<int>(SLType::kLast) + 1;
66 
67 enum class CType : unsigned {
68     // Any float/half, vector of floats/half, or matrices of floats/halfs are a tightly
69     // packed array of floats. Similarly, any bool/shorts/ints are a tightly packed array
70     // of int32_t.
71     kDefault,
72     // Can be used with kFloat3x3 or kHalf3x3
73     kSkMatrix,
74 
75     kLast = kSkMatrix
76 };
77 
78 /**
79  * This enum is used to specify the load operation to be used when a RenderPass begins execution
80  */
81 enum class LoadOp : uint8_t {
82     kLoad,
83     kClear,
84     kDiscard,
85 
86     kLast = kDiscard
87 };
88 inline static constexpr int kLoadOpCount = (int)(LoadOp::kLast) + 1;
89 
90 /**
91  * This enum is used to specify the store operation to be used when a RenderPass ends execution.
92  */
93 enum class StoreOp : uint8_t {
94     kStore,
95     kDiscard,
96 
97     kLast = kDiscard
98 };
99 inline static constexpr int kStoreOpCount = (int)(StoreOp::kLast) + 1;
100 
101 /**
102  * Geometric primitives used for drawing.
103  */
104 enum class PrimitiveType : uint8_t {
105     kTriangles,
106     kTriangleStrip,
107     kPoints,
108 };
109 
110 /**
111  * Types used to describe format of vertices in buffers.
112  */
113 enum class VertexAttribType : uint8_t {
114     kFloat = 0,
115     kFloat2,
116     kFloat3,
117     kFloat4,
118     kHalf,
119     kHalf2,
120     kHalf4,
121 
122     kInt2,   // vector of 2 32-bit ints
123     kInt3,   // vector of 3 32-bit ints
124     kInt4,   // vector of 4 32-bit ints
125 
126     kByte,  // signed byte
127     kByte2, // vector of 2 8-bit signed bytes
128     kByte4, // vector of 4 8-bit signed bytes
129     kUByte,  // unsigned byte
130     kUByte2, // vector of 2 8-bit unsigned bytes
131     kUByte4, // vector of 4 8-bit unsigned bytes
132 
133     kUByte_norm,  // unsigned byte, e.g. coverage, 0 -> 0.0f, 255 -> 1.0f.
134     kUByte4_norm, // vector of 4 unsigned bytes, e.g. colors, 0 -> 0.0f, 255 -> 1.0f.
135 
136     kShort2,       // vector of 2 16-bit shorts.
137     kShort4,       // vector of 4 16-bit shorts.
138 
139     kUShort2,      // vector of 2 unsigned shorts. 0 -> 0, 65535 -> 65535.
140     kUShort2_norm, // vector of 2 unsigned shorts. 0 -> 0.0f, 65535 -> 1.0f.
141 
142     kInt,
143     kUInt,
144 
145     kUShort_norm,
146 
147     kUShort4_norm, // vector of 4 unsigned shorts. 0 -> 0.0f, 65535 -> 1.0f.
148 
149     kLast = kUShort4_norm
150 };
151 static const int kVertexAttribTypeCount = (int)(VertexAttribType::kLast) + 1;
152 
153 /*
154  * Struct returned by the DrawBufferManager that can be passed into bind buffer calls on the
155  * CommandBuffer.
156  */
157 struct BindBufferInfo {
158     Buffer* fBuffer = nullptr;
159     size_t fOffset = 0;
160 };
161 
162 };  // namespace skgpu
163 
164 #endif // skgpu_DrawTypes_DEFINED
165 
166