diff options
| author | 2021-04-04 06:47:14 +0200 | |
|---|---|---|
| committer | 2021-07-22 21:51:26 -0400 | |
| commit | 1d51803169f72f79e19995072fb9e8a371dbdcbf (patch) | |
| tree | eb668d924985e4b0bd599a695a0a2eee30fd0090 /src/shader_recompiler/ir_opt | |
| parent | shader: Implement AL2P (diff) | |
| download | yuzu-1d51803169f72f79e19995072fb9e8a371dbdcbf.tar.gz yuzu-1d51803169f72f79e19995072fb9e8a371dbdcbf.tar.xz yuzu-1d51803169f72f79e19995072fb9e8a371dbdcbf.zip | |
shader: Implement indexed attributes
Diffstat (limited to 'src/shader_recompiler/ir_opt')
| -rw-r--r-- | src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp | 36 | ||||
| -rw-r--r-- | src/shader_recompiler/ir_opt/passes.h | 2 |
2 files changed, 36 insertions, 2 deletions
diff --git a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp index 0f870535b..dbe9f1f40 100644 --- a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp +++ b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "shader_recompiler/environment.h" | ||
| 5 | #include "shader_recompiler/frontend/ir/microinstruction.h" | 6 | #include "shader_recompiler/frontend/ir/microinstruction.h" |
| 6 | #include "shader_recompiler/frontend/ir/modifiers.h" | 7 | #include "shader_recompiler/frontend/ir/modifiers.h" |
| 7 | #include "shader_recompiler/frontend/ir/program.h" | 8 | #include "shader_recompiler/frontend/ir/program.h" |
| @@ -323,6 +324,12 @@ void VisitUsages(Info& info, IR::Inst& inst) { | |||
| 323 | case IR::Opcode::SetAttribute: | 324 | case IR::Opcode::SetAttribute: |
| 324 | SetAttribute(info, inst.Arg(0).Attribute()); | 325 | SetAttribute(info, inst.Arg(0).Attribute()); |
| 325 | break; | 326 | break; |
| 327 | case IR::Opcode::GetAttributeIndexed: | ||
| 328 | info.loads_indexed_attributes = true; | ||
| 329 | break; | ||
| 330 | case IR::Opcode::SetAttributeIndexed: | ||
| 331 | info.stores_indexed_attributes = true; | ||
| 332 | break; | ||
| 326 | case IR::Opcode::SetFragColor: | 333 | case IR::Opcode::SetFragColor: |
| 327 | info.stores_frag_color[inst.Arg(0).U32()] = true; | 334 | info.stores_frag_color[inst.Arg(0).U32()] = true; |
| 328 | break; | 335 | break; |
| @@ -502,15 +509,42 @@ void Visit(Info& info, IR::Inst& inst) { | |||
| 502 | VisitUsages(info, inst); | 509 | VisitUsages(info, inst); |
| 503 | VisitFpModifiers(info, inst); | 510 | VisitFpModifiers(info, inst); |
| 504 | } | 511 | } |
| 512 | |||
| 513 | void GatherInfoFromHeader(Environment& env, Info& info) { | ||
| 514 | auto stage = env.ShaderStage(); | ||
| 515 | if (stage == Stage::Compute) { | ||
| 516 | return; | ||
| 517 | } | ||
| 518 | const auto& header = env.SPH(); | ||
| 519 | if (stage == Stage::Fragment) { | ||
| 520 | for (size_t i = 0; i < info.input_generics.size(); i++) { | ||
| 521 | info.input_generics[i].used = | ||
| 522 | info.input_generics[i].used || header.ps.IsGenericVectorActive(i); | ||
| 523 | } | ||
| 524 | return; | ||
| 525 | } | ||
| 526 | for (size_t i = 0; i < info.input_generics.size(); i++) { | ||
| 527 | info.input_generics[i].used = | ||
| 528 | info.input_generics[i].used || header.vtg.IsInputGenericVectorActive(i); | ||
| 529 | } | ||
| 530 | for (size_t i = 0; i < info.stores_generics.size(); i++) { | ||
| 531 | info.stores_generics[i] = | ||
| 532 | info.stores_generics[i] || header.vtg.IsOutputGenericVectorActive(i); | ||
| 533 | } | ||
| 534 | info.stores_clip_distance = | ||
| 535 | info.stores_clip_distance || header.vtg.omap_systemc.clip_distances != 0; | ||
| 536 | } | ||
| 537 | |||
| 505 | } // Anonymous namespace | 538 | } // Anonymous namespace |
| 506 | 539 | ||
| 507 | void CollectShaderInfoPass(IR::Program& program) { | 540 | void CollectShaderInfoPass(Environment& env, IR::Program& program) { |
| 508 | Info& info{program.info}; | 541 | Info& info{program.info}; |
| 509 | for (IR::Block* const block : program.post_order_blocks) { | 542 | for (IR::Block* const block : program.post_order_blocks) { |
| 510 | for (IR::Inst& inst : block->Instructions()) { | 543 | for (IR::Inst& inst : block->Instructions()) { |
| 511 | Visit(info, inst); | 544 | Visit(info, inst); |
| 512 | } | 545 | } |
| 513 | } | 546 | } |
| 547 | GatherInfoFromHeader(env, info); | ||
| 514 | } | 548 | } |
| 515 | 549 | ||
| 516 | } // namespace Shader::Optimization | 550 | } // namespace Shader::Optimization |
diff --git a/src/shader_recompiler/ir_opt/passes.h b/src/shader_recompiler/ir_opt/passes.h index 5c1fc166c..186104713 100644 --- a/src/shader_recompiler/ir_opt/passes.h +++ b/src/shader_recompiler/ir_opt/passes.h | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | namespace Shader::Optimization { | 13 | namespace Shader::Optimization { |
| 14 | 14 | ||
| 15 | void CollectShaderInfoPass(IR::Program& program); | 15 | void CollectShaderInfoPass(Environment& env, IR::Program& program); |
| 16 | void ConstantPropagationPass(IR::Program& program); | 16 | void ConstantPropagationPass(IR::Program& program); |
| 17 | void DeadCodeEliminationPass(IR::Program& program); | 17 | void DeadCodeEliminationPass(IR::Program& program); |
| 18 | void GlobalMemoryToStorageBufferPass(IR::Program& program); | 18 | void GlobalMemoryToStorageBufferPass(IR::Program& program); |