@@ -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;
0 commit comments