vrend: Add support for PIPE_FORMAT_A4B4G4R4_UNORM

and make sure that on GLES it it chosen for GL_RGBA4 over
VIRGL_FORMAT_B4G4R4A4_UNORM, by removing support for the latter.

This is needed because on GLES3 GL_BGRA isn't a supported format to pass
to glTexImage3D.

Fixes the test dEQP-GLES3.functional.texture.format.sized.3d.rgba4_pot
on GLES hosts.

v2: * Make more explicit the GL/GLES split (Gert Wollny)

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Suggested-by: Jakob Bornecrantz <jakob@collabora.com>
Reviewed-By: Gert Wollny <gert.wollny@collabora.com>
Tested-by: Jakob Bornecrantz <jakob@collabora.com>
macos/master
Tomeu Vizoso 7 years ago committed by Dave Airlie
parent ec1e384dd2
commit b27fa082de
  1. 1
      src/gallium/auxiliary/util/u_format.csv
  2. 2
      src/virgl_hw.h
  3. 21
      src/vrend_formats.c
  4. 4
      src/vrend_renderer.c
  5. 3
      src/vrend_renderer.h

@ -76,6 +76,7 @@ PIPE_FORMAT_B5G5R5X1_UNORM , plain, 1, 1, un5 , un5 , un5 , x1 , zyx1, r
PIPE_FORMAT_B5G5R5A1_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb, un1 , un5 , un5 , un5 , yzwx PIPE_FORMAT_B5G5R5A1_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb, un1 , un5 , un5 , un5 , yzwx
PIPE_FORMAT_B4G4R4A4_UNORM , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb, un4 , un4 , un4 , un4 , yzwx PIPE_FORMAT_B4G4R4A4_UNORM , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb, un4 , un4 , un4 , un4 , yzwx
PIPE_FORMAT_B4G4R4X4_UNORM , plain, 1, 1, un4 , un4 , un4 , x4 , zyx1, rgb, x4 , un4 , un4 , un4 , yzw1 PIPE_FORMAT_B4G4R4X4_UNORM , plain, 1, 1, un4 , un4 , un4 , x4 , zyx1, rgb, x4 , un4 , un4 , un4 , yzw1
PIPE_FORMAT_A4B4G4R4_UNORM , plain, 1, 1, un4 , un4 , un4 , un4 , wzyx, rgb, un4 , un4 , un4 , un4 , xyzw
PIPE_FORMAT_B5G6R5_UNORM , plain, 1, 1, un5 , un6 , un5 , , zyx1, rgb, un5 , un6 , un5 , , xyz1 PIPE_FORMAT_B5G6R5_UNORM , plain, 1, 1, un5 , un6 , un5 , , zyx1, rgb, un5 , un6 , un5 , , xyz1
PIPE_FORMAT_R10G10B10A2_UNORM , plain, 1, 1, un10, un10, un10, un2 , xyzw, rgb, un2 , un10, un10, un10, wzyx PIPE_FORMAT_R10G10B10A2_UNORM , plain, 1, 1, un10, un10, un10, un2 , xyzw, rgb, un2 , un10, un10, un10, wzyx
PIPE_FORMAT_R10G10B10X2_UNORM , plain, 1, 1, un10, un10, un10, x2, xyz1, rgb, x2 , un10, un10, un10, wzy1 PIPE_FORMAT_R10G10B10X2_UNORM , plain, 1, 1, un10, un10, un10, x2, xyz1, rgb, x2 , un10, un10, un10, wzy1

Can't render this file because it contains an unexpected character in line 8 and column 3.

@ -207,7 +207,7 @@ enum virgl_formats {
VIRGL_FORMAT_BPTC_RGB_UFLOAT = 258, VIRGL_FORMAT_BPTC_RGB_UFLOAT = 258,
VIRGL_FORMAT_R10G10B10X2_UNORM = 308, VIRGL_FORMAT_R10G10B10X2_UNORM = 308,
VIRGL_FORMAT_A4B4G4R4_UNORM = 311,
VIRGL_FORMAT_MAX, VIRGL_FORMAT_MAX,
}; };

