summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2019-05-18 02:51:12 -0300
committerGravatar ReinUsesLisp2019-05-20 22:41:53 -0300
commit75e7b45d69db5b19958d7e9223ca562f8419e3d4 (patch)
tree5b418f73354d90982cf3d526116da14091fc1279 /src
parentshader/memory: Implement LD (generic memory) (diff)
downloadyuzu-75e7b45d69db5b19958d7e9223ca562f8419e3d4.tar.gz
yuzu-75e7b45d69db5b19958d7e9223ca562f8419e3d4.tar.xz
yuzu-75e7b45d69db5b19958d7e9223ca562f8419e3d4.zip
shader/memory: Implement ST (generic memory)
Diffstat (limited to 'src')
-rw-r--r--src/video_core/engines/shader_bytecode.h1
-rw-r--r--src/video_core/shader/decode/memory.cpp56
2 files changed, 36 insertions, 21 deletions
diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.h
index 073b622ef..e83f25fa1 100644
--- a/src/video_core/engines/shader_bytecode.h
+++ b/src/video_core/engines/shader_bytecode.h
@@ -1673,6 +1673,7 @@ private:
1673 INST("1110111111110---", Id::ST_A, Type::Memory, "ST_A"), 1673 INST("1110111111110---", Id::ST_A, Type::Memory, "ST_A"),
1674 INST("1110111101011---", Id::ST_S, Type::Memory, "ST_S"), 1674 INST("1110111101011---", Id::ST_S, Type::Memory, "ST_S"),
1675 INST("1110111101010---", Id::ST_L, Type::Memory, "ST_L"), 1675 INST("1110111101010---", Id::ST_L, Type::Memory, "ST_L"),
1676 INST("101-------------", Id::ST, Type::Memory, "ST"),
1676 INST("1110111011011---", Id::STG, Type::Memory, "STG"), 1677 INST("1110111011011---", Id::STG, Type::Memory, "STG"),
1677 INST("1110111110100---", Id::AL2P, Type::Memory, "AL2P"), 1678 INST("1110111110100---", Id::AL2P, Type::Memory, "AL2P"),
1678 INST("110000----111---", Id::TEX, Type::Texture, "TEX"), 1679 INST("110000----111---", Id::TEX, Type::Texture, "TEX"),
diff --git a/src/video_core/shader/decode/memory.cpp b/src/video_core/shader/decode/memory.cpp
index 8ac2fd4ac..a5ca9a164 100644
--- a/src/video_core/shader/decode/memory.cpp
+++ b/src/video_core/shader/decode/memory.cpp
@@ -180,27 +180,6 @@ u32 ShaderIR::DecodeMemory(NodeBlock& bb, u32 pc) {
180 } 180 }
181 break; 181 break;
182 } 182 }
183 case OpCode::Id::STG: {
184 const auto [real_address_base, base_address, descriptor] =
185 TrackAndGetGlobalMemory(bb, instr, true);
186
187 // Encode in temporary registers like this: real_base_address, {registers_to_be_written...}
188 SetTemporal(bb, 0, real_address_base);
189
190 const u32 count = GetUniformTypeElementsCount(instr.stg.type);
191 for (u32 i = 0; i < count; ++i) {
192 SetTemporal(bb, i + 1, GetRegister(instr.gpr0.Value() + i));
193 }
194 for (u32 i = 0; i < count; ++i) {
195 const Node it_offset = Immediate(i * 4);
196 const Node real_address =
197 Operation(OperationCode::UAdd, NO_PRECISE, real_address_base, it_offset);
198 const Node gmem = StoreNode(GmemNode(real_address, base_address, descriptor));
199
200 bb.push_back(Operation(OperationCode::Assign, gmem, GetTemporal(i + 1)));
201 }
202 break;
203 }
204 case OpCode::Id::ST_A: { 183 case OpCode::Id::ST_A: {
205 UNIMPLEMENTED_IF_MSG(instr.gpr8.Value() != Register::ZeroIndex, 184 UNIMPLEMENTED_IF_MSG(instr.gpr8.Value() != Register::ZeroIndex,
206 "Indirect attribute loads are not supported"); 185 "Indirect attribute loads are not supported");
@@ -256,6 +235,41 @@ u32 ShaderIR::DecodeMemory(NodeBlock& bb, u32 pc) {
256 } 235 }
257 break; 236 break;
258 } 237 }
238 case OpCode::Id::ST:
239 case OpCode::Id::STG: {
240 const auto type = [instr, &opcode]() -> Tegra::Shader::UniformType {
241 switch (opcode->get().GetId()) {
242 case OpCode::Id::ST:
243 UNIMPLEMENTED_IF_MSG(!instr.generic.extended, "Unextended ST is not implemented");
244 return instr.generic.type;
245 case OpCode::Id::STG:
246 return instr.stg.type;
247 default:
248 UNREACHABLE();
249 return {};
250 }
251 }();
252
253 const auto [real_address_base, base_address, descriptor] =
254 TrackAndGetGlobalMemory(bb, instr, true);
255
256 // Encode in temporary registers like this: real_base_address, {registers_to_be_written...}
257 SetTemporal(bb, 0, real_address_base);
258
259 const u32 count = GetUniformTypeElementsCount(type);
260 for (u32 i = 0; i < count; ++i) {
261 SetTemporal(bb, i + 1, GetRegister(instr.gpr0.Value() + i));
262 }
263 for (u32 i = 0; i < count; ++i) {
264 const Node it_offset = Immediate(i * 4);
265 const Node real_address =
266 Operation(OperationCode::UAdd, NO_PRECISE, real_address_base, it_offset);
267 const Node gmem = StoreNode(GmemNode(real_address, base_address, descriptor));
268
269 bb.push_back(Operation(OperationCode::Assign, gmem, GetTemporal(i + 1)));
270 }
271 break;
272 }
259 case OpCode::Id::AL2P: { 273 case OpCode::Id::AL2P: {
260 // Ignore al2p.direction since we don't care about it. 274 // Ignore al2p.direction since we don't care about it.
261 275