diff options
| author | 2018-12-23 20:59:49 -0300 | |
|---|---|---|
| committer | 2019-01-15 17:54:53 -0300 | |
| commit | 2df55985b691d659073dce2d857d46bc152b4842 (patch) | |
| tree | 334b3f81d183b48b81b1be82c8d92d4731bbdb61 /src | |
| parent | shader_decode: Implement R2P (diff) | |
| download | yuzu-2df55985b691d659073dce2d857d46bc152b4842.tar.gz yuzu-2df55985b691d659073dce2d857d46bc152b4842.tar.xz yuzu-2df55985b691d659073dce2d857d46bc152b4842.zip | |
shader_decode: Rework HSETP2
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/shader/decode/half_set_predicate.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/shader/glsl_decompiler.cpp | 59 | ||||
| -rw-r--r-- | src/video_core/shader/shader_ir.cpp | 22 | ||||
| -rw-r--r-- | src/video_core/shader/shader_ir.h | 15 |
4 files changed, 57 insertions, 47 deletions
diff --git a/src/video_core/shader/decode/half_set_predicate.cpp b/src/video_core/shader/decode/half_set_predicate.cpp index d7d63d50a..72cc3d5c8 100644 --- a/src/video_core/shader/decode/half_set_predicate.cpp +++ b/src/video_core/shader/decode/half_set_predicate.cpp | |||
| @@ -39,10 +39,12 @@ u32 ShaderIR::DecodeHalfSetPredicate(BasicBlock& bb, u32 pc) { | |||
| 39 | const Node second_pred = GetPredicate(instr.hsetp2.pred39, instr.hsetp2.neg_pred != 0); | 39 | const Node second_pred = GetPredicate(instr.hsetp2.pred39, instr.hsetp2.neg_pred != 0); |
| 40 | 40 | ||
| 41 | const OperationCode combiner = GetPredicateCombiner(instr.hsetp2.op); | 41 | const OperationCode combiner = GetPredicateCombiner(instr.hsetp2.op); |
| 42 | const OperationCode pair_combiner = | ||
| 43 | instr.hsetp2.h_and ? OperationCode::LogicalAll2 : OperationCode::LogicalAny2; | ||
| 42 | 44 | ||
| 43 | MetaHalfArithmetic meta = { | 45 | MetaHalfArithmetic meta = {false, {instr.hsetp2.type_a, instr.hsetp2.type_b}}; |
| 44 | false, {instr.hsetp2.type_a, instr.hsetp2.type_b}, instr.hsetp2.h_and != 0}; | 46 | const Node comparison = GetPredicateComparisonHalf(instr.hsetp2.cond, meta, op_a, op_b); |
| 45 | const Node first_pred = GetPredicateComparisonHalf(instr.hsetp2.cond, meta, op_a, op_b); | 47 | const Node first_pred = Operation(pair_combiner, comparison); |
| 46 | 48 | ||
| 47 | // Set the primary predicate to the result of Predicate OP SecondPredicate | 49 | // Set the primary predicate to the result of Predicate OP SecondPredicate |
| 48 | const Node value = Operation(combiner, first_pred, second_pred); | 50 | const Node value = Operation(combiner, first_pred, second_pred); |
diff --git a/src/video_core/shader/glsl_decompiler.cpp b/src/video_core/shader/glsl_decompiler.cpp index c364a43ce..8a2cc3c31 100644 --- a/src/video_core/shader/glsl_decompiler.cpp +++ b/src/video_core/shader/glsl_decompiler.cpp | |||
| @@ -31,7 +31,7 @@ using Operation = const OperationNode&; | |||
| 31 | enum : u32 { POSITION_VARYING_LOCATION = 0, GENERIC_VARYING_START_LOCATION = 1 }; | 31 | enum : u32 { POSITION_VARYING_LOCATION = 0, GENERIC_VARYING_START_LOCATION = 1 }; |
| 32 | constexpr u32 MAX_CONSTBUFFER_ELEMENTS = 65536 / 16; // TODO(Rodrigo): Use rasterizer's value | 32 | constexpr u32 MAX_CONSTBUFFER_ELEMENTS = 65536 / 16; // TODO(Rodrigo): Use rasterizer's value |
| 33 | 33 | ||
| 34 | enum class Type { Bool, Float, Int, Uint, HalfFloat }; | 34 | enum class Type { Bool, Bool2, Float, Int, Uint, HalfFloat }; |
| 35 | 35 | ||
| 36 | class ShaderWriter { | 36 | class ShaderWriter { |
| 37 | public: | 37 | public: |
| @@ -541,6 +541,7 @@ private: | |||
| 541 | 541 | ||
| 542 | switch (type) { | 542 | switch (type) { |
| 543 | case Type::Bool: | 543 | case Type::Bool: |
| 544 | case Type::Bool2: | ||
| 544 | case Type::Float: | 545 | case Type::Float: |
| 545 | return value; | 546 | return value; |
| 546 | case Type::Int: | 547 | case Type::Int: |
| @@ -1011,38 +1012,42 @@ private: | |||
| 1011 | return GenerateUnary(operation, "!", Type::Bool, Type::Bool, false); | 1012 | return GenerateUnary(operation, "!", Type::Bool, Type::Bool, false); |
| 1012 | } | 1013 | } |
| 1013 | 1014 | ||
| 1014 | std::string LogicalHComparison(Operation operation, const std::string& func) { | 1015 | std::string LogicalAll2(Operation operation) { |
| 1015 | const auto& meta = std::get<MetaHalfArithmetic>(operation.GetMeta()); | 1016 | return GenerateUnary(operation, "all", Type::Bool, Type::Bool2); |
| 1016 | const std::string op_a = VisitOperand(operation, 0, Type::HalfFloat); | 1017 | } |
| 1017 | const std::string op_b = VisitOperand(operation, 1, Type::HalfFloat); | ||
| 1018 | 1018 | ||
| 1019 | std::string value = meta.and_comparison ? "all" : "any"; | 1019 | std::string LogicalAny2(Operation operation) { |
| 1020 | value += '(' + func + '(' + op_a + ", " + op_b + "))"; | 1020 | return GenerateUnary(operation, "any", Type::Bool, Type::Bool2); |
| 1021 | return value; | ||
| 1022 | } | 1021 | } |
| 1023 | 1022 | ||
| 1024 | std::string LogicalHLessThan(Operation operation) { | 1023 | std::string Logical2HLessThan(Operation operation) { |
| 1025 | return LogicalHComparison(operation, "lessThan"); | 1024 | return GenerateBinaryCall(operation, "lessThan", Type::Bool2, Type::HalfFloat, |
| 1025 | Type::HalfFloat); | ||
| 1026 | } | 1026 | } |
| 1027 | 1027 | ||
| 1028 | std::string LogicalHEqual(Operation operation) { | 1028 | std::string Logical2HEqual(Operation operation) { |
| 1029 | return LogicalHComparison(operation, "equal"); | 1029 | return GenerateBinaryCall(operation, "equal", Type::Bool2, Type::HalfFloat, |
| 1030 | Type::HalfFloat); | ||
| 1030 | } | 1031 | } |
| 1031 | 1032 | ||
| 1032 | std::string LogicalHLessEqual(Operation operation) { | 1033 | std::string Logical2HLessEqual(Operation operation) { |
| 1033 | return LogicalHComparison(operation, "lessThanEqual"); | 1034 | return GenerateBinaryCall(operation, "lessThanEqual", Type::Bool2, Type::HalfFloat, |
| 1035 | Type::HalfFloat); | ||
| 1034 | } | 1036 | } |
| 1035 | 1037 | ||
| 1036 | std::string LogicalHGreaterThan(Operation operation) { | 1038 | std::string Logical2HGreaterThan(Operation operation) { |
| 1037 | return LogicalHComparison(operation, "greaterThan"); | 1039 | return GenerateBinaryCall(operation, "greaterThan", Type::Bool2, Type::HalfFloat, |
| 1040 | Type::HalfFloat); | ||
| 1038 | } | 1041 | } |
| 1039 | 1042 | ||
| 1040 | std::string LogicalHNotEqual(Operation operation) { | 1043 | std::string Logical2HNotEqual(Operation operation) { |
| 1041 | return LogicalHComparison(operation, "notEqual"); | 1044 | return GenerateBinaryCall(operation, "notEqual", Type::Bool2, Type::HalfFloat, |
| 1045 | Type::HalfFloat); | ||
| 1042 | } | 1046 | } |
| 1043 | 1047 | ||
| 1044 | std::string LogicalHGreaterEqual(Operation operation) { | 1048 | std::string Logical2HGreaterEqual(Operation operation) { |
| 1045 | return LogicalHComparison(operation, "greaterThanEqual"); | 1049 | return GenerateBinaryCall(operation, "greaterThanEqual", Type::Bool2, Type::HalfFloat, |
| 1050 | Type::HalfFloat); | ||
| 1046 | } | 1051 | } |
| 1047 | 1052 | ||
| 1048 | std::string F4Texture(Operation operation) { | 1053 | std::string F4Texture(Operation operation) { |
| @@ -1301,6 +1306,8 @@ private: | |||
| 1301 | &LogicalOr, | 1306 | &LogicalOr, |
| 1302 | &LogicalXor, | 1307 | &LogicalXor, |
| 1303 | &LogicalNegate, | 1308 | &LogicalNegate, |
| 1309 | &LogicalAll2, | ||
| 1310 | &LogicalAny2, | ||
| 1304 | 1311 | ||
| 1305 | &LogicalLessThan<Type::Float>, | 1312 | &LogicalLessThan<Type::Float>, |
| 1306 | &LogicalEqual<Type::Float>, | 1313 | &LogicalEqual<Type::Float>, |
| @@ -1324,12 +1331,12 @@ private: | |||
| 1324 | &LogicalNotEqual<Type::Uint>, | 1331 | &LogicalNotEqual<Type::Uint>, |
| 1325 | &LogicalGreaterEqual<Type::Uint>, | 1332 | &LogicalGreaterEqual<Type::Uint>, |
| 1326 | 1333 | ||
| 1327 | &LogicalHLessThan, | 1334 | &Logical2HLessThan, |
| 1328 | &LogicalHEqual, | 1335 | &Logical2HEqual, |
| 1329 | &LogicalHLessEqual, | 1336 | &Logical2HLessEqual, |
| 1330 | &LogicalHGreaterThan, | 1337 | &Logical2HGreaterThan, |
| 1331 | &LogicalHNotEqual, | 1338 | &Logical2HNotEqual, |
| 1332 | &LogicalHGreaterEqual, | 1339 | &Logical2HGreaterEqual, |
| 1333 | 1340 | ||
| 1334 | &F4Texture, | 1341 | &F4Texture, |
| 1335 | &F4TextureLod, | 1342 | &F4TextureLod, |
diff --git a/src/video_core/shader/shader_ir.cpp b/src/video_core/shader/shader_ir.cpp index 1fc838d15..b07642517 100644 --- a/src/video_core/shader/shader_ir.cpp +++ b/src/video_core/shader/shader_ir.cpp | |||
| @@ -289,17 +289,17 @@ Node ShaderIR::GetPredicateComparisonHalf(Tegra::Shader::PredCondition condition | |||
| 289 | "Unimplemented NaN comparison for half floats"); | 289 | "Unimplemented NaN comparison for half floats"); |
| 290 | 290 | ||
| 291 | static const std::unordered_map<PredCondition, OperationCode> PredicateComparisonTable = { | 291 | static const std::unordered_map<PredCondition, OperationCode> PredicateComparisonTable = { |
| 292 | {PredCondition::LessThan, OperationCode::LogicalHLessThan}, | 292 | {PredCondition::LessThan, OperationCode::Logical2HLessThan}, |
| 293 | {PredCondition::Equal, OperationCode::LogicalHEqual}, | 293 | {PredCondition::Equal, OperationCode::Logical2HEqual}, |
| 294 | {PredCondition::LessEqual, OperationCode::LogicalHLessEqual}, | 294 | {PredCondition::LessEqual, OperationCode::Logical2HLessEqual}, |
| 295 | {PredCondition::GreaterThan, OperationCode::LogicalHGreaterThan}, | 295 | {PredCondition::GreaterThan, OperationCode::Logical2HGreaterThan}, |
| 296 | {PredCondition::NotEqual, OperationCode::LogicalHNotEqual}, | 296 | {PredCondition::NotEqual, OperationCode::Logical2HNotEqual}, |
| 297 | {PredCondition::GreaterEqual, OperationCode::LogicalHGreaterEqual}, | 297 | {PredCondition::GreaterEqual, OperationCode::Logical2HGreaterEqual}, |
| 298 | {PredCondition::LessThanWithNan, OperationCode::LogicalHLessThan}, | 298 | {PredCondition::LessThanWithNan, OperationCode::Logical2HLessThan}, |
| 299 | {PredCondition::NotEqualWithNan, OperationCode::LogicalHNotEqual}, | 299 | {PredCondition::NotEqualWithNan, OperationCode::Logical2HNotEqual}, |
| 300 | {PredCondition::LessEqualWithNan, OperationCode::LogicalHLessEqual}, | 300 | {PredCondition::LessEqualWithNan, OperationCode::Logical2HLessEqual}, |
| 301 | {PredCondition::GreaterThanWithNan, OperationCode::LogicalHGreaterThan}, | 301 | {PredCondition::GreaterThanWithNan, OperationCode::Logical2HGreaterThan}, |
| 302 | {PredCondition::GreaterEqualWithNan, OperationCode::LogicalHGreaterEqual}}; | 302 | {PredCondition::GreaterEqualWithNan, OperationCode::Logical2HGreaterEqual}}; |
| 303 | 303 | ||
| 304 | const auto comparison{PredicateComparisonTable.find(condition)}; | 304 | const auto comparison{PredicateComparisonTable.find(condition)}; |
| 305 | UNIMPLEMENTED_IF_MSG(comparison == PredicateComparisonTable.end(), | 305 | UNIMPLEMENTED_IF_MSG(comparison == PredicateComparisonTable.end(), |
diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h index 928e3e7d5..5ef0a7779 100644 --- a/src/video_core/shader/shader_ir.h +++ b/src/video_core/shader/shader_ir.h | |||
| @@ -122,6 +122,8 @@ enum class OperationCode { | |||
| 122 | LogicalOr, /// (bool a, bool b) -> bool | 122 | LogicalOr, /// (bool a, bool b) -> bool |
| 123 | LogicalXor, /// (bool a, bool b) -> bool | 123 | LogicalXor, /// (bool a, bool b) -> bool |
| 124 | LogicalNegate, /// (bool a) -> bool | 124 | LogicalNegate, /// (bool a) -> bool |
| 125 | LogicalAll2, /// (bool2 a) -> bool | ||
| 126 | LogicalAny2, /// (bool2 a) -> bool | ||
| 125 | 127 | ||
| 126 | LogicalFLessThan, /// (float a, float b) -> bool | 128 | LogicalFLessThan, /// (float a, float b) -> bool |
| 127 | LogicalFEqual, /// (float a, float b) -> bool | 129 | LogicalFEqual, /// (float a, float b) -> bool |
| @@ -145,12 +147,12 @@ enum class OperationCode { | |||
| 145 | LogicalUNotEqual, /// (uint a, uint b) -> bool | 147 | LogicalUNotEqual, /// (uint a, uint b) -> bool |
| 146 | LogicalUGreaterEqual, /// (uint a, uint b) -> bool | 148 | LogicalUGreaterEqual, /// (uint a, uint b) -> bool |
| 147 | 149 | ||
| 148 | LogicalHLessThan, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool | 150 | Logical2HLessThan, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool2 |
| 149 | LogicalHEqual, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool | 151 | Logical2HEqual, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool2 |
| 150 | LogicalHLessEqual, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool | 152 | Logical2HLessEqual, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool2 |
| 151 | LogicalHGreaterThan, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool | 153 | Logical2HGreaterThan, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool2 |
| 152 | LogicalHNotEqual, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool | 154 | Logical2HNotEqual, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool2 |
| 153 | LogicalHGreaterEqual, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool | 155 | Logical2HGreaterEqual, /// (MetaHalfArithmetic, f16vec2 a, f16vec2) -> bool2 |
| 154 | 156 | ||
| 155 | F4Texture, /// (MetaTexture, float[N] coords, float[M] params) -> float4 | 157 | F4Texture, /// (MetaTexture, float[N] coords, float[M] params) -> float4 |
| 156 | F4TextureLod, /// (MetaTexture, float[N] coords, float[M] params) -> float4 | 158 | F4TextureLod, /// (MetaTexture, float[N] coords, float[M] params) -> float4 |
| @@ -263,7 +265,6 @@ struct MetaHalfArithmetic { | |||
| 263 | std::array<Tegra::Shader::HalfType, 3> types = {Tegra::Shader::HalfType::H0_H1, | 265 | std::array<Tegra::Shader::HalfType, 3> types = {Tegra::Shader::HalfType::H0_H1, |
| 264 | Tegra::Shader::HalfType::H0_H1, | 266 | Tegra::Shader::HalfType::H0_H1, |
| 265 | Tegra::Shader::HalfType::H0_H1}; | 267 | Tegra::Shader::HalfType::H0_H1}; |
| 266 | bool and_comparison{}; | ||
| 267 | }; | 268 | }; |
| 268 | 269 | ||
| 269 | struct MetaTexture { | 270 | struct MetaTexture { |