diff options
| author | Duck912 <350528965+Duck912@users.noreply.github.com> | 2026-11-03 12:10:30 -0500 |
|---|---|---|
| committer | Duck912 <350528965+Duck912@users.noreply.github.com> | 2026-11-03 12:33:16 -0500 |
| commit | 1d4ccdbb0cf01add647247a4ab64b5060b1bb8eb (patch) | |
| tree | ed865aba1224dbc777fb3720b38bdd2fc79984b2 | |
| parent | c91b9a71cc86d99f46d105223584cbe53c21b1cf (diff) | |
video_core: read the framebuffer before recording the upscaled-output blit
BlitColor(VkImageView, VkImage, ...), which draws FSR 3.1's output into the game's DLSS output,
captured the Framebuffer pointer and read its render pass, handle and size on the worker thread.
The pointer points into the texture cache's framebuffer slots, which can be reallocated before the
worker records the command, so the render pass could begin with a stale or null render pass and
framebuffer. FSR 3.1 records quickly enough that this rarely shows; with a slower first evaluation
(NVIDIA DLSS creating its feature) it crashed in vkCmdBeginRenderPass at the first evaluation in
every run.
Read the three values on the calling thread and capture those instead. Nothing else changes.
Assisted-by: Claude Opus 5.5 (debugging, implementation)
Signed-off-by: Duck912 <350528965+Duck912@users.noreply.github.com>
| -rw-r--r-- | src/video_core/renderer_vulkan/blit_image.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/video_core/renderer_vulkan/blit_image.cpp b/src/video_core/renderer_vulkan/blit_image.cpp index 0628da1d0f..4a274b2915 100644 --- a/src/video_core/renderer_vulkan/blit_image.cpp +++ b/src/video_core/renderer_vulkan/blit_image.cpp @@ -644,10 +644,8 @@ void RecordShaderReadBarrier(Scheduler& scheduler, const ImageView& image_view) }); } -void BeginRenderPass(vk::CommandBuffer& cmdbuf, const Framebuffer* framebuffer) { - const VkRenderPass render_pass = framebuffer->RenderPass(); - const VkFramebuffer framebuffer_handle = framebuffer->Handle(); - const VkExtent2D render_area = framebuffer->RenderArea(); +void BeginRenderPass(vk::CommandBuffer& cmdbuf, VkRenderPass render_pass, + VkFramebuffer framebuffer_handle, VkExtent2D render_area) { const VkRenderPassBeginInfo renderpass_bi{ .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, .pNext = nullptr, @@ -784,11 +782,17 @@ void BlitImageHelper::BlitColor(const Framebuffer* dst_framebuffer, VkImageView }; const VkPipelineLayout layout = *one_texture_pipeline_layout; const VkPipeline pipeline = FindOrEmplaceColorPipeline(key); + // Read the framebuffer now: the texture cache's framebuffer slots can move before the + // worker records this. + const VkRenderPass render_pass = dst_framebuffer->RenderPass(); + const VkFramebuffer framebuffer = dst_framebuffer->Handle(); + const VkExtent2D render_area = dst_framebuffer->RenderArea(); scheduler.RequestOutsideRenderPassOperationContext(); - scheduler.Record([this, dst_framebuffer, src_image_view, src_image, src_sampler, dst_region, - src_region, src_size, pipeline, layout](vk::CommandBuffer cmdbuf) { + scheduler.Record([this, render_pass, framebuffer, render_area, src_image_view, src_image, + src_sampler, dst_region, src_region, src_size, pipeline, + layout](vk::CommandBuffer cmdbuf) { TransitionImageLayout(cmdbuf, src_image, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); - BeginRenderPass(cmdbuf, dst_framebuffer); + BeginRenderPass(cmdbuf, render_pass, framebuffer, render_area); const VkDescriptorSet descriptor_set = one_texture_descriptor_allocator.Commit(); // The source was just transitioned: describe it in that layout. UpdateOneTextureDescriptorSet(device, descriptor_set, src_sampler, src_image_view, |
