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_BUFFER_H 17 #define DEVICE_GPU_BUFFER_H 18 19 #include <render/namespace.h> 20 21 RENDER_BEGIN_NAMESPACE() 22 struct GpuBufferDesc; 23 24 /** Gpu buffer. 25 * Immutable platform gpu buffer wrapper. 26 */ 27 class GpuBuffer { 28 public: 29 GpuBuffer() = default; 30 virtual ~GpuBuffer() = default; 31 32 GpuBuffer(const GpuBuffer&) = delete; 33 GpuBuffer& operator=(const GpuBuffer&) = delete; 34 35 virtual const GpuBufferDesc& GetDesc() const = 0; 36 37 // Map will return a pointer to the data. 38 // If mapBufferingCount is bigger than 1, the pointer advances to next block with every call (ring buffer) 39 virtual void* Map() = 0; 40 // Maps always from the beginning of the buffer. Does not advance dynamic ring buffer. 41 virtual void* MapMemory() = 0; 42 43 virtual void Unmap() const = 0; 44 }; 45 RENDER_END_NAMESPACE() 46 47 #endif // DEVICE_GPU_BUFFER_H 48