Greater Rift minion life fix (#23); Mac click-to-walk and keyboard key names; older-API declaration de-duplication
This commit is contained in:
+20
-1
@@ -2856,6 +2856,25 @@ static uint64_t ui_mat_patch(const p_bind_buf *u, void *mb, uint64_t mo) {
|
||||
la = u->addr; ls = u->size; lp = g_pass.serial; lo = g_ui_moff; lg = ring_gpu + at; at += n;
|
||||
return lg;
|
||||
}
|
||||
#if DM_NVN_M3
|
||||
// 老接口的资源声明去重:同一渲染编码器内对同一资源重复 useResource 是幂等的,而每次新编参数块都会把它引用的资源全声明一遍——
|
||||
// 营地实测每次绘制声明 9.7 次、其中 9.2 次是本编码器里已经声明过的,每次约 227 条指令。这里记下本通道(g_pass.serial,与渲染编码器一一对应:
|
||||
// 序号只在开渲染编码器前递增)已按哪些用法声明过哪些资源,已覆盖的跳过。表满(一个通道里超过表长个不同资源)时不记、照常声明。
|
||||
// 表项不持有资源:声明过的资源被编码器持有到提交完成,同一通道内它的地址不会被别的资源复用。只在提交线程上用
|
||||
// De-duplicating resource declarations on the older API: repeated useResource for the same resource within one render encoder is idempotent, yet every newly encoded argument block declares all the resources it references once more -
|
||||
// measured in the camp at 9.7 declarations per draw, of which 9.2 were already declared in this encoder, about 227 instructions per draw. Here it is recorded which resources have been declared with which usages in this pass (g_pass.serial, one-to-one with render encoders:
|
||||
// the serial only increments before a render encoder is opened), and those already covered are skipped. When the table is full (more distinct resources in one pass than the table holds) nothing is recorded and declarations proceed as usual.
|
||||
// Table entries do not retain resources: a declared resource is held by the encoder until the submission completes, so within one pass its address is not reused by another resource. Used only on the submission thread
|
||||
enum { M3_USE_N = 1024 };
|
||||
static struct { void *p; uint64_t pass; uint32_t u; } g_m3_use[M3_USE_N];
|
||||
static inline int m3_use_seen(void *p, uint32_t u) {
|
||||
for (uint32_t h = (uint32_t)(((uintptr_t)p >> 4) * 0x9E3779B1u) >> 22, k = 0; k < M3_USE_N; k++, h = (h + 1) & (M3_USE_N - 1)) {
|
||||
if (g_m3_use[h].pass != g_pass.serial) { g_m3_use[h].p = p; g_m3_use[h].pass = g_pass.serial; g_m3_use[h].u = u; return 0; }
|
||||
if (g_m3_use[h].p == p) { if ((g_m3_use[h].u & u) == u) return 1; g_m3_use[h].u |= u; return 0; }
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
static int encode_args(id<MTLCommandEncoder> en, NvShader *sh, int nvn_stage, int metal_vertex) {
|
||||
if (!sh->ae) return 1;
|
||||
uint64_t slots[NVN_REFL_MAXB] = {0};
|
||||
@@ -2870,7 +2889,7 @@ static int encode_args(id<MTLCommandEncoder> en, NvShader *sh, int nvn_stage, in
|
||||
// 不声明的话只读贴图会和写它的拷贝乱序(迁 Metal 4 前实测过)。同一编码器内重复声明是幂等的
|
||||
// Older API: every resource a shader accesses indirectly through an argument block must have its usage declared on this encoder, so that the system knows its ordering dependency against other encoders (upload copies, other passes);
|
||||
// without the declaration a read-only texture gets out of order with the copy that writes it (measured before the move to Metal 4). Repeated declarations within one encoder are idempotent
|
||||
#define USE(r, u) do { id<MTLResource> r_ = (id<MTLResource>)(r); if (r_) { if (nvn_stage == 5) [(id<MTLComputeCommandEncoder>)en useResource:r_ usage:(u)]; else [(id<MTLRenderCommandEncoder>)en useResource:r_ usage:(u) stages:MTLRenderStageVertex | MTLRenderStageFragment]; } \
|
||||
#define USE(r, u) do { id<MTLResource> r_ = (id<MTLResource>)(r); if (r_) { if (nvn_stage == 5) [(id<MTLComputeCommandEncoder>)en useResource:r_ usage:(u)]; else if (!m3_use_seen((__bridge void *)r_, (uint32_t)(u))) [(id<MTLRenderCommandEncoder>)en useResource:r_ usage:(u) stages:MTLRenderStageVertex | MTLRenderStageFragment]; } \
|
||||
if (__builtin_expect(g_res_check_on, 0)) res_check((r), sh->key, reg); } while (0)
|
||||
#define USE_SAMP(r, u) do { (void)(u); if (__builtin_expect(g_res_check_on, 0)) res_check((r), sh->key, reg); } while (0) // 采样器不是资源,不用声明 | samplers are not resources and need no declaration
|
||||
#else
|
||||
|
||||
+26
-1
@@ -54,7 +54,32 @@ t_pso_skey: t_pso_skey.m ../nvn/nvn_pso_skey.h ../nvn/nvn_obj.h
|
||||
clang $(CFLAGS) -fobjc-arc -o $@ t_pso_skey.m -framework Foundation
|
||||
t_pfv: t_pfv.m ../../host/crash.c $(GFX) $(GFX_H)
|
||||
clang $(CFLAGS) -fobjc-arc -o $@ t_pfv.m ../../host/crash.c $(filter-out ../nvn/nvn_mtl.m ../nvn/nvn_entry.S ../nvn/nvn_thunks.S,$(GFX)) $(FW)
|
||||
run: t_nvn t_dirty_slots t_dirty_race t_builtin t_deswz_gpu t_pace t_refl t_hmap t_cover t_fuse_check t_present_crop t_reorder_chain t_defer_chain t_zskip t_xv t_ub t_mip_extent t_rt_range_shape t_rt_range_ro t_rt_range t_rt_depth_ro t_pso_skey t_pfv
|
||||
# 依赖一行一个、按字母序(免得加一个测试就整行冲突);下面各条命令的先后不变
|
||||
# Dependencies one per line in alphabetical order (so that adding one test does not conflict on the whole line); the order of the commands below is unchanged
|
||||
run: \
|
||||
t_builtin \
|
||||
t_cover \
|
||||
t_defer_chain \
|
||||
t_deswz_gpu \
|
||||
t_dirty_race \
|
||||
t_dirty_slots \
|
||||
t_fuse_check \
|
||||
t_hmap \
|
||||
t_mip_extent \
|
||||
t_nvn \
|
||||
t_pace \
|
||||
t_pfv \
|
||||
t_present_crop \
|
||||
t_pso_skey \
|
||||
t_refl \
|
||||
t_reorder_chain \
|
||||
t_rt_depth_ro \
|
||||
t_rt_range \
|
||||
t_rt_range_ro \
|
||||
t_rt_range_shape \
|
||||
t_ub \
|
||||
t_xv \
|
||||
t_zskip
|
||||
./t_nvn
|
||||
./t_dirty_slots
|
||||
./t_dirty_race
|
||||
|
||||
Reference in New Issue
Block a user