mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-21 03:39:57 -04:00
Fix NVN2 compute constants, indirect mesh draws and empty descriptor sets, and cut the texture pool refresh.
NVN2 compute banks get the dispatch's group counts in bytes 0-0xb, for direct and indirect dispatches; the fog pass
after the integration divided by them. Indirect mesh draws read NVN's {count, first} record as {x, y, z}, so y = 0
drew nothing: each now draws from a ring entry holding {count, 1, 1}, copied on the GPU before the draw. An empty set 1
no longer leaves set 0 pushed with 0 bytes. Compute stages with subgroup operations whose width is a whole number of
subgroups require full subgroups.
The texture pool refresh fell from 3.1-3.7 ms to 1.0 ms a frame in Kokiri Forest: slots with the same descriptor,
address generation and entry generation share one lookup (about 14,500 of 15,000 refills a frame), and registering a
texture and view identical to what the slot holds keeps its resolution. Under 20 GiB of VRAM, ASTC textures are
encoded to BC3 by default (Kokiri: 15.9 to 8.2 GiB, same GPU time). The pool log counts refills by cause and what
invalidates them; frame dumps write BC textures as raw blocks and print a storage buffer's backing span; a profile with
NX2NAVI_PROFILE_FRAMES is written when its window ends; the alpha test logs once that it is not applied.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -79,7 +79,7 @@ static struct {
|
||||
struct { uint64_t links, wlinks, dlinks, requeued, link_fail, defer, lib_n[4], lib_fail, swaps, slow, pre_used[4]; double link_ms, link_max, lib_ms[4], lib_max[4], dlink_ms, dlink_max; } g;
|
||||
int vs_outs_all; // NX2NAVI_VS_OUTS: 0 union of paired fragment inputs, 1 (all) all 32 output locations
|
||||
int dyn_vi, dyn_clamp, dyn_poly, dyn_blend_en, dyn_blend_eq, dyn_wmask, dyn_a2c;
|
||||
int f_logic_op, f_depth_clamp, f_fill_non_solid, f_dual_src;
|
||||
int f_logic_op, f_depth_clamp, f_fill_non_solid, f_dual_src, f_full_subgroups;
|
||||
int pv_last; // provokingVertexLast enabled: NVN's default is the last vertex
|
||||
VkShaderStageFlags sg32_stages; // stages that accept requiredSubgroupSize = 32 (0: not available)
|
||||
VkDynamicState dyn[32];
|
||||
@@ -239,6 +239,7 @@ static int ensure_init(void) {
|
||||
rt_log("vk_pipeline: subgroup size %u-%u, requiredSubgroupSizeStages %#x, pinning %u on %#x", p13.minSubgroupSize,
|
||||
p13.maxSubgroupSize, (unsigned)p13.requiredSubgroupSizeStages, vk_caps.sg_size, (unsigned)P.sg32_stages);
|
||||
}
|
||||
P.f_full_subgroups = v13.computeFullSubgroups;
|
||||
P.f_logic_op = f2.features.logicOp;
|
||||
P.f_depth_clamp = f2.features.depthClamp;
|
||||
P.f_fill_non_solid = f2.features.fillModeNonSolid;
|
||||
@@ -877,6 +878,18 @@ static void pin_subgroup32(VkPipelineShaderStageCreateInfo *st, VkPipelineShader
|
||||
st->pNext = rq;
|
||||
}
|
||||
|
||||
// The x of a compute module's LocalSize (OpExecutionMode 17), 0 when it has none.
|
||||
static uint32_t local_size_x(const uint32_t *w, uint64_t words) {
|
||||
for (uint64_t i = 5; w && i < words;) {
|
||||
uint32_t op = w[i] & 0xffff, n = w[i] >> 16;
|
||||
if (!n || i + n > words) return 0;
|
||||
if (op == 16 && n >= 6 && w[i + 2] == 17) return w[i + 3];
|
||||
if (op == 54) return 0; // OpFunction: the execution modes are all before it
|
||||
i += n;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Pool arrays (the translator's bindless texture and sampler arrays of VK_POOL_TEX / VK_POOL_SAMP elements, found by
|
||||
// their types) move to set 2, at the binding of their view kind (vk.h VK_POOL_KINDS) or VK_POOL_KINDS for samplers;
|
||||
// the kinds used are noted in vk_pool_kinds_used so the replay fills them. NULL: nothing to move (or no memory).
|
||||
@@ -2692,6 +2705,12 @@ static VkPipeline compute_create(const GfxShader *cs, const Layout *l) {
|
||||
.stage = VK_SHADER_STAGE_COMPUTE_BIT, .module = m, .pName = "main"},
|
||||
.layout = l->layout};
|
||||
pin_subgroup32(&ci.stage, &rqc, code, words);
|
||||
// Subgroup operations in a workgroup whose width is a whole number of subgroups need every subgroup full: the
|
||||
// driver may otherwise run partial ones, and a ballot over the culling's candidates then counted differently from
|
||||
// one frame to the next
|
||||
uint32_t lx = local_size_x(code, words);
|
||||
if (P.f_full_subgroups && vk_caps.sg_size && lx && lx % vk_caps.sg_size == 0 && uses_subgroup_ops(code, words))
|
||||
ci.stage.flags |= VK_PIPELINE_SHADER_STAGE_CREATE_REQUIRE_FULL_SUBGROUPS_BIT;
|
||||
VkPipeline pipe = VK_NULL_HANDLE;
|
||||
crash_note("a compute pipeline", cs, NULL, NULL);
|
||||
if (vkCreateComputePipelines(P.device, P.cache, 1, &ci, NULL, &pipe) != VK_SUCCESS) pipe = VK_NULL_HANDLE;
|
||||
|
||||
Reference in New Issue
Block a user