diff options
Diffstat (limited to 'src/shader_recompiler')
6 files changed, 35 insertions, 39 deletions
diff --git a/src/shader_recompiler/CMakeLists.txt b/src/shader_recompiler/CMakeLists.txt index af8e51fe8..bcdd60db9 100644 --- a/src/shader_recompiler/CMakeLists.txt +++ b/src/shader_recompiler/CMakeLists.txt | |||
| @@ -241,24 +241,14 @@ target_link_libraries(shader_recompiler PUBLIC common fmt::fmt sirit) | |||
| 241 | if (MSVC) | 241 | if (MSVC) |
| 242 | target_compile_options(shader_recompiler PRIVATE | 242 | target_compile_options(shader_recompiler PRIVATE |
| 243 | /W4 | 243 | /W4 |
| 244 | /WX | 244 | |
| 245 | /we4018 # 'expression' : signed/unsigned mismatch | 245 | /we4242 # 'identifier': conversion from 'type1' to 'type2', possible loss of data |
| 246 | /we4244 # 'argument' : conversion from 'type1' to 'type2', possible loss of data (floating-point) | ||
| 247 | /we4245 # 'conversion' : conversion from 'type1' to 'type2', signed/unsigned mismatch | ||
| 248 | /we4254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data | 246 | /we4254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data |
| 249 | /we4267 # 'var' : conversion from 'size_t' to 'type', possible loss of data | ||
| 250 | /we4305 # 'context' : truncation from 'type1' to 'type2' | ||
| 251 | /we4800 # Implicit conversion from 'type' to bool. Possible information loss | 247 | /we4800 # Implicit conversion from 'type' to bool. Possible information loss |
| 252 | /we4826 # Conversion from 'type1' to 'type2' is sign-extended. This may cause unexpected runtime behavior. | ||
| 253 | ) | 248 | ) |
| 254 | else() | 249 | else() |
| 255 | target_compile_options(shader_recompiler PRIVATE | 250 | target_compile_options(shader_recompiler PRIVATE |
| 256 | -Werror | ||
| 257 | -Werror=conversion | 251 | -Werror=conversion |
| 258 | -Werror=ignored-qualifiers | ||
| 259 | $<$<CXX_COMPILER_ID:GNU>:-Werror=unused-but-set-parameter> | ||
| 260 | $<$<CXX_COMPILER_ID:GNU>:-Werror=unused-but-set-variable> | ||
| 261 | -Werror=unused-variable | ||
| 262 | 252 | ||
| 263 | # Bracket depth determines maximum size of a fold expression in Clang since 9c9974c3ccb6. | 253 | # Bracket depth determines maximum size of a fold expression in Clang since 9c9974c3ccb6. |
| 264 | # And this in turns limits the size of a std::array. | 254 | # And this in turns limits the size of a std::array. |
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_not_implemented.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_not_implemented.cpp index 7094d8e42..1f4ffdd62 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_not_implemented.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_not_implemented.cpp | |||
| @@ -5,10 +5,6 @@ | |||
| 5 | #include "shader_recompiler/backend/glasm/glasm_emit_context.h" | 5 | #include "shader_recompiler/backend/glasm/glasm_emit_context.h" |
| 6 | #include "shader_recompiler/frontend/ir/value.h" | 6 | #include "shader_recompiler/frontend/ir/value.h" |
| 7 | 7 | ||
| 8 | #ifdef _MSC_VER | ||
| 9 | #pragma warning(disable : 4100) | ||
| 10 | #endif | ||
| 11 | |||
| 12 | namespace Shader::Backend::GLASM { | 8 | namespace Shader::Backend::GLASM { |
| 13 | 9 | ||
| 14 | #define NotImplemented() throw NotImplementedException("GLASM instruction {}", __LINE__) | 10 | #define NotImplemented() throw NotImplementedException("GLASM instruction {}", __LINE__) |
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_not_implemented.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_not_implemented.cpp index b03a8ba1e..9f1ed95a4 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_not_implemented.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_not_implemented.cpp | |||
| @@ -7,10 +7,6 @@ | |||
| 7 | #include "shader_recompiler/backend/glsl/glsl_emit_context.h" | 7 | #include "shader_recompiler/backend/glsl/glsl_emit_context.h" |
| 8 | #include "shader_recompiler/frontend/ir/value.h" | 8 | #include "shader_recompiler/frontend/ir/value.h" |
| 9 | 9 | ||
| 10 | #ifdef _MSC_VER | ||
| 11 | #pragma warning(disable : 4100) | ||
| 12 | #endif | ||
| 13 | |||
| 14 | namespace Shader::Backend::GLSL { | 10 | namespace Shader::Backend::GLSL { |
| 15 | 11 | ||
| 16 | void EmitGetRegister(EmitContext& ctx) { | 12 | void EmitGetRegister(EmitContext& ctx) { |
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{}; |