ext_gpu_shader4: add compiler tests for everything
[piglit.git] / tests / spec / arb_shader_image_load_store / common.h
blob800a116f6b6335f764d49e8b41bd6e84e723c259
1 /*
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
13 * Software.
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
21 * IN THE SOFTWARE.
24 /** @file common.h
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__
32 #include "image.h"
33 #include "grid.h"
34 #include "piglit-util-gl.h"
36 /**
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 : \
42 PIGLIT_FAIL); \
44 piglit_report_subtest_result(_status, __VA_ARGS__); \
46 if (_status == PIGLIT_FAIL) \
47 *status = PIGLIT_FAIL; \
48 } while (0)
50 /**
51 * Set an integer uniform to the specified value.
53 bool
54 set_uniform_int(GLuint prog, const char *name, int value);
56 /**
57 * Accessor for the texture object bound to the specified image unit.
59 GLuint
60 get_texture(unsigned unit);
62 /**
63 * Accessor for the buffer object bound to the specified image unit.
65 GLuint
66 get_buffer(unsigned unit);
68 /**
69 * Upload \a pixels to an image of the specified format and
70 * dimensionality, and bind it to the specified image unit.
72 bool
73 upload_image(const struct image_info img, unsigned unit,
74 const uint32_t *pixels);
76 /**
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.
81 bool
82 upload_image_levels(const struct image_info img, unsigned num_levels,
83 unsigned level, unsigned unit,
84 const uint32_t *pixels);
86 /**
87 * Download the image bound to the specified image unit into
88 * \a r_pixels.
90 bool
91 download_image(const struct image_info img, unsigned unit,
92 uint32_t *r_pixels);
94 /**
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.
98 bool
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
104 * constant value.
106 bool
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.
114 bool
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.
121 bool
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.
130 bool
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.
137 bool
138 download_result(const struct grid_info grid, uint32_t *r_pixels);
140 #endif