mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-04 02:40:11 +01:00
pan/csf: add cs_builder unit test infrastructure
For now, just comparing the raw contents of the output buffer. Possibly in the future we could hook this up to the disassembly from decode_csf.c to make it a easier to edit. Signed-off-by: Olivia Lee <olivia.lee@collabora.com> Tested-by: Mary Guillemard <mary.guillemard@collabora.com> Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com> Reviewed-by: Ryan Mckeever <ryan.mckeever@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34974>
This commit is contained in:
parent
79a1d98e1e
commit
952703eefe
2 changed files with 69 additions and 0 deletions
|
|
@ -45,3 +45,19 @@ libpanfrost_decode = static_library(
|
|||
build_by_default : false,
|
||||
link_with: [libpanfrost_decode_per_arch],
|
||||
)
|
||||
|
||||
if with_tests
|
||||
test('cs_builder_tests',
|
||||
executable(
|
||||
'cs_builder_tests',
|
||||
['test/cs_builder.cpp'],
|
||||
# Nothing arch-specific is tested currently, only compile v10.
|
||||
cpp_args : [cpp_msvc_compat_args, no_override_init_args, '-DPAN_ARCH=10'],
|
||||
gnu_symbol_visibility : 'hidden',
|
||||
include_directories: [inc_include, inc_src, inc_panfrost],
|
||||
dependencies: [idep_gtest, idep_pan_packers, idep_mesautil],
|
||||
),
|
||||
suite: ['panfrost'],
|
||||
protocol: 'gtest',
|
||||
)
|
||||
endif
|
||||
|
|
|
|||
53
src/panfrost/genxml/test/cs_builder.cpp
Normal file
53
src/panfrost/genxml/test/cs_builder.cpp
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright 2025 Collabora Ltd
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "cs_builder.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "mesa-gtest-extras.h"
|
||||
|
||||
#define MAX_OUTPUT_SIZE 512
|
||||
|
||||
class CsBuilderTest : public ::testing::Test {
|
||||
public:
|
||||
CsBuilderTest();
|
||||
~CsBuilderTest();
|
||||
|
||||
struct cs_builder b;
|
||||
uint64_t *output;
|
||||
};
|
||||
|
||||
CsBuilderTest::CsBuilderTest()
|
||||
{
|
||||
output = new uint64_t[MAX_OUTPUT_SIZE];
|
||||
struct cs_builder_conf conf = {
|
||||
.nr_registers = 96,
|
||||
.nr_kernel_registers = 4,
|
||||
};
|
||||
struct cs_buffer buffer = {
|
||||
.cpu = output,
|
||||
.gpu = 0x0,
|
||||
.capacity = MAX_OUTPUT_SIZE,
|
||||
};
|
||||
cs_builder_init(&b, &conf, buffer);
|
||||
}
|
||||
|
||||
CsBuilderTest::~CsBuilderTest()
|
||||
{
|
||||
delete output;
|
||||
}
|
||||
|
||||
TEST_F(CsBuilderTest, basic)
|
||||
{
|
||||
cs_move32_to(&b, cs_reg32(&b, 42), 0xdeadbeef);
|
||||
cs_finish(&b);
|
||||
|
||||
uint64_t expected[] = {
|
||||
0x022a0000deadbeef, /* MOVE32 r42, #0xdeadbeef */
|
||||
};
|
||||
|
||||
EXPECT_EQ(b.root_chunk.size, ARRAY_SIZE(expected));
|
||||
EXPECT_U64_ARRAY_EQUAL(output, expected, ARRAY_SIZE(expected));
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue