engine: Super Resolution presets E and F, the DLSS 3 CNN, on RDNA2
Presets E (5) and F (6) run on d4r's own Vulkan engine without cooperative matrices: the input and reconstruction kernels translated from the user's DLL (engine/compile_sr_e.py, rr/ptx2rr.py), the network engine/sr/e_net.comp with packed v_pk_fma_f16 accumulation (engine/cnn_sr/mma_f16.glsl, the default head; --head-accumulation f32 keeps the f32 head). Runtime runtime_e.inc (EModel/EEngine), game adapter game_e.cpp, replay d4r-e; the shim serves them from engine\e and engine\f (D4R_ENGINE_MODEL_E_DIR / _F_DIR), LDR or HDR, any render size, not with AutoExposure. build-engine-models.sh builds both. Translator fixes that apply to every translated kernel: .relu on f16/f16x2 fma/add/mul was ignored; add.rz was always taken for the roundf idiom (lost the log1pf correction term); formatted image stores expand at the call site (SPIR-V image type fix); f16 mma.sync m16n8k8/k16, .const loads, shared 16-bit stores, aligned 32-bit arena words (D4R_WORD_ARENA), unified arena. Steam Deck gfx1033: 2.55 ms at 640x360 -> 1280x720, 6.20 ms at 1080p output; Rounded Quality sizes take mid_3x3 (reconstruction 2.44 -> 1.23 ms). Ray Reconstruction CNN presets A-C (compile_rr3.py, the packed RR flavor) stay out of this commit; engine/README.md already documents their tuning.
This commit is contained in:
1 parent
0e851b7f90
commit
b9254f7f96
25 files changed
+2406
-36
No files matched your search
@@ -0,0 +1,55 @@
|
||||
#include "game_e.h"
|
||||
#include "game_internal.h"
|
||||
|
||||
namespace d4r {
|
||||
|
||||
struct GameUpscalerE::Impl {
|
||||
EModel& model;
|
||||
EEngine engine;
|
||||
uint32_t width, height, outputWidth, outputHeight, motionWidth, motionHeight;
|
||||
game_detail::CanonicalInputs fallback;
|
||||
bool started = false;
|
||||
Impl(EModel& m, VkPhysicalDevice p, VkDevice d, uint32_t ow, uint32_t oh, uint32_t rw, uint32_t rh, bool hdr, bool lowRes)
|
||||
: model(m), engine(m, rw, rh, ow, oh, hdr, lowRes), width(rw), height(rh), outputWidth(ow), outputHeight(oh),
|
||||
motionWidth(lowRes ? rw : ow), motionHeight(lowRes ? rh : oh), fallback(p, d, rw, rh, motionWidth, motionHeight) {}
|
||||
};
|
||||
GameUpscalerE::GameUpscalerE(EModel& model, VkPhysicalDevice physical, VkDevice device, uint32_t outputWidth, uint32_t outputHeight,
|
||||
uint32_t renderWidth, uint32_t renderHeight, bool hdr, bool lowResMotion)
|
||||
: impl(std::make_unique<Impl>(model, physical, device, outputWidth, outputHeight, renderWidth, renderHeight, hdr, lowResMotion)) {}
|
||||
GameUpscalerE::~GameUpscalerE() = default;
|
||||
|
||||
void GameUpscalerE::record(VkCommandBuffer cb, const GameFrameE& frame) {
|
||||
auto& g = *impl;
|
||||
if (!gameColorFormat(frame.color.format) || !gameMotionFormat(frame.motion.format) ||
|
||||
!gameDepthFormat(frame.depth.format, frame.depth.aspect) || !gameOutputFormat(frame.output.format))
|
||||
throw std::runtime_error("unsupported game texture format");
|
||||
const bool directColor = frame.color.view != VK_NULL_HANDLE && !frame.color.x && !frame.color.y;
|
||||
const bool directMotion = frame.motion.view != VK_NULL_HANDLE && !frame.motion.x && !frame.motion.y;
|
||||
const bool directDepth = frame.depth.view != VK_NULL_HANDLE && !frame.depth.x && !frame.depth.y;
|
||||
const bool directOutput = game_detail::directOutput(frame.output, frame.color, frame.motion, frame.depth, false) &&
|
||||
!frame.output.x && !frame.output.y;
|
||||
if (!g.started) {
|
||||
if (!g.model.uploadRecorded()) g.model.recordUpload(cb);
|
||||
g.engine.recordInitialize(cb);
|
||||
g.started = true;
|
||||
}
|
||||
g.fallback.record(cb, frame.color, frame.motion, frame.depth, g.width, g.height, g.motionWidth, g.motionHeight,
|
||||
directColor, directMotion, directDepth);
|
||||
EFrameSettings s;
|
||||
s.jitter[0] = frame.jitter[0]; s.jitter[1] = frame.jitter[1];
|
||||
s.motionScale[0] = frame.motionScale[0]; s.motionScale[1] = frame.motionScale[1];
|
||||
s.reset = frame.reset;
|
||||
FrameImages images{};
|
||||
images.color = directColor ? frame.color.view : g.fallback.color.view;
|
||||
images.motion = directMotion ? frame.motion.view : g.fallback.motion.view;
|
||||
images.depth = directDepth ? frame.depth.view : g.fallback.depth.view;
|
||||
images.colorLayout = directColor ? frame.color.layout : VK_IMAGE_LAYOUT_GENERAL;
|
||||
images.motionLayout = directMotion ? frame.motion.layout : VK_IMAGE_LAYOUT_GENERAL;
|
||||
images.depthLayout = directDepth ? frame.depth.layout : VK_IMAGE_LAYOUT_GENERAL;
|
||||
images.exposure = frame.exposure.view;
|
||||
images.exposureLayout = frame.exposure.layout;
|
||||
g.engine.setFrame(images, s, directOutput ? FrameOutput{frame.output.view, frame.output.format} : FrameOutput{});
|
||||
g.engine.recordFrame(cb);
|
||||
if (!directOutput) game_detail::copyOutput(cb, g.engine.outputImage(), frame.output, g.outputWidth, g.outputHeight);
|
||||
}
|
||||
} // namespace d4r
|
||||
Reference in new issue
Block a user