mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-18 06:59:57 -04:00
Free a destroyed texture's record only after the GPU is past the submission being recorded, and cache no view of it.
A device lost seen on RTX 4090, 5090 and 5070 Ti cards in 0.5.0 and 0.6.0 (#177, #61, and a 0.6.0 test run): a "read invalid" at the start of a 128x128 scene capture pass, re-rendered at area loads. destroy_tex purged the views of the image and deferred the image, then freed its record at once, on whichever thread released the texture. The replay keeps &e->pub as a render target for the rest of a command buffer (vk_exec.c resolve_target) and DLSS for the frame: a pass that began again (each indirect mesh draw ends the pass) read the freed record and cached a view of the dead image, which nothing removed. Vulkan gives a destroyed image's handle to a later image, which then got that view, and the pass loaded its attachments from freed memory. - destroy_tex marks the record gone and frees it through the deferred destruction (vk_defer_free, a host kind stamped with the submission being recorded, as the image is). - A gone texture's attachment view is made per command buffer (vk_exec.c view_of) or deferred with it (vk_exec_target_view, for DLSS and the contact shadows), never cached. - A new image drops any view still cached under its handle, and the log counts it ("cached views of a destroyed image"). No rendering changes: the views and images live exactly as long as before, the records slightly longer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -377,7 +377,10 @@ void vk_texstat_add(int kind, uint64_t n, uint64_t bytes);
|
||||
// Deferred destruction: freed once the upload batches recorded so far and the timeline value last noted have completed.
|
||||
void vk_defer_image(VkImage img, VmaAllocation alloc); // alloc NULL: vkDestroyImage only
|
||||
void vk_defer_view(VkImageView view);
|
||||
void vk_exec_image_gone(VkImage image); // destroy_tex, texture lock held: the replay's views of image go with it
|
||||
// free(p) once the GPU is past the submission being recorded, as vk_defer_image: a host record other threads may still
|
||||
// read (a destroyed texture's, vk_texture.c destroy_tex).
|
||||
void vk_defer_free(void *p);
|
||||
int vk_exec_image_gone(VkImage image); // texture lock held: the replay's views of image go with it; returns how many
|
||||
void vk_defer_buffer(VkBuffer buf, VmaAllocation alloc);
|
||||
// ---- ASTC (vk_astc.c). NX2NAVI_ASTC = auto | gpu | native | cpu | check; see vk_astc.c.
|
||||
enum { VK_ASTC_CPU, VK_ASTC_GPU, VK_ASTC_NATIVE, VK_ASTC_CHECK };
|
||||
@@ -437,6 +440,9 @@ typedef struct {
|
||||
uint8_t scale; // 1, or NX2NAVI_SHADOW_SCALE for a shadow map made larger than the game's (vk_texture.c
|
||||
// shadow_scale_of): width and height above are the larger ones, the game's regions
|
||||
// are multiplied by it
|
||||
uint8_t gone; // destroyed (vk_texture.c destroy_tex, texture lock held): the record stays readable until
|
||||
// the GPU is past the submission being recorded (vk_defer_free), as the replay and DLSS
|
||||
// keep pointers to render targets across a command buffer; no view of it is cached
|
||||
} VkTexImage;
|
||||
// The window texture the backend presents (vk_backend.c): *image and *format become the float picture the game copied
|
||||
// into it, when the last draw into it was that copy and the swapchain is HDR10.
|
||||
|
||||
Reference in New Issue
Block a user