Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions impeller/renderer/backend/gles/proc_table_gles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "fml/closure.h"
#include "impeller/base/allocation.h"
#include "impeller/base/comparable.h"
#include "impeller/base/strings.h"
#include "impeller/base/validation.h"
#include "impeller/renderer/backend/gles/capabilities_gles.h"
#include "impeller/renderer/capabilities.h"
Expand Down Expand Up @@ -241,24 +242,24 @@ static const char* AttachmentTypeString(GLint type) {

static std::string DescribeFramebufferAttachment(const ProcTableGLES& gl,
GLenum attachment) {
GLint param = GL_NONE;
GLint type = GL_NONE;
gl.GetFramebufferAttachmentParameteriv(
GL_FRAMEBUFFER, // target
attachment, // attachment
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, // parameter name
&param // parameter
&type // parameter
);

if (param != GL_NONE) {
param = GL_NONE;
if (type != GL_NONE) {
GLint object = GL_NONE;
gl.GetFramebufferAttachmentParameteriv(
GL_FRAMEBUFFER, // target
attachment, // attachment
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, // parameter name
&param // parameter
&object // parameter
);
std::stringstream stream;
stream << AttachmentTypeString(param) << "(" << param << ")";
stream << AttachmentTypeString(type) << "(" << object << ")";
return stream.str();
}

Expand All @@ -268,11 +269,15 @@ static std::string DescribeFramebufferAttachment(const ProcTableGLES& gl,
std::string ProcTableGLES::DescribeCurrentFramebuffer() const {
GLint framebuffer = GL_NONE;
GetIntegerv(GL_FRAMEBUFFER_BINDING, &framebuffer);
if (framebuffer == GL_NONE) {
return "The default framebuffer (FBO0) was bound.";
}
if (IsFramebuffer(framebuffer) == GL_FALSE) {
return "No framebuffer or the default window framebuffer is bound.";
return SPrintF("The framebuffer binding (%d) was not a valid framebuffer.",
framebuffer);
}

GLenum status = CheckFramebufferStatus(framebuffer);
GLenum status = CheckFramebufferStatus(GL_FRAMEBUFFER);
std::stringstream stream;
stream << "FBO "
<< ((framebuffer == GL_NONE) ? "(Default)"
Expand All @@ -287,10 +292,10 @@ std::string ProcTableGLES::DescribeCurrentFramebuffer() const {
stream << "Color Attachment: "
<< DescribeFramebufferAttachment(*this, GL_COLOR_ATTACHMENT0)
<< std::endl;
stream << "Color Attachment: "
stream << "Depth Attachment: "
<< DescribeFramebufferAttachment(*this, GL_DEPTH_ATTACHMENT)
<< std::endl;
stream << "Color Attachment: "
stream << "Stencil Attachment: "
<< DescribeFramebufferAttachment(*this, GL_STENCIL_ATTACHMENT)
<< std::endl;
return stream.str();
Expand All @@ -303,7 +308,7 @@ bool ProcTableGLES::IsCurrentFramebufferComplete() const {
// The default framebuffer is always complete.
return true;
}
GLenum status = CheckFramebufferStatus(framebuffer);
GLenum status = CheckFramebufferStatus(GL_FRAMEBUFFER);
return status == GL_FRAMEBUFFER_COMPLETE;
}

Expand Down
37 changes: 37 additions & 0 deletions impeller/renderer/backend/gles/proc_table_gles.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,31 @@ struct AutoErrorCheck {
}
};

template <class Type>
void BuildGLArgumentsStream(std::stringstream& stream, Type arg) {
stream << arg;
}

constexpr void BuildGLArgumentsStream(std::stringstream& stream) {}

template <class Type, class... Rest>
void BuildGLArgumentsStream(std::stringstream& stream,
Type arg,
Rest... other_args) {
BuildGLArgumentsStream(stream, arg);
stream << ", ";
BuildGLArgumentsStream(stream, other_args...);
}

template <class... Type>
[[nodiscard]] std::string BuildGLArguments(Type... args) {
std::stringstream stream;
stream << "(";
BuildGLArgumentsStream(stream, args...);
stream << ")";
return stream.str();
}

template <class T>
struct GLProc {
using GLFunctionType = T;
Expand All @@ -66,6 +91,14 @@ struct GLProc {
///
PFNGLGETERRORPROC error_fn = nullptr;

//----------------------------------------------------------------------------
/// Whether the OpenGL call and its arguments should be logged.
///
/// Only works in IMPELLER_DEBUG and for environments where traditional
/// tracing is hard. Expect log spam and only use during development.
///
bool log_calls = false;

//----------------------------------------------------------------------------
/// @brief Call the GL function with the appropriate parameters. Lookup
/// the documentation for the GL function being called to
Expand All @@ -81,6 +114,10 @@ struct GLProc {
// validation log will at least give us a hint as to what's going on.
FML_CHECK(IsAvailable()) << "GL function " << name << " is not available. "
<< "This is likely due to a missing extension.";
if (log_calls) {
FML_LOG(IMPORTANT) << name
<< BuildGLArguments(std::forward<Args>(args)...);
}
#endif // defined(IMPELLER_DEBUG) && !defined(NDEBUG)
return function(std::forward<Args>(args)...);
}
Expand Down