mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 04:55:44 +00:00
* feat(lsfg): take Lossless Scaling from Steam by itself, import it once owned, rebuild on update - Lossless.kt owns the DLL and its shader cache. The copy the Steam client installs (runtime library or the card's) is taken by itself and taken again when the client updates it (size/mtime stamp). The DLL is copied in and built into a cache named after its SHA-256, so a new DLL hands the compositor a new path; a build that fails keeps the working cache. Builds are serialized. - The Steam session asks the signed-in client once per session whether the account owns app 993090 until the answer is yes, then records it and the app stops asking (BL_LOSSLESS_OWNED). Once owned, the frame generation menu offers "Import Lossless.dll…", on the main screen and in the session drawer; an import stays until Steam's copy changes. - The compositor restarts the LSFG engine when its cache path changes, and a new engine selection clears an earlier start failure, so an updated DLL or a retry no longer needs the app restarted. - The HUD says when LSFG is waiting on Lossless Scaling instead of "starting"; frame generation strings are resources. - Removed LsfgNative's unused DLL variant and cache-match calls. * Find Lossless.dll in added Games libraries too * LSFG: 120, 90 and 60 fps targets alongside 2x-4x The pacer's target-rate mode picks 0-3 generations per game frame. While it is warm the input ring and shared chain follow every frame, so frames that generate nothing don't leave the next one without history. * Credit LSFG: Camille LaVey / Eden, ported to WinNative and DroidDeck by @maxjivi05 * LSFG: aim 0.1 fps under the target so output never passes the refresh rate
86 lines
3.1 KiB
C++
86 lines
3.1 KiB
C++
// See lsfg_dxbc.h. DXBC -> SPIR-V via DXVK's vendored translator.
|
|
//
|
|
// Follows upstream lsfg-vk's src/extract/trans.cpp, including its
|
|
// encounter-order binding renumber. Ported to WinNative (lsfg_dxbc.cpp) and
|
|
// DroidDeck by @maxjivi05 from the work of Camille LaVey / the Eden Emulator
|
|
// Project (GPL-3.0-or-later); the translator itself is DXVK's, zlib licensed,
|
|
// vendored under cpp/thirdparty/dxbc.
|
|
|
|
#include "lsfg_dxbc.h"
|
|
|
|
#include <algorithm>
|
|
#include <cstring>
|
|
|
|
#include <dxbc_modinfo.h>
|
|
#include <dxbc_module.h>
|
|
#include <dxbc_reader.h>
|
|
#include <thirdparty/spirv.hpp>
|
|
|
|
namespace lsfg {
|
|
namespace {
|
|
|
|
struct BindingSlot {
|
|
uint32_t bindingIndex = 0;
|
|
uint32_t bindingOffset = 0; // word offset of the Binding literal
|
|
uint32_t setIndex = 0;
|
|
uint32_t setOffset = 0;
|
|
};
|
|
|
|
} // namespace
|
|
|
|
bool translateDxbc(const uint8_t* bytecode, uint32_t size, std::vector<uint32_t>& outWords) {
|
|
outWords.clear();
|
|
if (!bytecode || size < 4) return false;
|
|
|
|
try {
|
|
dxvk::DxbcReader reader(reinterpret_cast<const char*>(bytecode), size);
|
|
dxvk::DxbcModule module(reader);
|
|
const dxvk::DxbcModuleInfo info{};
|
|
auto code = module.compile(info, "CS");
|
|
|
|
// Collect the descriptor decorations in the order the Binding
|
|
// decorations appear. Everything before the first OpFunction is the
|
|
// decoration block, so the scan stops there.
|
|
std::vector<BindingSlot> slotsByVarId;
|
|
std::vector<uint32_t> varIdsInOrder;
|
|
for (auto ins : code) {
|
|
if (ins.opCode() == spv::OpDecorate) {
|
|
const uint32_t varId = ins.arg(1);
|
|
if (ins.arg(2) == spv::DecorationBinding) {
|
|
slotsByVarId.resize(std::max(slotsByVarId.size(), (size_t)varId + 1));
|
|
slotsByVarId[varId].bindingIndex = ins.arg(3);
|
|
slotsByVarId[varId].bindingOffset = ins.offset() + 3;
|
|
varIdsInOrder.push_back(varId);
|
|
} else if (ins.arg(2) == spv::DecorationDescriptorSet) {
|
|
slotsByVarId.resize(std::max(slotsByVarId.size(), (size_t)varId + 1));
|
|
slotsByVarId[varId].setIndex = ins.arg(3);
|
|
slotsByVarId[varId].setOffset = ins.offset() + 3;
|
|
}
|
|
}
|
|
if (ins.opCode() == spv::OpFunction) break;
|
|
}
|
|
|
|
// Renumber to a dense 0..n range, in encounter order.
|
|
uint32_t next = 0;
|
|
for (const uint32_t varId : varIdsInOrder) {
|
|
const BindingSlot& slot = slotsByVarId[varId];
|
|
if (slot.bindingOffset == 0) continue;
|
|
code.data()[slot.bindingOffset] = next++;
|
|
}
|
|
|
|
const size_t byteSize = code.size();
|
|
if (byteSize == 0 || byteSize % sizeof(uint32_t) != 0) return false;
|
|
|
|
outWords.resize(byteSize / sizeof(uint32_t));
|
|
std::memcpy(outWords.data(), code.data(), byteSize);
|
|
return true;
|
|
} catch (...) {
|
|
// DXVK's compiler signals malformed bytecode by throwing. A bad
|
|
// resource must degrade to "this DLL is unusable", never to a crash.
|
|
outWords.clear();
|
|
return false;
|
|
}
|
|
}
|
|
|
|
} // namespace lsfg
|