summaryrefslogtreecommitdiff
path: root/src/freedreno/fdl/fd5_layout_test.c
blob: adfd951b3b2031e27cb7099196e0185442224c3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
 * Copyright © 2020 Google LLC
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 */

#include "freedreno_layout.h"
#include "fd_layout_test.h"
#include "adreno_common.xml.h"
#include "util/half_float.h"
#include "util/u_math.h"
#include "a5xx.xml.h"

#include <stdio.h>

/* Testcases generated from cffdump --script texturator-to-unit-test-5xx.lua
 * on a Pixel 2
 */
static const struct testcase testcases[] = {
   /* Basic POT, non-UBWC layout test */
   {
      .format = PIPE_FORMAT_R9G9B9E5_FLOAT,
      .layout =
         {
            .tile_mode = TILE5_3,
            .width0 = 32,
            .height0 = 32,
            .slices =
               {
                  {.offset = 0, .pitch = 256},
                  {.offset = 8192, .pitch = 256},
                  {.offset = 12288, .pitch = 256},
                  {.offset = 14336, .pitch = 256},
                  {.offset = 15360, .pitch = 256},
                  {.offset = 15872, .pitch = 256},
               },
         },
   },

   /* Some 3D cases of sizes from the CTS, when I was suspicious of our 3D
    * layout.
    */
   {
      .format = PIPE_FORMAT_R9G9B9E5_FLOAT,
      .is_3d = true,
      .layout =
         {
            .tile_mode = TILE5_3,
            .ubwc = false,
            .width0 = 59,
            .height0 = 37,
            .depth0 = 11,
            .slices =
               {
                  {.offset = 0, .pitch = 256},
                  {.offset = 135168, .pitch = 256},
                  {.offset = 176128, .pitch = 256},
                  {.offset = 192512, .pitch = 256},
                  {.offset = 200704, .pitch = 256},
                  {.offset = 208896, .pitch = 256},
               },
         },
   },
   {
      .format = PIPE_FORMAT_R32G32_FLOAT,
      .is_3d = true,
      .layout =
         {
            .tile_mode = TILE5_3,
            .ubwc = false,
            .width0 = 63,
            .height0 = 29,
            .depth0 = 11,
            .slices =
               {
                  {.offset = 0, .pitch = 512},
                  {.offset = 180224, .pitch = 512},
                  {.offset = 221184, .pitch = 512},
                  {.offset = 237568, .pitch = 512},
                  {.offset = 245760, .pitch = 512},
                  {.offset = 253952, .pitch = 512},
               },
         },
   },
};

int
main(int argc, char **argv)
{
   int ret = 0;

   for (int i = 0; i < ARRAY_SIZE(testcases); i++) {
      if (!fdl_test_layout(&testcases[i], 540))
         ret = 1;
   }

   return ret;
}