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
@@ -307,4 +307,51 @@ private:
|
||||
struct Impl;
|
||||
std::unique_ptr<Impl> impl;
|
||||
};
|
||||
// ---------------------------------------------------------------- Super Resolution presets E and F (the DLSS 3 CNN)
|
||||
// NGX 310.7's CNN upscaler: its input kernel and its reconstruction kernel translated from the user's DLL, the
|
||||
// network between them d4r's own packed-f16 shaders (engine/sr/e_net.comp), so it runs on any GPU with binary16
|
||||
// arithmetic, cooperative matrices not required (engine/runtime_e.inc, built by engine/compile_sr_e.py). Same
|
||||
// conventions as the classes above. The device needs shaderFloat16, storageBuffer16BitAccess, shaderInt16,
|
||||
// subgroupSizeControl and computeFullSubgroups with 32-wide subgroups.
|
||||
struct EFrameSettings {
|
||||
float jitter[2] = {0, 0}; // render pixels, as the game passes them to NGX
|
||||
float motionScale[2] = {1, 1}; // NGX's MV scale: motion texels times this are the motion's pixels
|
||||
bool reset = false;
|
||||
};
|
||||
class EModel {
|
||||
public:
|
||||
EModel(VkPhysicalDevice physical, VkDevice device, const std::string& directory, VkPipelineCache cache = VK_NULL_HANDLE);
|
||||
~EModel();
|
||||
EModel(const EModel&) = delete;
|
||||
EModel& operator=(const EModel&) = delete;
|
||||
void recordUpload(VkCommandBuffer command);
|
||||
bool uploadRecorded() const;
|
||||
private:
|
||||
struct Impl;
|
||||
std::unique_ptr<Impl> impl;
|
||||
friend class EEngine;
|
||||
};
|
||||
class EEngine {
|
||||
public:
|
||||
// hdr: NGX's IsHDR (linear colour, the exposure textures); lowResMotion: MVLowRes (render-size motion vectors,
|
||||
// in render pixels; otherwise output-size motion in output pixels). Render size at most the output size.
|
||||
EEngine(EModel& model, uint32_t renderWidth, uint32_t renderHeight, uint32_t outputWidth, uint32_t outputHeight,
|
||||
bool hdr, bool lowResMotion);
|
||||
~EEngine();
|
||||
EEngine(const EEngine&) = delete;
|
||||
EEngine& operator=(const EEngine&) = delete;
|
||||
void recordInitialize(VkCommandBuffer command);
|
||||
// color (and depth with lowResMotion) at the render size, motion at the render or output size; images.exposure
|
||||
// the game's 1x1 exposure (HDR; 1 when absent). A borrowed RGBA16F finalOutput (GENERAL) is written directly.
|
||||
void setFrame(const FrameImages& images, const EFrameSettings& settings, FrameOutput finalOutput = {});
|
||||
// With a timestamp query pool, four stamps are written from query `first`: start, after the input kernel, after
|
||||
// the network and after the reconstruction.
|
||||
void recordFrame(VkCommandBuffer command, VkQueryPool stamps = VK_NULL_HANDLE, uint32_t first = 0);
|
||||
VkImage outputImage() const; // RGBA16F, GENERAL, when no finalOutput was bound
|
||||
struct DebugBuffer { std::string name; VkBuffer buffer; VkDeviceSize offset, bytes; };
|
||||
std::vector<DebugBuffer> debugBuffers() const; // the network's tensors in the arena (engine/replay_e.cpp)
|
||||
private:
|
||||
struct Impl;
|
||||
std::unique_ptr<Impl> impl;
|
||||
};
|
||||
} // namespace d4r
|
||||
Reference in new issue
Block a user