Re: [Piglit] [PATCH 3/3] depthstencil-render-miplevels: Present the results in non-auto mode.
Paul Berry writes: > On 26 February 2013 12:39, Eric Anholt wrote: > >> I tried to make the presentation be the data that was originally >> probed -- there's a second readpixels that's unfortunately, but we do >> use separate textures so that any workaround relayouts of the probed >> textures don't get tweaked in the process of displaying. >> > > I'm having trouble parsing this sentence. Can you explain further? Better? commit a01be8e55f6d4345df45d579677d4d4bfedbebbf Author: Eric Anholt Date: Tue Feb 26 12:23:52 2013 -0800 depthstencil-render-miplevels: Present the results in non-auto mode. I tried to make the presentation match the data that was originally probed out of the buffer. This means not using depth texturing, since on Intel that can trigger texture relayouts. I also left in use of the piglit probe functions for the auto path, so there are two separate readpixels calls on each level in the non-auto case where presentation happens. >> +/** >> + * Presents the results of the rendering on the screen. >> + */ >> +static void >> +render_results_to_screen() >> +{ >> + GLuint tex; >> + >> + printf("\n"); >> + printf("Depth is on the left, stencil is on the right.\n"); >> + printf("Colors should proceed from nearly-black to nearly-red.\n"); >> + >> + piglit_ortho_projection(piglit_width, piglit_height, false); >> > > This function draws an image whose width and height are 2*miplevel0_size. > Since the window size is 512x512, that means that the whole image won't > appear unless miplevel0_size is 256 or less (I believe this explains why > Chad didn't see the image he expected when running > "depthstencil-render-miplevels 1024 d=z24"). > > I'd be ok with a quick and dirty fix to this--for example, if you changed > this to do piglit_ortho_projection(2*miplevel0_size, 2*miplevel0_size, > false) in the case where miplevel0_size > 256, then the whole image would > appear in the window, but scaled down. It's hacky, but I think it would be > good enough for what you're trying to achieve here. Nice hack. I like it. >> + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); >> + glClearColor(0.5, 0.5, 0.5, 0.0); >> + glClear(GL_COLOR_BUFFER_BIT); >> + >> + glGenTextures(1, &tex); >> + glBindTexture(GL_TEXTURE_2D, tex); >> + >> + if (attach_depth) { >> + for (int level = 0; level <= max_miplevel; ++level) { >> + int dim = miplevel0_size >> level; >> + >> + glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, >> +dim, dim, >> +0, >> +GL_RED, GL_FLOAT, >> +depth_miplevel_data[level]); >> + if (!piglit_check_gl_error(GL_NO_ERROR)) >> + piglit_report_result(PIGLIT_FAIL); >> + } >> + >> + render_tex_to_screen(tex, 0, 1); >> > > Any particular reason the y coordinate is 1 rather than 0? No particularly great reason, other than having done so for many other tests like fbo-generatemipmap. pgpyI37ModDbg.pgp Description: PGP signature ___ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit
Re: [Piglit] [PATCH 3/3] depthstencil-render-miplevels: Present the results in non-auto mode.
On 26 February 2013 12:39, Eric Anholt wrote: > I tried to make the presentation be the data that was originally > probed -- there's a second readpixels that's unfortunately, but we do > use separate textures so that any workaround relayouts of the probed > textures don't get tweaked in the process of displaying. > I'm having trouble parsing this sentence. Can you explain further? > --- > tests/texturing/depthstencil-render-miplevels.cpp | 105 > - > 1 file changed, 102 insertions(+), 3 deletions(-) > > diff --git a/tests/texturing/depthstencil-render-miplevels.cpp > b/tests/texturing/depthstencil-render-miplevels.cpp > index b41fea8..2ffe07d 100644 > --- a/tests/texturing/depthstencil-render-miplevels.cpp > +++ b/tests/texturing/depthstencil-render-miplevels.cpp > @@ -90,8 +90,8 @@ PIGLIT_GL_TEST_CONFIG_BEGIN > > config.supports_gl_compat_version = 10; > > - config.window_width = 16; > - config.window_height = 16; > + config.window_width = 512; > + config.window_height = 512; > config.window_visual = PIGLIT_GL_VISUAL_RGBA; > > PIGLIT_GL_TEST_CONFIG_END > @@ -109,7 +109,8 @@ bool attach_stencil_first = false; > GLenum depth_format; > int miplevel0_size; > int max_miplevel; > - > +float **depth_miplevel_data; > +uint8_t **stencil_miplevel_data; > > /** > * Check if the given depth/stencil/rgba texture internal format is > supported. > @@ -260,6 +261,9 @@ populate_miplevel(int level) > /** > * Test that every pixel in the depth and stencil buffers (if present) > * is equal to the value set by populate_miplevel. > + * > + * If we're going to later render our results to the screen for > + * debugging, then save off a copy of the data we read now. > */ > bool > test_miplevel(int level) > @@ -272,6 +276,14 @@ test_miplevel(int level) > printf("Probing miplevel %d depth\n", level); > pass = piglit_probe_rect_depth(0, 0, dim, dim, float_value) > && pass; > + > + if (!piglit_automatic) { > + depth_miplevel_data[level] = > + (float *)malloc(4 * dim * dim); > + glReadPixels(0, 0, dim, dim, > +GL_DEPTH_COMPONENT, GL_FLOAT, > +depth_miplevel_data[level]); > + } > } > > if (attach_stencil) { > @@ -279,6 +291,14 @@ test_miplevel(int level) > pass = piglit_probe_rect_stencil(0, 0, dim, dim, > stencil_for_level(level)) > && pass; > + > + if (!piglit_automatic) { > + stencil_miplevel_data[level] = > + (uint8_t *)malloc(dim * dim); > + glReadPixels(0, 0, dim, dim, > +GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, > +stencil_miplevel_data[level]); > + } > } > > return pass; > @@ -332,6 +352,9 @@ piglit_init(int argc, char **argv) > while ((miplevel0_size >> (max_miplevel + 1)) > 0) > ++max_miplevel; > } > + depth_miplevel_data = (float **)calloc(max_miplevel, sizeof(float > *)); > + stencil_miplevel_data = (uint8_t **)calloc(max_miplevel, > + sizeof(uint8_t *)); > > /* argv[2]: buffer combination */ > if (strcmp(argv[2], "s=z24_s8") == 0) { > @@ -426,6 +449,79 @@ piglit_init(int argc, char **argv) > } > } > > +static void > +render_tex_to_screen(GLuint tex, int x, int y) > +{ > + glBindTexture(GL_TEXTURE_2D, tex); > + glEnable(GL_TEXTURE_2D); > + > + for (int level = 0; level <= max_miplevel; ++level) { > + int dim = miplevel0_size >> level; > + > + piglit_draw_rect_tex(x, y, dim, dim, > +0, 0, 1, 1); > + > + y += dim + 1; > + } > +} > + > +/** > + * Presents the results of the rendering on the screen. > + */ > +static void > +render_results_to_screen() > +{ > + GLuint tex; > + > + printf("\n"); > + printf("Depth is on the left, stencil is on the right.\n"); > + printf("Colors should proceed from nearly-black to nearly-red.\n"); > + > + piglit_ortho_projection(piglit_width, piglit_height, false); > This function draws an image whose width and height are 2*miplevel0_size. Since the window size is 512x512, that means that the whole image won't appear unless miplevel0_size is 256 or less (I believe this explains why Chad didn't see the image he expected when running "depthstencil-render-miplevels 1024 d=z24"). I'd be ok with a quick and dirty fix to this--for example, if you changed this to do piglit_ortho_projection(2*miplevel0_size, 2*miplevel0_size, false) in the case where mi
Re: [Piglit] [PATCH 3/3] depthstencil-render-miplevels: Present the results in non-auto mode.
On 02/26/2013 12:39 PM, Eric Anholt wrote: > I tried to make the presentation be the data that was originally > probed -- there's a second readpixels that's unfortunately, but we do ^^ Is "that's" a typo? > use separate textures so that any workaround relayouts of the probed > textures don't get tweaked in the process of displaying. This comment doesn't apply to all drivers, not even all Intel drivers, so please qualify the comment. > --- > tests/texturing/depthstencil-render-miplevels.cpp | 105 > - > 1 file changed, 102 insertions(+), 3 deletions(-) I applied your series on top of master and tested it on Sandybridge with `depthstencil-render-miplevels 1024 d=z24`. The window doesn't do the app says: "Colors should proceed from nearly-black to nearly-red". Is that expected? With PIGLIT_PLATFORM=x11_egl, the window is a solid dark red. With PIGLIT_PLATFORM=glx, the window content is garbage; it seems that swapbuffers doesn't happen (likely a bug in Piglit). ___ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit
[Piglit] [PATCH 3/3] depthstencil-render-miplevels: Present the results in non-auto mode.
I tried to make the presentation be the data that was originally probed -- there's a second readpixels that's unfortunately, but we do use separate textures so that any workaround relayouts of the probed textures don't get tweaked in the process of displaying. --- tests/texturing/depthstencil-render-miplevels.cpp | 105 - 1 file changed, 102 insertions(+), 3 deletions(-) diff --git a/tests/texturing/depthstencil-render-miplevels.cpp b/tests/texturing/depthstencil-render-miplevels.cpp index b41fea8..2ffe07d 100644 --- a/tests/texturing/depthstencil-render-miplevels.cpp +++ b/tests/texturing/depthstencil-render-miplevels.cpp @@ -90,8 +90,8 @@ PIGLIT_GL_TEST_CONFIG_BEGIN config.supports_gl_compat_version = 10; - config.window_width = 16; - config.window_height = 16; + config.window_width = 512; + config.window_height = 512; config.window_visual = PIGLIT_GL_VISUAL_RGBA; PIGLIT_GL_TEST_CONFIG_END @@ -109,7 +109,8 @@ bool attach_stencil_first = false; GLenum depth_format; int miplevel0_size; int max_miplevel; - +float **depth_miplevel_data; +uint8_t **stencil_miplevel_data; /** * Check if the given depth/stencil/rgba texture internal format is supported. @@ -260,6 +261,9 @@ populate_miplevel(int level) /** * Test that every pixel in the depth and stencil buffers (if present) * is equal to the value set by populate_miplevel. + * + * If we're going to later render our results to the screen for + * debugging, then save off a copy of the data we read now. */ bool test_miplevel(int level) @@ -272,6 +276,14 @@ test_miplevel(int level) printf("Probing miplevel %d depth\n", level); pass = piglit_probe_rect_depth(0, 0, dim, dim, float_value) && pass; + + if (!piglit_automatic) { + depth_miplevel_data[level] = + (float *)malloc(4 * dim * dim); + glReadPixels(0, 0, dim, dim, +GL_DEPTH_COMPONENT, GL_FLOAT, +depth_miplevel_data[level]); + } } if (attach_stencil) { @@ -279,6 +291,14 @@ test_miplevel(int level) pass = piglit_probe_rect_stencil(0, 0, dim, dim, stencil_for_level(level)) && pass; + + if (!piglit_automatic) { + stencil_miplevel_data[level] = + (uint8_t *)malloc(dim * dim); + glReadPixels(0, 0, dim, dim, +GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, +stencil_miplevel_data[level]); + } } return pass; @@ -332,6 +352,9 @@ piglit_init(int argc, char **argv) while ((miplevel0_size >> (max_miplevel + 1)) > 0) ++max_miplevel; } + depth_miplevel_data = (float **)calloc(max_miplevel, sizeof(float *)); + stencil_miplevel_data = (uint8_t **)calloc(max_miplevel, + sizeof(uint8_t *)); /* argv[2]: buffer combination */ if (strcmp(argv[2], "s=z24_s8") == 0) { @@ -426,6 +449,79 @@ piglit_init(int argc, char **argv) } } +static void +render_tex_to_screen(GLuint tex, int x, int y) +{ + glBindTexture(GL_TEXTURE_2D, tex); + glEnable(GL_TEXTURE_2D); + + for (int level = 0; level <= max_miplevel; ++level) { + int dim = miplevel0_size >> level; + + piglit_draw_rect_tex(x, y, dim, dim, +0, 0, 1, 1); + + y += dim + 1; + } +} + +/** + * Presents the results of the rendering on the screen. + */ +static void +render_results_to_screen() +{ + GLuint tex; + + printf("\n"); + printf("Depth is on the left, stencil is on the right.\n"); + printf("Colors should proceed from nearly-black to nearly-red.\n"); + + piglit_ortho_projection(piglit_width, piglit_height, false); + + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + glClearColor(0.5, 0.5, 0.5, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + glGenTextures(1, &tex); + glBindTexture(GL_TEXTURE_2D, tex); + + if (attach_depth) { + for (int level = 0; level <= max_miplevel; ++level) { + int dim = miplevel0_size >> level; + + glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, +dim, dim, +0, +GL_RED, GL_FLOAT, +depth_miplevel_data[level]); + if (!piglit_check_gl_error(GL_NO_ERROR)) + piglit_report_result(PIGLIT_FAIL); + } + + render_tex_to_scree