mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-20 10:56:58 +02:00
shader: reuse native emitters and simplify memory dispatch
This commit is contained in:
@@ -8708,6 +8708,38 @@ void TestNewShaderRecompilerDispatcherSpillsU32x3() {
|
||||
"dispatcher did not use one canonical U32x3 spill slot");
|
||||
}
|
||||
|
||||
void TestNewShaderRecompilerPlanningOnlyLoads() {
|
||||
using namespace ShaderRecompiler;
|
||||
const uint32_t shader[] = {EncodeSopp(0x01)};
|
||||
auto options = MakeCompileOptions(ShaderType::Compute);
|
||||
auto result = RecompileForTest(shader, options);
|
||||
auto& program = result.program;
|
||||
IR::IREmitter ir(program.blocks.front());
|
||||
IR::MemoryInfo memory;
|
||||
memory.kind = IR::ResourceKind::ScalarAddress;
|
||||
memory.planning_only = true;
|
||||
program.memory_info.push_back(memory);
|
||||
const auto address = ir.Emit(IR::ValueOpcode::GetAddressResource,
|
||||
{IR::Value(0x1000u), IR::Value(0u)});
|
||||
const auto load = ir.Emit(IR::ValueOpcode::LoadAddressU32,
|
||||
{address, IR::Value(0u), IR::Value(0u), IR::Value(true)});
|
||||
load.Instruction()->SetFlags(IR::MemoryFlags{.index = 0});
|
||||
memory.kind = IR::ResourceKind::ScalarBuffer;
|
||||
program.memory_info.push_back(memory);
|
||||
const auto buffer = ir.Emit(IR::ValueOpcode::GetBufferResource,
|
||||
{IR::Value(0x2000u), IR::Value(0u),
|
||||
IR::Value(16u), IR::Value(0u)});
|
||||
const auto read = ir.Emit(IR::ValueOpcode::ReadConstBuffer,
|
||||
{buffer, IR::Value(0u)});
|
||||
read.Instruction()->SetFlags(IR::MemoryFlags{.index = 1});
|
||||
ir.Emit(IR::ValueOpcode::ReferenceU32, {load});
|
||||
ir.Emit(IR::ValueOpcode::ReferenceU32, {read});
|
||||
const auto spirv = Spirv::EmitProgram(program, options.input_info);
|
||||
CheckSpirvBinaryValidates(spirv);
|
||||
Check(spirv == result.spirv,
|
||||
"planning-only loads or references emitted GPU operands/instructions");
|
||||
}
|
||||
|
||||
void TestNewShaderRecompilerU64PairTranslation() {
|
||||
using namespace ShaderRecompiler;
|
||||
|
||||
@@ -13017,6 +13049,7 @@ int main() {
|
||||
TestNewShaderRecompilerCfgPrunesUnreachableSelectionEntry();
|
||||
TestNewShaderRecompilerCfgIrreducibleDispatcher();
|
||||
TestNewShaderRecompilerDispatcherSpillsU32x3();
|
||||
TestNewShaderRecompilerPlanningOnlyLoads();
|
||||
TestNewShaderRecompilerU64PairTranslation();
|
||||
TestComputeDispatchWaveSize();
|
||||
TestNewShaderRecompilerBufferLoadsGuardedByExec();
|
||||
|
||||
Reference in New Issue
Block a user