mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-23 12:26:56 +02:00
shader: preserve folded native constants for descriptor provenance
This commit is contained in:
@@ -604,9 +604,20 @@ private:
|
||||
candidates.push_back(inst);
|
||||
}
|
||||
}
|
||||
if (candidates.empty()) return value;
|
||||
const auto source_at = [&](uint32_t pc) {
|
||||
Value source;
|
||||
bool dynamic = false;
|
||||
for (auto write = std::ranges::lower_bound(m_scalar_writes, pc, {}, &Program::ScalarWrite::pc);
|
||||
write != m_scalar_writes.end() && write->pc == pc; ++write) {
|
||||
if (RegIndex(write->reg) != reg) continue;
|
||||
if (!write->value.IsImmediate() || write->value.GetType() != Type::U32) {
|
||||
dynamic = true;
|
||||
continue;
|
||||
}
|
||||
if (!source.IsEmpty() && source != write->value) return Value {};
|
||||
source = write->value;
|
||||
}
|
||||
if (!source.IsEmpty()) return dynamic ? Value {} : source;
|
||||
const auto native = std::ranges::lower_bound(m_decoded.instructions, pc, {},
|
||||
&Decoder::Instruction::pc);
|
||||
for (const auto* candidate: candidates) {
|
||||
@@ -644,8 +655,9 @@ private:
|
||||
const auto source = source_at(pc);
|
||||
if (source.IsEmpty()) return false;
|
||||
if (!selected.IsEmpty()) {
|
||||
const auto op = source.TryInstruction()->GetOpcode();
|
||||
if ((op == ValueOpcode::LoadAddressU32 || op == ValueOpcode::ReadConstBuffer) &&
|
||||
const auto* inst = source.TryInstruction();
|
||||
if (inst != nullptr &&
|
||||
(inst->GetOpcode() == ValueOpcode::LoadAddressU32 || inst->GetOpcode() == ValueOpcode::ReadConstBuffer) &&
|
||||
selected_pc != pc) return false;
|
||||
if (!EquivalentValue(m_program, selected, source)) return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user