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 API_RENDER_IRENDER_DATA_STORE_SHADER_PASSES_H 17 #define API_RENDER_IRENDER_DATA_STORE_SHADER_PASSES_H 18 19 #include <cstdint> 20 21 #include <base/containers/array_view.h> 22 #include <base/containers/string.h> 23 #include <base/containers/string_view.h> 24 #include <base/util/uid.h> 25 #include <render/datastore/intf_render_data_store.h> 26 #include <render/device/intf_shader_pipeline_binder.h> 27 #include <render/namespace.h> 28 RENDER_BEGIN_NAMESPACE()29RENDER_BEGIN_NAMESPACE() 30 /** @ingroup group_render_IrenderDataStoreShaderPasses */ 31 /** IRenderDataStoreShaderPasses interface. 32 * Internally synchronized. 33 * The data should not be added during render front-end. 34 * 35 * Usage: 36 * AddRenderData() or AddComputeData() every frame to specific block name 37 * Fetch data in render node(s) with GetRenderData() or GetComputeData() 38 */ 39 40 class IRenderDataStoreShaderPasses : public IRenderDataStore { 41 public: 42 static constexpr BASE_NS::Uid UID { "1e85fc6d-09e0-4d2d-9422-3165f486c92d" }; 43 44 /** Compute pass data */ 45 struct ComputePassData { 46 BASE_NS::vector<IShaderPipelineBinder::Ptr> shaderBinders; 47 }; 48 /** Render pass data */ 49 struct RenderPassData { 50 RenderPassWithHandleReference renderPass; 51 BASE_NS::vector<IShaderPipelineBinder::Ptr> shaderBinders; 52 }; 53 /** Property binding data info */ 54 struct PropertyBindingDataInfo { 55 /** Aligned byte size needed for binding data which is not in local GPU buffers 56 * Alignment is based on minimun UBO dynamic binding offsets. 57 */ 58 uint32_t alignedByteSize { 0U }; 59 }; 60 61 /** Add data to named block for fetching. 62 * @param name Name of the data block. One can add data to same named block multiple times during a frame. 63 * @param data Render pass data. 64 */ 65 virtual void AddRenderData(BASE_NS::string_view name, BASE_NS::array_view<const RenderPassData> data) = 0; 66 67 /** Add data to named block for fetching. 68 * @param name Name of the data block. One can add data to same named block multiple times during a frame. 69 * @param data Render pass data. 70 */ 71 virtual void AddComputeData(BASE_NS::string_view name, BASE_NS::array_view<const ComputePassData> data) = 0; 72 73 /** Get compute data per block (name). 74 * @param name Name of the data block. One can add data to same named block multiple times during a frame. 75 * @return Render pass data. 76 */ 77 virtual BASE_NS::vector<RenderPassData> GetRenderData(BASE_NS::string_view name) const = 0; 78 79 /** Get compute data per block (name). 80 * @param name Name of the data block. One can add data to same named block multiple times during a frame. 81 * @return Compute pass data. 82 */ 83 virtual BASE_NS::vector<ComputePassData> GetComputeData(BASE_NS::string_view name) const = 0; 84 85 /** Get all rendering data. 86 * @return Returns all RenderPassData. 87 */ 88 virtual BASE_NS::vector<RenderPassData> GetRenderData() const = 0; 89 90 /** Get all rendering data. 91 * @return Returns all RenderPassData. 92 */ 93 virtual BASE_NS::vector<ComputePassData> GetComputeData() const = 0; 94 95 /** Get render property binding info. 96 * @param name Name of the data block. One can add data to named block multiple times during a frame. 97 * @return PropertyBindingDataInfo Returns all render related. 98 */ 99 virtual PropertyBindingDataInfo GetRenderPropertyBindingInfo(BASE_NS::string_view name) const = 0; 100 101 /** Get render property binding info. 102 * @param name Name of the data block. One can add data to named block multiple times during a frame. 103 * @return PropertyBindingDataInfo Returns all compute related. 104 */ 105 virtual PropertyBindingDataInfo GetComputePropertyBindingInfo(BASE_NS::string_view name) const = 0; 106 107 /** Get all render property binding info. 108 * @return PropertyBindingDataInfo Returns all render related. 109 */ 110 virtual PropertyBindingDataInfo GetRenderPropertyBindingInfo() const = 0; 111 112 /** Get all compute property binding info. 113 * @return PropertyBindingDataInfo Returns all compute related. 114 */ 115 virtual PropertyBindingDataInfo GetComputePropertyBindingInfo() const = 0; 116 117 protected: 118 virtual ~IRenderDataStoreShaderPasses() override = default; 119 IRenderDataStoreShaderPasses() = default; 120 }; 121 RENDER_END_NAMESPACE() 122 123 #endif // API_RENDER_IRENDER_DATA_STORE_SHADER_PASSES_H 124