Flutter Engine
 
Loading...
Searching...
No Matches
impeller::DeviceBufferGLES Class Referencefinal

#include <device_buffer_gles.h>

Inheritance diagram for impeller::DeviceBufferGLES:
impeller::DeviceBuffer impeller::BackendCast< DeviceBufferGLES, DeviceBuffer >

Public Types

enum class  BindingType {
  kArrayBuffer ,
  kElementArrayBuffer ,
  kUniformBuffer
}
 

Public Member Functions

 DeviceBufferGLES (DeviceBufferDescriptor desc, std::shared_ptr< ReactorGLES > reactor, std::shared_ptr< Allocation > backing_store)
 
 ~DeviceBufferGLES () override
 
const uint8_t * GetBufferData () const
 
void UpdateBufferData (const std::function< void(uint8_t *, size_t length)> &update_buffer_data)
 
bool BindAndUploadDataIfNecessary (BindingType type) const
 
void Flush (std::optional< Range > range=std::nullopt) const override
 
std::optional< GLuint > GetHandle () const
 
- Public Member Functions inherited from impeller::DeviceBuffer
virtual ~DeviceBuffer ()
 
bool CopyHostBuffer (const uint8_t *source, Range source_range, size_t offset=0u)
 
const DeviceBufferDescriptorGetDeviceBufferDescriptor () const
 
virtual void Invalidate (std::optional< Range > range=std::nullopt) const
 

Additional Inherited Members

- Static Public Member Functions inherited from impeller::DeviceBuffer
static BufferView AsBufferView (std::shared_ptr< DeviceBuffer > buffer)
 Create a buffer view of this entire buffer.
 
- Static Public Member Functions inherited from impeller::BackendCast< DeviceBufferGLES, DeviceBuffer >
static DeviceBufferGLESCast (DeviceBuffer &base)
 
static const DeviceBufferGLESCast (const DeviceBuffer &base)
 
static DeviceBufferGLESCast (DeviceBuffer *base)
 
static const DeviceBufferGLESCast (const DeviceBuffer *base)
 
- Protected Member Functions inherited from impeller::DeviceBuffer
 DeviceBuffer (DeviceBufferDescriptor desc)
 
- Protected Attributes inherited from impeller::DeviceBuffer
const DeviceBufferDescriptor desc_
 

Detailed Description

Definition at line 18 of file device_buffer_gles.h.

Member Enumeration Documentation

◆ BindingType

Enumerator
kArrayBuffer 
kElementArrayBuffer 
kUniformBuffer 

Definition at line 34 of file device_buffer_gles.h.

Constructor & Destructor Documentation

◆ DeviceBufferGLES()

impeller::DeviceBufferGLES::DeviceBufferGLES ( DeviceBufferDescriptor  desc,
std::shared_ptr< ReactorGLES reactor,
std::shared_ptr< Allocation backing_store 
)

Definition at line 15 of file device_buffer_gles.cc.

18 : DeviceBuffer(desc),
19 reactor_(std::move(reactor)),
20 backing_store_(std::move(backing_store)) {}
DeviceBuffer(DeviceBufferDescriptor desc)

◆ ~DeviceBufferGLES()

impeller::DeviceBufferGLES::~DeviceBufferGLES ( )
override

Definition at line 23 of file device_buffer_gles.cc.

23 {
24 if (handle_.has_value() && !handle_->IsDead()) {
25 reactor_->CollectHandle(*handle_);
26 }
27}

Member Function Documentation

◆ BindAndUploadDataIfNecessary()

bool impeller::DeviceBufferGLES::BindAndUploadDataIfNecessary ( BindingType  type) const

Definition at line 90 of file device_buffer_gles.cc.

90 {
91 if (!reactor_) {
92 return false;
93 }
94
95 if (!handle_.has_value()) {
96 handle_ = reactor_->CreateUntrackedHandle(HandleType::kBuffer);
97#ifdef IMPELLER_DEBUG
98 if (handle_.has_value() && label_.has_value()) {
99 reactor_->SetDebugLabel(*handle_, *label_);
100 }
101#endif
102 }
103
104 auto buffer = reactor_->GetGLHandle(*handle_);
105 if (!buffer.has_value()) {
106 return false;
107 }
108
109 const auto target_type = ToTarget(type);
110 const auto& gl = reactor_->GetProcTable();
111
112 gl.BindBuffer(target_type, buffer.value());
113 if (!initialized_) {
114 gl.BufferData(target_type, backing_store_->GetLength().GetByteSize(),
115 nullptr, GL_DYNAMIC_DRAW);
116 initialized_ = true;
117 }
118
119 if (dirty_range_.has_value()) {
120 auto range = dirty_range_.value();
121 gl.BufferSubData(target_type, range.offset, range.length,
122 backing_store_->GetBuffer() + range.offset);
123 dirty_range_ = std::nullopt;
124 }
125
126 return true;
127}
GLenum type
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set profile Make the profiler discard new samples once the profiler sample buffer is full When this flag is not the profiler sample buffer is used as a ring buffer
Definition switch_defs.h:98
static GLenum ToTarget(DeviceBufferGLES::BindingType type)

References impeller::kBuffer, impeller::ToTarget(), and type.

◆ Flush()

void impeller::DeviceBufferGLES::Flush ( std::optional< Range range = std::nullopt) const
overridevirtual

Make any pending writes visible to the GPU.

This method must be called if the device pointer provided by [OnGetContents] is written to without using [CopyHostBuffer]. On Devices with coherent host memory, this method will not perform extra work.

If the range is not provided, the entire buffer is flushed.

Reimplemented from impeller::DeviceBuffer.

Definition at line 65 of file device_buffer_gles.cc.

65 {
66 if (!range.has_value()) {
67 dirty_range_ = Range{
68 0, static_cast<size_t>(backing_store_->GetLength().GetByteSize())};
69 } else {
70 if (dirty_range_.has_value()) {
71 dirty_range_ = dirty_range_->Merge(range.value());
72 } else {
73 dirty_range_ = range.value();
74 }
75 }
76}

Referenced by UpdateBufferData().

◆ GetBufferData()

const uint8_t * impeller::DeviceBufferGLES::GetBufferData ( ) const

Definition at line 147 of file device_buffer_gles.cc.

147 {
148 return backing_store_->GetBuffer();
149}

◆ GetHandle()

std::optional< GLuint > impeller::DeviceBufferGLES::GetHandle ( ) const

Definition at line 57 of file device_buffer_gles.cc.

57 {
58 if (handle_.has_value()) {
59 return reactor_->GetGLHandle(*handle_);
60 } else {
61 return std::nullopt;
62 }
63}

◆ UpdateBufferData()

void impeller::DeviceBufferGLES::UpdateBufferData ( const std::function< void(uint8_t *, size_t length)> &  update_buffer_data)

Definition at line 151 of file device_buffer_gles.cc.

153 {
154 if (update_buffer_data) {
155 update_buffer_data(backing_store_->GetBuffer(),
156 backing_store_->GetLength().GetByteSize());
157 Flush(Range{
158 0, static_cast<size_t>(backing_store_->GetLength().GetByteSize())});
159 }
160}
void Flush(std::optional< Range > range=std::nullopt) const override

References Flush().

Referenced by impeller::BlitCopyTextureToBufferCommandGLES::Encode().


The documentation for this class was generated from the following files: