23 return "GL_INVALID_ENUM";
24 case GL_INVALID_VALUE:
25 return "GL_INVALID_VALUE";
26 case GL_INVALID_OPERATION:
27 return "GL_INVALID_OPERATION";
28 case GL_INVALID_FRAMEBUFFER_OPERATION:
29 return "GL_INVALID_FRAMEBUFFER_OPERATION";
30 case GL_FRAMEBUFFER_COMPLETE:
31 return "GL_FRAMEBUFFER_COMPLETE";
32 case GL_OUT_OF_MEMORY:
33 return "GL_OUT_OF_MEMORY";
43 case GL_INVALID_VALUE:
44 case GL_INVALID_OPERATION:
45 case GL_INVALID_FRAMEBUFFER_OPERATION:
46 case GL_OUT_OF_MEMORY:
64 return resolver(truncated.c_str());
68 return resolver(truncated.c_str());
85 auto error_fn =
reinterpret_cast<PFNGLGETERRORPROC
>(resolver(
"glGetError"));
91#define IMPELLER_PROC(proc_ivar) \
92 if (auto fn_ptr = resolver(proc_ivar.name)) { \
93 proc_ivar.function = \
94 reinterpret_cast<decltype(proc_ivar.function)>(fn_ptr); \
95 proc_ivar.error_fn = error_fn; \
97 VALIDATION_LOG << "Could not resolve " << proc_ivar.name; \
103 description_ = std::make_unique<DescriptionGLES>(*
this);
105 if (!description_->IsValid()) {
109 if (description_->IsES()) {
117#define IMPELLER_PROC(proc_ivar) \
118 if (auto fn_ptr = resolver(proc_ivar.name)) { \
119 proc_ivar.function = \
120 reinterpret_cast<decltype(proc_ivar.function)>(fn_ptr); \
121 proc_ivar.error_fn = error_fn; \
128 if (!description_->HasDebugExtension()) {
129 PushDebugGroupKHR.Reset();
130 PopDebugGroupKHR.Reset();
131 ObjectLabelKHR.Reset();
133 GetIntegerv(GL_MAX_LABEL_LENGTH_KHR, &debug_label_max_length_);
136 if (!description_->HasExtension(
"GL_EXT_discard_framebuffer")) {
137 DiscardFramebufferEXT.Reset();
140 capabilities_ = std::make_shared<CapabilitiesGLES>(*
this);
154 const std::vector<Scalar>& defines)
const {
155 if (defines.empty()) {
157 reinterpret_cast<const GLchar*
>(mapping.
GetMapping())};
158 const GLint lengths[] = {
static_cast<GLint
>(mapping.
GetSize())};
159 ShaderSource(shader, 1u,
sources, lengths);
163 if (!shader_source.has_value()) {
169 reinterpret_cast<const GLchar*
>(shader_source->c_str())};
170 const GLint lengths[] = {
static_cast<GLint
>(shader_source->size())};
171 ShaderSource(shader, 1u,
sources, lengths);
177 const std::vector<Scalar>& defines)
const {
178 auto shader_source = std::string{
183 auto index = shader_source.find(
'\n');
184 if (index == std::string::npos) {
189 std::stringstream ss;
191 for (
auto i = 0u;
i < defines.size();
i++) {
192 ss <<
"#define SPIRV_CROSS_CONSTANT_ID_" <<
i <<
" " << defines[
i] <<
'\n';
194 auto define_string = ss.str();
195 shader_source.insert(index + 1, define_string);
196 return shader_source;
200 return description_.get();
205 return capabilities_;
210 case GL_FRAMEBUFFER_COMPLETE:
211 return "GL_FRAMEBUFFER_COMPLETE";
212 case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
213 return "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT";
215 case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
216 return "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS";
218 case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
219 return "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";
220 case GL_FRAMEBUFFER_UNSUPPORTED:
221 return "GL_FRAMEBUFFER_UNSUPPORTED";
222 case GL_INVALID_ENUM:
223 return "GL_INVALID_ENUM";
226 return "Unknown FBO Error Status";
231 case GL_RENDERBUFFER:
232 return "GL_RENDERBUFFER";
239 return "Unknown Type";
244 GLint param = GL_NONE;
245 gl.GetFramebufferAttachmentParameteriv(
248 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
252 if (param != GL_NONE) {
254 gl.GetFramebufferAttachmentParameteriv(
257 GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
265 return "No Attachment";
269 GLint framebuffer = GL_NONE;
270 GetIntegerv(GL_FRAMEBUFFER_BINDING, &framebuffer);
271 if (IsFramebuffer(framebuffer) == GL_FALSE) {
272 return "No framebuffer or the default window framebuffer is bound.";
275 GLenum status = CheckFramebufferStatus(framebuffer);
278 << ((framebuffer == GL_NONE) ?
"(Default)"
282 stream <<
"Framebuffer is complete." << std::endl;
284 stream <<
"Framebuffer is incomplete." << std::endl;
286 stream <<
"Description: " << std::endl;
287 stream <<
"Color Attachment: "
290 stream <<
"Color Attachment: "
293 stream <<
"Color Attachment: "
300 GLint framebuffer = GL_NONE;
301 GetIntegerv(GL_FRAMEBUFFER_BINDING, &framebuffer);
302 if (IsFramebuffer(framebuffer) == GL_FALSE) {
306 GLenum status = CheckFramebufferStatus(framebuffer);
307 return status == GL_FRAMEBUFFER_COMPLETE;
315 return GL_BUFFER_KHR;
317 return GL_PROGRAM_KHR;
319 return GL_SHADER_KHR;
321 return GL_RENDERBUFFER;
323 return GL_FRAMEBUFFER;
333 return gl.IsTexture(
name);
337 return gl.IsProgram(
name);
341 return gl.IsRenderbuffer(
name);
343 return gl.IsFramebuffer(
name);
350 const std::string& label)
const {
351 if (debug_label_max_length_ <= 0) {
354 if (!ObjectLabelKHR.IsAvailable()) {
361 const auto label_length =
362 std::min<GLsizei>(debug_label_max_length_ - 1, label.size());
376 if (debug_label_max_length_ <= 0) {
381 const auto label_length =
382 std::min<GLsizei>(debug_label_max_length_ - 1, label.size());
383 PushDebugGroupKHR(GL_DEBUG_SOURCE_APPLICATION_KHR,
384 static_cast<GLuint
>(
id.
id),
393 if (debug_label_max_length_ <= 0) {
403 GetProgramiv(program, GL_INFO_LOG_LENGTH, &
length);
413 GetProgramInfoLog(program,
416 reinterpret_cast<GLchar*
>(allocation.
GetBuffer())
421 return std::string{
reinterpret_cast<const char*
>(allocation.
GetBuffer()),
422 static_cast<size_t>(
length)};
virtual const uint8_t * GetMapping() const =0
virtual size_t GetSize() const =0
uint8_t * GetBuffer() const
bool Truncate(size_t length, bool npot=true)
FOR_EACH_IMPELLER_ES_ONLY_PROC(IMPELLER_PROC)
std::optional< std::string > ComputeShaderWithDefines(const fml::Mapping &mapping, const std::vector< Scalar > &defines) const
void PopDebugGroup() const
FOR_EACH_IMPELLER_GLES3_PROC(IMPELLER_PROC)
std::function< void *(const char *function_name)> Resolver
void ShaderSourceMapping(GLuint shader, const fml::Mapping &mapping, const std::vector< Scalar > &defines={}) const
Set the source for the attached [shader].
FOR_EACH_IMPELLER_DESKTOP_ONLY_PROC(IMPELLER_PROC)
std::string GetProgramInfoLogString(GLuint program) const
bool SetDebugLabel(DebugResourceType type, GLint name, const std::string &label) const
std::string DescribeCurrentFramebuffer() const
const std::shared_ptr< const CapabilitiesGLES > & GetCapabilities() const
bool IsCurrentFramebufferComplete() const
ProcTableGLES(Resolver resolver)
FOR_EACH_IMPELLER_PROC(IMPELLER_PROC)
FOR_EACH_IMPELLER_EXT_PROC(IMPELLER_PROC)
void PushDebugGroup(const std::string &string) const
const DescriptionGLES * GetDescription() const
static SkString identifier(const FontFamilyDesc &family, const FontDesc &font)
#define FML_UNREACHABLE()
Dart_NativeFunction function
const char *const function_name
DEF_SWITCHES_START aot vmservice shared library name
ProcTableGLES::Resolver WrappedResolver(const ProcTableGLES::Resolver &resolver)
bool GLErrorIsFatal(GLenum value)
static std::optional< GLenum > ToDebugIdentifier(DebugResourceType type)
const char * GLErrorToString(GLenum value)
static const char * FramebufferStatusToString(GLenum status)
static const char * AttachmentTypeString(GLint type)
static bool ResourceIsLive(const ProcTableGLES &gl, DebugResourceType type, GLint name)
static std::string DescribeFramebufferAttachment(const ProcTableGLES &gl, GLenum attachment)
static SkString to_string(int n)
#define IMPELLER_PROC(proc_ivar)