diff options
| author | 2018-12-23 01:33:47 -0300 | |
|---|---|---|
| committer | 2019-01-15 17:54:52 -0300 | |
| commit | 027f443e699652fc30a849efaf8c12725a7b5729 (patch) | |
| tree | 10f5c18227a20ce4cf9295107ee16e310e0d41da /src | |
| parent | shader_decode: Implement TLDS (untested) (diff) | |
| download | yuzu-027f443e699652fc30a849efaf8c12725a7b5729.tar.gz yuzu-027f443e699652fc30a849efaf8c12725a7b5729.tar.xz yuzu-027f443e699652fc30a849efaf8c12725a7b5729.zip | |
shader_decode: Implement POPC
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/shader/decode/arithmetic_integer.cpp | 10 | ||||
| -rw-r--r-- | src/video_core/shader/glsl_decompiler.cpp | 7 | ||||
| -rw-r--r-- | src/video_core/shader/shader_ir.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/shader/shader_ir.h | 4 |
4 files changed, 22 insertions, 1 deletions
diff --git a/src/video_core/shader/decode/arithmetic_integer.cpp b/src/video_core/shader/decode/arithmetic_integer.cpp index b12dc5ba8..271ce205b 100644 --- a/src/video_core/shader/decode/arithmetic_integer.cpp +++ b/src/video_core/shader/decode/arithmetic_integer.cpp | |||
| @@ -119,6 +119,16 @@ u32 ShaderIR::DecodeArithmeticInteger(BasicBlock& bb, u32 pc) { | |||
| 119 | SetRegister(bb, instr.gpr0, value); | 119 | SetRegister(bb, instr.gpr0, value); |
| 120 | break; | 120 | break; |
| 121 | } | 121 | } |
| 122 | case OpCode::Id::POPC_C: | ||
| 123 | case OpCode::Id::POPC_R: | ||
| 124 | case OpCode::Id::POPC_IMM: { | ||
| 125 | if (instr.popc.invert) { | ||
| 126 | op_b = Operation(OperationCode::IBitwiseNot, NO_PRECISE, op_b); | ||
| 127 | } | ||
| 128 | const Node value = Operation(OperationCode::IBitCount, PRECISE, op_b); | ||
| 129 | SetRegister(bb, instr.gpr0, value); | ||
| 130 | break; | ||
| 131 | } | ||
| 122 | case OpCode::Id::SEL_C: | 132 | case OpCode::Id::SEL_C: |
| 123 | case OpCode::Id::SEL_R: | 133 | case OpCode::Id::SEL_R: |
| 124 | case OpCode::Id::SEL_IMM: { | 134 | case OpCode::Id::SEL_IMM: { |
diff --git a/src/video_core/shader/glsl_decompiler.cpp b/src/video_core/shader/glsl_decompiler.cpp index b93ea9ec6..1aff62882 100644 --- a/src/video_core/shader/glsl_decompiler.cpp +++ b/src/video_core/shader/glsl_decompiler.cpp | |||
| @@ -908,6 +908,11 @@ private: | |||
| 908 | Type::Int); | 908 | Type::Int); |
| 909 | } | 909 | } |
| 910 | 910 | ||
| 911 | template <Type type> | ||
| 912 | std::string BitCount(Operation operation) { | ||
| 913 | return GenerateUnary(operation, "bitCount", type, type, false); | ||
| 914 | } | ||
| 915 | |||
| 911 | std::string HNegate(Operation operation) { | 916 | std::string HNegate(Operation operation) { |
| 912 | const auto GetNegate = [&](std::size_t index) -> std::string { | 917 | const auto GetNegate = [&](std::size_t index) -> std::string { |
| 913 | if (const auto pred = std::get_if<PredicateNode>(operation[index])) { | 918 | if (const auto pred = std::get_if<PredicateNode>(operation[index])) { |
| @@ -1273,6 +1278,7 @@ private: | |||
| 1273 | &BitwiseXor<Type::Int>, | 1278 | &BitwiseXor<Type::Int>, |
| 1274 | &BitwiseNot<Type::Int>, | 1279 | &BitwiseNot<Type::Int>, |
| 1275 | &BitfieldInsert<Type::Int>, | 1280 | &BitfieldInsert<Type::Int>, |
| 1281 | &BitCount<Type::Int>, | ||
| 1276 | 1282 | ||
| 1277 | &Add<Type::Uint>, | 1283 | &Add<Type::Uint>, |
| 1278 | &Mul<Type::Uint>, | 1284 | &Mul<Type::Uint>, |
| @@ -1289,6 +1295,7 @@ private: | |||
| 1289 | &BitwiseXor<Type::Uint>, | 1295 | &BitwiseXor<Type::Uint>, |
| 1290 | &BitwiseNot<Type::Uint>, | 1296 | &BitwiseNot<Type::Uint>, |
| 1291 | &BitfieldInsert<Type::Uint>, | 1297 | &BitfieldInsert<Type::Uint>, |
| 1298 | &BitCount<Type::Uint>, | ||
| 1292 | 1299 | ||
| 1293 | &Add<Type::HalfFloat>, | 1300 | &Add<Type::HalfFloat>, |
| 1294 | &Mul<Type::HalfFloat>, | 1301 | &Mul<Type::HalfFloat>, |
diff --git a/src/video_core/shader/shader_ir.cpp b/src/video_core/shader/shader_ir.cpp index 1f39dc6d0..1fc838d15 100644 --- a/src/video_core/shader/shader_ir.cpp +++ b/src/video_core/shader/shader_ir.cpp | |||
| @@ -386,6 +386,8 @@ void ShaderIR::SetLocalMemory(BasicBlock& bb, Node address, Node value) { | |||
| 386 | return OperationCode::UBitwiseNot; | 386 | return OperationCode::UBitwiseNot; |
| 387 | case OperationCode::IBitfieldInsert: | 387 | case OperationCode::IBitfieldInsert: |
| 388 | return OperationCode::UBitfieldInsert; | 388 | return OperationCode::UBitfieldInsert; |
| 389 | case OperationCode::IBitCount: | ||
| 390 | return OperationCode::UBitCount; | ||
| 389 | case OperationCode::LogicalILessThan: | 391 | case OperationCode::LogicalILessThan: |
| 390 | return OperationCode::LogicalULessThan; | 392 | return OperationCode::LogicalULessThan; |
| 391 | case OperationCode::LogicalIEqual: | 393 | case OperationCode::LogicalIEqual: |
diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h index 231f58f6a..ccdf316ac 100644 --- a/src/video_core/shader/shader_ir.h +++ b/src/video_core/shader/shader_ir.h | |||
| @@ -89,6 +89,7 @@ enum class OperationCode { | |||
| 89 | IBitwiseXor, /// (MetaArithmetic, int a, int b) -> int | 89 | IBitwiseXor, /// (MetaArithmetic, int a, int b) -> int |
| 90 | IBitwiseNot, /// (MetaArithmetic, int a) -> int | 90 | IBitwiseNot, /// (MetaArithmetic, int a) -> int |
| 91 | IBitfieldInsert, /// (MetaArithmetic, int base, int insert, int offset, int bits) -> int | 91 | IBitfieldInsert, /// (MetaArithmetic, int base, int insert, int offset, int bits) -> int |
| 92 | IBitCount, /// (MetaArithmetic, int) -> int | ||
| 92 | 93 | ||
| 93 | UAdd, /// (MetaArithmetic, uint a, uint b) -> uint | 94 | UAdd, /// (MetaArithmetic, uint a, uint b) -> uint |
| 94 | UMul, /// (MetaArithmetic, uint a, uint b) -> uint | 95 | UMul, /// (MetaArithmetic, uint a, uint b) -> uint |
| @@ -103,8 +104,9 @@ enum class OperationCode { | |||
| 103 | UBitwiseAnd, /// (MetaArithmetic, uint a, uint b) -> uint | 104 | UBitwiseAnd, /// (MetaArithmetic, uint a, uint b) -> uint |
| 104 | UBitwiseOr, /// (MetaArithmetic, uint a, uint b) -> uint | 105 | UBitwiseOr, /// (MetaArithmetic, uint a, uint b) -> uint |
| 105 | UBitwiseXor, /// (MetaArithmetic, uint a, uint b) -> uint | 106 | UBitwiseXor, /// (MetaArithmetic, uint a, uint b) -> uint |
| 106 | UBitwiseNot, /// (MetaArithmetic, uint a) -> int | 107 | UBitwiseNot, /// (MetaArithmetic, uint a) -> uint |
| 107 | UBitfieldInsert, /// (MetaArithmetic, uint base, uint insert, int offset, int bits) -> uint | 108 | UBitfieldInsert, /// (MetaArithmetic, uint base, uint insert, int offset, int bits) -> uint |
| 109 | UBitCount, /// (MetaArithmetic, uint) -> uint | ||
| 108 | 110 | ||
| 109 | HAdd, /// (MetaHalfArithmetic, f16vec2 a, f16vec2 b) -> f16vec2 | 111 | HAdd, /// (MetaHalfArithmetic, f16vec2 a, f16vec2 b) -> f16vec2 |
| 110 | HMul, /// (MetaHalfArithmetic, f16vec2 a, f16vec2 b) -> f16vec2 | 112 | HMul, /// (MetaHalfArithmetic, f16vec2 a, f16vec2 b) -> f16vec2 |