Path: blob/21.2-virgl/src/freedreno/fdl/fd6_layout_test.c
4561 views
/*1* Copyright © 2020 Google LLC2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*/2223#include "freedreno_layout.h"24#include "fd_layout_test.h"25#include "adreno_common.xml.h"26#include "adreno_pm4.xml.h"27#include "a6xx.xml.h"2829#include <stdio.h>3031static const struct testcase32testcases[] =33{34/* A straightforward first testcase, linear, with an obvious format. */35{36.format = PIPE_FORMAT_R8G8B8A8_UNORM,37.layout =38{39.width0 = 32,40.height0 = 32,41.slices =42{43{.offset = 0, .pitch = 256},44{.offset = 8192, .pitch = 256},45{.offset = 12288, .pitch = 256},46{.offset = 14336, .pitch = 256},47{.offset = 15360, .pitch = 256},48{.offset = 15872, .pitch = 256},49},50},51},5253/* A tiled/ubwc layout from the blob driver, at a size where the a63054* blob driver does something interesting for linear.55*/56{57.format = PIPE_FORMAT_R8G8B8A8_UNORM,58.layout =59{60.tile_mode = TILE6_3,61.ubwc = true,62.width0 = 1024,63.height0 = 1,64.slices =65{66{.offset = 0, .pitch = 4096},67{.offset = 65536, .pitch = 2048},68{.offset = 98304, .pitch = 1024},69{.offset = 114688, .pitch = 512},70{.offset = 122880, .pitch = 256},71{.offset = 126976, .pitch = 256},72{.offset = 131072, .pitch = 256},73{.offset = 135168, .pitch = 256},74{.offset = 139264, .pitch = 256},75{.offset = 143360, .pitch = 256},76{.offset = 147456, .pitch = 256},77},78.ubwc_slices =79{80{.offset = 0, .pitch = 64},81{.offset = 4096, .pitch = 64},82{.offset = 8192, .pitch = 64},83{.offset = 12288, .pitch = 64},84{.offset = 16384, .pitch = 64},85{.offset = 20480, .pitch = 64},86{.offset = 24576, .pitch = 64},87{.offset = 28672, .pitch = 64},88{.offset = 32768, .pitch = 64},89{.offset = 36864, .pitch = 64},90{.offset = 40960, .pitch = 64},91},92},93},9495/* An interesting layout from the blob driver on a630, showing that96* per-level pitch must be derived from level 0's pitch, not width0. We97* don't do this level 0 pitch disalignment (we pick 4096), so disabled98* this test for now.99*/100#if 0101{102.format = PIPE_FORMAT_R8G8B8A8_UNORM,103.layout = {104.width0 = 1024, .height0 = 1,105.slices = {106{ .offset = 0, .pitch = 5120 },107{ .offset = 5120, .pitch = 2560 },108{ .offset = 7680, .pitch = 1280 },109{ .offset = 8960, .pitch = 768 },110{ .offset = 9728, .pitch = 512 },111{ .offset = 10240, .pitch = 256 },112{ .offset = 10496, .pitch = 256 },113{ .offset = 10752, .pitch = 256 },114{ .offset = 11008, .pitch = 256 },115{ .offset = 11264, .pitch = 256 },116{ .offset = 11520, .pitch = 256 },117},118},119},120#endif121122/* A layout that we failed on (129 wide has a surprise level 1 pitch123* increase), and the sizes bracketing it.124*/125{126.format = PIPE_FORMAT_R8G8B8A8_UNORM,127.layout =128{129.width0 = 128,130.height0 = 1,131.slices =132{133{.offset = 0, .pitch = 512},134{.offset = 512, .pitch = 256},135{.offset = 768, .pitch = 256},136{.offset = 1024, .pitch = 256},137{.offset = 1280, .pitch = 256},138{.offset = 1536, .pitch = 256},139{.offset = 1792, .pitch = 256},140{.offset = 2048, .pitch = 256},141},142},143},144{145.format = PIPE_FORMAT_R8G8B8A8_UNORM,146.layout =147{148.width0 = 129,149.height0 = 1,150.slices =151{152{.offset = 0, .pitch = 768},153{.offset = 768, .pitch = 512},154{.offset = 1280, .pitch = 256},155{.offset = 1536, .pitch = 256},156{.offset = 1792, .pitch = 256},157{.offset = 2048, .pitch = 256},158{.offset = 2304, .pitch = 256},159{.offset = 2560, .pitch = 256},160},161},162},163{164.format = PIPE_FORMAT_R8G8B8A8_UNORM,165.layout =166{167.width0 = 130,168.height0 = 1,169.slices =170{171{.offset = 0, .pitch = 768},172{.offset = 768, .pitch = 512},173{.offset = 1280, .pitch = 256},174{.offset = 1536, .pitch = 256},175{.offset = 1792, .pitch = 256},176{.offset = 2048, .pitch = 256},177{.offset = 2304, .pitch = 256},178{.offset = 2560, .pitch = 256},179},180},181},182183/* The 129 failure seems to be across formats, let's test some cpps */184{185.format = PIPE_FORMAT_R8_UNORM,186.layout =187{188.width0 = 129,189.height0 = 1,190.slices =191{192{.offset = 0, .pitch = 192},193{.offset = 192, .pitch = 128},194{.offset = 320, .pitch = 64},195{.offset = 384, .pitch = 64},196{.offset = 448, .pitch = 64},197{.offset = 512, .pitch = 64},198{.offset = 576, .pitch = 64},199{.offset = 640, .pitch = 64},200},201},202},203{204.format = PIPE_FORMAT_R16_UINT,205.layout =206{207.width0 = 129,208.height0 = 1,209.slices =210{211{.offset = 0, .pitch = 384},212{.offset = 384, .pitch = 256},213{.offset = 640, .pitch = 128},214{.offset = 768, .pitch = 128},215{.offset = 896, .pitch = 128},216{.offset = 1024, .pitch = 128},217{.offset = 1152, .pitch = 128},218{.offset = 1280, .pitch = 128},219},220},221},222{223.format = PIPE_FORMAT_R32G32B32A32_FLOAT,224.layout =225{226.width0 = 129,227.height0 = 1,228.slices =229{230{.offset = 0, .pitch = 3072},231{.offset = 3072, .pitch = 2048},232{.offset = 5120, .pitch = 1024},233{.offset = 6144, .pitch = 1024},234{.offset = 7168, .pitch = 1024},235{.offset = 8192, .pitch = 1024},236{.offset = 9216, .pitch = 1024},237{.offset = 10240, .pitch = 1024},238},239},240},241242/* The 129 failure replicated at every +256 pixels wide. Pick one of243* them, and this time increase the height as a new variable as well.244*/245{246.format = PIPE_FORMAT_R8G8B8A8_UNORM,247.layout =248{249.width0 = 385,250.height0 = 128,251.slices =252{253{.offset = 0, .pitch = 1792},254{.offset = 229376, .pitch = 1024},255{.offset = 294912, .pitch = 512},256{.offset = 311296, .pitch = 256},257{.offset = 315392, .pitch = 256},258{.offset = 317440, .pitch = 256},259{.offset = 318464, .pitch = 256},260{.offset = 318976, .pitch = 256},261{.offset = 319232, .pitch = 256},262},263},264},265266/* At 257-259 (and replicated every +256 pixels) we had another267failure. */268{269.format = PIPE_FORMAT_R8G8B8A8_UNORM,270.layout =271{272.width0 = 257,273.height0 = 1,274.slices =275{276{.offset = 0, .pitch = 1280},277{.offset = 1280, .pitch = 768},278{.offset = 2048, .pitch = 512},279{.offset = 2560, .pitch = 256},280{.offset = 2816, .pitch = 256},281{.offset = 3072, .pitch = 256},282{.offset = 3328, .pitch = 256},283{.offset = 3584, .pitch = 256},284{.offset = 3840, .pitch = 256},285},286},287},288{289.format = PIPE_FORMAT_R8G8B8A8_UNORM,290.layout =291{292.width0 = 258,293.height0 = 1,294.slices =295{296{.offset = 0, .pitch = 1280},297{.offset = 1280, .pitch = 768},298{.offset = 2048, .pitch = 512},299{.offset = 2560, .pitch = 256},300{.offset = 2816, .pitch = 256},301{.offset = 3072, .pitch = 256},302{.offset = 3328, .pitch = 256},303{.offset = 3584, .pitch = 256},304{.offset = 3840, .pitch = 256},305},306},307},308{309.format = PIPE_FORMAT_R8G8B8A8_UNORM,310.layout =311{312.width0 = 259,313.height0 = 1,314.slices =315{316{.offset = 0, .pitch = 1280},317{.offset = 1280, .pitch = 768},318{.offset = 2048, .pitch = 512},319{.offset = 2560, .pitch = 256},320{.offset = 2816, .pitch = 256},321{.offset = 3072, .pitch = 256},322{.offset = 3328, .pitch = 256},323{.offset = 3584, .pitch = 256},324{.offset = 3840, .pitch = 256},325},326},327},328{329.format = PIPE_FORMAT_R8G8B8A8_UNORM,330.layout =331{332.width0 = 260,333.height0 = 1,334.slices =335{336{.offset = 0, .pitch = 1280},337{.offset = 1280, .pitch = 768},338{.offset = 2048, .pitch = 512},339{.offset = 2560, .pitch = 256},340{.offset = 2816, .pitch = 256},341{.offset = 3072, .pitch = 256},342{.offset = 3328, .pitch = 256},343{.offset = 3584, .pitch = 256},344{.offset = 3840, .pitch = 256},345},346},347},348349/* And, again for the 257-9 failure, test a replica with a larger size*/350{351.format = PIPE_FORMAT_R8G8B8A8_UNORM,352.layout =353{354.width0 = 513,355.height0 = 32,356.slices =357{358{.offset = 0, .pitch = 2304},359{.offset = 73728, .pitch = 1280},360{.offset = 94208, .pitch = 768},361{.offset = 100352, .pitch = 512},362{.offset = 102400, .pitch = 256},363{.offset = 102912, .pitch = 256},364{.offset = 103168, .pitch = 256},365{.offset = 103424, .pitch = 256},366{.offset = 103680, .pitch = 256},367{.offset = 103936, .pitch = 256},368},369},370},371372/* Oh, look. The 513-517 failure extends up to 518 at the next texture373* level!374*/375{376.format = PIPE_FORMAT_R8G8B8A8_UNORM,377.layout =378{379.width0 = 518,380.height0 = 1,381.slices =382{383{.offset = 0, .pitch = 2304},384{.offset = 2304, .pitch = 1280},385{.offset = 3584, .pitch = 768},386{.offset = 4352, .pitch = 512},387{.offset = 4864, .pitch = 256},388{.offset = 5120, .pitch = 256},389{.offset = 5376, .pitch = 256},390{.offset = 5632, .pitch = 256},391{.offset = 5888, .pitch = 256},392{.offset = 6144, .pitch = 256},393},394},395},396397/* Tiled mode testing of the unusual 1/2-bytes-per-pixel pitch398alignment */399{400.format = PIPE_FORMAT_R8_UNORM,401.layout =402{403.tile_mode = TILE6_3,404.width0 = 129,405.height0 = 1,406.slices =407{408{.offset = 0, .pitch = 256},409{.offset = 8192, .pitch = 128},410{.offset = 12288, .pitch = 128},411{.offset = 16384, .pitch = 128},412{.offset = 20480, .pitch = 128},413{.offset = 20608, .pitch = 128},414{.offset = 20736, .pitch = 128},415{.offset = 20864, .pitch = 128},416},417},418},419420/* Single-level RGBA8888 UBWC following UBWC alignment rules laid out421* in msm_media_info.h to verify that we don't break buffer sharing.422*/423{424.format = PIPE_FORMAT_R8G8B8A8_UNORM,425.layout =426{427.tile_mode = TILE6_3,428.ubwc = true,429.width0 = 16384,430.height0 = 129,431.slices =432{433{.offset = 1024 * 48, .pitch = 16384 * 4},434},435.ubwc_slices =436{437{.offset = 0, .pitch = 1024},438},439},440},441442/* UBWC: Pitch comes from POT-aligned level 0. */443/* Pitch fixed in this commit, but offsets broken. Will be fixed in444* following commits.445*/446{447.format = PIPE_FORMAT_R8G8B8A8_UNORM,448.layout =449{450.tile_mode = TILE6_3,451.ubwc = true,452.width0 = 2049,453.height0 = 128,454.slices =455{456{.offset = 0, .pitch = 8448},457{.offset = 1081344, .pitch = 4352},458{.offset = 1359872, .pitch = 2304},459{.offset = 1433600, .pitch = 1280},460{.offset = 1454080, .pitch = 768},461{.offset = 1466368, .pitch = 512},462{.offset = 1474560, .pitch = 256},463{.offset = 1478656, .pitch = 256},464{.offset = 1482752, .pitch = 256},465{.offset = 1486848, .pitch = 256},466{.offset = 1490944, .pitch = 256},467{.offset = 1495040, .pitch = 256},468},469.ubwc_slices =470{471{.offset = 0, .pitch = 256},472{.offset = 16384, .pitch = 128},473{.offset = 24576, .pitch = 64},474{.offset = 28672, .pitch = 64},475{.offset = 32768, .pitch = 64},476{.offset = 36864, .pitch = 64},477{.offset = 40960, .pitch = 64},478{.offset = 45056, .pitch = 64},479{.offset = 49152, .pitch = 64},480{.offset = 53248, .pitch = 64},481{.offset = 57344, .pitch = 64},482{.offset = 61440, .pitch = 64},483},484},485},486/* UBWC: Height comes from POT-aligned level 0. */487{488.format = PIPE_FORMAT_R8G8B8A8_UNORM,489.layout =490{491.tile_mode = TILE6_3,492.ubwc = true,493.width0 = 1024,494.height0 = 1025,495.slices =496{497{.offset = 0, .pitch = 4096},498{.offset = 4259840, .pitch = 2048},499{.offset = 5308416, .pitch = 1024},500{.offset = 5570560, .pitch = 512},501{.offset = 5636096, .pitch = 256},502{.offset = 5652480, .pitch = 256},503{.offset = 5660672, .pitch = 256},504{.offset = 5664768, .pitch = 256},505{.offset = 5668864, .pitch = 256},506{.offset = 5672960, .pitch = 256},507{.offset = 5677056, .pitch = 256},508},509.ubwc_slices =510{511{.offset = 0, .pitch = 64},512{.offset = 32768, .pitch = 64},513{.offset = 49152, .pitch = 64},514{.offset = 57344, .pitch = 64},515{.offset = 61440, .pitch = 64},516{.offset = 65536, .pitch = 64},517{.offset = 69632, .pitch = 64},518{.offset = 73728, .pitch = 64},519{.offset = 77824, .pitch = 64},520{.offset = 81920, .pitch = 64},521{.offset = 86016, .pitch = 64},522},523},524},525526/* UBWC: Get at minimum height of a level across cpps */527{528.format = PIPE_FORMAT_R16_UINT,529.layout =530{531.tile_mode = TILE6_3,532.ubwc = true,533.width0 = 16384,534.height0 = 1,535.slices =536{537{.offset = 0, .pitch = 32768},538{.offset = 524288, .pitch = 16384},539{.offset = 786432, .pitch = 8192},540{.offset = 917504, .pitch = 4096},541{.offset = 983040, .pitch = 2048},542{.offset = 1015808, .pitch = 1024},543{.offset = 1032192, .pitch = 512},544{.offset = 1040384, .pitch = 256},545{.offset = 1044480, .pitch = 256},546{.offset = 1048576, .pitch = 256},547{.offset = 1052672, .pitch = 256},548{.offset = 1056768, .pitch = 256},549{.offset = 1060864, .pitch = 256},550{.offset = 1064960, .pitch = 256},551{.offset = 1069056, .pitch = 256},552},553.ubwc_slices =554{555{.offset = 0, .pitch = 1024},556{.offset = 65536, .pitch = 512},557{.offset = 98304, .pitch = 256},558{.offset = 114688, .pitch = 128},559{.offset = 122880, .pitch = 64},560{.offset = 126976, .pitch = 64},561{.offset = 131072, .pitch = 64},562{.offset = 135168, .pitch = 64},563{.offset = 139264, .pitch = 64},564{.offset = 143360, .pitch = 64},565{.offset = 147456, .pitch = 64},566{.offset = 151552, .pitch = 64},567{.offset = 155648, .pitch = 64},568{.offset = 159744, .pitch = 64},569{.offset = 163840, .pitch = 64},570},571},572},573{574.format = PIPE_FORMAT_R8G8B8A8_UNORM,575.layout =576{577.tile_mode = TILE6_3,578.ubwc = true,579.width0 = 16384,580.height0 = 1,581.slices =582{583{.offset = 0, .pitch = 65536},584{.offset = 1048576, .pitch = 32768},585{.offset = 1572864, .pitch = 16384},586{.offset = 1835008, .pitch = 8192},587{.offset = 1966080, .pitch = 4096},588{.offset = 2031616, .pitch = 2048},589{.offset = 2064384, .pitch = 1024},590{.offset = 2080768, .pitch = 512},591{.offset = 2088960, .pitch = 256},592{.offset = 2093056, .pitch = 256},593{.offset = 2097152, .pitch = 256},594{.offset = 2101248, .pitch = 256},595{.offset = 2105344, .pitch = 256},596{.offset = 2109440, .pitch = 256},597{.offset = 2113536, .pitch = 256},598},599.ubwc_slices =600{601{.offset = 0, .pitch = 1024},602{.offset = 65536, .pitch = 512},603{.offset = 98304, .pitch = 256},604{.offset = 114688, .pitch = 128},605{.offset = 122880, .pitch = 64},606{.offset = 126976, .pitch = 64},607{.offset = 131072, .pitch = 64},608{.offset = 135168, .pitch = 64},609{.offset = 139264, .pitch = 64},610{.offset = 143360, .pitch = 64},611{.offset = 147456, .pitch = 64},612{.offset = 151552, .pitch = 64},613{.offset = 155648, .pitch = 64},614{.offset = 159744, .pitch = 64},615{.offset = 163840, .pitch = 64},616},617},618},619{620.format = PIPE_FORMAT_R32G32B32A32_FLOAT,621.layout =622{623.tile_mode = TILE6_3,624.ubwc = true,625.width0 = 16384,626.height0 = 1,627.slices =628{629{.offset = 0, .pitch = 262144},630{.offset = 4194304, .pitch = 131072},631{.offset = 6291456, .pitch = 65536},632{.offset = 7340032, .pitch = 32768},633{.offset = 7864320, .pitch = 16384},634{.offset = 8126464, .pitch = 8192},635{.offset = 8257536, .pitch = 4096},636{.offset = 8323072, .pitch = 2048},637{.offset = 8355840, .pitch = 1024},638{.offset = 8372224, .pitch = 1024},639{.offset = 8388608, .pitch = 1024},640{.offset = 8404992, .pitch = 1024},641{.offset = 8421376, .pitch = 1024},642{.offset = 8437760, .pitch = 1024},643{.offset = 8454144, .pitch = 1024},644},645.ubwc_slices =646{647{.offset = 0, .pitch = 4096},648{.offset = 262144, .pitch = 2048},649{.offset = 393216, .pitch = 1024},650{.offset = 458752, .pitch = 512},651{.offset = 491520, .pitch = 256},652{.offset = 507904, .pitch = 128},653{.offset = 516096, .pitch = 64},654{.offset = 520192, .pitch = 64},655{.offset = 524288, .pitch = 64},656{.offset = 528384, .pitch = 64},657{.offset = 532480, .pitch = 64},658{.offset = 536576, .pitch = 64},659{.offset = 540672, .pitch = 64},660{.offset = 544768, .pitch = 64},661{.offset = 548864, .pitch = 64},662},663},664},665666{667.format = PIPE_FORMAT_R8G8B8A8_UNORM,668.layout =669{670.tile_mode = TILE6_3,671.ubwc = true,672.nr_samples = 4,673.width0 = 412,674.height0 = 732,675.slices =676{677{.offset = 0, .pitch = 7168},678},679.ubwc_slices =680{681{.offset = 0, .pitch = 128},682},683},684},685};686687int688main(int argc, char **argv)689{690int ret = 0;691692for (int i = 0; i < ARRAY_SIZE(testcases); i++) {693if (!fdl_test_layout(&testcases[i], 630))694ret = 1;695}696697return ret;698}699700701