etnaviv: add ext_texture_srgb support
authorChristian Gmeiner <christian.gmeiner@gmail.com>
Sat, 28 Oct 2017 15:24:58 +0000 (17:24 +0200)
committerChristian Gmeiner <christian.gmeiner@gmail.com>
Sat, 28 Oct 2017 19:20:42 +0000 (21:20 +0200)
Following piglits are passing:
 - glean@texture_srgb
 - spec@ext_texture_srgb@fbo-srgb
 - spec@ext_texture_srgb@tex-srgb
 - spec@ext_texture_srgb@texwrap formats
 - spec@ext_texture_srgb@texwrap formats-s3tc

Btw. this enables GL 2.1 :-)

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Wladimir J. van der Laan <laanwj@gmail.com>
src/gallium/drivers/etnaviv/etnaviv_format.c
src/gallium/drivers/etnaviv/etnaviv_screen.c
src/gallium/drivers/etnaviv/etnaviv_texture.c

index a2e215b439c3fe1bd14ea210a70457bd60a222bf..ac9b2d13b980297406afdeacdd36b946c3eb5fe1 100644 (file)
@@ -165,6 +165,8 @@ static struct etna_format formats[PIPE_FORMAT_COUNT] = {
 
    _T(B8G8R8A8_UNORM, A8R8G8B8, SWIZ(X, Y, Z, W), A8R8G8B8),
    _T(B8G8R8X8_UNORM, X8R8G8B8, SWIZ(X, Y, Z, W), X8R8G8B8),
+   _T(B8G8R8A8_SRGB,  A8R8G8B8, SWIZ(X, Y, Z, W), A8R8G8B8),
+   _T(B8G8R8X8_SRGB,  X8R8G8B8, SWIZ(X, Y, Z, W), X8R8G8B8),
 
    V_(R10G10B10A2_UNORM,   UNSIGNED_INT_10_10_10_2, NONE),
    V_(R10G10B10A2_SNORM,   INT_10_10_10_2,          NONE),
@@ -225,8 +227,11 @@ static struct etna_format formats[PIPE_FORMAT_COUNT] = {
    _T(ETC1_RGB8, ETC1, SWIZ(X, Y, Z, W), NONE),
 
    _T(DXT1_RGB,  DXT1,      SWIZ(X, Y, Z, W), NONE),
+   _T(DXT1_SRGBA,DXT1,      SWIZ(X, Y, Z, W), NONE),
    _T(DXT1_RGBA, DXT1,      SWIZ(X, Y, Z, W), NONE),
+   _T(DXT3_SRGBA,DXT2_DXT3, SWIZ(X, Y, Z, W), NONE),
    _T(DXT3_RGBA, DXT2_DXT3, SWIZ(X, Y, Z, W), NONE),
+   _T(DXT5_SRGBA,DXT4_DXT5, SWIZ(X, Y, Z, W), NONE),
    _T(DXT5_RGBA, DXT4_DXT5, SWIZ(X, Y, Z, W), NONE),
 
    _T(ETC2_RGB8,       EXT_NONE | EXT_FORMAT,                          SWIZ(X, Y, Z, W), NONE), /* Extd. format NONE doubles as ETC2_RGB8 */
index 009bc73c14abfab239ebd8b58a1fd9b1f946a5aa..4f55c2a96f6e07f9e3f070310a81cdea8d49a9ab 100644 (file)
@@ -482,6 +482,9 @@ gpu_supports_texure_format(struct etna_screen *screen, uint32_t fmt,
    if (fmt >= TEXTURE_FORMAT_DXT1 && fmt <= TEXTURE_FORMAT_DXT4_DXT5)
       supported = VIV_FEATURE(screen, chipFeatures, DXT_TEXTURE_COMPRESSION);
 
+   if (util_format_is_srgb(format))
+      supported = VIV_FEATURE(screen, chipMinorFeatures1, HALTI0);
+
    if (fmt & EXT_FORMAT) {
       supported = VIV_FEATURE(screen, chipMinorFeatures1, HALTI0);
 
index b8ebab60822eb4919a3971f9802df25f83f12f68..597390ae492a35aca7be1198f391b0425fea1052 100644 (file)
@@ -236,7 +236,8 @@ etna_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *prsc,
                          VIVS_TE_SAMPLER_SIZE_HEIGHT(res->base.height0);
    sv->TE_SAMPLER_LOG_SIZE =
       VIVS_TE_SAMPLER_LOG_SIZE_WIDTH(etna_log2_fixp55(res->base.width0)) |
-      VIVS_TE_SAMPLER_LOG_SIZE_HEIGHT(etna_log2_fixp55(res->base.height0));
+      VIVS_TE_SAMPLER_LOG_SIZE_HEIGHT(etna_log2_fixp55(res->base.height0)) |
+      COND(util_format_is_srgb(so->format), VIVS_TE_SAMPLER_LOG_SIZE_SRGB);
 
    /* Set up levels-of-detail */
    for (int lod = 0; lod <= res->base.last_level; ++lod) {