From: Danylo Piliaiev Date: Mon, 30 Dec 2019 13:51:12 +0000 (+0200) Subject: osmesa/tests: Cover OSMESA_RGB GL_UNSIGNED_BYTE case X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=75c50d03422eb6a74f462419015a697f371468d6;p=mesa.git osmesa/tests: Cover OSMESA_RGB GL_UNSIGNED_BYTE case Signed-off-by: Danylo Piliaiev Reviewed-by: Eric Anholt Part-of: --- 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) { 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 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 );