From f3220bd6fb28b38e807677194275eeeaae855187 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 16 Sep 2019 18:50:01 +0100 Subject: [PATCH] Use more stable clear color for comparison * We need to allow for off-by-one errors in our color comparisons --- util/test/demos/gl/gl_parameter_zoo.cpp | 2 +- util/test/tests/GL/GL_Parameter_Zoo.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/util/test/demos/gl/gl_parameter_zoo.cpp b/util/test/demos/gl/gl_parameter_zoo.cpp index b6d1d9dc0..0bdd3e397 100644 --- a/util/test/demos/gl/gl_parameter_zoo.cpp +++ b/util/test/demos/gl/gl_parameter_zoo.cpp @@ -155,7 +155,7 @@ void main() glViewport(0, 0, GLsizei(screenWidth), GLsizei(screenHeight)); glScissor(0, 0, GLsizei(screenWidth), GLsizei(screenHeight)); - float col[] = {0.4f, 0.5f, 0.6f, 1.0f}; + float col[] = {1.0f, 0.0f, 1.0f, 1.0f}; glClearBufferfv(GL_COLOR, 0, col); glBindVertexArray(vao); diff --git a/util/test/tests/GL/GL_Parameter_Zoo.py b/util/test/tests/GL/GL_Parameter_Zoo.py index ebc264aea..329749bf9 100644 --- a/util/test/tests/GL/GL_Parameter_Zoo.py +++ b/util/test/tests/GL/GL_Parameter_Zoo.py @@ -17,13 +17,15 @@ class GL_Parameter_Zoo(rdtest.TestCase): data = self.controller.GetTextureData(id, 0, 0) first_pixel = struct.unpack_from("BBBB", data, 0) - val = [int(round(v * 255)) for v in rdtest.linear_to_SRGB([0.4, 0.5, 0.6, 1.0])] + val = [255, 0, 255, 255] if not rdtest.value_compare(first_pixel, val): raise rdtest.TestFailureException("First pixel should be clear color {}, not {}".format(val, first_pixel)) magic_pixel = struct.unpack_from("BBBB", data, (50 * tex_details.width + 320) * 4) - if not rdtest.value_compare(magic_pixel, [0, 0, 255, 127]): + # allow 127 or 128 for alpha + val = [0, 0, 255, magic_pixel[3]] + if not rdtest.value_compare(magic_pixel, val) or magic_pixel[3] not in [127, 128]: raise rdtest.TestFailureException("Pixel @ 320,50 should be blue: {}, not {}".format(val, magic_pixel)) rdtest.log.success("Decoded pixels from texture data are correct") @@ -43,7 +45,8 @@ class GL_Parameter_Zoo(rdtest.TestCase): magic_pixel = struct.unpack_from("BBBB", data[-1-50], 320 * 4) - if not rdtest.value_compare(magic_pixel, [0, 0, 255, 127]): + val = [0, 0, 255, magic_pixel[3]] + if not rdtest.value_compare(magic_pixel, val) or magic_pixel[3] not in [127, 128]: raise rdtest.TestFailureException("Pixel @ 320,50 should be blue: {}, not {}".format(val, magic_pixel)) draw = self.find_draw("Draw")