summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTomeu Vizoso <[email protected]>2018-06-22 15:59:09 +0200
committerGert Wollny <[email protected]>2018-07-02 09:33:41 +0200
commit71867a0a61cea20bf3f6115692e70b0d60f0b70d (patch)
treebf46ad8881e8fef298f54e19c76e08ed19d818b1 /src
parente5604ef78bd56fc136f00ee39003e3996bf23c80 (diff)
st/mesa: Fall back to R8G8B8A8_SRGB for ETC2
If the driver doesn't support PIPE_FORMAT_B8G8R8A8_SRGB, fall back to PIPE_FORMAT_R8G8B8A8_SRGB. Drivers such as Virgl will have a hard time supporting PIPE_FORMAT_B8G8R8A8_SRGB when the host runs GLES, as GL_BGRA isn't as well suported there. So go with PIPE_FORMAT_R8G8B8A8_SRGB so these drivers can avoid a conversion copy. v2: Fix typo in commit message Signed-off-by: Tomeu Vizoso <[email protected]> Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/state_tracker/st_format.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 418f5342025..9ae796eca9e 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -61,6 +61,12 @@ enum pipe_format
st_mesa_format_to_pipe_format(const struct st_context *st,
mesa_format mesaFormat)
{
+ struct pipe_screen *screen = st->pipe->screen;
+ bool has_bgra_srgb = screen->is_format_supported(screen,
+ PIPE_FORMAT_B8G8R8A8_SRGB,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_SAMPLER_VIEW);
+
switch (mesaFormat) {
case MESA_FORMAT_A8B8G8R8_UNORM:
return PIPE_FORMAT_ABGR8888_UNORM;
@@ -458,11 +464,13 @@ st_mesa_format_to_pipe_format(const struct st_context *st,
case MESA_FORMAT_ETC2_RGB8:
return st->has_etc2 ? PIPE_FORMAT_ETC2_RGB8 : PIPE_FORMAT_R8G8B8A8_UNORM;
case MESA_FORMAT_ETC2_SRGB8:
- return st->has_etc2 ? PIPE_FORMAT_ETC2_SRGB8 : PIPE_FORMAT_B8G8R8A8_SRGB;
+ return st->has_etc2 ? PIPE_FORMAT_ETC2_SRGB8 :
+ has_bgra_srgb ? PIPE_FORMAT_B8G8R8A8_SRGB : PIPE_FORMAT_R8G8B8A8_SRGB;
case MESA_FORMAT_ETC2_RGBA8_EAC:
return st->has_etc2 ? PIPE_FORMAT_ETC2_RGBA8 : PIPE_FORMAT_R8G8B8A8_UNORM;
case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC:
- return st->has_etc2 ? PIPE_FORMAT_ETC2_SRGBA8 : PIPE_FORMAT_B8G8R8A8_SRGB;
+ return st->has_etc2 ? PIPE_FORMAT_ETC2_SRGBA8 :
+ has_bgra_srgb ? PIPE_FORMAT_B8G8R8A8_SRGB : PIPE_FORMAT_R8G8B8A8_SRGB;
case MESA_FORMAT_ETC2_R11_EAC:
return st->has_etc2 ? PIPE_FORMAT_ETC2_R11_UNORM : PIPE_FORMAT_R16_UNORM;
case MESA_FORMAT_ETC2_RG11_EAC:
@@ -474,7 +482,8 @@ st_mesa_format_to_pipe_format(const struct st_context *st,
case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1:
return st->has_etc2 ? PIPE_FORMAT_ETC2_RGB8A1 : PIPE_FORMAT_R8G8B8A8_UNORM;
case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:
- return st->has_etc2 ? PIPE_FORMAT_ETC2_SRGB8A1 : PIPE_FORMAT_B8G8R8A8_SRGB;
+ return st->has_etc2 ? PIPE_FORMAT_ETC2_SRGB8A1 :
+ has_bgra_srgb ? PIPE_FORMAT_B8G8R8A8_SRGB : PIPE_FORMAT_R8G8B8A8_SRGB;
case MESA_FORMAT_RGBA_ASTC_4x4:
return PIPE_FORMAT_ASTC_4x4;