Implements the naming of untracked gles handles (flutter/engine#56948)
issue: https://github.com/flutter/flutter/issues/159745 https://github.com/flutter/engine/pull/56927 introduced untracked handles, but naming them didn't work. This adds a test to make sure they work. I kept naming thread-safe since it isn't happening often anyways. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
parent
9e25a25686
commit
8c736f4144
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -386,16 +386,24 @@ 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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ReactorGLES::CanReactOnCurrentThread() const {
|
||||
|
@ -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;
|
||||
@ -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");
|
||||
@ -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,
|
||||
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user