1 /* Copyright © 2012 Intel Corporation
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice (including the next
11 * paragraph) shall be included in all copies or substantial portions of the
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 * This file declares functions which can be utilized to develop new multisample
29 #include "piglit-util-gl.h"
30 #include "piglit-test-pattern.h"
31 #include "piglit-fbo.h"
37 TEST_TYPE_STENCIL_DRAW
,
38 TEST_TYPE_STENCIL_RESOLVE
,
40 TEST_TYPE_DEPTH_RESOLVE
,
44 * Fragment shader program we apply to the supersampled color buffer
45 * to produce the reference image. This program manually blends each
46 * 16x16 block of samples in the supersampled color buffer down to a
47 * single sample in the downsampled buffer.
52 void compile(int supersample_factor
);
53 void run(const piglit_util_fbo::Fbo
*src_fbo
,
54 int dest_width
, int dest_height
,
64 * Data structure for keeping track of statistics on pixel accuracy.
66 * We keep track of the number of pixels tested, and the sum of the
67 * squared error, so that we can summarize the RMS error at the
68 * conclusion of the test.
75 void record(float error
)
78 sum_squared_error
+= error
* error
;
85 bool is_better_than(double rms_error_threshold
);
89 double sum_squared_error
;
93 * This data structure wraps up all the data we need to keep track of
99 Test(piglit_util_test_pattern::TestPattern
*pattern
,
100 piglit_util_test_pattern::ManifestProgram
*manifest_program
,
101 bool test_resolve
, GLbitfield blit_type
, bool srgb
);
102 void init(int num_samples
, bool small
, bool combine_depth_stencil
,
103 int pattern_width
, int pattern_height
,
104 int supersample_factor
, GLenum filter_mode
);
106 void draw_test_image(piglit_util_fbo::Fbo
*fbo
);
107 void draw_to_default_framebuffer();
108 void draw_reference_image();
109 bool measure_accuracy();
112 * Fbo that we use to just draw test image
114 piglit_util_fbo::Fbo test_fbo
;
117 void resolve(piglit_util_fbo::Fbo
*fbo
, GLbitfield which_buffers
);
118 void downsample_color(int downsampled_width
, int downsampled_height
);
119 void show(piglit_util_fbo::Fbo
*src_fbo
, int x_offset
, int y_offset
);
120 void draw_pattern(int x_offset
, int y_offset
, int width
, int height
);
122 /** The test pattern to draw. */
123 piglit_util_test_pattern::TestPattern
*pattern
;
126 * The program to use to manifest depth or stencil into color,
127 * or NULL if we're just testing color rendering.
129 piglit_util_test_pattern::ManifestProgram
*manifest_program
;
132 * True if we are testing the resolve pass, so we should
133 * downsample before manifesting; false if we should manifest
134 * before downsampling.
139 * The buffer under test--this should be compatible with the
141 * glBlitFramebuffer--i.e. GL_COLOR_BUFFER_BIT,
142 * GL_STENCIL_BUFFER_BIT, or GL_DEPTH_BUFFER_BIT.
144 GLbitfield blit_type
;
147 * Fbo that we perform MSAA rendering into.
149 piglit_util_fbo::Fbo multisample_fbo
;
152 * Single-sampled fbo that we blit into to force the
153 * implementation to resolve MSAA buffers.
155 piglit_util_fbo::Fbo resolve_fbo
;
158 * Large fbo that we perform high-resolution ("supersampled")
161 piglit_util_fbo::Fbo supersample_fbo
;
164 * Normal-sized fbo that we manually downsample the
165 * supersampled render result into, to create the reference
168 piglit_util_fbo::Fbo downsample_fbo
;
173 int supersample_factor
;
175 DownsampleProg downsample_prog
;
178 * Filter mode to use when downsampling the image
184 create_test(test_type_enum test_type
, int n_samples
, bool small
,
185 bool combine_depth_stencil
, int pattern_width
,
186 int pattern_height
, int supersample_factor
, GLenum filter_mode
);