[virglrenderer-devel] [PATCH 3/3] vrend_formats: Pad three component textures to use four components

Gert Wollny gert.wollny at collabora.com
Wed Jun 20 09:02:26 UTC 2018


From: Gert Wollny <gw.fossdev at gmail.com>

Gallium doesn't use 3-cannel textures in some case and four channel textures
padded with a 1-component texture in other cases. The result is that when trying
to copy data between these textures on an Intel host guest gallium fires an
assertion in the blit routine, and on an r600 host some glCopyImageSubData
copying of sRGB to RGB fail. The latter happens because the copy uses the GL
copy emulation code path, and a shader would have to counter the effect of
converting sRGB to RGB when a memcopy like blit is exectued.
Instead use texture formats padded to four components for all cases of
three-component textures to make it possible to use glCopyImageSubData also
on the host.

This fixes the remaining failures for
  dEQP-GLES31.functional.copy_image.non_compressed.*

Signed-off-by: Gert Wollny <gert.wollny at collabora.com>
---
 src/virgl_hw.h      | 10 +++++++++-
 src/vrend_formats.c | 16 ++++++++--------
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/src/virgl_hw.h b/src/virgl_hw.h
index ba0f758..27b1a25 100644
--- a/src/virgl_hw.h
+++ b/src/virgl_hw.h
@@ -83,6 +83,7 @@ enum virgl_formats {
 
    VIRGL_FORMAT_L8_SRGB                 = 95,
    VIRGL_FORMAT_L8A8_SRGB               = 96,
+   VIRGL_FORMAT_R8G8B8_SRGB             = 97,
    VIRGL_FORMAT_B8G8R8A8_SRGB           = 100,
    VIRGL_FORMAT_B8G8R8X8_SRGB           = 101,
    VIRGL_FORMAT_R8G8B8A8_SRGB           = 104,
@@ -194,10 +195,17 @@ enum virgl_formats {
    VIRGL_FORMAT_R8G8B8X8_SNORM          = 229,
 
    VIRGL_FORMAT_R8G8B8X8_SRGB           = 230,
-
+   VIRGL_FORMAT_R8G8B8X8_UINT           = 231,
+   VIRGL_FORMAT_R8G8B8X8_SINT           = 232,
    VIRGL_FORMAT_B10G10R10X2_UNORM       = 233,
    VIRGL_FORMAT_R16G16B16X16_UNORM      = 234,
    VIRGL_FORMAT_R16G16B16X16_SNORM      = 235,
+   VIRGL_FORMAT_R16G16B16X16_FLOAT      = 236,
+   VIRGL_FORMAT_R16G16B16X16_UINT       = 237,
+   VIRGL_FORMAT_R16G16B16X16_SINT       = 238,
+   VIRGL_FORMAT_R32G32B32X32_FLOAT      = 239,
+   VIRGL_FORMAT_R32G32B32X32_UINT       = 240,
+   VIRGL_FORMAT_R32G32B32X32_SINT       = 241,
 
    VIRGL_FORMAT_R10G10B10A2_UINT        = 253,
 
diff --git a/src/vrend_formats.c b/src/vrend_formats.c
index d1653a4..0bb23c4 100644
--- a/src/vrend_formats.c
+++ b/src/vrend_formats.c
@@ -119,12 +119,12 @@ static struct vrend_format_table integer_base_formats[] = {
 };
 
 static struct vrend_format_table integer_3comp_formats[] = {
-  { VIRGL_FORMAT_R8G8B8_UINT, GL_RGB8UI, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, NO_SWIZZLE },
-  { VIRGL_FORMAT_R8G8B8_SINT, GL_RGB8I, GL_RGB_INTEGER, GL_BYTE, NO_SWIZZLE },
-  { VIRGL_FORMAT_R16G16B16_UINT, GL_RGB16UI, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, NO_SWIZZLE },
-  { VIRGL_FORMAT_R16G16B16_SINT, GL_RGB16I, GL_RGB_INTEGER, GL_SHORT, NO_SWIZZLE },
-  { VIRGL_FORMAT_R32G32B32_UINT, GL_RGB32UI, GL_RGB_INTEGER, GL_UNSIGNED_INT, NO_SWIZZLE },
-  { VIRGL_FORMAT_R32G32B32_SINT, GL_RGB32I, GL_RGB_INTEGER, GL_INT, NO_SWIZZLE },
+  { VIRGL_FORMAT_R8G8B8X8_UINT, GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, RGB1_SWIZZLE },
+  { VIRGL_FORMAT_R8G8B8X8_SINT, GL_RGBA8I, GL_RGBA_INTEGER, GL_BYTE, RGB1_SWIZZLE },
+  { VIRGL_FORMAT_R16G16B16X16_UINT, GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, RGB1_SWIZZLE },
+  { VIRGL_FORMAT_R16G16B16X16_SINT, GL_RGBA16I, GL_RGBA_INTEGER, GL_SHORT, RGB1_SWIZZLE },
+  { VIRGL_FORMAT_R32G32B32X32_UINT, GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT, RGB1_SWIZZLE },
+  { VIRGL_FORMAT_R32G32B32X32_SINT, GL_RGBA32I, GL_RGBA_INTEGER, GL_INT, RGB1_SWIZZLE },
 };
 
 static struct vrend_format_table float_base_formats[] = {
@@ -167,8 +167,8 @@ static struct vrend_format_table float_rg_formats[] = {
 };
 
 static struct vrend_format_table float_3comp_formats[] = {
-  { VIRGL_FORMAT_R16G16B16_FLOAT, GL_RGB16F, GL_RGB, GL_HALF_FLOAT, NO_SWIZZLE },
-  { VIRGL_FORMAT_R32G32B32_FLOAT, GL_RGB32F, GL_RGB, GL_FLOAT, NO_SWIZZLE },
+  { VIRGL_FORMAT_R16G16B16X16_FLOAT, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, RGB1_SWIZZLE },
+  { VIRGL_FORMAT_R32G32B32X32_FLOAT, GL_RGBA32F, GL_RGBA, GL_FLOAT, RGB1_SWIZZLE },
 };
 
 
-- 
2.16.4



More information about the virglrenderer-devel mailing list