Пример #1
0
static bool
check(const struct grid_info grid, const struct image_info img, unsigned l)
{
        const unsigned layer_sz = 4 * product(grid.size);
        uint32_t pixels_fb[4 * N], expect_fb[4 * N];
        uint32_t pixels_img[4 * N], expect_img[4 * N];
        unsigned i;

        if (!download_result(grid, pixels_fb) ||
            !download_image(img, 0, pixels_img))
                return false;

        for (i = 0; i < layer_sz; ++i) {
                /*
                 * The framebuffer contents should reflect layer l of
                 * the image which is bound to the image unit.
                 */
                expect_fb[i] = encode(grid.format, layer_sz * l + i);
        }

        for (i = 0; i < 4 * N; ++i) {
                if (i / layer_sz == l) {
                        /*
                         * Layer l should have been modified by the
                         * shader.
                         */
                        expect_img[i] = encode(img.format, 33);
                } else {
                        /*
                         * Other layers should have remained
                         * unchanged.
                         */
                        expect_img[i] = encode(img.format, i);
                }
        }

        if (!check_pixels_v(image_info_for_grid(grid), pixels_fb, expect_fb)) {
                printf("  Source: framebuffer\n");
                return false;
        }

        if (!check_pixels_v(img, pixels_img, expect_img)) {
                printf("  Source: image\n");
                return false;
        }

        return true;
}
Пример #2
0
static bool
check(const struct grid_info grid, const struct image_info img)
{
        const int n = num_images_for_stages(grid, ~0);
        const int m = max_image_units();
        uint32_t pixels[N], expect[N];
        int i;

        for (i = 0; i < N; ++i) {
                if (i < m) {
                        /*
                         * The sum at this location is just the number
                         * of times that the image with index i was
                         * bound to the pipeline.
                         */
                        expect[i] = (n - i + m - 1) / m;
                } else {
                        /*
                         * No image has a non-zero value at this
                         * location, so the sum is zero.
                         */
                        expect[i] = 0;
                }
        }

        return download_result(grid, pixels) &&
                check_pixels_v(img, pixels, expect);
}
Пример #3
0
static bool
check(const struct grid_info grid, const struct image_info img)
{
        uint32_t pixels[4 * N], expect[4 * N];

        return init_image_pixels(img, 0, expect) &&
                download_image(img, 1, pixels) &&
                check_pixels_v(img, pixels, expect);
}
Пример #4
0
static bool
check(const struct image_info img)
{
        uint32_t pixels[N];
        uint32_t expect[N];
        int i;

        for (i = 0; i < N; ++i)
                expect[i] = (i > W ? 2 : 1) + (i % 2 ? -1 : 1);

        return download_image(img, 0, pixels) &&
                check_pixels_v(img, pixels, expect);
}
Пример #5
0
static bool
check_derivative(const struct grid_info grid, const struct image_info img,
                 unsigned w, unsigned h)
{
        uint32_t pixels_fb[H][W], expect_fb[H][W];
        uint32_t pixels_img[H][W], expect_img[H][W];
        int i, j;

        for (i = 0; i < W; ++i) {
                for (j = 0; j < H; ++j) {
                        expect_fb[j][i] = (j < h && i < w ? 1000 :
                                           encode(get_image_format(GL_R32F), 0.5));
                        expect_img[j][i] = (j < h && i < w ? 1 : 0) + j;
                }
        }

        if (!download_result(grid, pixels_fb[0]) ||
            !download_image(img, 0, pixels_img[0]))
                return false;

        if (!check_pixels_v(img, pixels_fb[0], expect_fb[0])) {
                printf("  Source: framebuffer\n");
                /*
                 * Purely informational check, we don't care what the
                 * result is as long as derivatives are being
                 * calculated, don't fail if the result doesn't equal
                 * the expected value as it's most likely an accuracy
                 * issue.
                 */
        }

        if (!check_pixels_v(img, pixels_img[0], expect_img[0])) {
                printf("  Source: image\n");
                return false;
        }

        return true;
}
Пример #6
0
static bool
check_discard(const struct grid_info grid, const struct image_info img,
              unsigned w, unsigned h)
{
        uint32_t pixels[H][W], expect[H][W];
        int i, j;

        for (i = 0; i < W; ++i)
                for (j = 0; j < H; ++j)
                        expect[j][i] = (i % 5 == 0 ? 0 : 1) + j;

        return download_image(img, 0, pixels[0]) &&
                check_pixels_v(img, pixels[0], expect[0]);
}
Пример #7
0
static bool
check(const struct image_info img)
{
        const unsigned n = image_num_components(img.format) * product(img.size);
        uint32_t *pixels = malloc(sizeof(uint32_t) * n);
        uint32_t *expect = malloc(sizeof(uint32_t) * n);
        bool ret;
        int i;

        for (i = 0; i < n; ++i)
                expect[i] = encode(img.format, i);

        ret = download_image(img, 1, pixels) &&
                check_pixels_v(img, pixels, expect);

        free(expect);
        free(pixels);
        return ret;
}