17ec681f3Smrg/* 27ec681f3Smrg * Copyright © 2020 Google LLC 37ec681f3Smrg * 47ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a 57ec681f3Smrg * copy of this software and associated documentation files (the "Software"), 67ec681f3Smrg * to deal in the Software without restriction, including without limitation 77ec681f3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 87ec681f3Smrg * and/or sell copies of the Software, and to permit persons to whom the 97ec681f3Smrg * Software is furnished to do so, subject to the following conditions: 107ec681f3Smrg * 117ec681f3Smrg * The above copyright notice and this permission notice (including the next 127ec681f3Smrg * paragraph) shall be included in all copies or substantial portions of the 137ec681f3Smrg * Software. 147ec681f3Smrg * 157ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 167ec681f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 177ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 187ec681f3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 197ec681f3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 207ec681f3Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 217ec681f3Smrg * IN THE SOFTWARE. 227ec681f3Smrg */ 237ec681f3Smrg 247ec681f3Smrg#include "freedreno_layout.h" 257ec681f3Smrg#include "fd_layout_test.h" 267ec681f3Smrg#include "adreno_common.xml.h" 277ec681f3Smrg#include "util/half_float.h" 287ec681f3Smrg#include "util/u_math.h" 297ec681f3Smrg#include "a5xx.xml.h" 307ec681f3Smrg 317ec681f3Smrg#include <stdio.h> 327ec681f3Smrg 337ec681f3Smrg/* Testcases generated from cffdump --script texturator-to-unit-test-5xx.lua 347ec681f3Smrg * on a Pixel 2 357ec681f3Smrg */ 367ec681f3Smrgstatic const struct testcase testcases[] = { 377ec681f3Smrg /* Basic POT, non-UBWC layout test */ 387ec681f3Smrg { 397ec681f3Smrg .format = PIPE_FORMAT_R9G9B9E5_FLOAT, 407ec681f3Smrg .layout = 417ec681f3Smrg { 427ec681f3Smrg .tile_mode = TILE5_3, 437ec681f3Smrg .width0 = 32, 447ec681f3Smrg .height0 = 32, 457ec681f3Smrg .slices = 467ec681f3Smrg { 477ec681f3Smrg {.offset = 0, .pitch = 256}, 487ec681f3Smrg {.offset = 8192, .pitch = 256}, 497ec681f3Smrg {.offset = 12288, .pitch = 256}, 507ec681f3Smrg {.offset = 14336, .pitch = 256}, 517ec681f3Smrg {.offset = 15360, .pitch = 256}, 527ec681f3Smrg {.offset = 15872, .pitch = 256}, 537ec681f3Smrg }, 547ec681f3Smrg }, 557ec681f3Smrg }, 567ec681f3Smrg 577ec681f3Smrg /* Some 3D cases of sizes from the CTS, when I was suspicious of our 3D 587ec681f3Smrg * layout. 597ec681f3Smrg */ 607ec681f3Smrg { 617ec681f3Smrg .format = PIPE_FORMAT_R9G9B9E5_FLOAT, 627ec681f3Smrg .is_3d = true, 637ec681f3Smrg .layout = 647ec681f3Smrg { 657ec681f3Smrg .tile_mode = TILE5_3, 667ec681f3Smrg .ubwc = false, 677ec681f3Smrg .width0 = 59, 687ec681f3Smrg .height0 = 37, 697ec681f3Smrg .depth0 = 11, 707ec681f3Smrg .slices = 717ec681f3Smrg { 727ec681f3Smrg {.offset = 0, .pitch = 256}, 737ec681f3Smrg {.offset = 135168, .pitch = 256}, 747ec681f3Smrg {.offset = 176128, .pitch = 256}, 757ec681f3Smrg {.offset = 192512, .pitch = 256}, 767ec681f3Smrg {.offset = 200704, .pitch = 256}, 777ec681f3Smrg {.offset = 208896, .pitch = 256}, 787ec681f3Smrg }, 797ec681f3Smrg }, 807ec681f3Smrg }, 817ec681f3Smrg { 827ec681f3Smrg .format = PIPE_FORMAT_R32G32_FLOAT, 837ec681f3Smrg .is_3d = true, 847ec681f3Smrg .layout = 857ec681f3Smrg { 867ec681f3Smrg .tile_mode = TILE5_3, 877ec681f3Smrg .ubwc = false, 887ec681f3Smrg .width0 = 63, 897ec681f3Smrg .height0 = 29, 907ec681f3Smrg .depth0 = 11, 917ec681f3Smrg .slices = 927ec681f3Smrg { 937ec681f3Smrg {.offset = 0, .pitch = 512}, 947ec681f3Smrg {.offset = 180224, .pitch = 512}, 957ec681f3Smrg {.offset = 221184, .pitch = 512}, 967ec681f3Smrg {.offset = 237568, .pitch = 512}, 977ec681f3Smrg {.offset = 245760, .pitch = 512}, 987ec681f3Smrg {.offset = 253952, .pitch = 512}, 997ec681f3Smrg }, 1007ec681f3Smrg }, 1017ec681f3Smrg }, 1027ec681f3Smrg}; 1037ec681f3Smrg 1047ec681f3Smrgint 1057ec681f3Smrgmain(int argc, char **argv) 1067ec681f3Smrg{ 1077ec681f3Smrg int ret = 0; 1087ec681f3Smrg 1097ec681f3Smrg for (int i = 0; i < ARRAY_SIZE(testcases); i++) { 1107ec681f3Smrg if (!fdl_test_layout(&testcases[i], 540)) 1117ec681f3Smrg ret = 1; 1127ec681f3Smrg } 1137ec681f3Smrg 1147ec681f3Smrg return ret; 1157ec681f3Smrg} 116