summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2019-12-16 02:06:42 -0300
committerGravatar ReinUsesLisp2019-12-16 02:06:42 -0300
commit3d2c44848b8e5cbbf674e2acc632008451c3cc5a (patch)
tree2008b91ba04deb020ab68538181632fd8cd2b839 /src
parentshader/texture: Remove unnecesary parenthesis (diff)
downloadyuzu-3d2c44848b8e5cbbf674e2acc632008451c3cc5a.tar.gz
yuzu-3d2c44848b8e5cbbf674e2acc632008451c3cc5a.tar.xz
yuzu-3d2c44848b8e5cbbf674e2acc632008451c3cc5a.zip
shader/texture: Implement AOFFI for TLD4S
Diffstat (limited to 'src')
-rw-r--r--src/video_core/shader/decode/texture.cpp31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp
index 38992e19c..ac5dfb8ab 100644
--- a/src/video_core/shader/decode/texture.cpp
+++ b/src/video_core/shader/decode/texture.cpp
@@ -107,41 +107,46 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) {
107 break; 107 break;
108 } 108 }
109 case OpCode::Id::TLD4S: { 109 case OpCode::Id::TLD4S: {
110 const bool uses_aoffi = instr.tld4s.UsesMiscMode(TextureMiscMode::AOFFI); 110 constexpr std::size_t num_coords = 2;
111 UNIMPLEMENTED_IF_MSG(uses_aoffi, "AOFFI is not implemented"); 111 const bool is_aoffi = instr.tld4s.UsesMiscMode(TextureMiscMode::AOFFI);
112 112 const bool is_depth_compare = instr.tld4s.UsesMiscMode(TextureMiscMode::DC);
113 const bool depth_compare = instr.tld4s.UsesMiscMode(TextureMiscMode::DC);
114 const Node op_a = GetRegister(instr.gpr8); 113 const Node op_a = GetRegister(instr.gpr8);
115 const Node op_b = GetRegister(instr.gpr20); 114 const Node op_b = GetRegister(instr.gpr20);
116 115
117 // TODO(Subv): Figure out how the sampler type is encoded in the TLD4S instruction. 116 // TODO(Subv): Figure out how the sampler type is encoded in the TLD4S instruction.
118 std::vector<Node> coords; 117 std::vector<Node> coords;
119 Node dc_reg; 118 std::vector<Node> aoffi;
120 if (depth_compare) { 119 Node depth_compare;
120 if (is_depth_compare) {
121 // Note: TLD4S coordinate encoding works just like TEXS's 121 // Note: TLD4S coordinate encoding works just like TEXS's
122 const Node op_y = GetRegister(instr.gpr8.Value() + 1); 122 const Node op_y = GetRegister(instr.gpr8.Value() + 1);
123 coords.push_back(op_a); 123 coords.push_back(op_a);
124 coords.push_back(op_y); 124 coords.push_back(op_y);
125 dc_reg = uses_aoffi ? GetRegister(instr.gpr20.Value() + 1) : op_b; 125 if (is_aoffi) {
126 aoffi = GetAoffiCoordinates(op_b, num_coords, true);
127 depth_compare = GetRegister(instr.gpr20.Value() + 1);
128 } else {
129 depth_compare = op_b;
130 }
126 } else { 131 } else {
132 // There's no depth compare
127 coords.push_back(op_a); 133 coords.push_back(op_a);
128 if (uses_aoffi) { 134 if (is_aoffi) {
129 const Node op_y = GetRegister(instr.gpr8.Value() + 1); 135 coords.push_back(GetRegister(instr.gpr8.Value() + 1));
130 coords.push_back(op_y); 136 aoffi = GetAoffiCoordinates(op_b, num_coords, true);
131 } else { 137 } else {
132 coords.push_back(op_b); 138 coords.push_back(op_b);
133 } 139 }
134 dc_reg = {};
135 } 140 }
136 const Node component = Immediate(static_cast<u32>(instr.tld4s.component)); 141 const Node component = Immediate(static_cast<u32>(instr.tld4s.component));
137 142
138 const SamplerInfo info{TextureType::Texture2D, false, depth_compare}; 143 const SamplerInfo info{TextureType::Texture2D, false, is_depth_compare};
139 const Sampler& sampler = *GetSampler(instr.sampler, info); 144 const Sampler& sampler = *GetSampler(instr.sampler, info);
140 145
141 Node4 values; 146 Node4 values;
142 for (u32 element = 0; element < values.size(); ++element) { 147 for (u32 element = 0; element < values.size(); ++element) {
143 auto coords_copy = coords; 148 auto coords_copy = coords;
144 MetaTexture meta{sampler, {}, dc_reg, {}, {}, {}, {}, component, element}; 149 MetaTexture meta{sampler, {}, depth_compare, aoffi, {}, {}, {}, component, element};
145 values[element] = Operation(OperationCode::TextureGather, meta, std::move(coords_copy)); 150 values[element] = Operation(OperationCode::TextureGather, meta, std::move(coords_copy));
146 } 151 }
147 152