nouveau/mme: Add a generic simulator function

This one takes a devinfo and decodes and simulates the shader with
whichever sim is appropriate.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30703>
This commit is contained in:
Faith Ekstrand
2024-08-16 16:05:53 -05:00
committed by Marge Bot
parent 33315ce136
commit 50a030b02a
3 changed files with 46 additions and 0 deletions
+1
View File
@@ -8,6 +8,7 @@ libnouveau_mme_files = files(
'mme_fermi_builder.c',
'mme_fermi_sim.c',
'mme_sim.h',
'mme_sim.c',
'mme_tu104.c',
'mme_tu104.h',
'mme_tu104_builder.c',
+40
View File
@@ -0,0 +1,40 @@
/*
* Copyright © 2022 Mary Guillemard
* SPDX-License-Identifier: MIT
*/
#include "mme_sim.h"
#include "mme_fermi.h"
#include "mme_fermi_sim.h"
#include "mme_tu104.h"
#include "mme_tu104_sim.h"
#define MME_CLS_FERMI 0x9000
#define MME_CLS_TURING 0xc500
void
mme_sim_core(const struct nv_device_info *devinfo,
size_t macro_size, const void *macro,
const struct mme_sim_state_ops *state_ops,
void *state_handler)
{
if (devinfo->cls_eng3d >= MME_CLS_TURING) {
assert(macro_size % 12 == 0);
uint32_t inst_count = macro_size / 12;
struct mme_tu104_inst *insts =
malloc(inst_count * sizeof(struct mme_tu104_inst));
mme_tu104_decode(insts, macro, inst_count);
mme_tu104_sim_core(inst_count, insts, state_ops, state_handler);
free(insts);
} else if (devinfo->cls_eng3d >= MME_CLS_FERMI) {
assert(macro_size % 4 == 0);
uint32_t inst_count = macro_size / 4;
struct mme_fermi_inst *insts =
malloc(inst_count * sizeof(struct mme_fermi_inst));
mme_fermi_decode(insts, macro, inst_count);
mme_fermi_sim_core(inst_count, insts, state_ops, state_handler);
free(insts);
} else {
unreachable("Unsupported GPU class");
}
}
+5
View File
@@ -19,6 +19,11 @@ struct mme_sim_state_ops {
uint32_t *(*map_dram)(void *handler, uint32_t idx);
};
void mme_sim_core(const struct nv_device_info *devinfo,
size_t macro_size, const void *macro,
const struct mme_sim_state_ops *state_ops,
void *state_handler);
#ifdef __cplusplus
}
#endif