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
2 changes: 1 addition & 1 deletion impeller/renderer/backend/gles/proc_table_gles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ static bool ResourceIsLive(const ProcTableGLES& gl,

bool ProcTableGLES::SetDebugLabel(DebugResourceType type,
GLint name,
const std::string& label) const {
std::string_view label) const {
if (debug_label_max_length_ <= 0) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion impeller/renderer/backend/gles/proc_table_gles.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class ProcTableGLES {

bool SetDebugLabel(DebugResourceType type,
GLint name,
const std::string& label) const;
std::string_view label) const;

void PushDebugGroup(const std::string& string) const;

Expand Down
14 changes: 11 additions & 3 deletions impeller/renderer/backend/gles/reactor_gles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -386,15 +386,23 @@ void ReactorGLES::SetupDebugGroups() {

void ReactorGLES::SetDebugLabel(const HandleGLES& handle,
std::string_view label) {
FML_DCHECK(handle.GetType() != HandleType::kFence);
if (!can_set_debug_labels_) {
return;
}
if (handle.IsDead()) {
return;
}
WriterLock handles_lock(handles_mutex_);
if (auto found = handles_.find(handle); found != handles_.end()) {
found->second.pending_debug_label = label;
if (handle.untracked_id_.has_value()) {
FML_DCHECK(CanReactOnCurrentThread());
const auto& gl = GetProcTable();
gl.SetDebugLabel(ToDebugResourceType(handle.GetType()),
handle.untracked_id_.value(), label);
} else {
WriterLock handles_lock(handles_mutex_);
if (auto found = handles_.find(handle); found != handles_.end()) {
found->second.pending_debug_label = label;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't just store this in handles_to_name_ right now since the thing might not have been created yet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the untracked handles are created immediately, why do we need to go through the reactor managed labeling at all? Can we use a different labeling function that calls the debug label methods directly?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can and I originally implemented it that way. I was thinking these would just get called once in a while so we might as well keep the same semantics, but there are things that we create each frame isn't there? So maybe I should switch it back.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do a lot of a labeling. it should be mostly switched off in release mode but it will still get in the way for profile mode.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I'm not sure where we will land on this. I am seeing code trying to create DeviceBufferGLES from threads that can't react. That's weird to me since we store ops based on the thread. I'm still sorting through this. This is good for now though.

}
}
}

Expand Down
20 changes: 18 additions & 2 deletions impeller/renderer/backend/gles/test/mock_gles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ void mockGetIntegerv(GLenum name, int* value) {
case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
*value = 8;
break;
case GL_MAX_LABEL_LENGTH_KHR:
*value = 64;
break;
default:
*value = 0;
break;
Expand Down Expand Up @@ -170,6 +173,8 @@ static_assert(CheckSameSignature<decltype(mockDeleteQueriesEXT), //
void mockUniform1fv(GLint location, GLsizei count, const GLfloat* value) {
RecordGLCall("glUniform1fv");
}
static_assert(CheckSameSignature<decltype(mockUniform1fv), //
decltype(glUniform1fv)>::value);

void mockGenTextures(GLsizei n, GLuint* textures) {
RecordGLCall("glGenTextures");
Expand All @@ -182,8 +187,17 @@ void mockGenTextures(GLsizei n, GLuint* textures) {
}
}

static_assert(CheckSameSignature<decltype(mockUniform1fv), //
decltype(glUniform1fv)>::value);
static_assert(CheckSameSignature<decltype(mockGenTextures), //
decltype(glGenTextures)>::value);

void mockObjectLabelKHR(GLenum identifier,
GLuint name,
GLsizei length,
const GLchar* label) {
RecordGLCall("glObjectLabelKHR");
}
static_assert(CheckSameSignature<decltype(mockObjectLabelKHR), //
decltype(glObjectLabelKHR)>::value);

std::shared_ptr<MockGLES> MockGLES::Init(
const std::optional<std::vector<const unsigned char*>>& extensions,
Expand Down Expand Up @@ -230,6 +244,8 @@ const ProcTableGLES::Resolver kMockResolverGLES = [](const char* name) {
return reinterpret_cast<void*>(mockUniform1fv);
} else if (strcmp(name, "glGenTextures") == 0) {
return reinterpret_cast<void*>(mockGenTextures);
} else if (strcmp(name, "glObjectLabelKHR") == 0) {
return reinterpret_cast<void*>(mockObjectLabelKHR);
} else {
return reinterpret_cast<void*>(&doNothing);
}
Expand Down
17 changes: 17 additions & 0 deletions impeller/renderer/backend/gles/test/reactor_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,23 @@ TEST(ReactorGLES, UntrackedHandle) {
calls.end());
}

TEST(ReactorGLES, NameUntrackedHandle) {
std::shared_ptr<MockGLES> mock_gles = MockGLES::Init();
ProcTableGLES::Resolver resolver = kMockResolverGLES;
auto proc_table = std::make_unique<ProcTableGLES>(resolver);
auto worker = std::make_shared<TestWorker>();
auto reactor = std::make_shared<ReactorGLES>(std::move(proc_table));
reactor->AddWorker(worker);

mock_gles->SetNextTexture(1234u);
HandleGLES handle = reactor->CreateUntrackedHandle(HandleType::kTexture);
mock_gles->GetCapturedCalls();
reactor->SetDebugLabel(handle, "hello, joe!");
std::vector<std::string> calls = mock_gles->GetCapturedCalls();
EXPECT_TRUE(std::find(calls.begin(), calls.end(), "glObjectLabelKHR") !=
calls.end());
}

TEST(ReactorGLES, PerThreadOperationQueues) {
auto mock_gles = MockGLES::Init();
ProcTableGLES::Resolver resolver = kMockResolverGLES;
Expand Down
Loading