mirror of
https://git.h3cjp.net/H3cJP/yuzu.git
synced 2024-11-14 13:42:56 +00:00
shader_ir: Remove RZ and use Register::ZeroIndex instead
This commit is contained in:
parent
5af82a8ed4
commit
d9118d324a
|
@ -91,12 +91,14 @@ u32 ShaderIR::DecodeMemory(BasicBlock& bb, u32 pc) {
|
||||||
GetConstBufferIndirect(instr.cbuf36.index, instr.cbuf36.offset + 4, index);
|
GetConstBufferIndirect(instr.cbuf36.index, instr.cbuf36.offset + 4, index);
|
||||||
|
|
||||||
const Node composite =
|
const Node composite =
|
||||||
Operation(OperationCode::Composite, op_a, op_b, GetRegister(RZ), GetRegister(RZ));
|
Operation(OperationCode::Composite, op_a, op_b, GetRegister(Register::ZeroIndex),
|
||||||
|
GetRegister(Register::ZeroIndex));
|
||||||
|
|
||||||
MetaComponents meta{{0, 1, 2, 3}};
|
MetaComponents meta{{0, 1, 2, 3}};
|
||||||
bb.push_back(Operation(OperationCode::AssignComposite, meta, composite,
|
bb.push_back(Operation(OperationCode::AssignComposite, meta, composite,
|
||||||
GetRegister(instr.gpr0), GetRegister(instr.gpr0.Value() + 1),
|
GetRegister(instr.gpr0), GetRegister(instr.gpr0.Value() + 1),
|
||||||
GetRegister(RZ), GetRegister(RZ)));
|
GetRegister(Register::ZeroIndex),
|
||||||
|
GetRegister(Register::ZeroIndex)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -197,7 +199,8 @@ u32 ShaderIR::DecodeMemory(BasicBlock& bb, u32 pc) {
|
||||||
|
|
||||||
++dest_elem;
|
++dest_elem;
|
||||||
}
|
}
|
||||||
std::generate(dest.begin() + dest_elem, dest.end(), [&]() { return GetRegister(RZ); });
|
std::generate(dest.begin() + dest_elem, dest.end(),
|
||||||
|
[&]() { return GetRegister(Register::ZeroIndex); });
|
||||||
|
|
||||||
bb.push_back(Operation(OperationCode::AssignComposite, std::move(meta), texture, dest[0],
|
bb.push_back(Operation(OperationCode::AssignComposite, std::move(meta), texture, dest[0],
|
||||||
dest[1], dest[2], dest[3]));
|
dest[1], dest[2], dest[3]));
|
||||||
|
@ -255,7 +258,8 @@ u32 ShaderIR::DecodeMemory(BasicBlock& bb, u32 pc) {
|
||||||
|
|
||||||
++dest_elem;
|
++dest_elem;
|
||||||
}
|
}
|
||||||
std::generate(dest.begin() + dest_elem, dest.end(), [&]() { return GetRegister(RZ); });
|
std::generate(dest.begin() + dest_elem, dest.end(),
|
||||||
|
[&]() { return GetRegister(Register::ZeroIndex); });
|
||||||
|
|
||||||
bb.push_back(Operation(OperationCode::AssignComposite, std::move(meta_components), texture,
|
bb.push_back(Operation(OperationCode::AssignComposite, std::move(meta_components), texture,
|
||||||
dest[0], dest[1], dest[2], dest[3]));
|
dest[0], dest[1], dest[2], dest[3]));
|
||||||
|
@ -369,7 +373,7 @@ u32 ShaderIR::DecodeMemory(BasicBlock& bb, u32 pc) {
|
||||||
const MetaComponents meta_composite{{0, 1, 2, 3}};
|
const MetaComponents meta_composite{{0, 1, 2, 3}};
|
||||||
bb.push_back(Operation(OperationCode::AssignComposite, meta_composite, texture,
|
bb.push_back(Operation(OperationCode::AssignComposite, meta_composite, texture,
|
||||||
GetRegister(instr.gpr0), GetRegister(instr.gpr0.Value() + 1),
|
GetRegister(instr.gpr0), GetRegister(instr.gpr0.Value() + 1),
|
||||||
GetRegister(RZ), GetRegister(RZ)));
|
GetRegister(Register::ZeroIndex), GetRegister(Register::ZeroIndex)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OpCode::Id::TLDS: {
|
case OpCode::Id::TLDS: {
|
||||||
|
@ -438,7 +442,8 @@ void ShaderIR::WriteTexsInstructionFloat(BasicBlock& bb, Instruction instr, Node
|
||||||
++meta.count;
|
++meta.count;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::generate(dest.begin() + meta.count, dest.end(), [&]() { return GetRegister(RZ); });
|
std::generate(dest.begin() + meta.count, dest.end(),
|
||||||
|
[&]() { return GetRegister(Register::ZeroIndex); });
|
||||||
|
|
||||||
bb.push_back(Operation(OperationCode::AssignComposite, meta, texture, dest[0], dest[1], dest[2],
|
bb.push_back(Operation(OperationCode::AssignComposite, meta, texture, dest[0], dest[1], dest[2],
|
||||||
dest[3]));
|
dest[3]));
|
||||||
|
|
|
@ -22,6 +22,7 @@ using Tegra::Shader::Header;
|
||||||
using Tegra::Shader::IpaInterpMode;
|
using Tegra::Shader::IpaInterpMode;
|
||||||
using Tegra::Shader::IpaMode;
|
using Tegra::Shader::IpaMode;
|
||||||
using Tegra::Shader::IpaSampleMode;
|
using Tegra::Shader::IpaSampleMode;
|
||||||
|
using Tegra::Shader::Register;
|
||||||
using namespace VideoCommon::Shader;
|
using namespace VideoCommon::Shader;
|
||||||
|
|
||||||
using Maxwell = Tegra::Engines::Maxwell3D::Regs;
|
using Maxwell = Tegra::Engines::Maxwell3D::Regs;
|
||||||
|
@ -419,7 +420,7 @@ private:
|
||||||
|
|
||||||
} else if (const auto gpr = std::get_if<GprNode>(node)) {
|
} else if (const auto gpr = std::get_if<GprNode>(node)) {
|
||||||
const u32 index = gpr->GetIndex();
|
const u32 index = gpr->GetIndex();
|
||||||
if (index == RZ) {
|
if (index == Register::ZeroIndex) {
|
||||||
return "0";
|
return "0";
|
||||||
}
|
}
|
||||||
return GetRegister(index);
|
return GetRegister(index);
|
||||||
|
@ -728,8 +729,8 @@ private:
|
||||||
|
|
||||||
std::string target;
|
std::string target;
|
||||||
if (const auto gpr = std::get_if<GprNode>(dest)) {
|
if (const auto gpr = std::get_if<GprNode>(dest)) {
|
||||||
if (gpr->GetIndex() == RZ) {
|
if (gpr->GetIndex() == Register::ZeroIndex) {
|
||||||
// Writing to RZ is a no op
|
// Writing to Register::ZeroIndex is a no op
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
target = GetRegister(gpr->GetIndex());
|
target = GetRegister(gpr->GetIndex());
|
||||||
|
@ -776,7 +777,7 @@ private:
|
||||||
constexpr u32 composite_size = 4;
|
constexpr u32 composite_size = 4;
|
||||||
for (u32 i = 0; i < composite_size; ++i) {
|
for (u32 i = 0; i < composite_size; ++i) {
|
||||||
const auto gpr = std::get<GprNode>(*operation[i + 1]).GetIndex();
|
const auto gpr = std::get<GprNode>(*operation[i + 1]).GetIndex();
|
||||||
if (gpr == RZ) {
|
if (gpr == Register::ZeroIndex) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
code.AddLine(GetRegister(gpr) + " = " + composite +
|
code.AddLine(GetRegister(gpr) + " = " + composite +
|
||||||
|
|
|
@ -41,8 +41,6 @@ using BasicBlock = std::vector<Node>;
|
||||||
|
|
||||||
constexpr u32 MAX_PROGRAM_LENGTH = 0x1000;
|
constexpr u32 MAX_PROGRAM_LENGTH = 0x1000;
|
||||||
|
|
||||||
constexpr u32 RZ = 0xff;
|
|
||||||
|
|
||||||
enum class OperationCode {
|
enum class OperationCode {
|
||||||
Assign, /// (float& dest, float src) -> void
|
Assign, /// (float& dest, float src) -> void
|
||||||
AssignComposite, /// (MetaComponents, float4 src, float&[4] dst) -> void
|
AssignComposite, /// (MetaComponents, float4 src, float&[4] dst) -> void
|
||||||
|
|
Loading…
Reference in a new issue