Signed-off-by: Topi Pohjolainen <topi.pohjolai...@intel.com> --- .../draw-buffers-common.cpp | 39 ++++++++++++++++------ tests/util/sized-internalformats.h | 8 +++++ 2 files changed, 36 insertions(+), 11 deletions(-)
diff --git a/tests/spec/ext_framebuffer_multisample/draw-buffers-common.cpp b/tests/spec/ext_framebuffer_multisample/draw-buffers-common.cpp index 7ca2e1d22..9c95af8a1 100644 --- a/tests/spec/ext_framebuffer_multisample/draw-buffers-common.cpp +++ b/tests/spec/ext_framebuffer_multisample/draw-buffers-common.cpp @@ -22,6 +22,7 @@ */ #include "draw-buffers-common.h" +#include "sized-internalformats.h" using namespace piglit_util_fbo; /** @@ -93,7 +94,6 @@ static bool is_dual_src_blending = false; static GLenum draw_buffer_zero_format; static const int num_components = 4; /* for RGBA formats */ -static const int num_color_bits = 8; /* for GL_RGBA & GL_RGBA8I formats */ static const float bg_depth = 0.8; static const float bg_color[4] = { @@ -303,11 +303,17 @@ free_data_arrays(void) expected_color = NULL; } -void -float_color_to_int_color(int *dst, float *src) +static void +float_color_to_int_color(int *dst, const float *src) { - float offset = 1 - (1 << (num_color_bits - 1)); - float scale = -2.0 * offset; + assert(is_buffer_zero_integer_format); + + const GLenum format = resolve_int_fbo.config.color_internalformat; + const struct sized_internalformat *sized_fmt = + get_sized_internalformat(format); + const unsigned num_color_bits = get_channel_size(sized_fmt, R); + const float offset = 1 - (1 << (num_color_bits - 1)); + const float scale = -2.0 * offset; for (int j = 0; j < num_rects; ++j) { for (int k = 0; k < num_components; ++k) { @@ -317,6 +323,22 @@ float_color_to_int_color(int *dst, float *src) } } +static void +int_color_to_float_color(float *image, unsigned size) +{ + assert(is_buffer_zero_integer_format); + + const GLenum format = resolve_int_fbo.config.color_internalformat; + const struct sized_internalformat *sized_fmt = + get_sized_internalformat(format); + const unsigned num_color_bits = get_channel_size(sized_fmt, R); + const float color_offset = 1.0 - (1 << (num_color_bits - 1)); + const float color_scale = -2.0 * color_offset; + + for (unsigned i = 0; i < size; ++i) + image[i] = (image[i] - color_offset) / color_scale; +} + void draw_pattern(bool sample_alpha_to_coverage, bool sample_alpha_to_one, @@ -732,13 +754,8 @@ draw_image_to_window_system_fb(int draw_buffer_count, bool rhs) image[i] = tmp[i]; } - /* Convert integer color data to float color data */ - float color_offset = 1.0 - (1 << (num_color_bits - 1)); - float color_scale = -2.0 * color_offset; + int_color_to_float_color(image, array_size); - for (unsigned i = 0; i < array_size; ++i) { - image[i] = (image[i] - color_offset) / color_scale; - } free(tmp); } else{ diff --git a/tests/util/sized-internalformats.h b/tests/util/sized-internalformats.h index e71abf564..9416c29b5 100644 --- a/tests/util/sized-internalformats.h +++ b/tests/util/sized-internalformats.h @@ -20,6 +20,10 @@ * IN THE SOFTWARE. */ +#ifdef __cplusplus +extern "C" { +#endif + /* F=float, UN=unsigned normalized, SN=signed normalized, I=int, * U=uint. * @@ -116,3 +120,7 @@ valid_for_gl_version(const struct required_format *format, int target_version); void setup_required_size_test(int argc, char **argv, struct piglit_gl_test_config *config); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif -- 2.11.0 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/piglit