mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-18 00:29:58 -04:00
Scale the scene with the edge-adaptive filter where the game's own upscaler ran.
The stand-in for the game's upscaler enlarged the scene with a linear filter, which is softer than the console's picture. It now enlarges with the edge-adaptive filter the present already scales to the window with: the same shader, built a second time with a constant set so it squares what it filtered, as the linear pass does. The stored square-root values are filtered as before and the decode is the same. standin_filter = bilinear brings the linear pass back, and the setting is live. The linear pass also stays where nothing is enlarged and while DLSS or FSR 3.1 runs, since that upscaler scales the scene itself and its picture goes over the stand-in's. The movies do not go through this pass and are not changed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -81,6 +81,7 @@ static const char *const known[] = {
|
||||
"TEXUP_LOG_MS", "DYN_RES", "DYN_RES_TARGET", "DYN_RES_STEP", "TEXTURE_DETAIL",
|
||||
"RECORDER_CORE", "RECORDER_PRIO", "REPLAY_TIME", "LOCK_TIME", "POOL_CREATE_BUDGET", "POOL_CREATE_MS", "POOL_FINI_IDLE", "POOL_LOAD_BACKLOG", "POOL_LOAD_MS",
|
||||
"VMA_BLOCK_MB", "SYNC_WAKE_ALL", "LOG_ASYNC", "DEVICE_LOST_AT", "STAGING_FAIL_AT", "VRAM_BALLAST_MB",
|
||||
"STANDIN_FILTER", // the filter of the scene upscaler's stand-in (vk_tonemap.c); no menu row
|
||||
"COOP", "COOP_BETA", "COOP_NAME", "COOP_SERVER", "COOP_PORT", "COOP_ROOM", "COOP_AUTO", "COOP_DROP", // co-op (coop.c); the last three have no menu row
|
||||
"COOP_PROGRESS", "COOP_ITEMS", "COOP_SONGS", "COOP_QUEST", "COOP_KEYS", "COOP_RUPEES", "COOP_AMMO", // the room's rules (coop_game.c)
|
||||
"COOP_TEST_SET", // test: sets flags by hash at given frames (coop_game.c); no menu row
|
||||
@@ -102,7 +103,7 @@ static const struct { const char *key, *section; } sections[] = {
|
||||
{"PHYSICS_STEPS", "frame rate"}, {"PICKUP_COUNT", "frame rate"}, {"STEP_STEADY", "frame rate"},
|
||||
{"FULLSCREEN", "display"}, {"WINDOW_SIZE", "display"}, {"PERF_OVERLAY", "display"}, {"VK_PRESENT", "display"},
|
||||
{"GPU_INDEX", "display"}, {"MONITOR", "display"}, {"OUTPUT_RES", "display"}, {"GAME_ASPECT", "display"}, {"GAME_RES", "display"}, {"RENDER_SCALE", "display"}, {"UPSCALER", "display"},
|
||||
{"SHARPNESS", "display"}, {"ASPECT", "display"}, {"FOV", "display"}, {"ANISO", "display"},
|
||||
{"SHARPNESS", "display"}, {"STANDIN_FILTER", "display"}, {"ASPECT", "display"}, {"FOV", "display"}, {"ANISO", "display"},
|
||||
{"TEXTURE_DETAIL", "display"},
|
||||
{"COLOR_PRESET", "display"},
|
||||
{"COLOR_BRIGHTNESS", "display"}, {"COLOR_CONTRAST", "display"}, {"COLOR_SATURATION", "display"},
|
||||
@@ -180,6 +181,7 @@ static const CfgMeta metas[] = {
|
||||
{"PERF_OVERLAY", "off", "off|fps|full", LIVE},
|
||||
{"OUTPUT_RES", "1920x1080", NULL, RESTART}, {"RENDER_SCALE", "game", "game|50|67|75|100|125|150|200", RESTART},
|
||||
{"UPSCALER", "fsr", "fsr|bilinear", LIVE}, {"SHARPNESS", "80", "0..100", LIVE},
|
||||
{"STANDIN_FILTER", "easu", "easu|bilinear", LIVE}, // vk_tonemap.c vk_tonemap_record: how the scene is scaled to the picture
|
||||
{"DLAA", "0", "0|1", LIVE}, {"DLSS", "dlaa", "dlaa|quality|balanced|performance|ultra_performance", LIVE},
|
||||
{"DLSS_PRESET", "default", "default|k|j", LIVE}, {"DLSS_IDLE_FREE", "1", "0|1|2", RESTART}, {"TAA", "dlss", "dlss|fsr3", LIVE}, // vk_dlaa.c fsr3
|
||||
{"FSR4", "0", "0|1", LIVE}, // vk_ffx.cpp vk_ffx_fsr4
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// AMD FidelityFX Super Resolution 1 edge-adaptive upscale (EASU) of the game's output to the swapchain size
|
||||
// (runtime/vk_fsr.c). ffx/ffx_a.h and ffx/ffx_fsr1.h are AMD's headers, unmodified (MIT, ffx/LICENSE.txt). Each
|
||||
// (runtime/vk_fsr.c), and of the scene to the picture's size where the game's own upscaler ran (runtime/vk_tonemap.c,
|
||||
// with SQUARE set). ffx/ffx_a.h and ffx/ffx_fsr1.h are AMD's headers, unmodified (MIT, ffx/LICENSE.txt). Each
|
||||
// invocation writes four pixels of a 16x16 tile, as AMD's sample does; the constants come from FsrEasuConOffset, so the
|
||||
// game's crop rectangle can start anywhere in its image.
|
||||
#version 450
|
||||
@@ -15,6 +16,12 @@ layout(push_constant) uniform Params {
|
||||
vec4 out_; // output width, output height, crop x, crop y
|
||||
} pc;
|
||||
|
||||
// Specialization constant 0, which only vk_tonemap.c sets: its source holds the square root of each linear value (the
|
||||
// game's post pass stores the picture so) and its output is linear, so what the filter gives is squared. The filter
|
||||
// runs on the stored values either way: square roots are the perceptual encoding it is made for, and the game's own
|
||||
// upscaler filters them too. Unset (the present): the filtered value as it is.
|
||||
layout(constant_id = 0) const bool SQUARE = false;
|
||||
|
||||
#define A_GPU 1
|
||||
#define A_GLSL 1
|
||||
#include "ffx/ffx_a.h"
|
||||
@@ -28,6 +35,7 @@ void put(AU2 p, AU4 c0, AU4 c1, AU4 c2, AU4 c3) {
|
||||
if (p.x >= uint(pc.out_.x) || p.y >= uint(pc.out_.y)) return;
|
||||
AF3 c;
|
||||
FsrEasuF(c, p, c0, c1, c2, c3);
|
||||
if (SQUARE) c *= c;
|
||||
imageStore(dst, ivec2(p), vec4(c, 1.0));
|
||||
}
|
||||
|
||||
|
||||
10
runtime/vk.h
10
runtime/vk.h
@@ -655,10 +655,12 @@ uint64_t vk_pool_takes(void);
|
||||
void vk_texture_pool_ctx(int on);
|
||||
VkDescriptorSetLayout vk_pool_set_layout(void); // the pools' layout (made on first use)
|
||||
VkDescriptorSetLayout vk_empty_set_layout(void); // set 1 of layouts without one
|
||||
// The upscaler stand-in (vk_tonemap.c): src (sampled) scaled to dw x dh and tonemapped into its own RGBA16F image, which
|
||||
// it returns for the caller to blit into the target; VK_NULL_HANDLE when it cannot. The caller binds its own compute
|
||||
// pipeline again afterwards.
|
||||
VkImage vk_tonemap_record(VkCommandBuffer cb, VkImage src, VkFormat sf, uint32_t dw, uint32_t dh);
|
||||
// The upscaler stand-in (vk_tonemap.c): src (sampled, sw x sh) scaled to dw x dh and tonemapped into its own RGBA16F
|
||||
// image, which it returns for the caller to blit into the target; VK_NULL_HANDLE when it cannot. edge: 1 lets it scale
|
||||
// with the edge-adaptive filter (NX2NAVI_STANDIN_FILTER), 0 keeps the linear one (another upscaler's picture replaces
|
||||
// this one). The caller binds its own compute pipeline again afterwards.
|
||||
VkImage vk_tonemap_record(VkCommandBuffer cb, VkImage src, VkFormat sf, uint32_t sw, uint32_t sh, uint32_t dw,
|
||||
uint32_t dh, int edge);
|
||||
// What vk_texture_by_id(id) returns can change only when this does: the slot is registered again, or a texture entry at
|
||||
// its storage address is created, dropped, released or taken back into use. Unlocked; read it before the lookup it
|
||||
// guards (a lookup may create an entry). 0 when the slot was never registered: nothing is kept under 0.
|
||||
|
||||
@@ -646,6 +646,9 @@ const VkTexImage *vk_dlaa_swap_img;
|
||||
VkImageView vk_dlaa_swap_view;
|
||||
|
||||
static int dl_active(void) { return N.available && !D.failed && D.on; }
|
||||
// The same for vk_exec_draw.c untranslated_dispatch_fallback: while it holds, DLSS or FSR 3.1 scales the scene and the
|
||||
// stand-in of the game's own upscaler does not make the picture the screen shows (vk_dlaa_upscaler).
|
||||
int vk_dlaa_active(void) { return dl_active(); }
|
||||
// The upscaler this frame runs with, as vk_dlaa_frame read it. The menu can set NX2NAVI_TAA to dlss between that and
|
||||
// evaluate; read again there while NGX is not up (DLSS starts only after a restart), it sent evaluate to DLSS's path
|
||||
// with NGX's functions not loaded, a call to address 0 (issue #325).
|
||||
|
||||
@@ -68,6 +68,9 @@ void vk_dlaa_pass(VkExec *ex);
|
||||
// vk_exec_draw.c untranslated_dispatch_fallback, after the stand-in of the game's own upscaler wrote its output image
|
||||
// (in GENERAL, of format fmt and w x h): DLSS or FSR runs there on the armed scene and its picture goes over it.
|
||||
void vk_dlaa_upscaler(VkExec *ex, VkImage out, VkFormat fmt, uint32_t w, uint32_t h);
|
||||
// 1 while DLSS or FSR 3.1 runs on the scene (the setting is on, the upscaler came up and has not failed): it scales the
|
||||
// scene itself, and vk_dlaa_upscaler puts its picture over the stand-in's. The thread that records the frame asks.
|
||||
int vk_dlaa_active(void);
|
||||
void vk_dlaa_frame(void);
|
||||
// 1 once, at the present of the first frame whose scene has a new size after a setting changed (vk_dlaa.c).
|
||||
int vk_dlaa_resized_take(void);
|
||||
|
||||
@@ -7089,7 +7089,12 @@ static void untranslated_dispatch_fallback(VkExec *ex) {
|
||||
#if NX2NAVI_TONEMAP_STANDIN
|
||||
// The square decode of the stored picture (vk_tonemap.c). Builds of round 24 lost the device with it: its descriptor
|
||||
// push did not go through the recorder (vk_rec.h rec_push; PORT-HANDOFF 7.12 item 11), which it now does.
|
||||
VkImage tm = e5 && dst_view ? vk_tonemap_record(ex->cb, e5, VK_FORMAT_E5B9G9R9_UFLOAT_PACK32, dw, dh) : VK_NULL_HANDLE;
|
||||
// Its edge-adaptive filter is for the picture the screen shows: while DLSS or FSR 3.1 runs (vk_dlaa_active) that
|
||||
// upscaler scales the scene itself and vk_dlaa_upscaler below puts its picture over this one, so the pass keeps
|
||||
// its linear filter there, also in the few frames that upscaler misses.
|
||||
VkImage tm = e5 && dst_view ? vk_tonemap_record(ex->cb, e5, VK_FORMAT_E5B9G9R9_UFLOAT_PACK32, sw, sh, dw, dh,
|
||||
!vk_dlaa_active())
|
||||
: VK_NULL_HANDLE;
|
||||
if (tm) { // the tonemapped picture, already at the target's size, then the same blit as below
|
||||
ex->dc->B.pipe[1] = VK_NULL_HANDLE; // the replay must bind its compute pipeline again
|
||||
si = tm, sw = dw, sh = dh;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "cfg.h"
|
||||
#include "fallback_tonemap_spv.h"
|
||||
#include "fsr_easu_spv.h"
|
||||
#include "host.h"
|
||||
|
||||
// The game's upscaler (tensor-core, untranslatable) reads the post pass's picture, whose channels hold the square root of
|
||||
@@ -16,12 +17,26 @@
|
||||
// and tonemaps before the post pass, so nothing here changes exposure. (It was a tonemap once, when the input was
|
||||
// taken for the raw HDR scene; the blit's sRGB decode that stood in since darkened mid-tones and lifted the darkest
|
||||
// values.)
|
||||
//
|
||||
// The filter: the console's upscaler is a network that rebuilds edges, and a linear filter over a scene drawn at about
|
||||
// three quarters of the picture is visibly softer than that. With NX2NAVI_STANDIN_FILTER = easu (the default) the
|
||||
// pass that enlarges is shaders/fsr_easu.comp instead, the edge-adaptive filter the present scales to the window with
|
||||
// (vk_fsr.c), built here with its SQUARE constant set: it filters the same stored values, which are the perceptual
|
||||
// encoding that filter is made for, and squares the result as the linear pass does, so only how the scaled sample is
|
||||
// taken differs. bilinear keeps the linear pass. The linear pass also stays where nothing is enlarged (the filter only
|
||||
// enlarges, and at the same size the linear pass copies each texel exactly) and where the caller says another
|
||||
// upscaler's picture replaces this one (vk_exec_draw.c untranslated_dispatch_fallback: DLSS or FSR 3.1, vk_dlaa.c).
|
||||
// The movie's frames do not come through here: the caller blits those (RGBA8) itself.
|
||||
static struct {
|
||||
int tried, ok;
|
||||
PFN_vkCmdPushDescriptorSetKHR push;
|
||||
VkDescriptorSetLayout dsl;
|
||||
VkPipelineLayout layout;
|
||||
VkPipeline pipe;
|
||||
VkPipeline pipe; // scale with linear filtering, then square (shaders/fallback_tonemap.spvasm)
|
||||
VkPipeline easu; // scale with the edge-adaptive filter, then square (shaders/fsr_easu.comp)
|
||||
int easu_tried;
|
||||
int filter_logs; // lines tm_filter_log has written
|
||||
int filter_last; // what its last line named: 1 the linear filter, 2 the edge-adaptive one
|
||||
VkSampler sampler;
|
||||
struct { VkImage img; VkFormat f; VkImageView view; } views[16];
|
||||
int nviews;
|
||||
@@ -74,7 +89,7 @@ static int tm_init(void) {
|
||||
VkDescriptorSetLayoutCreateInfo dci = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
|
||||
.flags = VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR,
|
||||
.bindingCount = 2, .pBindings = b};
|
||||
VkPushConstantRange pr = {VK_SHADER_STAGE_COMPUTE_BIT, 0, 24};
|
||||
VkPushConstantRange pr = {VK_SHADER_STAGE_COMPUTE_BIT, 0, 32}; // the linear pass reads 24 bytes, tm_easu's 32
|
||||
VkSamplerCreateInfo si = {.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, .magFilter = VK_FILTER_LINEAR,
|
||||
.minFilter = VK_FILTER_LINEAR, .mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST,
|
||||
.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||
@@ -101,6 +116,51 @@ static int tm_init(void) {
|
||||
return TM.ok = ok;
|
||||
}
|
||||
|
||||
// The edge-adaptive pipeline, made at the first frame that asks for it (a run that never does, with the setting at
|
||||
// bilinear or DLSS on, never builds it): the present's EASU shader with specialization constant 0 (SQUARE) set, on
|
||||
// this file's layout, whose two bindings are that shader's. VK_NULL_HANDLE when it cannot be made; the linear pass
|
||||
// then stays.
|
||||
static VkPipeline tm_easu(void) {
|
||||
if (TM.easu_tried) return TM.easu;
|
||||
TM.easu_tried = 1;
|
||||
VkCtx *c = vk_ctx();
|
||||
VkShaderModuleCreateInfo mi = {.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO, .codeSize = sizeof fsr_easu_spv,
|
||||
.pCode = fsr_easu_spv};
|
||||
VkShaderModule m = VK_NULL_HANDLE;
|
||||
static const VkBool32 square = VK_TRUE;
|
||||
VkSpecializationMapEntry me = {.constantID = 0, .offset = 0, .size = sizeof square};
|
||||
VkSpecializationInfo sp = {.mapEntryCount = 1, .pMapEntries = &me, .dataSize = sizeof square, .pData = &square};
|
||||
if (vkCreateShaderModule(c->device, &mi, NULL, &m) == VK_SUCCESS) {
|
||||
VkComputePipelineCreateInfo ci = {.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
|
||||
.stage = {.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
|
||||
.stage = VK_SHADER_STAGE_COMPUTE_BIT, .module = m, .pName = "main",
|
||||
.pSpecializationInfo = &sp},
|
||||
.layout = TM.layout};
|
||||
if (vkCreateComputePipelines(c->device, VK_NULL_HANDLE, 1, &ci, NULL, &TM.easu) != VK_SUCCESS)
|
||||
TM.easu = VK_NULL_HANDLE;
|
||||
vkDestroyShaderModule(c->device, m, NULL);
|
||||
}
|
||||
if (!TM.easu) rt_log("vk_exec: upscaler stand-in: its edge-adaptive pass could not be created; it scales bilinearly");
|
||||
return TM.easu;
|
||||
}
|
||||
|
||||
// One log line when the filter the pass scales with changes (the setting, DLSS or FSR switched on or off, a scene as
|
||||
// large as the picture), 8 at most: a scene whose size changes from frame to frame can cross the picture's size often.
|
||||
static void tm_filter_log(int easu, int edge, uint32_t sw, uint32_t sh, uint32_t dw, uint32_t dh) {
|
||||
int now = easu ? 2 : 1;
|
||||
if (TM.filter_last == now || TM.filter_logs >= 8) return;
|
||||
TM.filter_last = now, TM.filter_logs++;
|
||||
if (easu)
|
||||
rt_log("vk_exec: upscaler stand-in scales %ux%u to %ux%u with the edge-adaptive filter "
|
||||
"(NX2NAVI_STANDIN_FILTER=bilinear: the linear one)", sw, sh, dw, dh);
|
||||
else
|
||||
rt_log("vk_exec: upscaler stand-in scales %ux%u to %ux%u with the linear filter: %s", sw, sh, dw, dh,
|
||||
!edge ? "DLSS or FSR scales the scene and its picture goes over this one"
|
||||
: dw < sw || dh < sh || (dw == sw && dh == sh) ? "nothing to enlarge"
|
||||
: strcmp(cfg_value("NX2NAVI_STANDIN_FILTER"), "easu") ? "NX2NAVI_STANDIN_FILTER asks for it"
|
||||
: "the edge-adaptive pass is not there");
|
||||
}
|
||||
|
||||
// Views of the scratch images the pass samples, kept for the process (the scratch images live as long).
|
||||
static VkImageView tm_view(VkImage img, VkFormat f) {
|
||||
for (int i = 0; i < TM.nviews; i++)
|
||||
@@ -114,20 +174,27 @@ static VkImageView tm_view(VkImage img, VkFormat f) {
|
||||
return v;
|
||||
}
|
||||
|
||||
// Records the pass from src (sampled) into the pass's own RGBA16F image of dw x dh and returns it (the caller blits it
|
||||
// into the target); VK_NULL_HANDLE when it cannot (the caller blits the source instead).
|
||||
VkImage vk_tonemap_record(VkCommandBuffer cb, VkImage src, VkFormat sf, uint32_t dw, uint32_t dh) {
|
||||
// Records the pass from src (sampled, sw x sh) into the pass's own RGBA16F image of dw x dh and returns it (the caller
|
||||
// blits it into the target); VK_NULL_HANDLE when it cannot (the caller blits the source instead). edge: the picture is
|
||||
// what the screen shows, so the edge-adaptive filter may scale it (0: another upscaler's picture replaces it).
|
||||
VkImage vk_tonemap_record(VkCommandBuffer cb, VkImage src, VkFormat sf, uint32_t sw, uint32_t sh, uint32_t dw,
|
||||
uint32_t dh, int edge) {
|
||||
static int disp = -1; // NX2NAVI_TM_DISPATCH=0: everything but the dispatch, =2: not at all (diagnosis)
|
||||
if (disp < 0) disp = rt_knob("TM_DISPATCH", "1");
|
||||
if (disp == 2 || !tm_init() || !tm_out(cb, dw, dh)) return VK_NULL_HANDLE;
|
||||
VkImageView sv = tm_view(src, sf), dv = TM.out_view;
|
||||
if (!sv) return VK_NULL_HANDLE;
|
||||
// NX2NAVI_STANDIN_FILTER, read each frame (the setting is live). The edge-adaptive filter only enlarges: a target
|
||||
// smaller than the source in either direction, or of its size, keeps the linear pass.
|
||||
int want = edge && dw >= sw && dh >= sh && (dw > sw || dh > sh) && !strcmp(cfg_value("NX2NAVI_STANDIN_FILTER"), "easu");
|
||||
VkPipeline easu = want ? tm_easu() : VK_NULL_HANDLE;
|
||||
tm_filter_log(easu != VK_NULL_HANDLE, edge, sw, sh, dw, dh);
|
||||
VkMemoryBarrier2 mb = {.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER_2, .srcStageMask = VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT,
|
||||
.srcAccessMask = VK_ACCESS_2_MEMORY_WRITE_BIT, .dstStageMask = VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
|
||||
.dstAccessMask = VK_ACCESS_2_SHADER_READ_BIT | VK_ACCESS_2_SHADER_WRITE_BIT};
|
||||
VkDependencyInfo dep = {.sType = VK_STRUCTURE_TYPE_DEPENDENCY_INFO, .memoryBarrierCount = 1, .pMemoryBarriers = &mb};
|
||||
vkCmdPipelineBarrier2(cb, &dep);
|
||||
vkCmdBindPipeline(cb, VK_PIPELINE_BIND_POINT_COMPUTE, TM.pipe);
|
||||
vkCmdBindPipeline(cb, VK_PIPELINE_BIND_POINT_COMPUTE, easu ? easu : TM.pipe);
|
||||
VkDescriptorImageInfo ii[2] = {{TM.sampler, sv, VK_IMAGE_LAYOUT_GENERAL}, {VK_NULL_HANDLE, dv, VK_IMAGE_LAYOUT_GENERAL}};
|
||||
VkWriteDescriptorSet w[2] = {
|
||||
{.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .dstBinding = 0, .descriptorCount = 1,
|
||||
@@ -135,10 +202,19 @@ VkImage vk_tonemap_record(VkCommandBuffer cb, VkImage src, VkFormat sf, uint32_t
|
||||
{.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, .dstBinding = 1, .descriptorCount = 1,
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, .pImageInfo = &ii[1]}};
|
||||
rec_push(TM.push, cb, VK_PIPELINE_BIND_POINT_COMPUTE, TM.layout, 0, 2, w); // through the recorder (vk_rec.h), in order
|
||||
struct { float inv[2], unused, pad; int32_t size[2]; } pc = {{1.0f / (float)dw, 1.0f / (float)dh}, 0, 0,
|
||||
{(int32_t)dw, (int32_t)dh}};
|
||||
vkCmdPushConstants(cb, TM.layout, VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof pc, &pc);
|
||||
if (disp) vkCmdDispatch(cb, (dw + 7) / 8, (dh + 7) / 8, 1);
|
||||
if (easu) {
|
||||
// shaders/fsr_easu.comp's constants: the part of the source that is the picture and the source's size (the
|
||||
// whole image both times, as the linear pass maps it), then the output's size and the picture's corner in the
|
||||
// source. Each of its groups writes a 16x16 tile.
|
||||
const float pc[8] = {(float)sw, (float)sh, (float)sw, (float)sh, (float)dw, (float)dh, 0, 0};
|
||||
vkCmdPushConstants(cb, TM.layout, VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof pc, pc);
|
||||
if (disp) vkCmdDispatch(cb, (dw + 15) / 16, (dh + 15) / 16, 1);
|
||||
} else {
|
||||
struct { float inv[2], unused, pad; int32_t size[2]; } pc = {{1.0f / (float)dw, 1.0f / (float)dh}, 0, 0,
|
||||
{(int32_t)dw, (int32_t)dh}};
|
||||
vkCmdPushConstants(cb, TM.layout, VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof pc, &pc);
|
||||
if (disp) vkCmdDispatch(cb, (dw + 7) / 8, (dh + 7) / 8, 1);
|
||||
}
|
||||
VkMemoryBarrier2 after = {.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER_2, .srcStageMask = VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
|
||||
.srcAccessMask = VK_ACCESS_2_SHADER_WRITE_BIT, .dstStageMask = VK_PIPELINE_STAGE_2_ALL_TRANSFER_BIT,
|
||||
.dstAccessMask = VK_ACCESS_2_TRANSFER_READ_BIT};
|
||||
|
||||
Reference in New Issue
Block a user