From 0de4083544f88018e2c1fbdff7cc4e676df12e5c Mon Sep 17 00:00:00 2001 From: George Ouzounoudis Date: Wed, 9 Nov 2022 19:50:32 +0200 Subject: [PATCH] nvk: Do not increment instance id across draws In cases of multiple draws (i.e. indirect draws) instance id should not increment across draw boundaries. Use a local copy of "begin" to modify the instance id inside the instances loop only. Part-of: --- src/nouveau/vulkan/nvk_cmd_draw.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/nouveau/vulkan/nvk_cmd_draw.c b/src/nouveau/vulkan/nvk_cmd_draw.c index 4d5ad0fee1a..bcb3d94be69 100644 --- a/src/nouveau/vulkan/nvk_cmd_draw.c +++ b/src/nouveau/vulkan/nvk_cmd_draw.c @@ -1436,6 +1436,11 @@ nvk_build_mme_draw(struct mme_builder *b, struct mme_value begin) mme_mthd(b, NV9097_SET_GLOBAL_BASE_INSTANCE_INDEX); mme_emit(b, first_instance); + /* Make a copy of begin because this helper may be called inside an MME loop + * (i.e. indirect draws) and we're going to modify the value of begin below. + */ + begin = mme_mov(b, begin); + mme_loop(b, instance_count) { mme_mthd(b, NV9097_BEGIN); mme_emit(b, begin); @@ -1509,6 +1514,11 @@ nvk_mme_build_draw_indexed(struct mme_builder *b, mme_mthd(b, NV9097_SET_GLOBAL_BASE_INSTANCE_INDEX); mme_emit(b, first_instance); + /* Make a copy of begin because this helper may be called inside an MME loop + * (i.e. indirect draws) and we're going to modify the value of begin below. + */ + begin = mme_mov(b, begin); + mme_loop(b, instance_count) { mme_mthd(b, NV9097_BEGIN); mme_emit(b, begin);