Example #1
0
enum piglit_result
piglit_display(void)
{
	GLboolean pass = GL_TRUE;

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	pass = test_basic();
	pass = test_negative_crop() && pass;
	pass = test_right_top_win() && pass;
	pass = test_right_top_crop() && pass;
	pass = test_depth() && pass;

	glFinish();
	piglit_present_results();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Example #2
0
int
main()
{
    cu_init();

    test_path("", NULL);
    test_path("/", "/");
    test_path(".", ".");
    test_path("./", ".");
    test_path("/.", "/");
    test_path("..", "..");
    test_path("../", "..");
    test_path("/..", NULL);
    test_path("../..", "../..");
    test_path(".//./", ".");
    test_path("..///.", "..");
    test_path("../..///", "../..");
    test_path("a", "a");
    test_path("a/", "a");
    test_path("/a", "/a");
    test_path("./a", "a");
    test_path("././a/.", "a");
    test_path("a/b", "a/b");
    test_path("/a/b/", "/a/b");
    test_path("//a//b//.", "/a/b");
    test_path("a/./b/./../.", "a");
    test_path("a/b/../..", ".");
    test_path("a/b/..//../../..", "../..");
    test_path("a/.././b", "b");
    test_path("a/../../b/..", "..");
    test_path("bla/blaa/", "bla/blaa");
    test_path("bla/blaa//", "bla/blaa");
    test_path("/bla", "/bla");
    test_path("//bla", "/bla");
    test_path("test/./bla", "test/bla");
    test_path("test/../bla", "bla");
    test_path("test/../../bla", "../bla");
    test_path("test/../../bla/be/../../..", "../..");
    test_split_join();

    test_join(".", "..", "..");
    test_join("a/b", "..", "a");
    test_join("a/b", "../..", ".");
    test_join("a/b", "../../..", "..");
    test_join("../a", "..", "..");
    test_join("../a", "../..", "../..");
    test_join(".", ".", ".");

    test_split("/", 0, ".", "/");
    test_split("/", 1, "/", ".");
    test_split(".", 0, ".", ".");
    test_split("a", 0, ".", "a");
    test_split("a", 1, "a", ".");
    test_split("a", -1, ".", "a");
    test_split("/a", 0, ".", "/a");
    test_split("/a", 1, "/", "a");
    test_split("/a", 2, "/a", ".");
    test_split("/a", -1, "/", "a");
    test_split("/a", -2, ".", "/a");
    test_split("../vu", 0, ".", "../vu");
    test_split("../vu", 1, "..", "vu");
    test_split("../vu", 2, "../vu", ".");
    test_split("../vu", -1, "..", "vu");
    test_split("../vu", -2, ".", "../vu");

    test_depth(".", 0, 0);
    test_depth("/", 1, 1);
    test_depth("a", 1, 1);
    test_depth("a/b", 2, 2);
    test_depth("..", -1, 1);
    test_depth("../..", -2, 2);
    test_depth("../a/b", 1, 3);
    test_depth("/al", 2, 2);

    return errors != 0;
}
Example #3
0
static void
paint (TestState *state)
{
  /* Sanity check a few of the different depth test functions
   * and that depth writing can be disabled... */

  {
    /* Closest */
    TestDepthState rect0_state = {
      0xff0000ff, /* rgba color */
      -10, /* depth */
      FALSE, /* depth test enable */
      COGL_DEPTH_TEST_FUNCTION_ALWAYS,
      TRUE, /* depth write enable */
      TRUE, /* FB depth write enable */
      0, 1 /* depth range */
    };
    /* Furthest */
    TestDepthState rect1_state = {
      0x00ff00ff, /* rgba color */
      -70, /* depth */
      TRUE, /* depth test enable */
      COGL_DEPTH_TEST_FUNCTION_ALWAYS,
      TRUE, /* depth write enable */
      TRUE, /* FB depth write enable */
      0, 1 /* depth range */
    };
    /* In the middle */
    TestDepthState rect2_state = {
      0x0000ffff, /* rgba color */
      -20, /* depth */
      TRUE, /* depth test enable */
      COGL_DEPTH_TEST_FUNCTION_NEVER,
      TRUE, /* depth write enable */
      TRUE, /* FB depth write enable */
      0, 1 /* depth range */
    };

    test_depth (state, 0, 0, /* position */
                &rect0_state, &rect1_state, &rect2_state,
                FALSE, /* legacy mode */
                0x00ff00ff); /* expected */

    rect2_state.test_function = COGL_DEPTH_TEST_FUNCTION_ALWAYS;
    test_depth (state, 1, 0, /* position */
                &rect0_state, &rect1_state, &rect2_state,
                FALSE, /* legacy mode */
                0x0000ffff); /* expected */

    rect2_state.test_function = COGL_DEPTH_TEST_FUNCTION_LESS;
    test_depth (state, 2, 0, /* position */
                &rect0_state, &rect1_state, &rect2_state,
                FALSE, /* legacy mode */
                0x0000ffff); /* expected */

    rect2_state.test_function = COGL_DEPTH_TEST_FUNCTION_GREATER;
    test_depth (state, 3, 0, /* position */
                &rect0_state, &rect1_state, &rect2_state,
                FALSE, /* legacy mode */
                0x00ff00ff); /* expected */

    rect0_state.test_enable = TRUE;
    rect1_state.write_enable = FALSE;
    test_depth (state, 4, 0, /* position */
                &rect0_state, &rect1_state, &rect2_state,
                FALSE, /* legacy mode */
                0x0000ffff); /* expected */

    rect1_state.write_enable = TRUE;
    rect1_state.fb_write_enable = FALSE;
    test_depth (state, 4, 0, /* position */
                &rect0_state, &rect1_state, &rect2_state,
                FALSE, /* legacy mode */
                0x0000ffff); /* expected */

    /* Re-enable FB depth writing to verify state flush */
    rect1_state.write_enable = TRUE;
    rect1_state.fb_write_enable = TRUE;
    test_depth (state, 4, 0, /* position */
                &rect0_state, &rect1_state, &rect2_state,
                FALSE, /* legacy mode */
                0x00ff00ff); /* expected */
  }

  /* Check that the depth buffer values can be mapped into different
   * ranges... */

  {
    /* Closest by depth, furthest by depth range */
    TestDepthState rect0_state = {
      0xff0000ff, /* rgba color */
      -10, /* depth */
      TRUE, /* depth test enable */
      COGL_DEPTH_TEST_FUNCTION_ALWAYS,
      TRUE, /* depth write enable */
      TRUE, /* FB depth write enable */
      0.5, 1 /* depth range */
    };
    /* Furthest by depth, nearest by depth range */
    TestDepthState rect1_state = {
      0x00ff00ff, /* rgba color */
      -70, /* depth */
      TRUE, /* depth test enable */
      COGL_DEPTH_TEST_FUNCTION_GREATER,
      TRUE, /* depth write enable */
      TRUE, /* FB depth write enable */
      0, 0.5 /* depth range */
    };

    test_depth (state, 0, 1, /* position */
                &rect0_state, &rect1_state, NULL,
                FALSE, /* legacy mode */
                0xff0000ff); /* expected */
  }

  /* Test that the legacy cogl_set_depth_test_enabled() API still
   * works... */

  {
    /* Nearest */
    TestDepthState rect0_state = {
      0xff0000ff, /* rgba color */
      -10, /* depth */
      FALSE, /* depth test enable */
      COGL_DEPTH_TEST_FUNCTION_LESS,
      TRUE, /* depth write enable */
      TRUE, /* FB depth write enable */
      0, 1 /* depth range */
    };
    /* Furthest */
    TestDepthState rect1_state = {
      0x00ff00ff, /* rgba color */
      -70, /* depth */
      FALSE, /* depth test enable */
      COGL_DEPTH_TEST_FUNCTION_LESS,
      TRUE, /* depth write enable */
      TRUE, /* FB depth write enable */
      0, 1 /* depth range */
    };

    cogl_set_depth_test_enabled (TRUE);
    test_depth (state, 0, 2, /* position */
                &rect0_state, &rect1_state, NULL,
                TRUE, /* legacy mode */
                0xff0000ff); /* expected */
    cogl_set_depth_test_enabled (FALSE);
    test_depth (state, 1, 2, /* position */
                &rect0_state, &rect1_state, NULL,
                TRUE, /* legacy mode */
                0x00ff00ff); /* expected */
  }
}
Example #4
0
static void
paint (TestState *state)
{
  /* Sanity check a few of the different depth test functions
   * and that depth writing can be disabled... */

  {
    /* Closest */
    TestDepthState rect0_state = {
      0xff0000ff, /* rgba color */
      -10, /* depth */
      false, /* depth test enable */
      CG_DEPTH_TEST_FUNCTION_ALWAYS,
      true, /* depth write enable */
      true, /* FB depth write enable */
      0, 1 /* depth range */
    };
    /* Furthest */
    TestDepthState rect1_state = {
      0x00ff00ff, /* rgba color */
      -70, /* depth */
      true, /* depth test enable */
      CG_DEPTH_TEST_FUNCTION_ALWAYS,
      true, /* depth write enable */
      true, /* FB depth write enable */
      0, 1 /* depth range */
    };
    /* In the middle */
    TestDepthState rect2_state = {
      0x0000ffff, /* rgba color */
      -20, /* depth */
      true, /* depth test enable */
      CG_DEPTH_TEST_FUNCTION_NEVER,
      true, /* depth write enable */
      true, /* FB depth write enable */
      0, 1 /* depth range */
    };

    test_depth (state, 0, 0, /* position */
                &rect0_state, &rect1_state, &rect2_state,
                0x00ff00ff); /* expected */

    rect2_state.test_function = CG_DEPTH_TEST_FUNCTION_ALWAYS;
    test_depth (state, 1, 0, /* position */
                &rect0_state, &rect1_state, &rect2_state,
                0x0000ffff); /* expected */

    rect2_state.test_function = CG_DEPTH_TEST_FUNCTION_LESS;
    test_depth (state, 2, 0, /* position */
                &rect0_state, &rect1_state, &rect2_state,
                0x0000ffff); /* expected */

    rect2_state.test_function = CG_DEPTH_TEST_FUNCTION_GREATER;
    test_depth (state, 3, 0, /* position */
                &rect0_state, &rect1_state, &rect2_state,
                0x00ff00ff); /* expected */

    rect0_state.test_enable = true;
    rect1_state.write_enable = false;
    test_depth (state, 4, 0, /* position */
                &rect0_state, &rect1_state, &rect2_state,
                0x0000ffff); /* expected */

    rect1_state.write_enable = true;
    rect1_state.fb_write_enable = false;
    test_depth (state, 4, 0, /* position */
                &rect0_state, &rect1_state, &rect2_state,
                0x0000ffff); /* expected */

    /* Re-enable FB depth writing to verify state flush */
    rect1_state.write_enable = true;
    rect1_state.fb_write_enable = true;
    test_depth (state, 4, 0, /* position */
                &rect0_state, &rect1_state, &rect2_state,
                0x00ff00ff); /* expected */
  }

  /* Check that the depth buffer values can be mapped into different
   * ranges... */

  {
    /* Closest by depth, furthest by depth range */
    TestDepthState rect0_state = {
      0xff0000ff, /* rgba color */
      -10, /* depth */
      true, /* depth test enable */
      CG_DEPTH_TEST_FUNCTION_ALWAYS,
      true, /* depth write enable */
      true, /* FB depth write enable */
      0.5, 1 /* depth range */
    };
    /* Furthest by depth, nearest by depth range */
    TestDepthState rect1_state = {
      0x00ff00ff, /* rgba color */
      -70, /* depth */
      true, /* depth test enable */
      CG_DEPTH_TEST_FUNCTION_GREATER,
      true, /* depth write enable */
      true, /* FB depth write enable */
      0, 0.5 /* depth range */
    };

    test_depth (state, 0, 1, /* position */
                &rect0_state, &rect1_state, NULL,
                0xff0000ff); /* expected */
  }
}