Flutter Impeller
impeller::ProcTableGLES Class Reference

#include <proc_table_gles.h>

Public Types

using Resolver = std::function< void *(const char *function_name)>
 

Public Member Functions

 ProcTableGLES (Resolver resolver)
 
 ~ProcTableGLES ()
 
 FOR_EACH_IMPELLER_PROC (IMPELLER_PROC)
 
 FOR_EACH_IMPELLER_GLES3_PROC (IMPELLER_PROC)
 
 FOR_EACH_IMPELLER_EXT_PROC (IMPELLER_PROC)
 
bool IsValid () const
 
void ShaderSourceMapping (GLuint shader, const fml::Mapping &mapping) const
 
const DescriptionGLESGetDescription () const
 
const CapabilitiesGLESGetCapabilities () const
 
std::string DescribeCurrentFramebuffer () const
 
std::string GetProgramInfoLogString (GLuint program) const
 
bool IsCurrentFramebufferComplete () const
 
bool SetDebugLabel (DebugResourceType type, GLint name, const std::string &label) const
 
void PushDebugGroup (const std::string &string) const
 
void PopDebugGroup () const
 

Detailed Description

Definition at line 188 of file proc_table_gles.h.

Member Typedef Documentation

◆ Resolver

using impeller::ProcTableGLES::Resolver = std::function<void*(const char* function_name)>

Definition at line 190 of file proc_table_gles.h.

Constructor & Destructor Documentation

◆ ProcTableGLES()

impeller::ProcTableGLES::ProcTableGLES ( Resolver  resolver)
explicit

Definition at line 57 of file proc_table_gles.cc.

57  {
58  if (!resolver) {
59  return;
60  }
61 
62  resolver = WrappedResolver(resolver);
63 
64  auto error_fn = reinterpret_cast<PFNGLGETERRORPROC>(resolver("glGetError"));
65  if (!error_fn) {
66  VALIDATION_LOG << "Could not resolve "
67  << "glGetError";
68  return;
69  }
70 
71 #define IMPELLER_PROC(proc_ivar) \
72  if (auto fn_ptr = resolver(proc_ivar.name)) { \
73  proc_ivar.function = \
74  reinterpret_cast<decltype(proc_ivar.function)>(fn_ptr); \
75  proc_ivar.error_fn = error_fn; \
76  } else { \
77  VALIDATION_LOG << "Could not resolve " << proc_ivar.name; \
78  return; \
79  }
80 
82 
83 #undef IMPELLER_PROC
84 
85 #define IMPELLER_PROC(proc_ivar) \
86  if (auto fn_ptr = resolver(proc_ivar.name)) { \
87  proc_ivar.function = \
88  reinterpret_cast<decltype(proc_ivar.function)>(fn_ptr); \
89  proc_ivar.error_fn = error_fn; \
90  }
93 
94 #undef IMPELLER_PROC
95 
96  description_ = std::make_unique<DescriptionGLES>(*this);
97 
98  if (!description_->IsValid()) {
99  return;
100  }
101 
102  if (!description_->HasDebugExtension()) {
103  PushDebugGroupKHR.Reset();
104  PopDebugGroupKHR.Reset();
105  ObjectLabelKHR.Reset();
106  } else {
107  GetIntegerv(GL_MAX_LABEL_LENGTH_KHR, &debug_label_max_length_);
108  }
109 
110  if (!description_->HasExtension("GL_EXT_discard_framebuffer")) {
111  DiscardFramebufferEXT.Reset();
112  }
113 
114  capabilities_ = std::make_unique<CapabilitiesGLES>(*this);
115 
116  is_valid_ = true;
117 }

References FOR_EACH_IMPELLER_EXT_PROC(), FOR_EACH_IMPELLER_GLES3_PROC(), FOR_EACH_IMPELLER_PROC(), IMPELLER_PROC, VALIDATION_LOG, and impeller::WrappedResolver().

◆ ~ProcTableGLES()

impeller::ProcTableGLES::~ProcTableGLES ( )
default

Member Function Documentation

◆ DescribeCurrentFramebuffer()

std::string impeller::ProcTableGLES::DescribeCurrentFramebuffer ( ) const

Definition at line 201 of file proc_table_gles.cc.