@ -47,8 +47,8 @@ static struct vrend_format_table base_rgba_formats[] =
{ VIRGL_FORMAT_A8B8G8R8_UNORM, GL_RGBA8, GL_ABGR_EXT, GL_UNSIGNED_BYTE, NO_SWIZZLE }, { VIRGL_FORMAT_A8B8G8R8_UNORM, GL_RGBA8, GL_ABGR_EXT, GL_UNSIGNED_BYTE, NO_SWIZZLE },
{ VIRGL_FORMAT_B4G4R4A4_UNORM, GL_RGBA4, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, NO_SWIZZLE },
{ VIRGL_FORMAT_B4G4R4X4_UNORM, GL_RGBA4, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, RGB1_SWIZZLE }, { VIRGL_FORMAT_B4G4R4X4_UNORM, GL_RGBA4, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, RGB1_SWIZZLE },
{ VIRGL_FORMAT_A4B4G4R4_UNORM, GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, NO_SWIZZLE },
{ VIRGL_FORMAT_B5G5R5X1_UNORM, GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, RGB1_SWIZZLE }, { VIRGL_FORMAT_B5G5R5X1_UNORM, GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, RGB1_SWIZZLE },
{ VIRGL_FORMAT_B5G5R5A1_UNORM, GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, NO_SWIZZLE }, { VIRGL_FORMAT_B5G5R5A1_UNORM, GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, NO_SWIZZLE },
@ -60,6 +60,11 @@ static struct vrend_format_table base_rgba_formats[] =
{ VIRGL_FORMAT_R16G16B16A16_UNORM, GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, NO_SWIZZLE }, { VIRGL_FORMAT_R16G16B16A16_UNORM, GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, NO_SWIZZLE },
}; };
static struct vrend_format_table gl_base_rgba_formats[] =
{
{ VIRGL_FORMAT_B4G4R4A4_UNORM, GL_RGBA4, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, NO_SWIZZLE },
};
static struct vrend_format_table base_depth_formats[] = static struct vrend_format_table base_depth_formats[] =
{ {
{ VIRGL_FORMAT_Z16_UNORM, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, NO_SWIZZLE }, { VIRGL_FORMAT_Z16_UNORM, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, NO_SWIZZLE },
@ -352,7 +357,7 @@ static void vrend_add_formats(struct vrend_format_table *table, int num_entries)
#define add_formats(x) vrend_add_formats((x), ARRAY_SIZE((x))) #define add_formats(x) vrend_add_formats((x), ARRAY_SIZE((x)))
void vrend_build_format_list(void) void vrend_build_format_list_common(void)
{ {
add_formats(base_rgba_formats); add_formats(base_rgba_formats);
add_formats(base_depth_formats); add_formats(base_depth_formats);
@ -394,10 +399,18 @@ void vrend_build_format_list(void)
add_formats(bptc_formats); add_formats(bptc_formats);
} }
void vrend_build_format_list_gles(void)
void vrend_build_format_list_gl(void)
{ {
vrend_build_format_list(); /* We don't want VIRGL_FORMAT_B4G4R4A4_UNORM to be supported on GLES because
* it's not as well supported as VIRGL_FORMAT_A4B4G4R4_UNORM in some
* operations.
*/
add_formats(gl_base_rgba_formats);
}
void vrend_build_format_list_gles(void)
{
/* The BGR[A|X] formats is required but OpenGL ES does not /* The BGR[A|X] formats is required but OpenGL ES does not
* support rendering to it. Try to use GL_BGRA_EXT from the * support rendering to it. Try to use GL_BGRA_EXT from the
* GL_EXT_texture_format_BGRA8888 extension. But the * GL_EXT_texture_format_BGRA8888 extension. But the

@ -4276,10 +4276,12 @@ int vrend_renderer_init(struct vrend_if_cbs *cbs, uint32_t flags)
glDisable(GL_DEBUG_OUTPUT); glDisable(GL_DEBUG_OUTPUT);
} }
vrend_build_format_list_common();
if (vrend_state.use_gles) { if (vrend_state.use_gles) {
vrend_build_format_list_gles(); vrend_build_format_list_gles();
} else { } else {
vrend_build_format_list(); vrend_build_format_list_gl();
} }
/* disable for format testing */ /* disable for format testing */

@ -313,7 +313,8 @@ void vrend_renderer_fill_caps(uint32_t set, uint32_t version,
GLint64 vrend_renderer_get_timestamp(void); GLint64 vrend_renderer_get_timestamp(void);
void vrend_build_format_list(void); void vrend_build_format_list_common(void);
void vrend_build_format_list_gl(void);
void vrend_build_format_list_gles(void); void vrend_build_format_list_gles(void);
int vrend_renderer_resource_attach_iov(int res_handle, struct iovec *iov, int vrend_renderer_resource_attach_iov(int res_handle, struct iovec *iov,

Loading…
Cancel
Save