summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Laku2018-08-31 04:32:58 +0300
committerGravatar bunnei2018-08-30 21:32:58 -0400
commit915ab81ec203d40e6f67d3cfa6e2e26599bec570 (patch)
tree1e74c1c52f86e89c3ddc9e166034f5b96b194760 /src
parentMerge pull request #1200 from bunnei/improve-ipa (diff)
downloadyuzu-915ab81ec203d40e6f67d3cfa6e2e26599bec570.tar.gz
yuzu-915ab81ec203d40e6f67d3cfa6e2e26599bec570.tar.xz
yuzu-915ab81ec203d40e6f67d3cfa6e2e26599bec570.zip
gl_shader_decompiler: Implement POPC (#1203)
* Implement POPC * implement invert
Diffstat (limited to 'src')
-rw-r--r--src/video_core/engines/shader_bytecode.h10
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp9
2 files changed, 19 insertions, 0 deletions
diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.h
index dc98bdc3d..65e0c469f 100644
--- a/src/video_core/engines/shader_bytecode.h
+++ b/src/video_core/engines/shader_bytecode.h
@@ -345,6 +345,10 @@ union Instruction {
345 } alu_integer; 345 } alu_integer;
346 346
347 union { 347 union {
348 BitField<40, 1, u64> invert;
349 } popc;
350
351 union {
348 BitField<39, 3, u64> pred; 352 BitField<39, 3, u64> pred;
349 BitField<42, 1, u64> neg_pred; 353 BitField<42, 1, u64> neg_pred;
350 } sel; 354 } sel;
@@ -671,6 +675,9 @@ public:
671 ISCADD_C, // Scale and Add 675 ISCADD_C, // Scale and Add
672 ISCADD_R, 676 ISCADD_R,
673 ISCADD_IMM, 677 ISCADD_IMM,
678 POPC_C,
679 POPC_R,
680 POPC_IMM,
674 SEL_C, 681 SEL_C,
675 SEL_R, 682 SEL_R,
676 SEL_IMM, 683 SEL_IMM,
@@ -892,6 +899,9 @@ private:
892 INST("0100110000011---", Id::ISCADD_C, Type::ArithmeticInteger, "ISCADD_C"), 899 INST("0100110000011---", Id::ISCADD_C, Type::ArithmeticInteger, "ISCADD_C"),
893 INST("0101110000011---", Id::ISCADD_R, Type::ArithmeticInteger, "ISCADD_R"), 900 INST("0101110000011---", Id::ISCADD_R, Type::ArithmeticInteger, "ISCADD_R"),
894 INST("0011100-00011---", Id::ISCADD_IMM, Type::ArithmeticInteger, "ISCADD_IMM"), 901 INST("0011100-00011---", Id::ISCADD_IMM, Type::ArithmeticInteger, "ISCADD_IMM"),
902 INST("0100110000001---", Id::POPC_C, Type::ArithmeticInteger, "POPC_C"),
903 INST("0101110000001---", Id::POPC_R, Type::ArithmeticInteger, "POPC_R"),
904 INST("0011100-00001---", Id::POPC_IMM, Type::ArithmeticInteger, "POPC_IMM"),
895 INST("0100110010100---", Id::SEL_C, Type::ArithmeticInteger, "SEL_C"), 905 INST("0100110010100---", Id::SEL_C, Type::ArithmeticInteger, "SEL_C"),
896 INST("0101110010100---", Id::SEL_R, Type::ArithmeticInteger, "SEL_R"), 906 INST("0101110010100---", Id::SEL_R, Type::ArithmeticInteger, "SEL_R"),
897 INST("0011100-10100---", Id::SEL_IMM, Type::ArithmeticInteger, "SEL_IMM"), 907 INST("0011100-10100---", Id::SEL_IMM, Type::ArithmeticInteger, "SEL_IMM"),
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index 7b6eb25a4..842bfa0b7 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -1363,6 +1363,15 @@ private:
1363 "((" + op_a + " << " + shift + ") + " + op_b + ')', 1, 1); 1363 "((" + op_a + " << " + shift + ") + " + op_b + ')', 1, 1);
1364 break; 1364 break;
1365 } 1365 }
1366 case OpCode::Id::POPC_C:
1367 case OpCode::Id::POPC_R:
1368 case OpCode::Id::POPC_IMM: {
1369 if (instr.popc.invert) {
1370 op_b = "~(" + op_b + ')';
1371 }
1372 regs.SetRegisterToInteger(instr.gpr0, true, 0, "bitCount(" + op_b + ')', 1, 1);
1373 break;
1374 }
1366 case OpCode::Id::SEL_C: 1375 case OpCode::Id::SEL_C:
1367 case OpCode::Id::SEL_R: 1376 case OpCode::Id::SEL_R:
1368 case OpCode::Id::SEL_IMM: { 1377 case OpCode::Id::SEL_IMM: {