From 775a8790750a28d7c39cd1ff54f62b90edc8ad2d Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 15 Aug 2012 11:16:52 -0700 Subject: [PATCH] glxsimple: Introduce an inter-frame texture dependency to exercise trim code The previous glxsimple program was too simple as each frame was entirely self-contained, (textures were created, initialized, and referenced only within single frames). For more realistic trimming, we create and initialize a texture in one frame, then reference that texture in a later frame. This is a better test to ensure that when trimming the first frame the texture creation and initialization is not discarded. --- cli/src/glxsimple.c | 33 +++++++++++++++++++++++++-------- trim_stress/glxsimple.trace | Bin 42592 -> 42689 bytes 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/cli/src/glxsimple.c b/cli/src/glxsimple.c index b29fa9e..a4c9560 100644 --- a/cli/src/glxsimple.c +++ b/cli/src/glxsimple.c @@ -118,11 +118,11 @@ paint_rgb_using_glsl (double r, double g, double b) glUseProgram (0); } -static void -paint_rgb_using_texture (double r, double g, double b) +static GLuint +create_rgb_texture (double r, double g, double b) { uint8_t data[3]; - GLuint texture; + GLuint texture = 0; data[0] = (uint8_t) (255.0 * r); data[1] = (uint8_t) (255.0 * g); @@ -137,6 +137,14 @@ paint_rgb_using_texture (double r, double g, double b) 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, data); + return texture; +} + +static void +paint_using_texture (GLuint texture) +{ + glBindTexture (GL_TEXTURE_2D, texture); + glEnable (GL_TEXTURE_2D); draw_fullscreen_textured_quad (); @@ -147,8 +155,10 @@ paint_rgb_using_texture (double r, double g, double b) static void draw (Display *dpy, Window window, int width, int height) { +#define PASSES 2 int i; GLenum glew_err; + GLuint texture[PASSES]; int visual_attr[] = { GLX_RGBA, @@ -184,23 +194,30 @@ draw (Display *dpy, Window window, int width, int height) #define RGB(frame) (((frame+1)/4) % 2), (((frame+1)/2) % 2), ((frame+1) % 2) int frame = 0; - for (i = 0; i < 2; i++) { - /* Frame: Draw a solid (magenta) frame using glClear. */ + for (i = 0; i < PASSES; i++) { + + /* Frame: Draw a solid frame using glClear. */ paint_rgb_using_clear (RGB(frame)); glXSwapBuffers (dpy, window); frame++; - /* Frame: Draw a solid (yellow) frame using GLSL. */ + /* Frame: Draw a solid frame using GLSL. */ paint_rgb_using_glsl (RGB(frame)); glXSwapBuffers (dpy, window); frame++; - /* Frame: Draw a solid (cyan) frame using a texture. */ - paint_rgb_using_texture (RGB(frame)); + /* Frame: Draw a solid frame using a texture. */ + texture[i] = create_rgb_texture (RGB(frame)); + paint_using_texture (texture[i]); glXSwapBuffers (dpy, window); frame++; } + /* Draw another frame with a re-used texture. */ + paint_using_texture (texture[0]); + glXSwapBuffers (dpy, window); + frame++; + /* Cleanup */ glXDestroyContext (dpy, ctx); } diff --git a/trim_stress/glxsimple.trace b/trim_stress/glxsimple.trace index 9c22592ea950878603fb42b10027f191edc315f8..162de4df36e4d729390801ab31b80a8695fe217a 100644 GIT binary patch delta 696 zcmXw%ZAep57{~w5-3#|_ceaTxuMoJ*YIV1KucmJ8Zq6(-cYCwaYN;)0HPb-_$tEQB zHHP#;L`4()l*6F1Rt#AXl#n3wMF^x%5(Uy1KV)ZxU(Wv=o^yV1e$Vsm6PNwW@uAq8 z3E=+19ll2M{iQkWZqR8mGv?$?-GFA|ojLha=b-ZGP5SW%23980jwBN0({CSN($G}W z{>%~AWu(S30+jK+Ws9+%R9uX|t)+ z91LFPs;Wm_dRjDq>ZM4|RkWMa8UY~!V{zn-M8UWtndclXNN8{w{{_5c_jkWqG~zpAB~KwA_r=9jcf9GAU;xic}z?6Xh~DF zw#M!q473Anp(Rs0YrrAr212{y(a-`8D@$OSJ0y8{7C~mX0V)$4x{D)uzd;<8^ zd>>mEeB2(!iO_8EJUZ2W!bz7vte+D{;fWAEFf+|p3nDsDMXbDF;{e45R!RQTN^h$QJ&~0SH6ubU=Lz!uc JO(W~|-nHw$EGt`P7WQy6k?iJ77gQ9R zpw(*)dyoPbnGiiVq$o^6;r0*(;*$h|Jq1A&^dLlJzaDxz=kWa=4(D^u{6}H+gTTz> z*{8tQrF*POv_C01z1ATa`j!4%tPOKY_BiSHLc>$!g}{*O>%t)fvjYI`ft@`yndg%|PYrS-X!_3DW%i$yvB# zn|?)|*qxh@-JojKvcrKILCOPM7V`3~KVfG)?8F}Bj+_VDYlnTHeY|%C-?Cp=N+zPm z*q>V?pO5Rc$gUL-BpGzzN>=8fZt^`9%uPYhO__FM8(*^~L!jI!qGj&{95f1rkd2rc zJa-p{5k#yB^}OgpLrWJLl~*!AO>s#;^XQqes4RdEjYcnDmH6C^Xh{u+RR8#*7+7ED zzQg9CrO0U(~&@+@AOkA%|^k;AQH@Ic7+nc=hVs(pWnm-Gu6Mq37 C29&!1 -- 2.43.0