diff options
author | Laura Ekstrand <laura@jlekstrand.net> | 2015-01-07 17:04:26 -0800 |
---|---|---|
committer | Laura Ekstrand <laura@jlekstrand.net> | 2015-03-09 16:20:43 -0700 |
commit | eed2aeff15bae55999d962883cdd4f3914120fab (patch) | |
tree | fa8b4bc76e57a794e2bb9cce401b29d7afd3181c | |
parent | cc5b2a8bae47ff862a0a1e96628107d4b15da93a (diff) |
arb_direct_state_access: gettextureimage-targets.c has display.
-rw-r--r-- | tests/spec/arb_direct_state_access/gettextureimage-targets.c | 65 |
1 files changed, 63 insertions, 2 deletions
diff --git a/tests/spec/arb_direct_state_access/gettextureimage-targets.c b/tests/spec/arb_direct_state_access/gettextureimage-targets.c index 7f5c51e03..73b4e5586 100644 --- a/tests/spec/arb_direct_state_access/gettextureimage-targets.c +++ b/tests/spec/arb_direct_state_access/gettextureimage-targets.c @@ -33,6 +33,7 @@ PIGLIT_GL_TEST_CONFIG_BEGIN + config.window_width = 216; config.supports_gl_compat_version = 10; config.window_visual = PIGLIT_GL_VISUAL_RGBA | @@ -43,6 +44,52 @@ PIGLIT_GL_TEST_CONFIG_END #define IMAGE_WIDTH 32 #define IMAGE_HEIGHT 32 #define IMAGE_SIZE (IMAGE_WIDTH * IMAGE_HEIGHT * 4) +#define DISPLAY_GAP 4 + +static void +show_image(GLubyte *data, int num_layers, const char *title) +{ + GLuint name; + int i; + char junk[50]; + + if (!piglit_automatic) { + /* Create the texture handle. */ + glCreateTextures(GL_TEXTURE_2D, 1, &name); + glTextureStorage2D(name, 1, GL_RGBA8, IMAGE_WIDTH, + IMAGE_HEIGHT); + glTextureParameteri(name, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTextureParameteri(name, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glEnable(GL_TEXTURE_2D); + glBindTextureUnit(0, name); + + /* Draw the layers, separated by some space */ + glClear(GL_COLOR_BUFFER_BIT); + for (i = 0; i < num_layers; ++i) { + int x = (IMAGE_WIDTH + DISPLAY_GAP) * (i % 6); + int y = (IMAGE_HEIGHT + DISPLAY_GAP) * (i / 6); + glTextureSubImage2D(name, 0, 0, 0, + IMAGE_WIDTH, IMAGE_HEIGHT, + GL_RGBA, GL_UNSIGNED_BYTE, + data + i * IMAGE_SIZE); + piglit_draw_rect_tex(x, y, IMAGE_WIDTH, IMAGE_HEIGHT, + 0, 0, 1, 1); + } + + /* Make the title. */ + printf("****** %s ******\n", title); + + piglit_present_results(); + + /* Pause. */ + printf("Enter any char to continue.\n>>>>>>"); + scanf("%s", junk); + printf("\n"); + + glDeleteTextures(1, &name); + } +} + static void init_layer_data(GLubyte *layer_data, int num_layers) @@ -56,8 +103,8 @@ init_layer_data(GLubyte *layer_data, int num_layers) for (y = 0; y < IMAGE_HEIGHT; y += 4) { int r = (x + 1) * 255 / (IMAGE_WIDTH - 1); int g = (y + 1) * 255 / (IMAGE_HEIGHT - 1); - int b = (z + 1) * 255 / (num_layers - 1); - int a = x ^ y ^ z; + int b = (z + 1) * 255 / (num_layers); + int a = 255; //x ^ y ^ z; /* each 4x4 block constains only one color (for S3TC) */ for (i = 0; i < 4; i++) { @@ -75,6 +122,10 @@ init_layer_data(GLubyte *layer_data, int num_layers) } } } + + /* Show the first layer of the completed layer data. */ + show_image(layer_data, num_layers, "Test Data"); + } static bool @@ -177,6 +228,10 @@ getTexImage(bool doPBO, GLenum target, GLubyte data[][IMAGE_SIZE], } + /* Show the initial data. */ + show_image(data[0], num_layers * num_faces, "Data Before Upload"); + + /* Setup the PBO or data array to read into from glGetTextureImage */ if (doPBO) { glGenBuffers(1, &packPBO); @@ -210,6 +265,9 @@ getTexImage(bool doPBO, GLenum target, GLubyte data[][IMAGE_SIZE], else dataGet = data2[0]; + /* Examine the image after pulling it off the graphics card. */ + show_image(dataGet, num_layers * num_faces, "Data After Download"); + for (i = 0; i < num_faces * num_layers; i++) { pass = compare_layer(i, layer_size, tolerance, dataGet, data[i]) && pass; @@ -271,6 +329,9 @@ piglit_init(int argc, char **argv) } if (!piglit_is_extension_supported("GL_ARB_texture_cube_map_array")) clear_target_mask(GL_TEXTURE_CUBE_MAP_ARRAY); + + glClearColor(0.5, 0.5, 0.5, 1); + piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); } enum piglit_result |