201  {
202  GLint framebuffer = GL_NONE;
203  GetIntegerv(GL_FRAMEBUFFER_BINDING, &framebuffer);
204  if (IsFramebuffer(framebuffer) == GL_FALSE) {
205  return "No framebuffer or the default window framebuffer is bound.";
206  }
207 
208  GLenum status = CheckFramebufferStatus(framebuffer);
209  std::stringstream stream;
210  stream << "FBO "
211  << ((framebuffer == GL_NONE) ? "(Default)"
212  : std::to_string(framebuffer))
213  << ": " << FramebufferStatusToString(status) << std::endl;
215  stream << "Framebuffer is complete." << std::endl;
216  } else {
217  stream << "Framebuffer is incomplete." << std::endl;
218  }
219  stream << "Description: " << std::endl;
220  stream << "Color Attachment: "
221  << DescribeFramebufferAttachment(*this, GL_COLOR_ATTACHMENT0)
222  << std::endl;
223  stream << "Color Attachment: "
224  << DescribeFramebufferAttachment(*this, GL_DEPTH_ATTACHMENT)
225  << std::endl;
226  stream << "Color Attachment: "
227  << DescribeFramebufferAttachment(*this, GL_STENCIL_ATTACHMENT)
228  << std::endl;
229  return stream.str();
230 }

References impeller::DescribeFramebufferAttachment(), impeller::FramebufferStatusToString(), and IsCurrentFramebufferComplete().

◆ FOR_EACH_IMPELLER_EXT_PROC()

impeller::ProcTableGLES::FOR_EACH_IMPELLER_EXT_PROC ( IMPELLER_PROC  )

Referenced by ProcTableGLES().

◆ FOR_EACH_IMPELLER_GLES3_PROC()

impeller::ProcTableGLES::FOR_EACH_IMPELLER_GLES3_PROC ( IMPELLER_PROC  )

Referenced by ProcTableGLES().

◆ FOR_EACH_IMPELLER_PROC()

impeller::ProcTableGLES::FOR_EACH_IMPELLER_PROC ( IMPELLER_PROC  )

Referenced by ProcTableGLES().

◆ GetCapabilities()

const CapabilitiesGLES * impeller::ProcTableGLES::GetCapabilities ( ) const

Definition at line 137 of file proc_table_gles.cc.

137  {
138  return capabilities_.get();
139 }

◆ GetDescription()

const DescriptionGLES * impeller::ProcTableGLES::GetDescription ( ) const

Definition at line 133 of file proc_table_gles.cc.

133  {
134  return description_.get();
135 }

Referenced by impeller::CapabilitiesGLES::CapabilitiesGLES().

◆ GetProgramInfoLogString()

std::string impeller::ProcTableGLES::GetProgramInfoLogString ( GLuint  program) const

Definition at line 328 of file proc_table_gles.cc.

328  {
329  GLint length = 0;
330  GetProgramiv(program, GL_INFO_LOG_LENGTH, &length);
331  if (length <= 0) {
332  return "";
333  }
334 
335  length = std::min<GLint>(length, 1024);
336  Allocation allocation;
337  if (!allocation.Truncate(length, false)) {
338  return "";
339  }
340  GetProgramInfoLog(program, // program
341  length, // max length
342  &length, // length written (excluding NULL terminator)
343  reinterpret_cast<GLchar*>(allocation.GetBuffer()) // buffer
344  );
345  if (length <= 0) {
346  return "";
347  }
348  return std::string{reinterpret_cast<const char*>(allocation.GetBuffer()),
349  static_cast<size_t>(length)};
350 }

References impeller::Allocation::GetBuffer(), and impeller::Allocation::Truncate().

◆ IsCurrentFramebufferComplete()

bool impeller::ProcTableGLES::IsCurrentFramebufferComplete ( ) const

Definition at line 232 of file proc_table_gles.cc.

232  {
233  GLint framebuffer = GL_NONE;
234  GetIntegerv(GL_FRAMEBUFFER_BINDING, &framebuffer);
235  if (IsFramebuffer(framebuffer) == GL_FALSE) {
236  // The default framebuffer is always complete.
237  return true;
238  }
239  GLenum status = CheckFramebufferStatus(framebuffer);
240  return status == GL_FRAMEBUFFER_COMPLETE;
241 }

Referenced by DescribeCurrentFramebuffer().

