mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-20 10:56:58 +02:00
shader: expose graphics compute queue fields to GETREG
This commit is contained in:
@@ -5055,7 +5055,7 @@ public:
|
||||
for (const auto mode : {0x41u, 0x61u}) {
|
||||
for (const auto &groups : empty_dispatches) {
|
||||
context.GetRenderExecutor().DispatchDirect(
|
||||
0, scheduler.Current(), groups[0], groups[1], groups[2], mode);
|
||||
0, scheduler.Current(), groups[0], groups[1], groups[2], mode, false);
|
||||
}
|
||||
}
|
||||
Require(name, "HTile fixture",
|
||||
@@ -10006,14 +10006,22 @@ public:
|
||||
for (u32 i = 0; i < 4; ++i)
|
||||
shaders.SetCsUserSgpr(i, out.fields[i], HW::UserSgprType::Unknown);
|
||||
uint64_t original_id = 0;
|
||||
struct Case { uint64_t address; u32 value; bool update; };
|
||||
struct Case { uint64_t address; u32 value; bool update; u32 field = 0; };
|
||||
for (const auto test : {Case{first, 41, false}, Case{first, 41, false},
|
||||
Case{second, 41, false}, Case{second, 73, true},
|
||||
Case{first, 41, false}}) {
|
||||
Case{first, 41, false}, Case{first, 6, false, 0x1818},
|
||||
Case{first, 0, false, 0x0a18}}) {
|
||||
Require(name, "refresh function pointer", context.InvalidateMemory(table + 0x20, 8),
|
||||
"function table escaped mapped memory");
|
||||
const uint64_t target = test.address | 3u;
|
||||
LibKernel::Memory::WriteBacking(table + 0x20, &target, sizeof(target));
|
||||
if (test.field != 0) {
|
||||
Require(name, "refresh hardware-field leaf", context.InvalidateMemory(first, sizeof(leaf)),
|
||||
"hardware-field leaf escaped mapped memory");
|
||||
const std::array field_leaf{0xb96a0000u | test.field,
|
||||
EncodeSMovB32(20, 106), EncodeSop1(0x21, 125, 14)};
|
||||
LibKernel::Memory::WriteBacking(first, field_leaf.data(), sizeof(field_leaf));
|
||||
}
|
||||
if (test.update) {
|
||||
auto [buffer, offset] = cache.ObtainBuffer(test.address + 4, 4, true);
|
||||
buffer->Fill(offset, 4, test.value);
|
||||
@@ -10703,7 +10711,7 @@ public:
|
||||
for (uint32_t i = 0; i < user_data.size(); i++) {
|
||||
shaders.SetCsUserSgpr(i, user_data[i], HW::UserSgprType::Unknown);
|
||||
}
|
||||
executor.DispatchDirect(0, scheduler.Current(), (count + 63) / 64, 1, 1, 0x41u);
|
||||
executor.DispatchDirect(0, scheduler.Current(), (count + 63) / 64, 1, 1, 0x41u, false);
|
||||
};
|
||||
const auto metadata_words = static_cast<uint32_t>(metadata_size / 4);
|
||||
fill_metadata(metadata_words);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "graphics/shader/recompiler/frontend/cfg/ShaderCFG.h"
|
||||
#include "graphics/shader/recompiler/frontend/decode/ShaderDecoder.h"
|
||||
#include "graphics/shader/recompiler/frontend/translate/Translate.h"
|
||||
#include "graphics/shader/recompiler/frontend/translate/Translator.h"
|
||||
#include "graphics/shader/recompiler/ir/IREmitter.h"
|
||||
#include "graphics/shader/recompiler/ir/ShaderIR.h"
|
||||
#include "graphics/shader/recompiler/ir/passes/ConstantPropagation.h"
|
||||
@@ -10308,6 +10309,62 @@ void TestNewShaderRecompilerBranchConditionForms() {
|
||||
}
|
||||
}
|
||||
|
||||
void TestGraphicsComputeGetreg() {
|
||||
using namespace ShaderRecompiler;
|
||||
for (const auto [word, expected] : {std::pair{0xb96a1818u, 6u}, std::pair{0xb96a0a18u, 0u}}) {
|
||||
Decoder::Instruction decoded;
|
||||
Decoder::DecodeInstruction(std::span(&word, 1), 0, decoded);
|
||||
Check(decoded.opcode == Decoder::Opcode::S_GETREG_B32 &&
|
||||
decoded.dst.kind == Decoder::OperandKind::VccLo &&
|
||||
decoded.src0.value == (word & 0xffffu), "GETREG field or VCC destination decoded incorrectly");
|
||||
for (const auto wave : {32u, 64u}) {
|
||||
IR::Program program;
|
||||
program.wave_size = wave;
|
||||
IR::Block block;
|
||||
Frontend::Translator translator(program, &block, 1, false, true);
|
||||
translator.TranslateInstruction(decoded);
|
||||
bool wrote_vcc = false;
|
||||
for (const auto& inst : block) {
|
||||
Check(inst.GetOpcode() != IR::ValueOpcode::SetScc, "GETREG changed SCC");
|
||||
if (inst.GetOpcode() == IR::ValueOpcode::SetVccLo) {
|
||||
Check(inst.Arg(0).IsImmediate() && inst.Arg(0).U32() == expected,
|
||||
"graphics compute hardware field has the wrong value");
|
||||
wrote_vcc = true;
|
||||
}
|
||||
}
|
||||
Check(wrote_vcc, "GETREG did not write VCC_LO");
|
||||
}
|
||||
}
|
||||
const uint32_t shader[] = {0xb96a1818u, EncodeSopp(0x01)};
|
||||
HW::ComputeShaderInfo regs{};
|
||||
regs.cs_regs.data_addr = reinterpret_cast<uint64_t>(shader);
|
||||
ShaderMappedData mapped{};
|
||||
mapped.code_size_bytes = sizeof(shader);
|
||||
ShaderMapUserData(regs.cs_regs.data_addr, mapped);
|
||||
HW::ShaderRegisters sh{};
|
||||
ShaderComputeInputInfo graphics{}, async{};
|
||||
async.async_compute = true;
|
||||
(void)PrepareProgram(regs, sh, graphics);
|
||||
(void)PrepareProgram(regs, sh, async);
|
||||
Check(!graphics.async_compute && async.async_compute &&
|
||||
MakeStageStaticKey(graphics) != MakeStageStaticKey(async) &&
|
||||
MakeStageStaticKey(graphics).size() == MakeStageStaticKey(async).size(),
|
||||
"compute input reset or cache identity lost queue provenance");
|
||||
#if KYTY_PLATFORM != KYTY_PLATFORM_WINDOWS
|
||||
auto options = MakeCompileOptions(ShaderType::Compute);
|
||||
options.input_info.compute = &async;
|
||||
ExpectFatal([&] { (void)TranslateProgram(shader, options); }, "async GETREG used graphics constants");
|
||||
auto vertex = MakeCompileOptions(ShaderType::Vertex);
|
||||
ExpectFatal([&] { (void)TranslateProgram(shader, vertex); }, "vertex GETREG used compute constants");
|
||||
options.input_info.compute = &graphics;
|
||||
const uint32_t unsupported[] = {0xb96af818u, EncodeSopp(0x01)};
|
||||
Decoder::Program decoded;
|
||||
Decoder::DecodeProgram(unsupported, decoded);
|
||||
Check(decoded.instructions[0].src0.value == 0xf818u, "GETREG selector was sign extended");
|
||||
ExpectFatal([&] { (void)TranslateProgram(unsupported, options); }, "unsupported GETREG field was accepted");
|
||||
#endif
|
||||
}
|
||||
|
||||
void TestMemoryFedScalarLeafCall() {
|
||||
using namespace ShaderRecompiler;
|
||||
constexpr uint64_t base = 0xfe0040000ull;
|
||||
@@ -15586,6 +15643,7 @@ int main() {
|
||||
TestNewShaderRecompilerPixelImageSampleLodSelection();
|
||||
TestNewShaderRecompilerBranchConditionForms();
|
||||
TestNewShaderRecompilerSetpcBranch();
|
||||
TestGraphicsComputeGetreg();
|
||||
TestMemoryFedScalarLeafCall();
|
||||
TestFusedShaderHandoffPreservesRegisters();
|
||||
TestMeshExportStorage();
|
||||
|
||||
Reference in New Issue
Block a user