diff --git a/app/src/main/java/com/droiddeck/launcher/session/UpscaleComponent.kt b/app/src/main/java/com/droiddeck/launcher/session/UpscaleComponent.kt index cf3cfc400e..95619111d1 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/UpscaleComponent.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/UpscaleComponent.kt @@ -168,15 +168,26 @@ object UpscaleComponent { if (engine.npu && npu) add(Group.NPU) } - fun ready(context: Context, groups: Set): Boolean = + /** The bridge DLLs (tools/upscale/bridges/build.sh), each in both Wine PE folders. */ + private val BRIDGE_NAMES = listOf( + "_nvngx.dll", "amd_fidelityfx_dx12.dll", "amd_fidelityfx_loader_dx12.dll", "amd_fidelityfx_upscaler_dx12.dll", + "amd_fidelityfx_upscaler_vk.dll", "amd_fidelityfx_vk.dll", "ffx_fsr2_api_x64.dll", "ffx_fsr3upscaler_x64.dll", + "libxess.dll", "nvapi64.dll", "nvngx.dll", "nvngx_dlss.dll", + ) + internal val BRIDGE_FILES = listOf("x86_64-windows", "aarch64-windows").flatMap { arch -> BRIDGE_NAMES.map { "$arch/$it" } } + + fun filesReady(context: Context, groups: Set): Boolean = FILES.filter { it.group in groups }.all { f -> File(dataDir(context), f.relative).let { it.isFile && it.length() == f.size } } - fun bridgesReady(context: Context): Boolean = File(bridgesDir(context), "x86_64-windows/libxess.dll").isFile + fun bridgesReady(context: Context): Boolean = + BRIDGE_FILES.all { File(bridgesDir(context), it).let { f -> f.isFile && f.length() > 0 } } - /** Fetches what [groups] still lack (and the bridge pack) in the background. */ + /** Everything a game with [groups] needs: the data files and the bridge DLLs. */ + fun ready(context: Context, groups: Set): Boolean = filesReady(context, groups) && bridgesReady(context) + + /** Fetches what [groups] still lack (data files, then the bridge DLLs) in the background. */ fun ensure(context: Context, groups: Set, onDone: (Boolean) -> Unit = {}) { val app = context.applicationContext - ensureBridges(app) if (ready(app, groups)) { mutableState.value = State.Ready onDone(true) @@ -188,7 +199,13 @@ object UpscaleComponent { } Thread({ val ok = try { - download(app, groups) + val files = filesReady(app, groups) || download(app, groups) + val bridges = files && (bridgesReady(app) || fetchBridges(app)) + when { + bridges -> mutableState.value = State.Ready + files -> mutableState.value = State.Failed("upscaler DLLs not installed") + } + bridges } catch (e: Exception) { Log.w(TAG, "upscaler files not fetched", e) mutableState.value = State.Failed(e.message ?: e.javaClass.simpleName) @@ -210,7 +227,7 @@ object UpscaleComponent { val target = File(dataDir(context), f.relative) target.parentFile?.mkdirs() val part = File(target.path + ".part") - val ok = copyLocal(f, part) || Downloader.downloadFile(f.url, part, true, f.sha256) { p -> + val ok = copyLocal(context, f, part) || Downloader.downloadFile(f.url, part, true, f.sha256) { p -> mutableState.value = State.Downloading(((done + p * f.size) / total).coerceIn(0f, 1f)) } if (!ok || !part.renameTo(target)) { @@ -227,19 +244,28 @@ object UpscaleComponent { done += f.size mutableState.value = State.Downloading((done.toFloat() / total).coerceIn(0f, 1f)) } - mutableState.value = State.Ready Log.i(TAG, "upscaler files ready (${wanted.size} files, groups $groups)") return true } - /** A copy of the same file under Download/droiddeck-upscale (same relative path), used when its SHA-256 matches. */ - private fun copyLocal(f: DataFile, part: File): Boolean = runCatching { - @Suppress("DEPRECATION") - val local = File(Environment.getExternalStorageDirectory(), "Download/$LOCAL_COPY/${f.relative}") - if (!local.isFile || local.length() != f.size || sha256(local) != f.sha256) return false - local.inputStream().use { input -> part.outputStream().use { output -> input.copyTo(output, 1 shl 20) } } - sha256(part) == f.sha256 - }.getOrDefault(false) + /** + * Folders that may hold a local copy (same layout as the upstream tree): the app's own external + * files folders, readable without any storage permission, then Download/droiddeck-upscale. + */ + @Suppress("DEPRECATION") + private fun localRoots(context: Context): List = + context.getExternalFilesDirs(null).orEmpty().filterNotNull().map { File(it, LOCAL_COPY) } + + File(Environment.getExternalStorageDirectory(), "Download/$LOCAL_COPY") + + /** A local copy of [f] (see [localRoots]), used when its SHA-256 matches. */ + private fun copyLocal(context: Context, f: DataFile, part: File): Boolean = localRoots(context).any { root -> + runCatching { + val local = File(root, f.relative) + if (!local.isFile || !local.canRead() || local.length() != f.size || sha256(local) != f.sha256) return@runCatching false + local.inputStream().use { input -> part.outputStream().use { output -> input.copyTo(output, 1 shl 20) } } + sha256(part) == f.sha256 + }.getOrDefault(false) + } private fun sha256(file: File): String { val digest = MessageDigest.getInstance("SHA-256") @@ -254,46 +280,53 @@ object UpscaleComponent { return digest.digest().joinToString("") { "%02x".format(it) } } - fun ensureBridges(context: Context) { - val app = context.applicationContext - if (localBridges() != null && !AddonPack.UPSCALE.installed(app)) { - Thread({ stageBridges(app) }, "upscale-bridges").start() - return - } - if (!AddonPack.UPSCALE.available) return - AddonPack.UPSCALE.ensure(app) { stageBridges(it) } + /** The add-on pack's bridges/ (fetched now when there is no local copy), staged into the rootfs. */ + private fun fetchBridges(context: Context): Boolean { + val pack = AddonPack.UPSCALE + if (!pack.installed(context) && localBridges(context) == null && pack.available) pack.await(context) + return stageBridges(context) } - /** A bridges/ tree beside the data files under Download/droiddeck-upscale: builds without a published pack. */ - @Suppress("DEPRECATION") - private fun localBridges(): File? = runCatching { - File(Environment.getExternalStorageDirectory(), "Download/$LOCAL_COPY/bridges") - .takeIf { File(it, "x86_64-windows/libxess.dll").isFile } - }.getOrNull() + /** A complete, readable bridges/ tree in one of [localRoots]: builds without a published pack. */ + private fun localBridges(context: Context): File? = localRoots(context).map { File(it, "bridges") }.firstOrNull { dir -> + runCatching { BRIDGE_FILES.all { File(dir, it).let { f -> f.isFile && f.canRead() && f.length() > 0 } } }.getOrDefault(false) + } - /** Copies the add-on pack's bridges/ tree (or the local one) into the rootfs, once per version. */ + /** + * Copies the bridge DLLs from the add-on pack (or the local tree) into the rootfs, once per version. True only + * when every one of [BRIDGE_FILES] is in place afterwards. + */ @Synchronized fun stageBridges(context: Context): Boolean { - val pack = AddonPack.UPSCALE.takeIf { it.installed(context) }?.dir(context) - val source = pack?.let { File(it, "bridges") } ?: localBridges() ?: return bridgesReady(context) - if (!source.isDirectory) return false - val version = pack?.name ?: ("local-" + File(source, "x86_64-windows/libxess.dll").let { it.length().toString() + "-" + it.lastModified() }) + val packDir = AddonPack.UPSCALE.takeIf { it.installed(context) }?.dir(context) + val pack = packDir?.let { File(it, "bridges") } + val source = pack?.takeIf { dir -> BRIDGE_FILES.all { File(dir, it).isFile } } ?: localBridges(context) + if (source == null) { + val ready = bridgesReady(context) + if (!ready) Log.w(TAG, "upscaler bridges: no add-on pack and no readable local copy") + return ready + } + val version = if (packDir != null && source == pack) packDir.name + else "local-" + File(source, "x86_64-windows/libxess.dll").let { it.length().toString() + "-" + it.lastModified() } val target = bridgesDir(context) val stamp = File(target, BRIDGES_STAMP) if (bridgesReady(context) && runCatching { stamp.readText() }.getOrNull() == version) return true - var ok = true - source.walkTopDown().filter { it.isFile }.forEach { file -> - val out = File(target, file.relativeTo(source).path) + var copied = 0 + for (name in BRIDGE_FILES) { + val from = File(source, name) + val out = File(target, name) out.parentFile?.mkdirs() val staged = File(out.path + ".staged") - ok = runCatching { - file.inputStream().use { input -> staged.outputStream().use { output -> input.copyTo(output) } } - staged.renameTo(out) - }.getOrDefault(false) && ok + val ok = runCatching { + from.inputStream().use { input -> staged.outputStream().use { output -> input.copyTo(output) } } + staged.length() == from.length() && staged.renameTo(out) + }.getOrDefault(false) staged.delete() + if (ok) copied++ else Log.w(TAG, "upscaler bridge $name not staged from $source") } + val ok = copied == BRIDGE_FILES.size && bridgesReady(context) if (ok) runCatching { stamp.writeText(version) } - Log.i(TAG, "upscaler bridges staged from $version: $ok") + Log.i(TAG, "upscaler bridges staged from $version: $copied/${BRIDGE_FILES.size} files") return ok } diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env index b758b6667c..8463c69018 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env @@ -1132,7 +1132,8 @@ def time_now(): def upscale_xess(prefix, data): - """Intel's XeSS runtime beside the bridge: libxess.dll loads wl_xess_official.dll from system32.""" + """Intel's XeSS runtime beside the bridge: libxess.dll loads wl_xess_official.dll from system32. A hard link + when the prefix is on the same file system as the data, else a copy.""" source = os.path.join(data, "xess", UPSCALE_XESS) if not os.path.isfile(source): return "XeSS runtime not downloaded" @@ -1140,16 +1141,32 @@ def upscale_xess(prefix, data): if os.path.isfile(target) and os.path.getsize(target) == os.path.getsize(source): return None staged = target + ".droiddeck-tmp" - with open(source, "rb") as src, open(staged, "wb") as dst: - while True: - chunk = src.read(1 << 20) - if not chunk: - break - dst.write(chunk) + if os.path.lexists(staged): + os.unlink(staged) + try: + os.link(source, staged) + except OSError: + with open(source, "rb") as src, open(staged, "wb") as dst: + while True: + chunk = src.read(1 << 20) + if not chunk: + break + dst.write(chunk) os.replace(staged, target) return None +def upscale_control(engine, sharpness, npu_sync, run=None): + """The live switch file the layer polls, written from this game's settings at every launch: a file left by the + previous game (or the in-game menu) would otherwise win over them.""" + run = run or UPSCALE_RUN + os.makedirs(run, exist_ok=True) + staged = os.path.join(run, "ctrl.%d" % os.getpid()) + with open(staged, "w") as f: + f.write("enabled=1\nbackend=%s\nsharpness=%.2f\nnpu_sync=%d\n" % (engine, sharpness / 100.0, 1 if npu_sync else 0)) + os.replace(staged, os.path.join(run, "ctrl")) + + def upscale_settings(env, prefix): """The game's upscaler choice -> DLL overrides, bridge folder, layer switch and the files the layer reads.""" mode = (env.get("DROIDDECK_UPSCALE_MODE") or "").strip().lower() @@ -1216,13 +1233,19 @@ def upscale_settings(env, prefix): result["DXVK_CONFIG"] = current + "; " + dxvk if current else dxvk own = result.get("WINEDLLOVERRIDES") result["WINEDLLOVERRIDES"] = (own + ";" if own else "") + ";".join(overrides) - if engine == "xess3_gpu" and prefix: + # Intel's runtime goes into every upscaler game once it is downloaded, so XeSS 3 also works when it is + # picked in the in-game menu; a game started on XeSS 3 without it falls back to FSR. + if prefix and (engine == "xess3_gpu" or os.path.isfile(os.path.join(data, "xess", UPSCALE_XESS))): try: problem = upscale_xess(prefix, data) except OSError as error: problem = str(error) - if problem: + if problem and engine == "xess3_gpu": notes.append("XeSS: %s; the layer falls back to FSR" % problem) + try: + upscale_control(engine, sharpness, env.get("DROIDDECK_UPSCALE_NPU_SYNC") == "1") + except OSError as error: + notes.append("upscaler control file not written (%s)" % error) notes.append("in-game upscaler: mode %s, engine %s, sharpness %d%%" % (mode, engine, sharpness)) return result, notes diff --git a/tools/tests/test_game_environment.py b/tools/tests/test_game_environment.py index 1118771663..1136d86f52 100644 --- a/tools/tests/test_game_environment.py +++ b/tools/tests/test_game_environment.py @@ -4,6 +4,7 @@ import hashlib import io import json import os +import re import shutil from pathlib import Path import runpy @@ -29,7 +30,8 @@ class UpscalerSettingsTest(unittest.TestCase): self.root = tempfile.mkdtemp() Path(self.root, "bridges/x86_64-windows").mkdir(parents=True) Path(self.root, "bridges/x86_64-windows/libxess.dll").write_bytes(b"MZ") - self.patch = patch.dict(MODULE["upscale_settings"].__globals__, {"UPSCALE_ROOT": self.root}) + self.run = os.path.join(self.root, "run") + self.patch = patch.dict(MODULE["upscale_settings"].__globals__, {"UPSCALE_ROOT": self.root, "UPSCALE_RUN": self.run}) self.patch.start() def tearDown(self): @@ -70,6 +72,41 @@ class UpscalerSettingsTest(unittest.TestCase): self.assertEqual(env, result) self.assertTrue(notes) + def test_the_control_file_follows_this_games_settings(self): + Path(self.run).mkdir() + Path(self.run, "ctrl").write_text("enabled=0\nbackend=fsr4_1_lite_gpu\nsharpness=0.55\nnpu_sync=0\n") + _, notes = MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "fsr", "DROIDDECK_UPSCALE_ENGINE": "xess3_gpu", + "DROIDDECK_UPSCALE_SHARPNESS": "40"}, None) + self.assertEqual("enabled=1\nbackend=xess3_gpu\nsharpness=0.40\nnpu_sync=0\n", Path(self.run, "ctrl").read_text()) + self.assertFalse([n for n in notes if "control file" in n]) + + def test_the_xess_runtime_goes_into_any_upscaler_game_once_downloaded(self): + prefix = tempfile.mkdtemp() + self.addCleanup(shutil.rmtree, prefix, True) + Path(prefix, "pfx/drive_c/windows/system32").mkdir(parents=True) + source = Path(self.root, "data/xess", MODULE["UPSCALE_XESS"]) + source.parent.mkdir(parents=True) + source.write_bytes(b"MZ-xess") + MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "fsr", "DROIDDECK_UPSCALE_ENGINE": "fsr4_1_lite_gpu"}, prefix) + target = Path(prefix, "pfx/drive_c/windows/system32", MODULE["UPSCALE_XESS"]) + self.assertEqual(b"MZ-xess", target.read_bytes()) + self.assertEqual(source.stat().st_ino, target.stat().st_ino) + + def test_a_game_started_on_xess_without_the_runtime_says_so(self): + prefix = tempfile.mkdtemp() + self.addCleanup(shutil.rmtree, prefix, True) + Path(prefix, "pfx/drive_c/windows/system32").mkdir(parents=True) + _, notes = MODULE["upscale_settings"]({"DROIDDECK_UPSCALE_MODE": "fsr", "DROIDDECK_UPSCALE_ENGINE": "xess3_gpu"}, prefix) + self.assertTrue([n for n in notes if "XeSS runtime not downloaded" in n]) + + def test_the_app_stages_every_dll_the_bridge_build_makes(self): + repo = Path(__file__).resolve().parents[2] + build = (repo / "tools/upscale/bridges/build.sh").read_text() + built = set(re.search(r"names=\(([^)]*)\)", build).group(1).split()) + kotlin = (repo / "app/src/main/java/com/droiddeck/launcher/session/UpscaleComponent.kt").read_text() + staged = set(re.findall(r'"([A-Za-z0-9_]+\.dll)"', kotlin[kotlin.index("BRIDGE_NAMES"):kotlin.index("BRIDGE_FILES")])) + self.assertEqual(built, staged) + def test_ngx_registry_entries_are_added_once(self): prefix = tempfile.mkdtemp() try: diff --git a/tools/upscale/layer/fsr4_layer.c b/tools/upscale/layer/fsr4_layer.c index 46365b7bd6..44de658ef7 100644 --- a/tools/upscale/layer/fsr4_layer.c +++ b/tools/upscale/layer/fsr4_layer.c @@ -1240,7 +1240,7 @@ static VkResult VKAPI_CALL hook_vkCreateDevice(VkPhysicalDevice pd, LOAD_V(CmdBindPipeline); LOAD_V(CmdPushConstants); LOAD_V(CmdDispatch); LOAD_V(CmdPipelineBarrier); LOAD_V(CmdPipelineBarrier2); if (!v->CmdPipelineBarrier2) v->CmdPipelineBarrier2 = (PFN_vkCmdPipelineBarrier2)next_gdpa(*pDevice, "vkCmdPipelineBarrier2KHR"); - LOAD_V(CmdClearColorImage); LOAD_V(CmdFillBuffer); + LOAD_V(CmdClearColorImage); LOAD_V(CmdClearDepthStencilImage); LOAD_V(CmdFillBuffer); LOAD_V(CmdCopyBuffer); LOAD_V(CmdCopyImageToBuffer); LOAD_V(CmdCopyBufferToImage); LOAD_V(CmdBlitImage); LOAD_V(CmdCopyImage); LOAD_V(DeviceWaitIdle); LOAD_V(CreateEvent); LOAD_V(DestroyEvent); LOAD_V(SetEvent); LOAD_V(ResetEvent); LOAD_V(GetEventStatus); diff --git a/tools/upscale/layer/fsr4_pipeline.c b/tools/upscale/layer/fsr4_pipeline.c index cb50ecabb3..5a55fc9bf7 100644 --- a/tools/upscale/layer/fsr4_pipeline.c +++ b/tools/upscale/layer/fsr4_pipeline.c @@ -132,6 +132,8 @@ struct WlFsr4Pipeline { f4_buf scratch_buf; f4_img img_hist, img_reproj, img_recurrent, img_out; + /* Stand-in depth for callers that send none (XeSS makes depth optional): D32, cleared to "far". */ + VkImage blank_depth; VkDeviceMemory blank_depth_mem; uint32_t blank_depth_w, blank_depth_h; int blank_depth_far_zero; f4_img img_exp_out, img_exp_at, img_exp_mip; f4_preset presets[2]; @@ -350,6 +352,51 @@ static void img_bar2(WlFsr4Pipeline *p, VkCommandBuffer cb, VkImage img, VkImage p->vk.CmdPipelineBarrier2(cb, &dep); } +static void blank_depth_free(WlFsr4Pipeline *p) { + if (p->blank_depth) p->vk.DestroyImage(p->vk.device, p->blank_depth, NULL); + if (p->blank_depth_mem) p->vk.FreeMemory(p->vk.device, p->blank_depth_mem, NULL); + p->blank_depth = VK_NULL_HANDLE; p->blank_depth_mem = VK_NULL_HANDLE; + p->blank_depth_w = p->blank_depth_h = 0; +} + +/* A render-sized D32 depth image cleared to the far plane (0 with inverted depth, 1 otherwise), left in + * SHADER_READ_ONLY_OPTIMAL like a game's depth input. Only for callers that pass no depth at all: FSR 4 + * then reconstructs from colour and motion alone instead of being skipped. */ +static VkImage blank_depth_get(WlFsr4Pipeline *p, VkCommandBuffer cb, uint32_t w, uint32_t h, int inverted) { + if (p->blank_depth && p->blank_depth_w == w && p->blank_depth_h == h && p->blank_depth_far_zero == inverted) + return p->blank_depth; + blank_depth_free(p); + VkImageCreateInfo ici = { + VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, + .imageType = VK_IMAGE_TYPE_2D, .format = VK_FORMAT_D32_SFLOAT, .extent = {w, h, 1}, .mipLevels = 1, + .arrayLayers = 1, .samples = VK_SAMPLE_COUNT_1_BIT, .tiling = VK_IMAGE_TILING_OPTIMAL, + .usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, + .sharingMode = VK_SHARING_MODE_EXCLUSIVE, .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED, + }; + if (p->vk.CreateImage(p->vk.device, &ici, NULL, &p->blank_depth) != VK_SUCCESS) { p->blank_depth = VK_NULL_HANDLE; return VK_NULL_HANDLE; } + VkMemoryRequirements mr; + p->vk.GetImageMemoryRequirements(p->vk.device, p->blank_depth, &mr); + uint32_t mt = pick_mem_type(&p->memp, mr.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); + VkMemoryAllocateInfo ai = {VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, .allocationSize = mr.size, .memoryTypeIndex = mt}; + if (mt == UINT32_MAX || p->vk.AllocateMemory(p->vk.device, &ai, NULL, &p->blank_depth_mem) != VK_SUCCESS || + p->vk.BindImageMemory(p->vk.device, p->blank_depth, p->blank_depth_mem, 0) != VK_SUCCESS) { + blank_depth_free(p); + return VK_NULL_HANDLE; + } + VkImageSubresourceRange range = {VK_IMAGE_ASPECT_DEPTH_BIT, 0, 1, 0, 1}; + img_bar2(p, cb, p->blank_depth, VK_IMAGE_ASPECT_DEPTH_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT, 0, VK_PIPELINE_STAGE_2_CLEAR_BIT, VK_ACCESS_2_TRANSFER_WRITE_BIT); + VkClearDepthStencilValue far = {inverted ? 0.0f : 1.0f, 0}; + p->vk.CmdClearDepthStencilImage(cb, p->blank_depth, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &far, 1, &range); + img_bar2(p, cb, p->blank_depth, VK_IMAGE_ASPECT_DEPTH_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_PIPELINE_STAGE_2_CLEAR_BIT, VK_ACCESS_2_TRANSFER_WRITE_BIT, + VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT, VK_ACCESS_2_SHADER_READ_BIT); + p->blank_depth_w = w; p->blank_depth_h = h; p->blank_depth_far_zero = inverted; + F4_LOGI("the game sends no depth; a %ux%u stand-in (far = %d) is used", w, h, inverted ? 0 : 1); + return p->blank_depth; +} + + static void mem_bar2(WlFsr4Pipeline *p, VkCommandBuffer cb, VkPipelineStageFlags2 src_s, VkAccessFlags2 src_a, VkPipelineStageFlags2 dst_s, VkAccessFlags2 dst_a) { @@ -859,6 +906,7 @@ void wl_fsr4_pipe_destroy(WlFsr4Pipeline *p) { if (p->fsr411_full) { wl_fsr411_full_gpu_destroy(p->fsr411_full); p->fsr411_full = NULL; } if (p->fsr3_gpu) { wl_fsr3_gpu_destroy(p->fsr3_gpu); p->fsr3_gpu = NULL; } f4_cleanup_npu(p); + blank_depth_free(p); for (uint32_t i = 0; i < F4_VIEW_CACHE; i++) { if (p->view_cache[i].view) p->vk.DestroyImageView(p->vk.device, p->view_cache[i].view, NULL); } @@ -1190,6 +1238,11 @@ int wl_fsr4_pipe_dispatch(WlFsr4Pipeline *p, VkCommandBuffer cb, } if (!rw || !rh || !ow || !oh) return 0; + if (!dep_img) { + dep_img = blank_depth_get(p, cb, rw, rh, (frame->flags & WLFSR4_FLAG_DEPTH_INVERTED) != 0); + if (dep_img) dep_fmt = VK_FORMAT_D32_SFLOAT; + } + VkImageLayout src_lay = frame->color.vk_layout ? (VkImageLayout)frame->color.vk_layout : VK_IMAGE_LAYOUT_GENERAL; VkImageLayout dep_lay = frame->depth.vk_layout ? (VkImageLayout)frame->depth.vk_layout : VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; VkImageLayout mv_lay = frame->motion.vk_layout ? (VkImageLayout)frame->motion.vk_layout : VK_IMAGE_LAYOUT_GENERAL; diff --git a/tools/upscale/layer/fsr4_pipeline.h b/tools/upscale/layer/fsr4_pipeline.h index e08ee3e33c..65480da5e3 100644 --- a/tools/upscale/layer/fsr4_pipeline.h +++ b/tools/upscale/layer/fsr4_pipeline.h @@ -79,6 +79,7 @@ typedef struct WlVkDispatch { PFN_vkCmdPipelineBarrier CmdPipelineBarrier; PFN_vkCmdPipelineBarrier2 CmdPipelineBarrier2; PFN_vkCmdClearColorImage CmdClearColorImage; + PFN_vkCmdClearDepthStencilImage CmdClearDepthStencilImage; PFN_vkCmdFillBuffer CmdFillBuffer; PFN_vkCmdCopyBuffer CmdCopyBuffer; PFN_vkCmdCopyImageToBuffer CmdCopyImageToBuffer;