Mesh emulation: point meshes too, and a warning for draws from a nonzero workgroup.

The 8 point-list mesh programs of Ocarina 1.1.1 (32 points, position and point size) were left unemulated. Their
indices are single uints and the point size goes to an extra vertex slot, which the generated vertex shader writes to
PointSize; the draw asks for a point list (the pipeline key's topology class follows the draw's primitive for mesh
draws), chosen from the mesh stage's OutputPoints. A mesh draw from a nonzero first workgroup is drawn from 0 as
before, now with a warning in the emulated path too. All 1016 programs convert and pass spirv-val.

(cherry picked from commit 8900aeaffa3264e4cc655ffd487cb2d2f3e3dd17)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Tobim6
2026-11-12 16:22:07 +01:00
parent 1534dc570a
commit 8b78e64539
4 changed files with 91 additions and 2 deletions

View File

@@ -5569,6 +5569,20 @@ static void mfb_draw(VkExec *ex, uint32_t count, const VkMemSpan *ind) {
ex->recorded++;
}
// The primitive an emulated draw's mesh stage outputs: point meshes draw point lists, the rest triangles.
static int mesh_emu_draw_prim(VkExec *ex) {
static struct { const GfxShader *s; int prim; } memo[256];
int present = 0, pending = 0;
const GfxShader *ms = ex->prog ? shader_for(ex, NVN_STAGE_MESH, &present, &pending, 0) : NULL;
if (!ms) return NVN_DRAW_PRIMITIVE_TRIANGLES;
unsigned h = (unsigned)((uintptr_t)ms >> 4) & 255;
if (memo[h].s != ms) {
uint64_t n = 0;
const uint32_t *w = gfx_shader_spirv(ms, &n);
memo[h].s = ms, memo[h].prim = w && mesh_emu_prim(w, (size_t)n) == 1 ? NVN_DRAW_PRIMITIVE_POINTS : NVN_DRAW_PRIMITIVE_TRIANGLES;
}
return memo[h].prim;
}
static int mesh_emu_on(void) {
static int on = -1;
if (on < 0) {
@@ -5580,6 +5594,7 @@ static int mesh_emu_on(void) {
static void op_draw_mesh(VkExec *ex, const p_draw_mesh *d) {
PFN_vkCmdDrawMeshTasksEXT fn = draw_mesh_fn();
if (!fn && mesh_emu_on()) {
if (d->first) warn_once(W_MESH, "an emulated mesh draw from workgroup %u: drawn from workgroup 0", d->first);
static int on = -1;
if (on < 0) on = rt_knob("MESH", "1"); // NX2NAVI_MESH=0: mesh draws are skipped (diagnosis)
if (!d->count || !on) return;
@@ -5849,6 +5864,8 @@ static void me_barrier(VkCommandBuffer cb, VkPipelineStageFlags2 ss, VkAccessFla
// count: the first stage's workgroups, or ind: a {count, 1, 1} record to dispatch from
if (!me_arena()) return 0;
ex->dc->c0_binst = 0;
int prim = mesh_emu_draw_prim(ex);
if (!prepare_draw_ex(ex, prim, 0x7fffffff, 0, 1)) return 0;
const VkPipeInfo *info = PD_info;
const GfxShader *ms = ex->dc->B.st.vs, *ts = ex->dc->B.st.ts;
VkPipeline mp = VK_NULL_HANDLE, tp = VK_NULL_HANDLE;