Path: blob/21.2-virgl/src/freedreno/fdl/fd_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>3031bool32fdl_test_layout(const struct testcase *testcase, int gpu_id)33{34struct fdl_layout layout = {35.ubwc = testcase->layout.ubwc,36.tile_mode = testcase->layout.tile_mode,37};38bool ok = true;3940int max_size = MAX2(testcase->layout.width0, testcase->layout.height0);41int mip_levels = 1;42while (max_size > 1 && testcase->layout.slices[mip_levels].pitch) {43mip_levels++;44max_size = u_minify(max_size, 1);45}4647if (gpu_id >= 600) {48fdl6_layout(&layout, testcase->format,49MAX2(testcase->layout.nr_samples, 1), testcase->layout.width0,50MAX2(testcase->layout.height0, 1),51MAX2(testcase->layout.depth0, 1), mip_levels,52MAX2(testcase->array_size, 1), testcase->is_3d, NULL);53} else {54assert(gpu_id >= 500);55fdl5_layout(&layout, testcase->format,56MAX2(testcase->layout.nr_samples, 1), testcase->layout.width0,57MAX2(testcase->layout.height0, 1),58MAX2(testcase->layout.depth0, 1), mip_levels,59MAX2(testcase->array_size, 1), testcase->is_3d);60}6162/* fdl lays out UBWC data before the color data, while all we have63* recorded in this testcase are the color offsets (other than the UBWC64* buffer sharing test). Shift the fdl layout down so we can compare65* color offsets.66*/67if (layout.ubwc && !testcase->layout.slices[0].offset) {68for (int l = 1; l < mip_levels; l++)69layout.slices[l].offset -= layout.slices[0].offset;70layout.slices[0].offset = 0;71}7273for (int l = 0; l < mip_levels; l++) {74if (layout.slices[l].offset != testcase->layout.slices[l].offset) {75fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: offset 0x%x != 0x%x\n",76util_format_short_name(testcase->format), layout.width0,77layout.height0, layout.depth0, layout.nr_samples, l,78layout.slices[l].offset, testcase->layout.slices[l].offset);79ok = false;80}81if (fdl_pitch(&layout, l) != testcase->layout.slices[l].pitch) {82fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: pitch %d != %d\n",83util_format_short_name(testcase->format), layout.width0,84layout.height0, layout.depth0, layout.nr_samples, l,85fdl_pitch(&layout, l), testcase->layout.slices[l].pitch);86ok = false;87}8889if (layout.ubwc_slices[l].offset !=90testcase->layout.ubwc_slices[l].offset) {91fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: UBWC offset 0x%x != 0x%x\n",92util_format_short_name(testcase->format), layout.width0,93layout.height0, layout.depth0, layout.nr_samples, l,94layout.ubwc_slices[l].offset,95testcase->layout.ubwc_slices[l].offset);96ok = false;97}98if (fdl_ubwc_pitch(&layout, l) != testcase->layout.ubwc_slices[l].pitch) {99fprintf(stderr, "%s %dx%dx%d@%dx lvl%d: UBWC pitch %d != %d\n",100util_format_short_name(testcase->format), layout.width0,101layout.height0, layout.depth0, layout.nr_samples, l,102fdl_ubwc_pitch(&layout, l),103testcase->layout.ubwc_slices[l].pitch);104ok = false;105}106}107108if (!ok)109fprintf(stderr, "\n");110111return ok;112}113114115