]> git.sesse.net Git - movit/blob - test_util.cpp
30ba94a699eee1db954f98fac19b565f3f6c9aaa
[movit] / test_util.cpp
1 #include <assert.h>
2 #include <math.h>
3 #include <stdio.h>
4 #include <algorithm>
5 #include <epoxy/gl.h>
6 #include <gtest/gtest.h>
7 #include <gtest/gtest-message.h>
8
9 #include "flat_input.h"
10 #include "init.h"
11 #include "resource_pool.h"
12 #include "test_util.h"
13 #include "util.h"
14
15 using namespace std;
16
17 namespace movit {
18
19 class Input;
20
21 namespace {
22
23 // Not thread-safe, but this isn't a big problem for testing.
24 ResourcePool *get_static_pool()
25 {
26         static ResourcePool *resource_pool = nullptr;
27         if (!resource_pool) {
28                 resource_pool = new ResourcePool();
29         }
30         return resource_pool;
31 }
32
33 // Flip upside-down to compensate for different origin.
34 template<class T>
35 void vertical_flip(T *data, unsigned width, unsigned height)
36 {
37         for (unsigned y = 0; y < height / 2; ++y) {
38                 unsigned flip_y = height - y - 1;
39                 for (unsigned x = 0; x < width; ++x) {
40                         swap(data[y * width + x], data[flip_y * width + x]);
41                 }
42         }
43 }
44
45 void init_movit_for_test()
46 {
47        CHECK(init_movit(".", MOVIT_DEBUG_OFF));
48 }
49
50 }  // namespace
51
52 EffectChainTester::EffectChainTester(const float *data, unsigned width, unsigned height,
53                                      MovitPixelFormat pixel_format, Colorspace color_space, GammaCurve gamma_curve,
54                                      GLenum framebuffer_format)
55         : chain(width, height, get_static_pool()),
56           width(width),
57           height(height),
58           framebuffer_format(framebuffer_format),
59           output_added(false),
60           finalized(false)
61 {
62         init_movit_for_test();
63
64         if (data != nullptr) {
65                 add_input(data, pixel_format, color_space, gamma_curve);
66         }
67 }
68
69 EffectChainTester::~EffectChainTester()
70 {
71 }
72
73 Input *EffectChainTester::add_input(const float *data, MovitPixelFormat pixel_format, Colorspace color_space, GammaCurve gamma_curve, int input_width, int input_height)
74 {
75         ImageFormat format;
76         format.color_space = color_space;
77         format.gamma_curve = gamma_curve;
78
79         if (input_width == -1) {
80                 input_width = width;
81         }
82         if (input_height == -1) {
83                 input_height = height;
84         }
85
86         FlatInput *input = new FlatInput(format, pixel_format, GL_FLOAT, input_width, input_height);
87         input->set_pixel_data(data);
88         chain.add_input(input);
89         return input;
90 }
91
92 Input *EffectChainTester::add_input(const fp16_int_t *data, MovitPixelFormat pixel_format, Colorspace color_space, GammaCurve gamma_curve, int input_width, int input_height)
93 {
94         ImageFormat format;
95         format.color_space = color_space;
96         format.gamma_curve = gamma_curve;
97
98         if (input_width == -1) {
99                 input_width = width;
100         }
101         if (input_height == -1) {
102                 input_height = height;
103         }
104
105         FlatInput *input = new FlatInput(format, pixel_format, GL_HALF_FLOAT, input_width, input_height);
106         input->set_pixel_data_fp16(data);
107         chain.add_input(input);
108         return input;
109 }
110
111 Input *EffectChainTester::add_input(const unsigned char *data, MovitPixelFormat pixel_format, Colorspace color_space, GammaCurve gamma_curve, int input_width, int input_height)
112 {
113         ImageFormat format;
114         format.color_space = color_space;
115         format.gamma_curve = gamma_curve;
116
117         if (input_width == -1) {
118                 input_width = width;
119         }
120         if (input_height == -1) {
121                 input_height = height;
122         }
123
124         FlatInput *input = new FlatInput(format, pixel_format, GL_UNSIGNED_BYTE, input_width, input_height);
125         input->set_pixel_data(data);
126         chain.add_input(input);
127         return input;
128 }
129
130 void EffectChainTester::run(float *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
131 {
132         internal_run<float>(out_data, nullptr, nullptr, nullptr, format, color_space, gamma_curve, alpha_format);
133 }
134
135 void EffectChainTester::run(float *out_data, float *out_data2, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
136 {
137         internal_run<float>(out_data, out_data2, nullptr, nullptr, format, color_space, gamma_curve, alpha_format);
138 }
139
140 void EffectChainTester::run(float *out_data, float *out_data2, float *out_data3, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
141 {
142         internal_run<float>(out_data, out_data2, out_data3, nullptr, format, color_space, gamma_curve, alpha_format);
143 }
144
145 void EffectChainTester::run(float *out_data, float *out_data2, float *out_data3, float *out_data4, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
146 {
147         internal_run(out_data, out_data2, out_data3, out_data4, format, color_space, gamma_curve, alpha_format);
148 }
149
150 void EffectChainTester::run(unsigned char *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
151 {
152         internal_run<unsigned char>(out_data, nullptr, nullptr, nullptr, format, color_space, gamma_curve, alpha_format);
153 }
154
155 void EffectChainTester::run(unsigned char *out_data, unsigned char *out_data2, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
156 {
157         internal_run<unsigned char>(out_data, out_data2, nullptr, nullptr, format, color_space, gamma_curve, alpha_format);
158 }
159
160 void EffectChainTester::run(unsigned char *out_data, unsigned char *out_data2, unsigned char *out_data3, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
161 {
162         internal_run<unsigned char>(out_data, out_data2, out_data3, nullptr, format, color_space, gamma_curve, alpha_format);
163 }
164
165 void EffectChainTester::run(unsigned char *out_data, unsigned char *out_data2, unsigned char *out_data3, unsigned char *out_data4, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
166 {
167         internal_run(out_data, out_data2, out_data3, out_data4, format, color_space, gamma_curve, alpha_format);
168 }
169
170 void EffectChainTester::run(uint16_t *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
171 {
172         internal_run<uint16_t>(out_data, nullptr, nullptr, nullptr, format, color_space, gamma_curve, alpha_format);
173 }
174
175 void EffectChainTester::run_10_10_10_2(uint32_t *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
176 {
177         internal_run<uint32_t>(out_data, nullptr, nullptr, nullptr, format, color_space, gamma_curve, alpha_format);
178 }
179
180 #ifdef HAVE_BENCHMARK
181
182 void EffectChainTester::benchmark(benchmark::State &state, float *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
183 {
184         internal_run<float>(out_data, nullptr, nullptr, nullptr, format, color_space, gamma_curve, alpha_format, &state);
185 }
186
187 void EffectChainTester::benchmark(benchmark::State &state, float *out_data, float *out_data2, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
188 {
189         internal_run<float>(out_data, out_data2, nullptr, nullptr, format, color_space, gamma_curve, alpha_format, &state);
190 }
191
192 void EffectChainTester::benchmark(benchmark::State &state, float *out_data, float *out_data2, float *out_data3, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
193 {
194         internal_run<float>(out_data, out_data2, out_data3, nullptr, format, color_space, gamma_curve, alpha_format, &state);
195 }
196
197 void EffectChainTester::benchmark(benchmark::State &state, float *out_data, float *out_data2, float *out_data3, float *out_data4, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
198 {
199         internal_run(out_data, out_data2, out_data3, out_data4, format, color_space, gamma_curve, alpha_format, &state);
200 }
201
202 void EffectChainTester::benchmark(benchmark::State &state, fp16_int_t *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
203 {
204         internal_run<fp16_int_t>(out_data, nullptr, nullptr, nullptr, format, color_space, gamma_curve, alpha_format, &state);
205 }
206
207 void EffectChainTester::benchmark(benchmark::State &state, fp16_int_t *out_data, fp16_int_t *out_data2, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
208 {
209         internal_run<fp16_int_t>(out_data, out_data2, nullptr, nullptr, format, color_space, gamma_curve, alpha_format, &state);
210 }
211
212 void EffectChainTester::benchmark(benchmark::State &state, fp16_int_t *out_data, fp16_int_t *out_data2, fp16_int_t *out_data3, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
213 {
214         internal_run<fp16_int_t>(out_data, out_data2, out_data3, nullptr, format, color_space, gamma_curve, alpha_format, &state);
215 }
216
217 void EffectChainTester::benchmark(benchmark::State &state, fp16_int_t *out_data, fp16_int_t *out_data2, fp16_int_t *out_data3, fp16_int_t *out_data4, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
218 {
219         internal_run(out_data, out_data2, out_data3, out_data4, format, color_space, gamma_curve, alpha_format, &state);
220 }
221
222 void EffectChainTester::benchmark(benchmark::State &state, unsigned char *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
223 {
224         internal_run<unsigned char>(out_data, nullptr, nullptr, nullptr, format, color_space, gamma_curve, alpha_format, &state);
225 }
226
227 void EffectChainTester::benchmark(benchmark::State &state, unsigned char *out_data, unsigned char *out_data2, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
228 {
229         internal_run<unsigned char>(out_data, out_data2, nullptr, nullptr, format, color_space, gamma_curve, alpha_format, &state);
230 }
231
232 void EffectChainTester::benchmark(benchmark::State &state, unsigned char *out_data, unsigned char *out_data2, unsigned char *out_data3, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
233 {
234         internal_run<unsigned char>(out_data, out_data2, out_data3, nullptr, format, color_space, gamma_curve, alpha_format, &state);
235 }
236
237 void EffectChainTester::benchmark(benchmark::State &state, unsigned char *out_data, unsigned char *out_data2, unsigned char *out_data3, unsigned char *out_data4, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
238 {
239         internal_run(out_data, out_data2, out_data3, out_data4, format, color_space, gamma_curve, alpha_format, &state);
240 }
241
242 void EffectChainTester::benchmark(benchmark::State &state, uint16_t *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
243 {
244         internal_run<uint16_t>(out_data, nullptr, nullptr, nullptr, format, color_space, gamma_curve, alpha_format, &state);
245 }
246
247 void EffectChainTester::benchmark_10_10_10_2(benchmark::State &state, uint32_t *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
248 {
249         internal_run<uint32_t>(out_data, nullptr, nullptr, nullptr, format, color_space, gamma_curve, alpha_format, &state);
250 }
251
252 #endif
253
254 template<class T>
255 void EffectChainTester::internal_run(T *out_data, T *out_data2, T *out_data3, T *out_data4, GLenum format, Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format
256 #ifdef HAVE_BENCHMARK
257 , benchmark::State *benchmark_state
258 #endif
259 )
260 {
261         if (!finalized) {
262                 finalize_chain(color_space, gamma_curve, alpha_format);
263         }
264
265         GLuint type;
266         if (framebuffer_format == GL_RGBA8) {
267                 type = GL_UNSIGNED_BYTE;
268         } else if (framebuffer_format == GL_RGBA16) {
269                 type = GL_UNSIGNED_SHORT;
270         } else if (framebuffer_format == GL_RGBA16F && sizeof(T) == 2) {
271                 type = GL_HALF_FLOAT;
272         } else if (framebuffer_format == GL_RGBA16F || framebuffer_format == GL_RGBA32F) {
273                 type = GL_FLOAT;
274         } else if (framebuffer_format == GL_RGB10_A2) {
275                 type = GL_UNSIGNED_INT_2_10_10_10_REV;
276         } else {
277                 // Add more here as needed.
278                 assert(false);
279         }
280
281         unsigned num_outputs;
282         if (out_data4 != nullptr) {
283                 num_outputs = 4;
284         } else if (out_data3 != nullptr) {
285                 num_outputs = 3;
286         } else if (out_data2 != nullptr) {
287                 num_outputs = 2;
288         } else {
289                 num_outputs = 1;
290         }
291
292         glActiveTexture(GL_TEXTURE0);
293         check_error();
294
295         vector<EffectChain::DestinationTexture> textures;
296         for (unsigned i = 0; i < num_outputs; ++i) {
297                 GLuint texnum = chain.get_resource_pool()->create_2d_texture(framebuffer_format, width, height);
298                 textures.push_back(EffectChain::DestinationTexture{texnum, framebuffer_format});
299
300                 // The output texture needs to have valid state to be written to by a compute shader.
301                 glBindTexture(GL_TEXTURE_2D, texnum);
302                 check_error();
303                 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
304                 check_error();
305         }
306
307         chain.render_to_texture(textures, width, height);
308
309 #ifdef HAVE_BENCHMARK
310         // If running benchmarks: Now we've warmed up everything, so let's run the
311         // actual benchmark loop.
312         if (benchmark_state != nullptr) {
313                 glFinish();
314                 size_t iters = benchmark_state->max_iterations;
315                 for (auto _ : *benchmark_state) {
316                         chain.render_to_texture(textures, width, height);
317                         if (--iters == 0) {
318                                 glFinish();
319                         }
320                 }
321                 benchmark_state->SetItemsProcessed(benchmark_state->iterations() * width * height);
322         }
323 #endif
324
325         T *data[4] = { out_data, out_data2, out_data3, out_data4 };
326
327         for (unsigned i = 0; i < num_outputs; ++i) {
328                 T *ptr = data[i];
329                 glBindTexture(GL_TEXTURE_2D, textures[i].texnum);
330                 check_error();
331                 if (!epoxy_is_desktop_gl() && (format == GL_RED || format == GL_BLUE || format == GL_ALPHA)) {
332                         // GLES will only read GL_RGBA.
333                         T *temp = new T[width * height * 4];
334                         glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, type, temp);
335                         check_error();
336                         if (format == GL_ALPHA) {
337                                 for (unsigned i = 0; i < width * height; ++i) {
338                                         ptr[i] = temp[i * 4 + 3];
339                                 }
340                         } else if (format == GL_BLUE) {
341                                 for (unsigned i = 0; i < width * height; ++i) {
342                                         ptr[i] = temp[i * 4 + 2];
343                                 }
344                         } else {
345                                 for (unsigned i = 0; i < width * height; ++i) {
346                                         ptr[i] = temp[i * 4];
347                                 }
348                         }
349                         delete[] temp;
350                 } else {
351                         glGetTexImage(GL_TEXTURE_2D, 0, format, type, ptr);
352                         check_error();
353                 }
354
355                 if (format == GL_RGBA && (type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_SHORT || type == GL_FLOAT)) {
356                         vertical_flip(ptr, width * 4, height);
357                 } else {
358                         vertical_flip(ptr, width, height);
359                 }
360         }
361
362         for (unsigned i = 0; i < num_outputs; ++i) {
363                 chain.get_resource_pool()->release_2d_texture(textures[i].texnum);
364         }
365 }
366
367 void EffectChainTester::add_output(const ImageFormat &format, OutputAlphaFormat alpha_format)
368 {
369         chain.add_output(format, alpha_format);
370         output_added = true;
371 }
372
373 void EffectChainTester::add_ycbcr_output(const ImageFormat &format, OutputAlphaFormat alpha_format, const YCbCrFormat &ycbcr_format, YCbCrOutputSplitting output_splitting, GLenum type)
374 {
375         chain.add_ycbcr_output(format, alpha_format, ycbcr_format, output_splitting, type);
376         output_added = true;
377 }
378
379 void EffectChainTester::finalize_chain(Colorspace color_space, GammaCurve gamma_curve, OutputAlphaFormat alpha_format)
380 {
381         assert(!finalized);
382         if (!output_added) {
383                 ImageFormat image_format;
384                 image_format.color_space = color_space;
385                 image_format.gamma_curve = gamma_curve;
386                 chain.add_output(image_format, alpha_format);
387                 output_added = true;
388         }
389         chain.finalize();
390         finalized = true;
391 }
392
393 void expect_equal(const float *ref, const float *result, unsigned width, unsigned height, float largest_difference_limit, float rms_limit)
394 {
395         float largest_difference = -1.0f;
396         float squared_difference = 0.0f;
397         int largest_diff_x = -1, largest_diff_y = -1;
398
399         for (unsigned y = 0; y < height; ++y) {
400                 for (unsigned x = 0; x < width; ++x) {
401                         float diff = ref[y * width + x] - result[y * width + x];
402                         if (fabs(diff) > largest_difference) {
403                                 largest_difference = fabs(diff);
404                                 largest_diff_x = x;
405                                 largest_diff_y = y;
406                         }
407                         squared_difference += diff * diff;
408                 }
409         }
410
411         EXPECT_LT(largest_difference, largest_difference_limit)
412                 << "Largest difference is in x=" << largest_diff_x << ", y=" << largest_diff_y << ":\n"
413                 << "Reference: " << ref[largest_diff_y * width + largest_diff_x] << "\n"
414                 << "Result:    " << result[largest_diff_y * width + largest_diff_x];
415
416         float rms = sqrt(squared_difference) / (width * height);
417         EXPECT_LT(rms, rms_limit);
418
419         if (largest_difference >= largest_difference_limit || isnan(rms) || rms >= rms_limit) {
420                 fprintf(stderr, "Dumping matrices for easier debugging, since at least one test failed.\n");
421
422                 fprintf(stderr, "Reference:\n");
423                 for (unsigned y = 0; y < height; ++y) {
424                         for (unsigned x = 0; x < width; ++x) {
425                                 fprintf(stderr, "%7.4f ", ref[y * width + x]);
426                         }
427                         fprintf(stderr, "\n");
428                 }
429
430                 fprintf(stderr, "\nResult:\n");
431                 for (unsigned y = 0; y < height; ++y) {
432                         for (unsigned x = 0; x < width; ++x) {
433                                 fprintf(stderr, "%7.4f ", result[y * width + x]);
434                         }
435                         fprintf(stderr, "\n");
436                 }
437         }
438 }
439
440 void expect_equal(const unsigned char *ref, const unsigned char *result, unsigned width, unsigned height, unsigned largest_difference_limit, float rms_limit)
441 {
442         assert(width > 0);
443         assert(height > 0);
444
445         float *ref_float = new float[width * height];
446         float *result_float = new float[width * height];
447
448         for (unsigned y = 0; y < height; ++y) {
449                 for (unsigned x = 0; x < width; ++x) {
450                         ref_float[y * width + x] = ref[y * width + x];
451                         result_float[y * width + x] = result[y * width + x];
452                 }
453         }
454
455         expect_equal(ref_float, result_float, width, height, largest_difference_limit, rms_limit);
456
457         delete[] ref_float;
458         delete[] result_float;
459 }
460
461 void expect_equal(const uint16_t *ref, const uint16_t *result, unsigned width, unsigned height, unsigned largest_difference_limit, float rms_limit)
462 {
463         assert(width > 0);
464         assert(height > 0);
465
466         float *ref_float = new float[width * height];
467         float *result_float = new float[width * height];
468
469         for (unsigned y = 0; y < height; ++y) {
470                 for (unsigned x = 0; x < width; ++x) {
471                         ref_float[y * width + x] = ref[y * width + x];
472                         result_float[y * width + x] = result[y * width + x];
473                 }
474         }
475
476         expect_equal(ref_float, result_float, width, height, largest_difference_limit, rms_limit);
477
478         delete[] ref_float;
479         delete[] result_float;
480 }
481
482 void expect_equal(const int *ref, const int *result, unsigned width, unsigned height, unsigned largest_difference_limit, float rms_limit)
483 {
484         assert(width > 0);
485         assert(height > 0);
486
487         float *ref_float = new float[width * height];
488         float *result_float = new float[width * height];
489
490         for (unsigned y = 0; y < height; ++y) {
491                 for (unsigned x = 0; x < width; ++x) {
492                         ref_float[y * width + x] = ref[y * width + x];
493                         result_float[y * width + x] = result[y * width + x];
494                 }
495         }
496
497         expect_equal(ref_float, result_float, width, height, largest_difference_limit, rms_limit);
498
499         delete[] ref_float;
500         delete[] result_float;
501 }
502
503 void test_accuracy(const float *expected, const float *result, unsigned num_values, double absolute_error_limit, double relative_error_limit, double local_relative_error_limit, double rms_limit)
504 {
505         double squared_difference = 0.0;
506         for (unsigned i = 0; i < num_values; ++i) {
507                 double absolute_error = fabs(expected[i] - result[i]);
508                 squared_difference += absolute_error * absolute_error;
509                 EXPECT_LT(absolute_error, absolute_error_limit);
510
511                 if (expected[i] > 0.0) {
512                         double relative_error = fabs(absolute_error / expected[i]);
513
514                         EXPECT_LT(relative_error, relative_error_limit);
515                 }
516                 if (i < num_values - 1) {
517                         double delta = expected[i + 1] - expected[i];
518                         double local_relative_error = fabs(absolute_error / delta);
519                         EXPECT_LT(local_relative_error, local_relative_error_limit);
520                 }
521         }
522         double rms = sqrt(squared_difference) / num_values;
523         EXPECT_LT(rms, rms_limit);
524 }
525
526 double srgb_to_linear(double x)
527 {
528         // From the Wikipedia article on sRGB.
529         if (x < 0.04045) {
530                 return x / 12.92;
531         } else {
532                 return pow((x + 0.055) / 1.055, 2.4);
533         }
534 }
535
536 double linear_to_srgb(double x)
537 {
538         // From the Wikipedia article on sRGB.
539         if (x < 0.0031308) {
540                 return 12.92 * x;
541         } else {
542                 return 1.055 * pow(x, 1.0 / 2.4) - 0.055;
543         }
544 }
545
546 DisableComputeShadersTemporarily::DisableComputeShadersTemporarily(bool disable_compute_shaders)
547         : disable_compute_shaders(disable_compute_shaders)
548 {
549         init_movit_for_test();
550         saved_compute_shaders_supported = movit_compute_shaders_supported;
551         if (disable_compute_shaders) {
552                 movit_compute_shaders_supported = false;
553         }
554 }
555
556 DisableComputeShadersTemporarily::~DisableComputeShadersTemporarily()
557 {
558         movit_compute_shaders_supported = saved_compute_shaders_supported;
559 }
560
561 bool DisableComputeShadersTemporarily::should_skip()
562 {
563         if (disable_compute_shaders) {
564                 return false;
565         }
566
567         if (!movit_compute_shaders_supported) {
568                 fprintf(stderr, "Compute shaders not supported; skipping.\n");
569                 return true;
570         }
571         return false;
572 }
573
574 #ifdef HAVE_BENCHMARK
575 bool DisableComputeShadersTemporarily::should_skip(benchmark::State *benchmark_state)
576 {
577         if (disable_compute_shaders) {
578                 return false;
579         }
580
581         if (!movit_compute_shaders_supported) {
582                 benchmark_state->SkipWithError("Compute shaders not supported");
583                 return true;
584         }
585         return false;
586 }
587 #endif
588
589 }  // namespace movit