lima: fix texture descriptor issues
authorVasily Khoruzhick <anarsoul@gmail.com>
Sun, 25 Aug 2019 19:54:14 +0000 (12:54 -0700)
committerVasily Khoruzhick <anarsoul@gmail.com>
Wed, 28 Aug 2019 00:28:38 +0000 (00:28 +0000)
Looks like initial RE was wrong and some fields have different purpose.
I.e. there's no "disable_mipmap" field, it's actually part of another field
that selects mipmap filtering.

Also fix layout position.

Reviewed-by: Qiang Yu <yuq825@gmail.com>
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
src/gallium/drivers/lima/lima_texture.c
src/gallium/drivers/lima/lima_texture.h

index 379bf387330984403bb58bf1f63c893996a089cc..6a44253ba58afb43d539fc6279e42c6fe63700ae 100644 (file)
@@ -121,7 +121,6 @@ lima_update_tex_desc(struct lima_context *ctx, struct lima_sampler_state *sample
    lima_tex_desc *desc = pdesc;
    unsigned first_level;
    unsigned last_level;
-   bool mipmapping;
 
    memset(desc, 0, desc_size);
 
@@ -133,25 +132,25 @@ lima_update_tex_desc(struct lima_context *ctx, struct lima_sampler_state *sample
    if (last_level - first_level >= LIMA_MAX_MIP_LEVELS)
       last_level = first_level + LIMA_MAX_MIP_LEVELS - 1;
 
+   desc->miplevels = (last_level - first_level);
+
    switch (sampler->base.min_mip_filter) {
       case PIPE_TEX_MIPFILTER_LINEAR:
-         desc->min_mipfilter = 3;
+         desc->min_mipfilter_1 = 0;
+         desc->min_mipfilter_2 = 3;
+         break;
       case PIPE_TEX_MIPFILTER_NEAREST:
-         mipmapping = true;
-         desc->miplevels = (last_level - first_level);
+         desc->min_mipfilter_1 = 0x1ff;
+         desc->min_mipfilter_2 = 0;
          break;
       case PIPE_TEX_MIPFILTER_NONE:
       default:
-         mipmapping = false;
          break;
    }
 
    switch (sampler->base.mag_img_filter) {
    case PIPE_TEX_FILTER_LINEAR:
       desc->mag_img_filter_nearest = 0;
-      /* no mipmap, filter_mag = linear */
-      if (!mipmapping)
-         desc->disable_mipmap = 1;
       break;
    case PIPE_TEX_FILTER_NEAREST:
    default:
index c1bc34f874087967454802632a2aacb797aa423d..7a185bc75d05f72934b895f575e19f1253a7dd76 100644 (file)
@@ -36,18 +36,15 @@ typedef struct __attribute__((__packed__)) {
    uint32_t stride: 13;
    uint32_t unknown_0_2: 1;
 
-   /* Word 1*/
+   /* Word 1-3 */
    uint32_t unknown_1_1: 10;
    uint32_t texture_2d: 1;
    uint32_t unknown_1_2: 13;
    uint32_t miplevels: 4;
-   uint32_t unknown_1_3: 3;
-   uint32_t disable_mipmap: 1;
-
-   /* Word 2-3 */
-   uint32_t unknown_2_1: 8;
+   uint32_t min_mipfilter_1: 9; /* 0x0 for linear, 0x1ff for nearest */
+   uint32_t unknown_2_1: 3;
    uint32_t has_stride: 1;
-   uint32_t min_mipfilter: 2; /* 0x3 for linear, 0x0 for neares */
+   uint32_t min_mipfilter_2: 2; /* 0x3 for linear, 0x0 for nearest */
    uint32_t min_img_filter_nearest: 1;
    uint32_t mag_img_filter_nearest: 1;
    uint32_t wrap_s_clamp_to_edge: 1;
@@ -75,9 +72,9 @@ typedef struct __attribute__((__packed__)) {
    union {
       uint32_t va[0];
       struct __attribute__((__packed__)) {
-         uint32_t unknown_6_1: 12;
+         uint32_t unknown_6_1: 13;
          uint32_t layout: 2;
-         uint32_t unknown_6_2: 10;
+         uint32_t unknown_6_2: 9;
          uint32_t unknown_6_3: 6;
 #define VA_BIT_OFFSET 30
 #define VA_BIT_SIZE 26