diff options
| author | 2021-03-19 19:28:31 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:23 -0400 | |
| commit | 260743f371236f7c57b01334b1c3474b15a47c39 (patch) | |
| tree | 312d89fa8215199ef5f7ec1fc84b025df526e107 /src/shader_recompiler/ir_opt | |
| parent | shader: Implement DADD (diff) | |
| download | yuzu-260743f371236f7c57b01334b1c3474b15a47c39.tar.gz yuzu-260743f371236f7c57b01334b1c3474b15a47c39.tar.xz yuzu-260743f371236f7c57b01334b1c3474b15a47c39.zip | |
shader: Add partial rasterizer integration
Diffstat (limited to 'src/shader_recompiler/ir_opt')
| -rw-r--r-- | src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp | 60 | ||||
| -rw-r--r-- | src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp | 2 |
2 files changed, 57 insertions, 5 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 708b6b267..fbbe28632 100644 --- a/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp +++ b/src/shader_recompiler/ir_opt/collect_shader_info_pass.cpp | |||
| @@ -17,10 +17,47 @@ void AddConstantBufferDescriptor(Info& info, u32 index, u32 count) { | |||
| 17 | return; | 17 | return; |
| 18 | } | 18 | } |
| 19 | info.constant_buffer_mask |= 1U << index; | 19 | info.constant_buffer_mask |= 1U << index; |
| 20 | info.constant_buffer_descriptors.push_back({ | 20 | |
| 21 | .index{index}, | 21 | auto& cbufs{info.constant_buffer_descriptors}; |
| 22 | .count{1}, | 22 | cbufs.insert(std::ranges::lower_bound(cbufs, index, {}, &ConstantBufferDescriptor::index), |
| 23 | }); | 23 | ConstantBufferDescriptor{ |
| 24 | .index{index}, | ||
| 25 | .count{1}, | ||
| 26 | }); | ||
| 27 | } | ||
| 28 | |||
| 29 | void GetAttribute(Info& info, IR::Attribute attribute) { | ||
| 30 | if (IR::IsGeneric(attribute)) { | ||
| 31 | info.loads_generics.at(IR::GenericAttributeIndex(attribute)) = true; | ||
| 32 | return; | ||
| 33 | } | ||
| 34 | switch (attribute) { | ||
| 35 | case IR::Attribute::PositionX: | ||
| 36 | case IR::Attribute::PositionY: | ||
| 37 | case IR::Attribute::PositionZ: | ||
| 38 | case IR::Attribute::PositionW: | ||
| 39 | info.loads_position = true; | ||
| 40 | break; | ||
| 41 | default: | ||
| 42 | throw NotImplementedException("Get attribute {}", attribute); | ||
| 43 | } | ||
| 44 | } | ||
| 45 | |||
| 46 | void SetAttribute(Info& info, IR::Attribute attribute) { | ||
| 47 | if (IR::IsGeneric(attribute)) { | ||
| 48 | info.stores_generics.at(IR::GenericAttributeIndex(attribute)) = true; | ||
| 49 | return; | ||
| 50 | } | ||
| 51 | switch (attribute) { | ||
| 52 | case IR::Attribute::PositionX: | ||
| 53 | case IR::Attribute::PositionY: | ||
| 54 | case IR::Attribute::PositionZ: | ||
| 55 | case IR::Attribute::PositionW: | ||
| 56 | info.stores_position = true; | ||
| 57 | break; | ||
| 58 | default: | ||
| 59 | throw NotImplementedException("Set attribute {}", attribute); | ||
| 60 | } | ||
| 24 | } | 61 | } |
| 25 | 62 | ||
| 26 | void VisitUsages(Info& info, IR::Inst& inst) { | 63 | void VisitUsages(Info& info, IR::Inst& inst) { |
| @@ -162,6 +199,21 @@ void VisitUsages(Info& info, IR::Inst& inst) { | |||
| 162 | break; | 199 | break; |
| 163 | } | 200 | } |
| 164 | switch (inst.Opcode()) { | 201 | switch (inst.Opcode()) { |
| 202 | case IR::Opcode::DemoteToHelperInvocation: | ||
| 203 | info.uses_demote_to_helper_invocation = true; | ||
| 204 | break; | ||
| 205 | case IR::Opcode::GetAttribute: | ||
| 206 | GetAttribute(info, inst.Arg(0).Attribute()); | ||
| 207 | break; | ||
| 208 | case IR::Opcode::SetAttribute: | ||
| 209 | SetAttribute(info, inst.Arg(0).Attribute()); | ||
| 210 | break; | ||
| 211 | case IR::Opcode::SetFragColor: | ||
| 212 | info.stores_frag_color[inst.Arg(0).U32()] = true; | ||
| 213 | break; | ||
| 214 | case IR::Opcode::SetFragDepth: | ||
| 215 | info.stores_frag_depth = true; | ||
| 216 | break; | ||
| 165 | case IR::Opcode::WorkgroupId: | 217 | case IR::Opcode::WorkgroupId: |
| 166 | info.uses_workgroup_id = true; | 218 | info.uses_workgroup_id = true; |
| 167 | break; | 219 | break; |
diff --git a/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp b/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp index d09bcec36..bab7ca186 100644 --- a/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp +++ b/src/shader_recompiler/ir_opt/ssa_rewrite_pass.cpp | |||
| @@ -169,7 +169,7 @@ private: | |||
| 169 | const size_t num_args{phi.NumArgs()}; | 169 | const size_t num_args{phi.NumArgs()}; |
| 170 | for (size_t arg_index = 0; arg_index < num_args; ++arg_index) { | 170 | for (size_t arg_index = 0; arg_index < num_args; ++arg_index) { |
| 171 | const IR::Value& op{phi.Arg(arg_index)}; | 171 | const IR::Value& op{phi.Arg(arg_index)}; |
| 172 | if (op == same || op == IR::Value{&phi}) { | 172 | if (op.Resolve() == same.Resolve() || op == IR::Value{&phi}) { |
| 173 | // Unique value or self-reference | 173 | // Unique value or self-reference |
| 174 | continue; | 174 | continue; |
| 175 | } | 175 | } |