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_DEFAULT_GPU_RESOURCE_DATA_COPY_H 17 #define API_RENDER_IRENDER_DATA_STORE_DEFAULT_GPU_RESOURCE_DATA_COPY_H 18 19 #include <base/containers/byte_array.h> 20 #include <render/datastore/intf_render_data_store.h> 21 #include <render/namespace.h> 22 #include <render/resource_handle.h> 23 RENDER_BEGIN_NAMESPACE()24RENDER_BEGIN_NAMESPACE() 25 /** 26 * IRenderDataStoreDefaultGpuResourceDataCopy interface. 27 * Interface to add copy operations. 28 * 29 * Copy will happen after the frame has been rendered. 30 * 31 * Internally synchronized. 32 */ 33 class IRenderDataStoreDefaultGpuResourceDataCopy : public IRenderDataStore { 34 public: 35 static constexpr BASE_NS::Uid UID { "f3ce24fd-a624-4b8f-9013-006fc5fd8760" }; 36 37 /* The type of the copy */ 38 enum class CopyType : uint8_t { 39 /** Undefined */ 40 UNDEFINED, 41 /** Wait for idle (waits for the GPU) */ 42 WAIT_FOR_IDLE, 43 }; 44 45 struct GpuResourceDataCopy { 46 /* The type of the copy */ 47 CopyType copyType { CopyType::UNDEFINED }; 48 /* GPU resource handle that will be copied. */ 49 RenderHandleReference gpuHandle; 50 /* Byte array where to copy. */ 51 BASE_NS::ByteArray* byteArray { nullptr }; 52 }; 53 54 /** Copy data to buffer on GPU through staging GPU buffer. 55 * @param data Byte data. 56 * @param dstHandle Dst resource. 57 * @param bufferCopy Buffer copy info struct. 58 */ 59 virtual void AddCopyOperation(const GpuResourceDataCopy& copyOp) = 0; 60 61 protected: 62 IRenderDataStoreDefaultGpuResourceDataCopy() = default; 63 ~IRenderDataStoreDefaultGpuResourceDataCopy() override = default; 64 }; 65 RENDER_END_NAMESPACE() 66 67 #endif // API_RENDER_IRENDER_DATA_STORE_DEFAULT_GPU_RESOURCE_DATA_COPY_H 68