nvk: Add a build test for MMEs

This simple test compiles all the MMEs for Turing and Volta to ensure
that they build and don't run out of registers.  We could, in theory, do
actual unit testing here with gtest but just building is enough to
ensure that no one breaks driver start-up on hardware they don't own.
They can still break the driver functionally, of course, but at least
it'll initialize.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:
Faith Ekstrand 2023-01-30 20:12:07 -06:00 committed by Marge Bot
parent 978415e7a2
commit 715dff0b93
8 changed files with 76 additions and 7 deletions

View file

@ -17,6 +17,7 @@ nvk_classes = [
'clc397',
'clc3c0',
'clc597',
'clc5c0',
]
nvk_cl_header_depend_files = [

View file

@ -85,8 +85,8 @@ nvk_deps = [
idep_vulkan_wsi_headers,
]
libvulkan_nouveau = shared_library(
'vulkan_nouveau',
libnvk = static_library(
'nvk',
[
nvk_entrypoints,
cl_generated,
@ -101,6 +101,12 @@ libvulkan_nouveau = shared_library(
link_with : [libnouveau_codegen],
dependencies : [nvk_deps, idep_nouveau_codegen],
gnu_symbol_visibility : 'hidden',
)
libvulkan_nouveau = shared_library(
'vulkan_nouveau',
link_whole : [libnvk],
gnu_symbol_visibility : 'hidden',
install : true,
)
@ -143,3 +149,15 @@ if meson.version().version_compare('>= 0.58')
devenv.append('VK_ICD_FILENAMES', meson.current_build_dir() / _dev_icdname)
endif
if with_tests and not with_platform_android
test(
'nvk_mme',
executable(
'test_nvk_mme',
files('test_nvk_mme.c'),
dependencies : [nvk_deps],
link_with : [libnvk],
)
)
endif

View file

@ -56,7 +56,7 @@ nvc0c0_qmd_set_dispatch_size(UNUSED struct nvk_device *dev, uint32_t *qmd,
static uint32_t
qmd_dispatch_size_offset(struct nvk_device *dev)
{
assert(dev->ctx->compute.cls >= VOLTA_COMPUTE_A);
assert(dev->pdev->info.cls_compute >= VOLTA_COMPUTE_A);
uint32_t bit = DRF_LO(DRF_MW(NVC3C0_QMDV02_02_CTA_RASTER_WIDTH));
assert(bit % 32 == 0);
assert(DRF_LO(DRF_MW(NVC3C0_QMDV02_02_CTA_RASTER_HEIGHT)) == bit + 32);
@ -278,7 +278,7 @@ mme_store_global_vec3(struct mme_builder *b,
void
nvk_mme_dispatch_indirect(struct nvk_device *dev, struct mme_builder *b)
{
if (dev->ctx->eng3d.cls < TURING_A)
if (dev->pdev->info.cls_eng3d < TURING_A)
return;
struct mme_value local_size = mme_load(b);

View file

@ -1735,7 +1735,7 @@ nvk_mme_draw_indirect(struct nvk_device *dev, struct mme_builder *b)
{
struct mme_value begin = mme_load(b);
if (dev->ctx->eng3d.cls >= TURING_A) {
if (dev->pdev->info.cls_eng3d >= TURING_A) {
struct mme_value64 draw_addr = mme_load_addr64(b);
struct mme_value draw_count = mme_load(b);
struct mme_value stride = mme_load(b);
@ -1850,7 +1850,7 @@ nvk_mme_draw_indexed_indirect(struct nvk_device *dev, struct mme_builder *b)
{
struct mme_value begin = mme_load(b);
if (dev->ctx->eng3d.cls >= TURING_A) {
if (dev->pdev->info.cls_eng3d >= TURING_A) {
struct mme_value64 draw_addr = mme_load_addr64(b);
struct mme_value draw_count = mme_load(b);
struct mme_value stride = mme_load(b);

View file

@ -26,3 +26,21 @@ nvk_build_mme(struct nvk_device *dev, enum nvk_mme mme, size_t *size_out)
return mme_builder_finish(&b, size_out);
}
void
nvk_test_build_all_mmes(const struct nv_device_info *devinfo)
{
struct nvk_physical_device pdev = { .info = *devinfo };
vk_object_base_init(NULL, &pdev.vk.base, VK_OBJECT_TYPE_PHYSICAL_DEVICE);
struct nvk_device dev = { .pdev = &pdev };
vk_object_base_init(NULL, &dev.vk.base, VK_OBJECT_TYPE_DEVICE);
dev.vk.physical = &pdev.vk;
for (uint32_t mme = 0; mme < NVK_MME_COUNT; mme++) {
size_t size;
uint32_t *dw = nvk_build_mme(&dev, mme, &size);
assert(dw != NULL);
free(dw);
}
}

View file

@ -33,6 +33,8 @@ typedef void (*nvk_mme_builder_func)(struct nvk_device *dev,
uint32_t *nvk_build_mme(struct nvk_device *dev, enum nvk_mme mme,
size_t *size_out);
void nvk_test_build_all_mmes(const struct nv_device_info *devinfo);
void nvk_mme_clear_views(struct nvk_device *dev, struct mme_builder *b);
void nvk_mme_clear_layers(struct nvk_device *dev, struct mme_builder *b);
void nvk_mme_draw(struct nvk_device *dev, struct mme_builder *b);

View file

@ -536,7 +536,7 @@ nvk_GetQueryPoolResults(VkDevice device,
void
nvk_mme_copy_queries(struct nvk_device *dev, struct mme_builder *b)
{
if (dev->ctx->eng3d.cls < TURING_A)
if (dev->pdev->info.cls_eng3d < TURING_A)
return;
struct mme_value64 dst_addr = mme_load_addr64(b);

View file

@ -0,0 +1,30 @@
#include "nvk_mme.h"
#include "nvk_cla097.h"
#include "nvk_cla0c0.h"
#include "nvk_clc397.h"
#include "nvk_clc3c0.h"
#include "nvk_clc597.h"
#include "nvk_clc5c0.h"
int main(int argc, char **argv)
{
// static const struct nv_device_info kepler = {
// .cls_eng3d = KEPLER_A,
// .cls_compute = KEPLER_COMPUTE_A,
// };
static const struct nv_device_info volta = {
.cls_eng3d = VOLTA_A,
.cls_compute = VOLTA_COMPUTE_A,
};
static const struct nv_device_info turing = {
.cls_eng3d = TURING_A,
.cls_compute = TURING_COMPUTE_A,
};
// nvk_test_build_all_mmes(&kepler);
nvk_test_build_all_mmes(&volta);
nvk_test_build_all_mmes(&turing);
return 0;
}