summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTopi Pohjolainen <topi.pohjolainen@intel.com>2017-07-15 12:15:37 +0300
committerTopi Pohjolainen <topi.pohjolainen@intel.com>2017-07-18 21:58:40 +0300
commit4e65dbecff480d5380db59398bc7af7eef742929 (patch)
treeadcf74db6267a64a23163ccd3ac6482ddf1a390f
parent28aa631f0a85b99dd9425158ed47a7fbc0cb8d26 (diff)
ext_framebuffer_multisample: Use full value range for integer formatsmsaa_wide
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
-rw-r--r--tests/spec/ext_framebuffer_multisample/draw-buffers-common.cpp39
-rw-r--r--tests/util/sized-internalformats.h8
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