mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-30 09:08:19 +00:00
shader: hash only the program code and literal buffer
This commit is contained in:
1 parent
1703836d06
commit
ae67e2db51
2 files changed
+59
-2
No files matched your search
@@ -1941,6 +1941,42 @@ void TestVertexBufferGrouping() {
|
||||
Check(!input.has_dynamic_vertex_fetch, "remapping a shader kept its previous vertex metadata");
|
||||
}
|
||||
|
||||
void TestShaderProgramHash() {
|
||||
using Binary = std::array<uint32_t, 22>;
|
||||
// One code word, a 16-byte literal buffer at 16, 8 bytes of metadata, then the 0x30-byte
|
||||
// footer, whose key and checksum cover the whole binary.
|
||||
const auto Make = [](uint32_t literal, uint32_t metadata, uint32_t version = 1,
|
||||
uint32_t code_size = 4) {
|
||||
Binary words{};
|
||||
words[0] = EncodeSopp(0x01);
|
||||
words[4] = literal;
|
||||
words[8] = metadata;
|
||||
std::memcpy(&words[10], "barefoot", 8);
|
||||
words[12] = metadata;
|
||||
words[14] = version;
|
||||
words[15] = code_size;
|
||||
words[16] = 16;
|
||||
words[18] = metadata;
|
||||
return words;
|
||||
};
|
||||
const auto Map = [](const Binary &binary) {
|
||||
ShaderMappedData mapped{};
|
||||
mapped.code_size_bytes = sizeof(binary);
|
||||
HW::ComputeShaderInfo regs{};
|
||||
regs.cs_regs.data_addr = reinterpret_cast<uint64_t>(binary.data());
|
||||
ShaderMapUserData(regs.cs_regs.data_addr, mapped);
|
||||
ShaderComputeInputInfo input{};
|
||||
return PrepareProgram(regs, input);
|
||||
};
|
||||
Check(Map(Make(7, 1)).hash == Map(Make(7, 2)).hash,
|
||||
"binaries differing only in metadata got different programs");
|
||||
Check(Map(Make(7, 1)).hash != Map(Make(8, 1)).hash, "the program hash missed the literal buffer");
|
||||
Check(Map(Make(7, 1)).code.size() == 8, "translation must read only the hashed program bytes");
|
||||
Check(Map(Make(7, 1, 2)).hash != Map(Make(7, 2, 2)).hash &&
|
||||
Map(Make(7, 1, 1, 0)).hash != Map(Make(7, 2, 1, 0)).hash,
|
||||
"a binary with an unknown footer must hash whole");
|
||||
}
|
||||
|
||||
void TestNggVertexEntryState() {
|
||||
using namespace ShaderRecompiler;
|
||||
// PPSA03309 shader 5a39eb2021a5d2c1: retain its NGG prologue and replace
|
||||
@@ -17221,6 +17257,7 @@ int main() {
|
||||
TestNewShaderRecompilerSMovB32();
|
||||
TestShaderStageBarriers();
|
||||
TestVertexBufferGrouping();
|
||||
TestShaderProgramHash();
|
||||
TestNggVertexEntryState();
|
||||
TestNewShaderRecompilerClipDisabledPosition();
|
||||
TestNewShaderRecompilerAuxPositionExports();
|
||||
|
||||
Reference in new issue
Block a user