Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
device_buffer.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_IMPELLER_CORE_DEVICE_BUFFER_H_
6#define FLUTTER_IMPELLER_CORE_DEVICE_BUFFER_H_
7
8#include <memory>
9#include <string>
10
14#include "impeller/core/range.h"
15
16namespace impeller {
17
19 public:
20 virtual ~DeviceBuffer();
21
22 [[nodiscard]] bool CopyHostBuffer(const uint8_t* source,
23 Range source_range,
24 size_t offset = 0u);
25
26 virtual bool SetLabel(std::string_view label) = 0;
27
28 virtual bool SetLabel(std::string_view label, Range range) = 0;
29
30 /// @brief Create a buffer view of this entire buffer.
31 static BufferView AsBufferView(std::shared_ptr<DeviceBuffer> buffer);
32
34
35 virtual uint8_t* OnGetContents() const = 0;
36
37 /// Make any pending writes visible to the GPU.
38 ///
39 /// This method must be called if the device pointer provided by
40 /// [OnGetContents] is written to without using [CopyHostBuffer]. On Devices
41 /// with coherent host memory, this method will not perform extra work.
42 ///
43 /// If the range is not provided, the entire buffer is flushed.
44 virtual void Flush(std::optional<Range> range = std::nullopt) const;
45
46 virtual void Invalidate(std::optional<Range> range = std::nullopt) const;
47
48 protected:
50
52
53 virtual bool OnCopyHostBuffer(const uint8_t* source,
54 Range source_range,
55 size_t offset) = 0;
56
57 private:
58 DeviceBuffer(const DeviceBuffer&) = delete;
59
60 DeviceBuffer& operator=(const DeviceBuffer&) = delete;
61};
62
63} // namespace impeller
64
65#endif // FLUTTER_IMPELLER_CORE_DEVICE_BUFFER_H_
static BufferView AsBufferView(std::shared_ptr< DeviceBuffer > buffer)
Create a buffer view of this entire buffer.
virtual void Flush(std::optional< Range > range=std::nullopt) const
const DeviceBufferDescriptor desc_
virtual bool SetLabel(std::string_view label, Range range)=0
virtual void Invalidate(std::optional< Range > range=std::nullopt) const
virtual uint8_t * OnGetContents() const =0
const DeviceBufferDescriptor & GetDeviceBufferDescriptor() const
virtual bool SetLabel(std::string_view label)=0
virtual bool OnCopyHostBuffer(const uint8_t *source, Range source_range, size_t offset)=0
bool CopyHostBuffer(const uint8_t *source, Range source_range, size_t offset=0u)