r100/r200: factor out txformat/txfilter setup from the TFP path.
authorEric Anholt <eric@anholt.net>
Thu, 5 Sep 2019 22:48:58 +0000 (15:48 -0700)
committerEric Anholt <eric@anholt.net>
Sun, 20 Oct 2019 04:39:48 +0000 (04:39 +0000)
No matter what, we deref the texFormat from the table, except for a
mistake in cpp=4 where we pulled a 0 out of the table either way.

v2: Rebase on dropping r200 table deduplication patch.

Reviewed-by: Marek Olšák <marek.olsak@amd.com> (v1)
src/mesa/drivers/dri/r200/r200_texstate.c
src/mesa/drivers/dri/radeon/radeon_texstate.c

index 60a20071d9789a5c82d50f436b05e88951a4c150..8826a9bd7e798baf2f62b6444b52c659be500671 100644 (file)
@@ -691,29 +691,23 @@ void r200SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint texture_format
        pitch_val = rb->pitch;
        switch (rb->cpp) {
        case 4:
-               if (texture_format == __DRI_TEXTURE_FORMAT_RGB) {
+               if (texture_format == __DRI_TEXTURE_FORMAT_RGB)
                        texFormat = MESA_FORMAT_BGR_UNORM8;
-                       t->pp_txformat = tx_table_le[MESA_FORMAT_BGR_UNORM8].format;
-               }
-               else {
+               else
                        texFormat = MESA_FORMAT_B8G8R8A8_UNORM;
-                       t->pp_txformat = tx_table_le[MESA_FORMAT_B8G8R8A8_UNORM].format;
-               }
-               t->pp_txfilter |= tx_table_le[MESA_FORMAT_B8G8R8A8_UNORM].filter;
                break;
        case 3:
        default:
                texFormat = MESA_FORMAT_BGR_UNORM8;
-               t->pp_txformat = tx_table_le[MESA_FORMAT_BGR_UNORM8].format;
-               t->pp_txfilter |= tx_table_le[MESA_FORMAT_BGR_UNORM8].filter;
                break;
        case 2:
                texFormat = MESA_FORMAT_B5G6R5_UNORM;
-               t->pp_txformat = tx_table_le[MESA_FORMAT_B5G6R5_UNORM].format;
-               t->pp_txfilter |= tx_table_le[MESA_FORMAT_B5G6R5_UNORM].filter;
                break;
        }
 
+        t->pp_txformat = tx_table_le[texFormat].format;
+        t->pp_txfilter |= tx_table_le[texFormat].filter;
+
        _mesa_init_teximage_fields(&radeon->glCtx, texImage,
                                   rb->base.Base.Width, rb->base.Base.Height,
                                   1, 0,
index 47eac855c66506352726fd2419a67c333b6015a7..1cfca191375bb6e2cfb417c0ede72a924e569d95 100644 (file)
@@ -597,29 +597,23 @@ void radeonSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint texture_form
        t->override_offset = 0;
        switch (rb->cpp) {
        case 4:
-               if (texture_format == __DRI_TEXTURE_FORMAT_RGB) {
-                       t->pp_txformat = tx_table[MESA_FORMAT_BGR_UNORM8].format;
+               if (texture_format == __DRI_TEXTURE_FORMAT_RGB)
                        texFormat = MESA_FORMAT_BGR_UNORM8;
-               }
-               else {
-                       t->pp_txformat = tx_table[MESA_FORMAT_B8G8R8A8_UNORM].format;
+               else
                        texFormat = MESA_FORMAT_B8G8R8A8_UNORM;
-               }
-               t->pp_txfilter |= tx_table[MESA_FORMAT_B8G8R8A8_UNORM].filter;
                break;
        case 3:
        default:
                texFormat = MESA_FORMAT_BGR_UNORM8;
-               t->pp_txformat = tx_table[MESA_FORMAT_BGR_UNORM8].format;
-               t->pp_txfilter |= tx_table[MESA_FORMAT_BGR_UNORM8].filter;
                break;
        case 2:
                texFormat = MESA_FORMAT_B5G6R5_UNORM;
-               t->pp_txformat = tx_table[MESA_FORMAT_B5G6R5_UNORM].format;
-               t->pp_txfilter |= tx_table[MESA_FORMAT_B5G6R5_UNORM].filter;
                break;
        }
 
+        t->pp_txformat = tx_table[texFormat].format;
+        t->pp_txfilter |= tx_table[texFormat].filter;
+
        _mesa_init_teximage_fields(&radeon->glCtx, texImage,
                                   rb->base.Base.Width, rb->base.Base.Height,
                                   1, 0,