Valve games use GL_SRGB8 textures. Instead of supporting that properly, we fell back to MESA_FORMAT_R8G8B8A8_SRGB (with an alpha channel), which meant that we had to use texture swizzling to override the alpha to 1.0 when sampling. This meant shader recompiles on Gen < 7.5 platforms.
By supporting MESA_FORMAT_R8G8B8X8_SRGB, the hardware just returns 1.0 for us, so we can just use SWIZZLE_XYZW, and avoid any recompiles. All generations of hardware have supported the format for sampling and filtering; we can easily support rendering by using the R8G8B8A8_SRGB format and writing garbage to the X channel. (We do this already for the non-SRGB version of this format.) This removes all remaining shader recompiles in a time demo of "Counter Strike: Global Offensive" (32 -> 0) on Sandybridge. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=87886 Signed-off-by: Kenneth Graunke <kenn...@whitecape.org> --- src/mesa/drivers/dri/i965/brw_surface_formats.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) I thought about hooking up BGRX, but texformat.c does: RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8X8_SRGB); RETURN_IF_SUPPORTED(MESA_FORMAT_R8G8B8A8_SRGB); RETURN_IF_SUPPORTED(MESA_FORMAT_BGR_SRGB8); RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB); RETURN_IF_SUPPORTED(MESA_FORMAT_X8B8G8R8_SRGB); RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB); It never checks MESA_FORMAT_B8G8R8X8_SRGB, which is odd. I could add that, but it still prefers RGBA over BGR/BGRX/XBGR...which I assume is because of ARB_texture_view restrictions, but I haven't thought about it much. At any rate, R8G8B8A8_SRGB is supported by hardware, and seems to work okay... diff --git a/src/mesa/drivers/dri/i965/brw_surface_formats.c b/src/mesa/drivers/dri/i965/brw_surface_formats.c index 2841f81..7261c01 100644 --- a/src/mesa/drivers/dri/i965/brw_surface_formats.c +++ b/src/mesa/drivers/dri/i965/brw_surface_formats.c @@ -518,7 +518,7 @@ brw_format_for_mesa_format(mesa_format mesa_format) [MESA_FORMAT_B4G4R4X4_UNORM] = 0, [MESA_FORMAT_B5G5R5X1_UNORM] = BRW_SURFACEFORMAT_B5G5R5X1_UNORM, [MESA_FORMAT_R8G8B8X8_SNORM] = 0, - [MESA_FORMAT_R8G8B8X8_SRGB] = 0, + [MESA_FORMAT_R8G8B8X8_SRGB] = BRW_SURFACEFORMAT_R8G8B8X8_UNORM_SRGB, [MESA_FORMAT_X8B8G8R8_SRGB] = 0, [MESA_FORMAT_RGBX_UINT8] = 0, [MESA_FORMAT_RGBX_SINT8] = 0, @@ -595,6 +595,9 @@ brw_init_surface_formats(struct brw_context *brw) case BRW_SURFACEFORMAT_R8G8B8X8_UNORM: render = BRW_SURFACEFORMAT_R8G8B8A8_UNORM; break; + case BRW_SURFACEFORMAT_R8G8B8X8_UNORM_SRGB: + render = BRW_SURFACEFORMAT_R8G8B8A8_UNORM_SRGB; + break; } rinfo = &surface_formats[render]; -- 2.2.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev