# Trim to the same callset used to generate reference images
-apitrace trim --calls=10,31,50,71,87,88 glxsimple.trace
+apitrace trim --auto -o glxsimple-trim-unused-textures.trace --calls=10,31,50,71,87,88 glxsimple.trace
# Verify that we actually trimmed what we wanted to
-apitrace diff --diff=diff glxsimple.trace glxsimple-trim.trace
-expect "44d43\n< glGenTextures(1, &1)\n46d44\n< glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, blob(3))\n48,57d45\n< glBegin(GL_QUADS)\n< glTexCoord2f(0, 0)\n< glVertex2f(0, 0)\n< glTexCoord2f(1, 0)\n< glVertex2f(64, 0)\n< glTexCoord2f(1, 1)\n< glVertex2f(64, 64)\n< glTexCoord2f(0, 1)\n< glVertex2f(0, 64)\n< glEnd()\n59,60d46\n< glXSwapBuffers(0x236a280, 41943041)\n< \n"
+apitrace diff --diff=python glxsimple.trace glxsimple-trim-unused-textures.trace
+expect r""" glXChooseVisual(37134976, 0, (GLX_RGBA, GLX_RED_SIZE, GLX_RED_SIZE, GLX_GREEN_SIZE, GLX_RED_SIZE, GLX_BLUE_SIZE, GLX_RED_SIZE, GLX_ALPHA_SIZE, GLX_RED_SIZE, GLX_DOUBLEBUFFER, GLX_DEPTH_SIZE, 24, GLX_STENCIL_SIZE, GLX_RED_SIZE, GLX_X_VISUAL_TYPE, GLX_DIRECT_COLOR, 0)) = ([37179128, 34, 0, 24, 5, 16711680, 65280, 255, 256, 8])
+ glXCreateContext(37134976, ([37179128, 34, 0, 24, 5, 16711680, 65280, 255, 256, 8]), 0, True) = 37241648
+ glXMakeCurrent(37134976, 41943041, 37241648) = True
+ glViewport(0, 0, 64, 64)
+ glMatrixMode(GL_PROJECTION)
+ glLoadIdentity()
+ glOrtho(0.0, 64.0, 64.0, 0.0, 0.0, 1.0)
+ glMatrixMode(GL_MODELVIEW)
+ glClearColor(0.0, 0.0, 1.0, 1.0)
+ glClear((GL_COLOR_BUFFER_BIT))
+ glXSwapBuffers(37134976, 41943041)
+ glCreateShader(GL_VERTEX_SHADER) = 7
+ glShaderSource(7, 1, ('void main()\n{\n gl_Position = ftransform();\n}\n'), 0)
+ glCompileShader(7)
+ glCreateShader(GL_FRAGMENT_SHADER) = 8
+ glShaderSource(8, 1, ('#version 120\nuniform vec4 color;\nvoid main()\n{\n gl_FragColor = color;\n}\n'), 0)
+ glCompileShader(8)
+ glCreateProgram() = 9
+ glAttachShader(9, 7)
+ glAttachShader(9, 8)
+ glLinkProgram(9)
+ glUseProgram(9)
+ glGetUniformLocation(9, color) = 0
+ glUniform4f(0, 0.0, 1.0, 0.0, 1.0)
+ glBegin(GL_QUADS)
+ glVertex2f(0.0, 0.0)
+ glVertex2f(64.0, 0.0)
+ glVertex2f(64.0, 64.0)
+ glVertex2f(0.0, 64.0)
+ glEnd()
+ glUseProgram(0)
+ glXSwapBuffers(37134976, 41943041)
+- glGenTextures(1, (1))
+ glBindTexture(GL_TEXTURE_2D, 1)
+- glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, blob(3))
+ glEnable(GL_TEXTURE_2D)
+- glBegin(GL_QUADS)
+- glTexCoord2f(0.0, 0.0)
+- glVertex2f(0.0, 0.0)
+- glTexCoord2f(1.0, 0.0)
+- glVertex2f(64.0, 0.0)
+- glTexCoord2f(1.0, 1.0)
+- glVertex2f(64.0, 64.0)
+- glTexCoord2f(0.0, 1.0)
+- glVertex2f(0.0, 64.0)
+- glEnd()
+ glDisable(GL_TEXTURE_2D)
+- glXSwapBuffers(37134976, 41943041)
+ glClearColor(1.0, 0.0, 0.0, 1.0)
+ glClear((GL_COLOR_BUFFER_BIT))
+ glXSwapBuffers(37134976, 41943041)
+ glCreateShader(GL_VERTEX_SHADER) = 10
+ glShaderSource(10, 1, ('void main()\n{\n gl_Position = ftransform();\n}\n'), 0)
+ glCompileShader(10)
+ glCreateShader(GL_FRAGMENT_SHADER) = 11
+ glShaderSource(11, 1, ('#version 120\nuniform vec4 color;\nvoid main()\n{\n gl_FragColor = color;\n}\n'), 0)
+ glCompileShader(11)
+ glCreateProgram() = 12
+ glAttachShader(12, 10)
+ glAttachShader(12, 11)
+ glLinkProgram(12)
+ glUseProgram(12)
+ glGetUniformLocation(12, color) = 0
+ glUniform4f(0, 1.0, 0.0, 1.0, 1.0)
+ glBegin(GL_QUADS)
+ glVertex2f(0.0, 0.0)
+ glVertex2f(64.0, 0.0)
+ glVertex2f(64.0, 64.0)
+ glVertex2f(0.0, 64.0)
+ glEnd()
+ glUseProgram(0)
+ glXSwapBuffers(37134976, 41943041)
+ glGenTextures(1, (2))
+ glBindTexture(GL_TEXTURE_2D, 2)
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, blob(3))
+ glEnable(GL_TEXTURE_2D)
+ glBegin(GL_QUADS)
+ glTexCoord2f(0.0, 0.0)
+ glVertex2f(0.0, 0.0)
+ glTexCoord2f(1.0, 0.0)
+ glVertex2f(64.0, 0.0)
+ glTexCoord2f(1.0, 1.0)
+ glVertex2f(64.0, 64.0)
+ glTexCoord2f(0.0, 1.0)
+ glVertex2f(0.0, 64.0)
+ glEnd()
+ glDisable(GL_TEXTURE_2D)
+ glXSwapBuffers(37134976, 41943041)
+ glXDestroyContext(37134976, 37241648)
+"""
# Generate output images for all frames in the trimmed trace
rm_and_mkdir glxsimple-out
-apitrace dump-images --call-nos=no -o ./glxsimple-out/ glxsimple-trim.trace
+apitrace dump-images --call-nos=no -o ./glxsimple-out/ glxsimple-trim-unused-textures.trace
# Compare output to reference images
apitrace diff-images -v ./glxsimple-ref ./glxsimple-out
-expect "Comparing ./glxsimple-ref/0000000000.png and ./glxsimple-out/0000000000.png ... MATCH\nComparing ./glxsimple-ref/0000000001.png and ./glxsimple-out/0000000001.png ... MATCH\nComparing ./glxsimple-ref/0000000002.png and ./glxsimple-out/0000000002.png ... MATCH\nComparing ./glxsimple-ref/0000000003.png and ./glxsimple-out/0000000003.png ... MATCH\nComparing ./glxsimple-ref/0000000004.png and ./glxsimple-out/0000000004.png ... MATCH\n"
+expect r"""Comparing ./glxsimple-ref/0000000000.png and ./glxsimple-out/0000000000.png ... MATCH
+Comparing ./glxsimple-ref/0000000001.png and ./glxsimple-out/0000000001.png ... MATCH
+Comparing ./glxsimple-ref/0000000002.png and ./glxsimple-out/0000000002.png ... MATCH
+Comparing ./glxsimple-ref/0000000003.png and ./glxsimple-out/0000000003.png ... MATCH
+Comparing ./glxsimple-ref/0000000004.png and ./glxsimple-out/0000000004.png ... MATCH
+"""