1 /* 2 * Copyright (C) 2023 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_FULLSCREEN_SHADER_H 17 #define API_RENDER_IRENDER_DATA_STORE_FULLSCREEN_SHADER_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 <render/datastore/intf_render_data_store.h> 25 #include <render/device/intf_shader_pipeline_binder.h> 26 #include <render/namespace.h> 27 RENDER_BEGIN_NAMESPACE()28RENDER_BEGIN_NAMESPACE() 29 /** @ingroup group_render_irenderdatastorefullscreenshader */ 30 /** IRenderDataStoreFullscreenShader interface. 31 * Internally synchronized. 32 * 33 * One must call Destroy() to destroy IShaderPipelineBinder::Ptr reference from render data store. 34 * 35 * The render data store could be used for fullscreen effect rendering. 36 * One should create a IShaderPipelineBinder from shader, 37 * and bind buffers or uniform data in code, or use materialMetadata from shader 38 * to initialize pipeline binder uniform data 39 * 40 * Usage: 41 * CreateFullscreenShader() with a unique name/id and a valid shader. 42 * Get() get reference counted shader binder object. 43 * Destroy() destroy IShaderPipelineBinder::Ptr from render data store. 44 */ 45 class IRenderDataStoreFullscreenShader : public IRenderDataStore { 46 public: 47 static constexpr BASE_NS::Uid UID { "82bd1502-2bd1-4a20-8c99-74f134f11af8" }; 48 49 /** Create a new fullscreen material shader and store it to render data store. 50 * If the name is already the already created object is returned. 51 * @param name A unique name for the fullscreen shader material. 52 * @param shader Shader handle. 53 * @return Reference counted shader pipeline binder. 54 */ 55 virtual IShaderPipelineBinder::Ptr Create(const BASE_NS::string_view name, const RenderHandleReference& shader) = 0; 56 57 /** Create a new fullscreen material shader and store it to render data store. 58 * If the id is already found the already created object is returned. 59 * @param id A unique id for the fullscreen shader material. 60 * @param shader Shader handle. 61 * @return Reference counted shader pipeline binder. 62 */ 63 virtual IShaderPipelineBinder::Ptr Create(const uint64_t id, const RenderHandleReference& shader) = 0; 64 65 /** Destroy the fullscreen shader IShaderPipelineBinder::Ptr from the render data store. 66 * It cannot be accessed after destroy from render data store. It can still be alive if someone is keeping the 67 * reference. 68 * @param name Name of the the stored fullscreen shader. 69 */ 70 virtual void Destroy(const BASE_NS::string_view name) = 0; 71 72 /** Destroy the fullscreen shader IShaderPipelineBinder::Ptr from the render data store. 73 * It cannot be accessed after destroy from render data store. It can still be alive if someone is keeping the 74 * reference. 75 * @param name id of the the stored fullscreen shader. 76 */ 77 virtual void Destroy(const uint64_t id) = 0; 78 79 /** Get reference counted shader pipeline binder object 80 * @param name Name 81 * @return Reference counted shader pipeline binder. Null if not found. 82 */ 83 virtual IShaderPipelineBinder::Ptr Get(const BASE_NS::string_view name) const = 0; 84 85 /** Get reference counted shader pipeline binder object 86 * @param id ID 87 * @return Reference counted shader pipeline binder. Null if not found. 88 */ 89 virtual IShaderPipelineBinder::Ptr Get(const uint64_t id) const = 0; 90 91 protected: 92 virtual ~IRenderDataStoreFullscreenShader() override = default; 93 IRenderDataStoreFullscreenShader() = default; 94 }; 95 RENDER_END_NAMESPACE() 96 97 #endif // API_RENDER_IRENDER_DATA_STORE_FULLSCREEN_SHADER_H 98