Files
d4r/engine/game_e.h
T
woutermans 3f66081add engine: presets E/F AutoExposure, the game's exposure fields and NGX's jitter order
NGX's CNN takes this frame's exposure scale and pre-exposure in both translated kernels (input words 244-256,
reconstruction 592-604) and the previous frame's exposure as the input kernel's texture 352
(cuda_copy_exposure_kernel's half surface). The runtime left all of it at the model dump's values, so HDR games
with a pre-exposure other than 1 or a changing exposure measured 18-39 dB against NGX; now 54-64 dB.

AutoExposure (flag 0x40), which the shim refused for E/F: NGX runs K's log-mean measurement on M's grid every
second frame. exposure_k.comp MODE 3 writes it to the 1x1 image the kernels sample; sr/exposure_copy_e.comp
keeps the previous exposure. 60-66 dB over eleven frames at 960x540 -> 1920x1080, pre-exposure 19-21.

The reconstruction's jitter words 544-556 are (y, x); the runtime wrote (-x, -y), which matches only the
harness's first three jitters, so every later frame of a game's jitter sequence measured 26-28 dB. Twelve-frame
captures now measure 60-66 dB HDR and LDR; on the Steam Deck through the shim 51-67 dB against ZLUDA.

The D3D12 harness takes per-frame lists in D4R_HARNESS_PRE_EXPOSURE / _EXPOSURE_SCALE; d4r-e takes the
AutoExposure flag, per-frame exposure values and the game's exposure texture. E/F models need rebuilding
(the install's model cache key changes); older models keep the old binding and refuse AutoExposure.
2026-10-19 02:42:48 +02:00

31 lines
1.7 KiB
C++

// Adapter between a game's own textures and the preset E/F engine (DLSS 3's CNN, engine/runtime_e.inc): input
// conversion, the frame and the copy into the game's output texture, all recorded into the game's command buffer.
#pragma once
#include "game.h"
namespace d4r {
struct GameFrameE {
GameImage color, depth, motion, output; // as for GameUpscaler; compatible views at origin zero may be borrowed
GameImage exposure; // HDR without autoExposure: the game's 1x1 float exposure (a sampled view), else 1
float jitter[2] = {0, 0};
float motionScale[2] = {1, 1}; // NGX's MV scale
float preExposure = 1, exposureScale = 1; // the game's (DLSS.Pre.Exposure, DLSS.Exposure.Scale)
bool reset = false;
};
class GameUpscalerE {
public:
// The model must outlive this object. Render size fixed for its lifetime (a new size needs a new adapter).
// lowResMotion: motion at the render size (NGX's MVLowRes), otherwise at the output size. autoExposure: NGX's
// AutoExposure (HDR), the exposure measured from the colour (EModel::hasAutoExposure).
GameUpscalerE(EModel& model, VkPhysicalDevice physical, VkDevice device, uint32_t outputWidth, uint32_t outputHeight,
uint32_t renderWidth, uint32_t renderHeight, bool hdr, bool lowResMotion, bool autoExposure = false);
~GameUpscalerE(); // only once every recorded frame has completed on the GPU
GameUpscalerE(const GameUpscalerE&) = delete;
GameUpscalerE& operator=(const GameUpscalerE&) = delete;
void record(VkCommandBuffer command, const GameFrameE& frame);
private:
struct Impl;
std::unique_ptr<Impl> impl;
};
} // namespace d4r