• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 RENDER_DATA_STORE_RENDER_DATA_STORE_DEFAULT_GPU_RESOURCE_DATA_COPY_H
17 #define RENDER_DATA_STORE_RENDER_DATA_STORE_DEFAULT_GPU_RESOURCE_DATA_COPY_H
18 
19 #include <cstdint>
20 #include <mutex>
21 
22 #include <base/containers/string.h>
23 #include <base/containers/string_view.h>
24 #include <base/containers/vector.h>
25 #include <base/util/uid.h>
26 #include <render/datastore/intf_render_data_store_default_gpu_resource_data_copy.h>
27 #include <render/namespace.h>
28 
29 RENDER_BEGIN_NAMESPACE()
30 class IRenderContext;
31 class IDevice;
32 class GpuResourceManager;
33 /**
34 RenderDataStoreDefaultGpuResourceDataCopy implementation.
35 */
36 class RenderDataStoreDefaultGpuResourceDataCopy final : public IRenderDataStoreDefaultGpuResourceDataCopy {
37 public:
38     RenderDataStoreDefaultGpuResourceDataCopy(IRenderContext& renderContext, const BASE_NS::string_view name);
39     ~RenderDataStoreDefaultGpuResourceDataCopy() override = default;
40 
PreRender()41     void PreRender() override {};
PreRenderBackend()42     void PreRenderBackend() override {};
43     // Do copy operation in end frame.
44     void PostRender() override;
45     void Clear() override;
46 
47     void AddCopyOperation(const GpuResourceDataCopy& copyOp) override;
48 
49     // for plugin / factory interface
50     static constexpr const char* const TYPE_NAME = "RenderDataStoreDefaultGpuResourceDataCopy";
51 
52     static IRenderDataStore* Create(IRenderContext& renderContext, char const* name);
53     static void Destroy(IRenderDataStore* instance);
54 
GetTypeName()55     BASE_NS::string_view GetTypeName() const override
56     {
57         return TYPE_NAME;
58     }
59 
GetName()60     BASE_NS::string_view GetName() const override
61     {
62         return name_;
63     }
64 
GetUid()65     const BASE_NS::Uid& GetUid() const override
66     {
67         return UID;
68     }
69 
70 private:
71     IDevice& device_;
72     GpuResourceManager& gpuResourceMgr_;
73     const BASE_NS::string name_;
74 
75     mutable std::mutex mutex_;
76 
77     bool waitForIdle_ { false };
78     BASE_NS::vector<GpuResourceDataCopy> copyData_;
79 };
80 RENDER_END_NAMESPACE()
81 
82 #endif // RENDER_DATA_STORE_RENDER_DATA_STORE_DEFAULT_GPU_RESOURCE_DATA_COPY_H
83