2 * Copyright (C) 2014 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26 * Common utility functions for the ARB_shader_image_load_store tests.
29 #ifndef __PIGLIT_ARB_SHADER_IMAGE_LOAD_STORE_COMMON_H__
30 #define __PIGLIT_ARB_SHADER_IMAGE_LOAD_STORE_COMMON_H__
34 #include "piglit-util-gl.h"
37 * Report the result of a subtest using a more convenient syntax.
39 #define subtest(status, guard, result, ...) do { \
40 enum piglit_result _status = (!(guard) ? PIGLIT_SKIP : \
41 (result) ? PIGLIT_PASS : \
44 piglit_report_subtest_result(_status, __VA_ARGS__); \
46 if (_status == PIGLIT_FAIL) \
47 *status = PIGLIT_FAIL; \
51 * Set an integer uniform to the specified value.
54 set_uniform_int(GLuint prog
, const char *name
, int value
);
57 * Accessor for the texture object bound to the specified image unit.
60 get_texture(unsigned unit
);
63 * Accessor for the buffer object bound to the specified image unit.
66 get_buffer(unsigned unit
);
69 * Upload \a pixels to an image of the specified format and
70 * dimensionality, and bind it to the specified image unit.
73 upload_image(const struct image_info img
, unsigned unit
,
74 const uint32_t *pixels
);
77 * Analogous to upload_image(), but in addition it may be used to
78 * specify \a num_levels mipmap levels for the same texture at once.
79 * Level \a level will be bound to the given image unit.
82 upload_image_levels(const struct image_info img
, unsigned num_levels
,
83 unsigned level
, unsigned unit
,
84 const uint32_t *pixels
);
87 * Download the image bound to the specified image unit into
91 download_image(const struct image_info img
, unsigned unit
,
95 * Analogous to download_image(), but in addition it may be used to
96 * download \a num_levels mipmap levels at once from the same image.
99 download_image_levels(const struct image_info img
, unsigned num_levels
,
100 unsigned unit
, uint32_t *r_pixels
);
103 * Initialize a two-dimensional array of pixels to the specified
107 init_pixels(const struct image_info img
, uint32_t *pixels
,
108 double r
, double g
, double b
, double a
);
111 * Check that all elements from a two-dimensional array of pixels
112 * equal the specified constant value.
115 check_pixels(const struct image_info img
, const uint32_t *pixels
,
116 double r
, double g
, double b
, double a
);
119 * Check that two two-dimensional arrays of pixels are equal.
122 check_pixels_v(const struct image_info img
,
123 const uint32_t *pixels
,
124 const uint32_t *expect
);
127 * Initialize and clear the framebuffer, or an image read-back buffer
128 * when using the compute stage.
131 init_fb(const struct grid_info grid
);
134 * Download the contents of the framebuffer, or the image read-back
135 * buffer when using the compute stage.
138 download_result(const struct grid_info grid
, uint32_t *r_pixels
);