Skip to content

Commit f40b05b

Browse files
committed
test(tvos): trace texture allocations without unavailable GLES 3.1 query
1 parent 06fed02 commit f40b05b

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

‎.github/workflows/tvos.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ jobs:
172172
"render context was not ready", "first video frame",
173173
"render context handoff did not complete", "native target:",
174174
"native GL provider:", "native draw:", "native renderer result:",
175-
"native uniform:", "native sampler:"]):
175+
"native uniform:", "native sampler:", "native texture allocation:"]):
176176
print(line)
177177
raise SystemExit(1)
178178
finally:

‎src/player/MpvVideoItem.cpp‎

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,18 @@ namespace {
7272
std::memcpy(nativeVertexData, data, sizeof(nativeVertexData));
7373
::glBufferData(target, size, data, usage);
7474
}
75+
void diagnosticTexImage2D(GLenum target, GLint level, GLint internal, GLsizei width, GLsizei height,
76+
GLint border, GLenum format, GLenum type, const void *data)
77+
{
78+
static thread_local int allocations = 0;
79+
if (allocations++ < 40) {
80+
GLint texture = 0;
81+
::glGetIntegerv(GL_TEXTURE_BINDING_2D, &texture);
82+
std::fprintf(stderr, "native texture allocation: texture=%d size=%dx%d level=%d format=%d\n",
83+
texture, width, height, level, internal);
84+
}
85+
::glTexImage2D(target, level, internal, width, height, border, format, type, data);
86+
}
7587
void diagnosticDrawArrays(GLenum mode, GLint first, GLsizei count)
7688
{
7789
GLint viewport[4] {}, scissor[4] {}, fbo = 0, program = 0, vao = 0;
@@ -102,14 +114,12 @@ namespace {
102114
}
103115
const GLint sampler = ::glGetUniformLocation(program, "texture0");
104116
if (sampler >= 0) {
105-
GLint unit = 0, active = 0, texture = 0, width = 0, height = 0;
117+
GLint unit = 0, active = 0, texture = 0;
106118
::glGetUniformiv(program, sampler, &unit);
107119
::glGetIntegerv(GL_ACTIVE_TEXTURE, &active);
108120
::glActiveTexture(GL_TEXTURE0 + unit);
109121
::glGetIntegerv(GL_TEXTURE_BINDING_2D, &texture);
110-
::glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);
111-
::glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height);
112-
std::fprintf(stderr, "native sampler: unit=%d texture=%d size=%dx%d\n", unit, texture, width, height);
122+
std::fprintf(stderr, "native sampler: unit=%d texture=%d\n", unit, texture);
113123
::glActiveTexture(active);
114124
}
115125
}
@@ -138,6 +148,8 @@ namespace {
138148
return reinterpret_cast<void *>(&diagnosticDrawArrays);
139149
if (std::strcmp(name, "glBufferData") == 0)
140150
return reinterpret_cast<void *>(&diagnosticBufferData);
151+
if (std::strcmp(name, "glTexImage2D") == 0)
152+
return reinterpret_cast<void *>(&diagnosticTexImage2D);
141153
}
142154
#endif
143155
return address;

‎tools/apple/smoke-tvos.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ for bundle, arguments, expected in checks:
104104
"player: render backend", "first video frame",
105105
"render context handoff did not complete", "native target:", "native GL provider:",
106106
"native presentation diagnostic:", "native draw:", "native renderer result:",
107-
"native uniform:", "native sampler:"]):
107+
"native uniform:", "native sampler:", "native texture allocation:"]):
108108
print(re.sub(r"https?://\S+", "[redacted-url]", line))
109109
if any(marker in line for marker in ["launch test:", "video result:", "orientation:", "viewport:", "decoder:",
110110
"render context was not ready", "failed to initialize mpv",

0 commit comments

Comments
 (0)