mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-16 13:59:56 -04:00
Kokiri Forest drew black, in tiles and in shadowed and indoor areas, where shaders read light, probe and instance data through pointers they load from other buffers at an index (a phi of a pushed pointer and a loaded one, a pointer spilled to local memory): those reads returned 0. Translator patch 0030 keeps such accesses global, with a new first source naming the table, and the SPIR-V back end looks the address's 4 KiB page up in it and loads through the buffer device address it gives (PhysicalStorageBuffer64). runtime/vk_gpa.c keeps the table: two levels over the 40-bit GPU address space, page entries naming immutable records, records reused only after the GPU finished with them. Imported pools, their VRAM mirrors and the pages of virtual pools go in it; pools in it are destroyed after the submissions that may still read them. The last failing compute program needed MATCH.ALL (subgroupAllEqual) and the aggregated shared increment ATOMS.POPC.INC, now lowered in AmpereLowering.cs; Kokiri Forest translates without a failure. NX2NAVI_GPA=0 turns the table off and NX2NAVI_GPA_EMPTY=1 keeps it empty. A first try synced every VRAM mirror at each table reader's draw, which overwrote what the GPU had written into them and made the black worse; mirrors sync only when bound. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
25 lines
1.6 KiB
C
25 lines
1.6 KiB
C
// The device address table (vk_gpa.c): GPU address pages to buffer device addresses for shaders' global memory accesses.
|
|
#pragma once
|
|
#include <stdint.h>
|
|
|
|
#include "vk.h"
|
|
|
|
#define VK_GPA_CB_SLOT 0x40 // res.json cb_slot of the table (translator ResourceManager.DeviceAddressTableCbSlot)
|
|
|
|
int vk_gpa_wanted(void); // the device has buffer device addresses and NX2NAVI_GPA is not 0
|
|
int vk_gpa_wanted_ctx(const VkCtx *c); // the same during device creation, before vk_ctx() returns it
|
|
int vk_gpa_on(void); // the table exists (created on first use)
|
|
uint64_t vk_gpa_device_address(VkBuffer b);
|
|
VkDescriptorBufferInfo vk_gpa_info(void); // the whole table, for a storage descriptor
|
|
// Maps the pages [lo, hi) holds whole to buf, whose byte 0 is GPU address buf_lo. Returns the record (0: not mapped).
|
|
uint32_t vk_gpa_map(uint64_t lo, uint64_t hi, VkBuffer buf, uint64_t buf_lo);
|
|
// Unmaps the pages of [lo, hi) that name rec; cover (may be NULL) gives the record of another live buffer that holds a
|
|
// page whole, or 0. rec is reused once the GPU finished the submissions issued until now.
|
|
void vk_gpa_unmap(uint64_t lo, uint64_t hi, uint32_t rec, uint32_t (*cover)(uint64_t page_addr));
|
|
// Unmaps every page of [lo, hi), whatever record it names (pages of a virtual pool whose physical memory goes away).
|
|
void vk_gpa_clear(uint64_t lo, uint64_t hi);
|
|
// Moves the pages of [lo, hi) that name old_rec (or none) to buf (a pool's VRAM mirror); returns the new record.
|
|
uint32_t vk_gpa_remap(uint64_t lo, uint64_t hi, uint32_t old_rec, VkBuffer buf, uint64_t buf_lo);
|
|
void vk_gpa_report(void);
|
|
void vk_gpa_shutdown(void);
|