Mesa (master): osmesa/tests: Cover OSMESA_RGB GL_UNSIGNED_BYTE case

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Feb 4 18:07:06 UTC 2020


Module: Mesa
Branch: master
Commit: 75c50d03422eb6a74f462419015a697f371468d6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=75c50d03422eb6a74f462419015a697f371468d6

Author: Danylo Piliaiev <danylo.piliaiev at globallogic.com>
Date:   Mon Dec 30 15:51:12 2019 +0200

osmesa/tests: Cover OSMESA_RGB GL_UNSIGNED_BYTE case

Signed-off-by: Danylo Piliaiev <danylo.piliaiev at globallogic.com>
Reviewed-by: Eric Anholt <eric at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3216>

---

 src/gallium/targets/osmesa/test-render.cpp | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/src/gallium/targets/osmesa/test-render.cpp b/src/gallium/targets/osmesa/test-render.cpp
index b31789abcd5..ab11f665f10 100644
--- a/src/gallium/targets/osmesa/test-render.cpp
+++ b/src/gallium/targets/osmesa/test-render.cpp
@@ -56,17 +56,27 @@ name_params(const testing::TestParamInfo<Params> params) {
 TEST_P(OSMesaRenderTestFixture, Render)
 {
    auto params = GetParam();
-   uint32_t pixel = 0;
+   const int w = 2, h = 2;
+   uint8_t pixels[w * h * 4] = { 0 };
    uint32_t expected;  // This should be green for the given color model
-   int w = 1, h = 1;
 
    std::unique_ptr<osmesa_context, decltype(&OSMesaDestroyContext)> ctx{
       OSMesaCreateContext(params[0], NULL), &OSMesaDestroyContext};
    ASSERT_TRUE(ctx);
 
-   auto ret = OSMesaMakeCurrent(ctx.get(), &pixel, params[1], w, h);
+   auto ret = OSMesaMakeCurrent(ctx.get(), &pixels, params[1], w, h);
    ASSERT_EQ(ret, GL_TRUE);
 
+   int bpp = 4;
+   switch (params[0]) {
+   case OSMESA_RGB:
+      bpp = 3;
+      break;
+   case OSMESA_RGB_565:
+      bpp = 2;
+      break;
+   }
+
    switch (params[0]) {
    case OSMESA_RGBA:
    case OSMESA_BGRA:
@@ -86,7 +96,12 @@ TEST_P(OSMesaRenderTestFixture, Render)
    glClear(GL_COLOR_BUFFER_BIT);
    glFinish();
 
-   ASSERT_EQ(expected, pixel);
+   for (unsigned i = 0; i < w * h; i++) {
+      uint32_t color = 0;
+      memcpy(&color, &pixels[i * bpp], bpp);
+
+      ASSERT_EQ(expected, color);
+   }
 }
 
 INSTANTIATE_TEST_CASE_P(
@@ -95,7 +110,8 @@ INSTANTIATE_TEST_CASE_P(
    testing::Values(
       Params{ OSMESA_RGBA, GL_UNSIGNED_BYTE },
       Params{ OSMESA_BGRA, GL_UNSIGNED_BYTE },
-      Params{ OSMESA_ARGB, GL_UNSIGNED_BYTE }
+      Params{ OSMESA_ARGB, GL_UNSIGNED_BYTE },
+      Params{ OSMESA_RGB, GL_UNSIGNED_BYTE }
    ),
    name_params
 );



More information about the mesa-commit mailing list