Fix black Steam output with FSR 1 (#597)

This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-10-11 21:03:07 -04:00
1 parent b1690852e9
commit 5527f9b77e
6 files changed
+189 -1

No files matched your search

@@ -255,7 +255,11 @@ static void target_destroy(struct fx_target *t) {
static int target_ensure(struct fx_target *t, int w, int h, const char *what) {
if (t->img && t->w == w && t->h == h) return 0;
target_destroy(t);
VkImageCreateInfo ii = {.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, .imageType = VK_IMAGE_TYPE_2D,
/* Unrestricted mutable views keep these render-then-blit targets uncompressed on Turnip.
* UBWC targets corrupt even a constant-colour pass on Adreno 740 (FSR becomes black).
* Only the chain's intermediate images need this; the scene and guest images stay unchanged. */
VkImageCreateInfo ii = {.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT, .imageType = VK_IMAGE_TYPE_2D,
.format = g_fx_fmt, .extent = {(uint32_t)w, (uint32_t)h, 1}, .mipLevels = 1,
.arrayLayers = 1, .samples = VK_SAMPLE_COUNT_1_BIT, .tiling = VK_IMAGE_TILING_OPTIMAL,
.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT |
@@ -292,6 +296,10 @@ static void scene_release(void) {
memset(&g_scene, 0, sizeof(g_scene));
}
void vkp_effects_forget_image(VkImage img) {
if (img && g_scene.img == img) scene_release();
}
static int scene_ensure(VkImage img, int w, int h) {
if (g_scene.img == img && g_scene.w == w && g_scene.h == h && g_scene.ds) return 0;
scene_release();
@@ -55,6 +55,10 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce
/* Compositor thread: drop every Vulkan object (device teardown / device lost). */
void vkp_effects_destroy(void);
/* Compositor thread: release the cached source view/descriptor before its owner destroys img.
* A later image can reuse the same Vulkan handle and dimensions; that is not the same resource. */
void vkp_effects_forget_image(VkImage img);
/* Compositor thread, before vkp_effects_run(): the format of the scene image it will be handed and the
* format its own targets use. R8G8B8A8 / R8G8B8A8 for every SDR frame (the default); A2B10G10R10 /
* A2B10G10R10 while an HDR picture runs through it (hdr_compose.h). A target-format change rebuilds the
@@ -1164,6 +1164,7 @@ static void record_draw(VkCommandBuffer cmd, const struct vkp_draw *d, const VkI
}
static void destroy_scene_image(void) {
if (g_scene.img) vkp_effects_forget_image(g_scene.img);
if (g_scene.img) hdrc_forget_image(g_scene.img); /* the HDR pass may have drawn into it */
if (g_scene.img) blendp_forget_image(g_scene.img);
if (g_scene.img) g_vk.DestroyImage(g_dev, g_scene.img, NULL);
@@ -1203,6 +1204,7 @@ static int ensure_scene_image(int w, int h) {
static int ensure_img(struct vkp_img_slot *s, int w, int h, VkFormat fmt, VkImageUsageFlags usage, const char *what) {
if (s->img && s->w == w && s->h == h && s->fmt == fmt) return 0;
if (s->img) hdrc_forget_image(s->img);
if (s->img) vkp_effects_forget_image(s->img);
if (s->img) blendp_forget_image(s->img);
if (s->img) g_vk.DestroyImage(g_dev, s->img, NULL);
if (s->mem) g_vk.FreeMemory(g_dev, s->mem, NULL);