diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/shader_recompiler/frontend/maxwell/translate_program.cpp | 47 | ||||
| -rw-r--r-- | src/shader_recompiler/runtime_info.h | 2 | ||||
| -rw-r--r-- | src/shader_recompiler/shader_info.h | 3 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_cache.cpp | 1 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | 1 |
5 files changed, 35 insertions, 19 deletions
diff --git a/src/shader_recompiler/frontend/maxwell/translate_program.cpp b/src/shader_recompiler/frontend/maxwell/translate_program.cpp index 77efb4f57..b58741d4d 100644 --- a/src/shader_recompiler/frontend/maxwell/translate_program.cpp +++ b/src/shader_recompiler/frontend/maxwell/translate_program.cpp | |||
| @@ -137,28 +137,35 @@ bool IsLegacyAttribute(IR::Attribute attribute) { | |||
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | std::map<IR::Attribute, IR::Attribute> GenerateLegacyToGenericMappings( | 139 | std::map<IR::Attribute, IR::Attribute> GenerateLegacyToGenericMappings( |
| 140 | const VaryingState& state, std::queue<IR::Attribute> ununsed_generics) { | 140 | const VaryingState& state, std::queue<IR::Attribute> unused_generics, |
| 141 | const std::map<IR::Attribute, IR::Attribute>& previous_stage_mapping) { | ||
| 141 | std::map<IR::Attribute, IR::Attribute> mapping; | 142 | std::map<IR::Attribute, IR::Attribute> mapping; |
| 143 | auto update_mapping = [&mapping, &unused_generics, previous_stage_mapping](IR::Attribute attr, | ||
| 144 | size_t count) { | ||
| 145 | if (previous_stage_mapping.find(attr) != previous_stage_mapping.end()) { | ||
| 146 | for (size_t i = 0; i < count; ++i) { | ||
| 147 | mapping.insert({attr + i, previous_stage_mapping.at(attr + i)}); | ||
| 148 | } | ||
| 149 | } else { | ||
| 150 | for (size_t i = 0; i < count; ++i) { | ||
| 151 | mapping.insert({attr + i, unused_generics.front() + i}); | ||
| 152 | } | ||
| 153 | unused_generics.pop(); | ||
| 154 | } | ||
| 155 | }; | ||
| 142 | for (size_t index = 0; index < 4; ++index) { | 156 | for (size_t index = 0; index < 4; ++index) { |
| 143 | auto attr = IR::Attribute::ColorFrontDiffuseR + index * 4; | 157 | auto attr = IR::Attribute::ColorFrontDiffuseR + index * 4; |
| 144 | if (state.AnyComponent(attr)) { | 158 | if (state.AnyComponent(attr)) { |
| 145 | for (size_t i = 0; i < 4; ++i) { | 159 | update_mapping(attr, 4); |
| 146 | mapping.insert({attr + i, ununsed_generics.front() + i}); | ||
| 147 | } | ||
| 148 | ununsed_generics.pop(); | ||
| 149 | } | 160 | } |
| 150 | } | 161 | } |
| 151 | if (state[IR::Attribute::FogCoordinate]) { | 162 | if (state[IR::Attribute::FogCoordinate]) { |
| 152 | mapping.insert({IR::Attribute::FogCoordinate, ununsed_generics.front()}); | 163 | update_mapping(IR::Attribute::FogCoordinate, 1); |
| 153 | ununsed_generics.pop(); | ||
| 154 | } | 164 | } |
| 155 | for (size_t index = 0; index < IR::NUM_FIXEDFNCTEXTURE; ++index) { | 165 | for (size_t index = 0; index < IR::NUM_FIXEDFNCTEXTURE; ++index) { |
| 156 | auto attr = IR::Attribute::FixedFncTexture0S + index * 4; | 166 | auto attr = IR::Attribute::FixedFncTexture0S + index * 4; |
| 157 | if (state.AnyComponent(attr)) { | 167 | if (state.AnyComponent(attr)) { |
| 158 | for (size_t i = 0; i < 4; ++i) { | 168 | update_mapping(attr, 4); |
| 159 | mapping.insert({attr + i, ununsed_generics.front() + i}); | ||
| 160 | } | ||
| 161 | ununsed_generics.pop(); | ||
| 162 | } | 169 | } |
| 163 | } | 170 | } |
| 164 | return mapping; | 171 | return mapping; |
| @@ -265,21 +272,22 @@ IR::Program MergeDualVertexPrograms(IR::Program& vertex_a, IR::Program& vertex_b | |||
| 265 | void ConvertLegacyToGeneric(IR::Program& program, const Shader::RuntimeInfo& runtime_info) { | 272 | void ConvertLegacyToGeneric(IR::Program& program, const Shader::RuntimeInfo& runtime_info) { |
| 266 | auto& stores = program.info.stores; | 273 | auto& stores = program.info.stores; |
| 267 | if (stores.Legacy()) { | 274 | if (stores.Legacy()) { |
| 268 | std::queue<IR::Attribute> ununsed_output_generics{}; | 275 | std::queue<IR::Attribute> unused_output_generics{}; |
| 269 | for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { | 276 | for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { |
| 270 | if (!stores.Generic(index)) { | 277 | if (!stores.Generic(index)) { |
| 271 | ununsed_output_generics.push(IR::Attribute::Generic0X + index * 4); | 278 | unused_output_generics.push(IR::Attribute::Generic0X + index * 4); |
| 272 | } | 279 | } |
| 273 | } | 280 | } |
| 274 | auto mappings = GenerateLegacyToGenericMappings(stores, ununsed_output_generics); | 281 | program.info.legacy_stores_mapping = |
| 282 | GenerateLegacyToGenericMappings(stores, unused_output_generics, {}); | ||
| 275 | for (IR::Block* const block : program.post_order_blocks) { | 283 | for (IR::Block* const block : program.post_order_blocks) { |
| 276 | for (IR::Inst& inst : block->Instructions()) { | 284 | for (IR::Inst& inst : block->Instructions()) { |
| 277 | switch (inst.GetOpcode()) { | 285 | switch (inst.GetOpcode()) { |
| 278 | case IR::Opcode::SetAttribute: { | 286 | case IR::Opcode::SetAttribute: { |
| 279 | const auto attr = inst.Arg(0).Attribute(); | 287 | const auto attr = inst.Arg(0).Attribute(); |
| 280 | if (IsLegacyAttribute(attr)) { | 288 | if (IsLegacyAttribute(attr)) { |
| 281 | stores.Set(mappings[attr], true); | 289 | stores.Set(program.info.legacy_stores_mapping[attr], true); |
| 282 | inst.SetArg(0, Shader::IR::Value(mappings[attr])); | 290 | inst.SetArg(0, Shader::IR::Value(program.info.legacy_stores_mapping[attr])); |
| 283 | } | 291 | } |
| 284 | break; | 292 | break; |
| 285 | } | 293 | } |
| @@ -292,15 +300,16 @@ void ConvertLegacyToGeneric(IR::Program& program, const Shader::RuntimeInfo& run | |||
| 292 | 300 | ||
| 293 | auto& loads = program.info.loads; | 301 | auto& loads = program.info.loads; |
| 294 | if (loads.Legacy()) { | 302 | if (loads.Legacy()) { |
| 295 | std::queue<IR::Attribute> ununsed_input_generics{}; | 303 | std::queue<IR::Attribute> unused_input_generics{}; |
| 296 | for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { | 304 | for (size_t index = 0; index < IR::NUM_GENERICS; ++index) { |
| 297 | const AttributeType input_type{runtime_info.generic_input_types[index]}; | 305 | const AttributeType input_type{runtime_info.generic_input_types[index]}; |
| 298 | if (!runtime_info.previous_stage_stores.Generic(index) || !loads.Generic(index) || | 306 | if (!runtime_info.previous_stage_stores.Generic(index) || !loads.Generic(index) || |
| 299 | input_type == AttributeType::Disabled) { | 307 | input_type == AttributeType::Disabled) { |
| 300 | ununsed_input_generics.push(IR::Attribute::Generic0X + index * 4); | 308 | unused_input_generics.push(IR::Attribute::Generic0X + index * 4); |
| 301 | } | 309 | } |
| 302 | } | 310 | } |
| 303 | auto mappings = GenerateLegacyToGenericMappings(loads, ununsed_input_generics); | 311 | auto mappings = GenerateLegacyToGenericMappings( |
| 312 | loads, unused_input_generics, runtime_info.previous_stage_legacy_stores_mapping); | ||
| 304 | for (IR::Block* const block : program.post_order_blocks) { | 313 | for (IR::Block* const block : program.post_order_blocks) { |
| 305 | for (IR::Inst& inst : block->Instructions()) { | 314 | for (IR::Inst& inst : block->Instructions()) { |
| 306 | switch (inst.GetOpcode()) { | 315 | switch (inst.GetOpcode()) { |
diff --git a/src/shader_recompiler/runtime_info.h b/src/shader_recompiler/runtime_info.h index dcb5ab158..549b81ef7 100644 --- a/src/shader_recompiler/runtime_info.h +++ b/src/shader_recompiler/runtime_info.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <array> | 6 | #include <array> |
| 7 | #include <map> | ||
| 7 | #include <optional> | 8 | #include <optional> |
| 8 | #include <vector> | 9 | #include <vector> |
| 9 | 10 | ||
| @@ -60,6 +61,7 @@ struct TransformFeedbackVarying { | |||
| 60 | struct RuntimeInfo { | 61 | struct RuntimeInfo { |
| 61 | std::array<AttributeType, 32> generic_input_types{}; | 62 | std::array<AttributeType, 32> generic_input_types{}; |
| 62 | VaryingState previous_stage_stores; | 63 | VaryingState previous_stage_stores; |
| 64 | std::map<IR::Attribute, IR::Attribute> previous_stage_legacy_stores_mapping; | ||
| 63 | 65 | ||
| 64 | bool convert_depth_mode{}; | 66 | bool convert_depth_mode{}; |
| 65 | bool force_early_z{}; | 67 | bool force_early_z{}; |
diff --git a/src/shader_recompiler/shader_info.h b/src/shader_recompiler/shader_info.h index cc596da4f..81097bf1a 100644 --- a/src/shader_recompiler/shader_info.h +++ b/src/shader_recompiler/shader_info.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | #include <array> | 6 | #include <array> |
| 7 | #include <bitset> | 7 | #include <bitset> |
| 8 | #include <map> | ||
| 8 | 9 | ||
| 9 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 10 | #include "shader_recompiler/frontend/ir/type.h" | 11 | #include "shader_recompiler/frontend/ir/type.h" |
| @@ -127,6 +128,8 @@ struct Info { | |||
| 127 | VaryingState stores; | 128 | VaryingState stores; |
| 128 | VaryingState passthrough; | 129 | VaryingState passthrough; |
| 129 | 130 | ||
| 131 | std::map<IR::Attribute, IR::Attribute> legacy_stores_mapping; | ||
| 132 | |||
| 130 | bool loads_indexed_attributes{}; | 133 | bool loads_indexed_attributes{}; |
| 131 | 134 | ||
| 132 | std::array<bool, 8> stores_frag_color{}; | 135 | std::array<bool, 8> stores_frag_color{}; |
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp index 609f0a772..e94cfdb1a 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp | |||
| @@ -63,6 +63,7 @@ Shader::RuntimeInfo MakeRuntimeInfo(const GraphicsPipelineKey& key, | |||
| 63 | Shader::RuntimeInfo info; | 63 | Shader::RuntimeInfo info; |
| 64 | if (previous_program) { | 64 | if (previous_program) { |
| 65 | info.previous_stage_stores = previous_program->info.stores; | 65 | info.previous_stage_stores = previous_program->info.stores; |
| 66 | info.previous_stage_legacy_stores_mapping = previous_program->info.legacy_stores_mapping; | ||
| 66 | } else { | 67 | } else { |
| 67 | // Mark all stores as available for vertex shaders | 68 | // Mark all stores as available for vertex shaders |
| 68 | info.previous_stage_stores.mask.set(); | 69 | info.previous_stage_stores.mask.set(); |
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index 20f1d6584..13d5a1f67 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | |||
| @@ -134,6 +134,7 @@ Shader::RuntimeInfo MakeRuntimeInfo(std::span<const Shader::IR::Program> program | |||
| 134 | Shader::RuntimeInfo info; | 134 | Shader::RuntimeInfo info; |
| 135 | if (previous_program) { | 135 | if (previous_program) { |
| 136 | info.previous_stage_stores = previous_program->info.stores; | 136 | info.previous_stage_stores = previous_program->info.stores; |
| 137 | info.previous_stage_legacy_stores_mapping = previous_program->info.legacy_stores_mapping; | ||
| 137 | if (previous_program->is_geometry_passthrough) { | 138 | if (previous_program->is_geometry_passthrough) { |
| 138 | info.previous_stage_stores.mask |= previous_program->info.passthrough.mask; | 139 | info.previous_stage_stores.mask |= previous_program->info.passthrough.mask; |
| 139 | } | 140 | } |