◆ IsValid()

bool impeller::ProcTableGLES::IsValid ( ) const

Definition at line 121 of file proc_table_gles.cc.

121  {
122  return is_valid_;
123 }

◆ PopDebugGroup()

void impeller::ProcTableGLES::PopDebugGroup ( ) const

Definition at line 321 of file proc_table_gles.cc.

321  {
322  if (debug_label_max_length_ <= 0) {
323  return;
324  }
325  PopDebugGroupKHR();
326 }

◆ PushDebugGroup()

void impeller::ProcTableGLES::PushDebugGroup ( const std::string &  string) const

Definition at line 307 of file proc_table_gles.cc.

307  {
308  if (debug_label_max_length_ <= 0) {
309  return;
310  }
311  UniqueID id;
312  const auto label_length =
313  std::min<GLsizei>(debug_label_max_length_ - 1, label.size());
314  PushDebugGroupKHR(GL_DEBUG_SOURCE_APPLICATION_KHR, // source
315  static_cast<GLuint>(id.id), // id
316  label_length, // length
317  label.data() // message
318  );
319 }

Referenced by impeller::EncodeCommandsInReactor().

◆ SetDebugLabel()

bool impeller::ProcTableGLES::SetDebugLabel ( DebugResourceType  type,
GLint  name,
const std::string &  label 
) const

Definition at line 281 of file proc_table_gles.cc.

283  {
284  if (debug_label_max_length_ <= 0) {
285  return true;
286  }
287  if (!ObjectLabelKHR.IsAvailable()) {
288  return true;
289  }
290  if (!ResourceIsLive(*this, type, name)) {
291  return false;
292  }
293  const auto identifier = ToDebugIdentifier(type);
294  const auto label_length =
295  std::min<GLsizei>(debug_label_max_length_ - 1, label.size());
296  if (!identifier.has_value()) {
297  return true;
298  }
299  ObjectLabelKHR(identifier.value(), // identifier
300  name, // name
301  label_length, // length
302  label.data() // label
303  );
304  return true;
305 }

References impeller::ResourceIsLive(), and impeller::ToDebugIdentifier().

◆ ShaderSourceMapping()

void impeller::ProcTableGLES::ShaderSourceMapping ( GLuint  shader,
const fml::Mapping &  mapping 
) const

Definition at line 125 of file proc_table_gles.cc.

126  {
127  const GLchar* sources[] = {
128  reinterpret_cast<const GLchar*>(mapping.GetMapping())};
129  const GLint lengths[] = {static_cast<GLint>(mapping.GetSize())};
130  ShaderSource(shader, 1u, sources, lengths);
131 }

The documentation for this class was generated from the following files:
impeller::DescribeFramebufferAttachment
static std::string DescribeFramebufferAttachment(const ProcTableGLES &gl, GLenum attachment)
Definition: proc_table_gles.cc:175
impeller::ProcTableGLES::FOR_EACH_IMPELLER_PROC
FOR_EACH_IMPELLER_PROC(IMPELLER_PROC)
impeller::ProcTableGLES::FOR_EACH_IMPELLER_GLES3_PROC
FOR_EACH_IMPELLER_GLES3_PROC(IMPELLER_PROC)
IMPELLER_PROC
#define IMPELLER_PROC(proc_ivar)
impeller::ResourceIsLive
static bool ResourceIsLive(const ProcTableGLES &gl, DebugResourceType type, GLint name)
Definition: proc_table_gles.cc:261
impeller::WrappedResolver
ProcTableGLES::Resolver WrappedResolver(const ProcTableGLES::Resolver &resolver)
Definition: proc_table_gles.cc:35
impeller::ProcTableGLES::FOR_EACH_IMPELLER_EXT_PROC
FOR_EACH_IMPELLER_EXT_PROC(IMPELLER_PROC)
impeller::FramebufferStatusToString
static const char * FramebufferStatusToString(GLenum status)
Definition: proc_table_gles.cc:141
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:60
impeller::ProcTableGLES::IsCurrentFramebufferComplete
bool IsCurrentFramebufferComplete() const
Definition: proc_table_gles.cc:232
impeller::ToDebugIdentifier
static std::optional< GLenum > ToDebugIdentifier(DebugResourceType type)
Definition: proc_table_gles.cc:243