glretrace: Support traces which use GL_ARB_program_interface_query
During retrace, the driver may choose a different uniform location
than was recorded at trace time. If the traced program looks up
uniforms by name with glGetUniformLocation or similar apis, Apitrace
correctly remaps locations at retrace time.
However, GL_ARB_program_interface_query allows programs to iterate
over program resources querying program names. This reverse-lookup is
not supported by glretrace, and any change to uniform bindings will
result in a crash.
Programs looking up names for each index will:
- iterate the resources attached to the program, calling
glGetProgramResourceName to record the name at each index.
- iterate the resources attached to the program, calling
glGetProgramResourceiv to get the uniform location for each index.
This patch tracks the name at each program index, and then call into
GL to determined current bindings for the named resource whenever
glGetProgramResourceiv is encountered.
Fixes GFXBench Aztec Ruins traces, which crashed when retraced on
various drivers. A trace made on Mesa would work on Intel and AMD
Linux platforms, but would crash on Windows
platforms (AMD/Intel/Nvidia).
Change-Id: Ia2d7725223fbcaa689b7679154efcb3776aa2d23
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/apitrace/+/2224515
Reviewed-by: Po-Hsien Wang <pwang@chromium.org>
Commit-Queue: Robert Tarasov <tutankhamen@chromium.org>
Commit-Queue: Ilja H. Friedel <ihf@chromium.org>
Tested-by: Robert Tarasov <tutankhamen@chromium.org>
Tested-by: Ilja H. Friedel <ihf@chromium.org>
diff --git a/specs/glapi.py b/specs/glapi.py
index a2032b5..a263ceb 100644
--- a/specs/glapi.py
+++ b/specs/glapi.py
@@ -1389,8 +1389,8 @@
# GL_ARB_program_interface_query
GlFunction(Void, "glGetProgramInterfaceiv", [(GLprogram, "program"), (GLenum, "programInterface"), (GLenum, "pname"), Out(Array(GLint, "_gl_param_size(pname)"), "params")], sideeffects=False),
GlFunction(GLuint, "glGetProgramResourceIndex", [(GLprogram, "program"), (GLenum, "programInterface"), (GLstringConst, "name")], sideeffects=False),
- GlFunction(Void, "glGetProgramResourceName", [(GLprogram, "program"), (GLenum, "programInterface"), (GLuint, "index"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), OutGlString(GLchar, "length", "name")], sideeffects=False),
- GlFunction(Void, "glGetProgramResourceiv", [(GLprogram, "program"), (GLenum, "programInterface"), (GLuint, "index"), (GLsizei, "propCount"), (Array(Const(GLenum), "propCount"), "props"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(Array(GLint, "bufSize"), "params")], sideeffects=False),
+ GlFunction(Void, "glGetProgramResourceName", [(GLprogram, "program"), (GLenum, "programInterface"), (GLuint, "index"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), OutGlString(GLchar, "length", "name")]),
+ GlFunction(Void, "glGetProgramResourceiv", [(GLprogram, "program"), (GLenum, "programInterface"), (GLuint, "index"), (GLsizei, "propCount"), (Array(Const(GLenum), "propCount"), "props"), (GLsizei, "bufSize"), Out(Pointer(GLsizei), "length"), Out(Array(GLint, "bufSize"), "params")]),
GlFunction(GLlocation, "glGetProgramResourceLocation", [(GLprogram, "program"), (GLenum, "programInterface"), (GLstringConst, "name")]),
GlFunction(GLint, "glGetProgramResourceLocationIndex", [(GLprogram, "program"), (GLenum, "programInterface"), (GLstringConst, "name")], sideeffects=False),