• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #ifndef DEVICE_GPU_PROGRAM_UTIL_H
17 #define DEVICE_GPU_PROGRAM_UTIL_H
18 
19 #include <cstdint>
20 
21 #include <base/containers/vector.h>
22 #include <base/math/vector.h>
23 #include <base/util/formats.h>
24 #include <render/device/pipeline_layout_desc.h>
25 #include <render/device/pipeline_state_desc.h>
26 #include <render/namespace.h>
27 
RENDER_BEGIN_NAMESPACE()28 RENDER_BEGIN_NAMESPACE()
29 namespace GpuProgramUtil {
30 uint32_t SpecializationByteSize(RENDER_NS::ShaderSpecialization::Constant::Type type);
31 
32 void AddSpecializationConstants(BASE_NS::array_view<const ShaderSpecialization::Constant> inSpecializationConstants,
33     BASE_NS::vector<ShaderSpecialization::Constant>& outSpecializationConstants);
34 // has sorting for constants
35 void CombineSpecializationConstants(BASE_NS::array_view<const ShaderSpecialization::Constant> inSc,
36     BASE_NS::vector<ShaderSpecialization::Constant>& outSc);
37 
38 // returns true if combination of descriptor sets is valid
39 [[nodiscard]] bool AddBindings(
40     const DescriptorSetLayout& inDescriptorSetLayout, DescriptorSetLayout& outDescriptorSetLayout);
41 // has sorting for bindings and sets
42 void CombinePipelineLayouts(BASE_NS::array_view<const PipelineLayout> inPl, PipelineLayout& outPl);
43 
44 uint32_t FormatByteSize(BASE_NS::Format format);
45 } // namespace GpuProgramUtil
46 RENDER_END_NAMESPACE()
47 
48 #endif // DEVICE_GPU_PROGRAM_UTIL_H
49