1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
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 GLES_SPIRV_CROSS_HELPER_STRUCTS_H
16 #define GLES_SPIRV_CROSS_HELPER_STRUCTS_H
17
18 #include <base/containers/string.h>
19 #include <render/device/pipeline_state_desc.h>
20
RENDER_BEGIN_NAMESPACE()21 RENDER_BEGIN_NAMESPACE()
22 namespace Gles {
23 // Bind limits.
24 // https://www.khronos.org/registry/vulkan/specs/1.1/html/chap31.html#limits-minmax
25 // maxBoundDescriptorSets is 4 (so there can be at most 4 sets...)
26 // maxPerStageDescriptorUniformBuffers is 12
27 // maxPerStageDescriptorStorageBuffers is 4
28 // maxPerStageDescriptorStorageImages is 4
29 // maxPerStageDescriptorSamplers is 16
30 // maxPerStageDescriptorSampledImages is 16
31 // maxDescriptorSetSamplers is 96 (all stages)
32 // maxDescriptorSetSampledImages is 96 (all stages)
33 // maxColorAttachments is 4 (subpass inputs?)
34 // maxVertexInputAttributes is 16
35 // maxVertexInputBindings is 16
36 // gles = GL_MAX_TEXTURE_IMAGE_UNITS 16 (so 16 texture units can be active, ie combined samplers/sampledimages and
37 // subpass inputs) NOTE: The macro allows for 16 sets, with 16 binds per type (uniform buffer, storage buffer)
38 struct ResourceLimits {
39 // 4 slots and 16 binds = 64 possible binds.
40 static constexpr uint32_t MAX_SETS { 4 };
41 static constexpr uint32_t MAX_BIND_IN_SET { 16 };
42 static constexpr uint32_t MAX_BINDS { MAX_SETS * MAX_BIND_IN_SET };
43
44 static constexpr uint32_t MAX_VERTEXINPUT_ATTRIBUTES { 16 };
45 static constexpr uint32_t MAX_UNIFORM_BUFFERS_IN_STAGE { 12 };
46 static constexpr uint32_t MAX_STORAGE_BUFFERS_IN_STAGE { 4 };
47 static constexpr uint32_t MAX_SAMPLERS_IN_STAGE { 16 };
48 static constexpr uint32_t MAX_IMAGES_IN_STAGE { 16 };
49 static constexpr uint32_t MAX_STORAGE_IMAGES_IN_STAGE { 4 };
50 static constexpr uint32_t MAX_INPUT_ATTACHMENTS_IN_STAGE { 4 };
51 static constexpr uint32_t MAX_SAMPLERS_IN_PROGRAM { MAX_SAMPLERS_IN_STAGE + MAX_SAMPLERS_IN_STAGE };
52 static constexpr uint32_t MAX_IMAGES_IN_PROGRAM { MAX_IMAGES_IN_STAGE + MAX_IMAGES_IN_STAGE };
53 };
54 static constexpr int32_t INVALID_LOCATION = -1;
55 struct SpecConstantInfo {
56 enum class Types { INVALID = 0, BOOL, UINT32, INT32, FLOAT };
57 Types constantType = Types::INVALID;
58 uint32_t constantId;
59 uint32_t vectorSize;
60 uint32_t columns;
61 BASE_NS::string name;
62 };
63 struct PushConstantReflection {
64 ShaderStageFlags stage;
65 int32_t location { INVALID_LOCATION };
66 uint32_t type;
67 BASE_NS::string name;
68 size_t offset;
69 size_t size;
70 size_t arraySize;
71 size_t arrayStride;
72 size_t matrixStride;
73 };
74 } // namespace Gles
75 RENDER_END_NAMESPACE()
76 #endif // GLES_SPIRV_CROSS_HELPER_STRUCTS_H
77