summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2019-11-12 10:07:22 -0400
committerGravatar FernandoS272019-11-14 11:15:27 -0400
commitf3d1b370aa0fd614cf28f8a609b70906d40da751 (patch)
tree028b5f4b34c30d477e6989b49540db508a8db075 /src
parentShader_Bytecode: Add encodings for FLO, SHF and TXD (diff)
downloadyuzu-f3d1b370aa0fd614cf28f8a609b70906d40da751.tar.gz
yuzu-f3d1b370aa0fd614cf28f8a609b70906d40da751.tar.xz
yuzu-f3d1b370aa0fd614cf28f8a609b70906d40da751.zip
Shader_IR: Implement FLO instruction.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/engines/shader_bytecode.h6
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp7
-rw-r--r--src/video_core/renderer_vulkan/vk_shader_decompiler.cpp2
-rw-r--r--src/video_core/shader/decode/arithmetic_integer.cpp18
-rw-r--r--src/video_core/shader/node.h2
5 files changed, 35 insertions, 0 deletions
diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.h
index f8d67e227..16f410538 100644
--- a/src/video_core/engines/shader_bytecode.h
+++ b/src/video_core/engines/shader_bytecode.h
@@ -800,6 +800,12 @@ union Instruction {
800 } popc; 800 } popc;
801 801
802 union { 802 union {
803 BitField<41, 1, u64> sh;
804 BitField<40, 1, u64> invert;
805 BitField<48, 1, u64> is_signed;
806 } flo;
807
808 union {
803 BitField<39, 3, u64> pred; 809 BitField<39, 3, u64> pred;
804 BitField<42, 1, u64> neg_pred; 810 BitField<42, 1, u64> neg_pred;
805 } sel; 811 } sel;
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index e56ed51de..b87ee2ae8 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -1472,6 +1472,11 @@ private:
1472 return GenerateUnary(operation, "bitCount", type, type); 1472 return GenerateUnary(operation, "bitCount", type, type);
1473 } 1473 }
1474 1474
1475 template <Type type>
1476 Expression BitMSB(Operation operation) {
1477 return GenerateUnary(operation, "findMSB", type, type);
1478 }
1479
1475 Expression HNegate(Operation operation) { 1480 Expression HNegate(Operation operation) {
1476 const auto GetNegate = [&](std::size_t index) { 1481 const auto GetNegate = [&](std::size_t index) {
1477 return VisitOperand(operation, index).AsBool() + " ? -1 : 1"; 1482 return VisitOperand(operation, index).AsBool() + " ? -1 : 1";
@@ -2043,6 +2048,7 @@ private:
2043 &GLSLDecompiler::BitfieldInsert<Type::Int>, 2048 &GLSLDecompiler::BitfieldInsert<Type::Int>,
2044 &GLSLDecompiler::BitfieldExtract<Type::Int>, 2049 &GLSLDecompiler::BitfieldExtract<Type::Int>,
2045 &GLSLDecompiler::BitCount<Type::Int>, 2050 &GLSLDecompiler::BitCount<Type::Int>,
2051 &GLSLDecompiler::BitMSB<Type::Int>,
2046 2052
2047 &GLSLDecompiler::Add<Type::Uint>, 2053 &GLSLDecompiler::Add<Type::Uint>,
2048 &GLSLDecompiler::Mul<Type::Uint>, 2054 &GLSLDecompiler::Mul<Type::Uint>,
@@ -2061,6 +2067,7 @@ private:
2061 &GLSLDecompiler::BitfieldInsert<Type::Uint>, 2067 &GLSLDecompiler::BitfieldInsert<Type::Uint>,
2062 &GLSLDecompiler::BitfieldExtract<Type::Uint>, 2068 &GLSLDecompiler::BitfieldExtract<Type::Uint>,
2063 &GLSLDecompiler::BitCount<Type::Uint>, 2069 &GLSLDecompiler::BitCount<Type::Uint>,
2070 &GLSLDecompiler::BitMSB<Type::Uint>,
2064 2071
2065 &GLSLDecompiler::Add<Type::HalfFloat>, 2072 &GLSLDecompiler::Add<Type::HalfFloat>,
2066 &GLSLDecompiler::Mul<Type::HalfFloat>, 2073 &GLSLDecompiler::Mul<Type::HalfFloat>,
diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
index 2850d5b59..8378b35ac 100644
--- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
+++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
@@ -1390,6 +1390,7 @@ private:
1390 &SPIRVDecompiler::Quaternary<&Module::OpBitFieldInsert, Type::Int>, 1390 &SPIRVDecompiler::Quaternary<&Module::OpBitFieldInsert, Type::Int>,
1391 &SPIRVDecompiler::Ternary<&Module::OpBitFieldSExtract, Type::Int>, 1391 &SPIRVDecompiler::Ternary<&Module::OpBitFieldSExtract, Type::Int>,
1392 &SPIRVDecompiler::Unary<&Module::OpBitCount, Type::Int>, 1392 &SPIRVDecompiler::Unary<&Module::OpBitCount, Type::Int>,
1393 &SPIRVDecompiler::Unary<&Module::OpFindSMsb, Type::Int>,
1393 1394
1394 &SPIRVDecompiler::Binary<&Module::OpIAdd, Type::Uint>, 1395 &SPIRVDecompiler::Binary<&Module::OpIAdd, Type::Uint>,
1395 &SPIRVDecompiler::Binary<&Module::OpIMul, Type::Uint>, 1396 &SPIRVDecompiler::Binary<&Module::OpIMul, Type::Uint>,
@@ -1408,6 +1409,7 @@ private:
1408 &SPIRVDecompiler::Quaternary<&Module::OpBitFieldInsert, Type::Uint>, 1409 &SPIRVDecompiler::Quaternary<&Module::OpBitFieldInsert, Type::Uint>,
1409 &SPIRVDecompiler::Ternary<&Module::OpBitFieldUExtract, Type::Uint>, 1410 &SPIRVDecompiler::Ternary<&Module::OpBitFieldUExtract, Type::Uint>,
1410 &SPIRVDecompiler::Unary<&Module::OpBitCount, Type::Uint>, 1411 &SPIRVDecompiler::Unary<&Module::OpBitCount, Type::Uint>,
1412 &SPIRVDecompiler::Unary<&Module::OpFindUMsb, Type::Uint>,
1411 1413
1412 &SPIRVDecompiler::Binary<&Module::OpFAdd, Type::HalfFloat>, 1414 &SPIRVDecompiler::Binary<&Module::OpFAdd, Type::HalfFloat>,
1413 &SPIRVDecompiler::Binary<&Module::OpFMul, Type::HalfFloat>, 1415 &SPIRVDecompiler::Binary<&Module::OpFMul, Type::HalfFloat>,
diff --git a/src/video_core/shader/decode/arithmetic_integer.cpp b/src/video_core/shader/decode/arithmetic_integer.cpp
index a33d242e9..9208b7bef 100644
--- a/src/video_core/shader/decode/arithmetic_integer.cpp
+++ b/src/video_core/shader/decode/arithmetic_integer.cpp
@@ -130,6 +130,24 @@ u32 ShaderIR::DecodeArithmeticInteger(NodeBlock& bb, u32 pc) {
130 SetRegister(bb, instr.gpr0, value); 130 SetRegister(bb, instr.gpr0, value);
131 break; 131 break;
132 } 132 }
133 case OpCode::Id::FLO_R:
134 case OpCode::Id::FLO_C:
135 case OpCode::Id::FLO_IMM: {
136 Node value;
137 if (instr.flo.invert) {
138 op_b = Operation(OperationCode::IBitwiseNot, NO_PRECISE, op_b);
139 }
140 if (instr.flo.is_signed) {
141 value = Operation(OperationCode::IBitMSB, NO_PRECISE, op_b);
142 } else {
143 value = Operation(OperationCode::UBitMSB, NO_PRECISE, op_b);
144 }
145 if (instr.flo.sh) {
146 value = Operation(OperationCode::UBitwiseXor, NO_PRECISE, value, Immediate(31));
147 }
148 SetRegister(bb, instr.gpr0, value);
149 break;
150 }
133 case OpCode::Id::SEL_C: 151 case OpCode::Id::SEL_C:
134 case OpCode::Id::SEL_R: 152 case OpCode::Id::SEL_R:
135 case OpCode::Id::SEL_IMM: { 153 case OpCode::Id::SEL_IMM: {
diff --git a/src/video_core/shader/node.h b/src/video_core/shader/node.h
index 54217e6a4..2d11facaf 100644
--- a/src/video_core/shader/node.h
+++ b/src/video_core/shader/node.h
@@ -68,6 +68,7 @@ enum class OperationCode {
68 IBitfieldInsert, /// (MetaArithmetic, int base, int insert, int offset, int bits) -> int 68 IBitfieldInsert, /// (MetaArithmetic, int base, int insert, int offset, int bits) -> int
69 IBitfieldExtract, /// (MetaArithmetic, int value, int offset, int offset) -> int 69 IBitfieldExtract, /// (MetaArithmetic, int value, int offset, int offset) -> int
70 IBitCount, /// (MetaArithmetic, int) -> int 70 IBitCount, /// (MetaArithmetic, int) -> int
71 IBitMSB, /// (MetaArithmetic, int) -> int
71 72
72 UAdd, /// (MetaArithmetic, uint a, uint b) -> uint 73 UAdd, /// (MetaArithmetic, uint a, uint b) -> uint
73 UMul, /// (MetaArithmetic, uint a, uint b) -> uint 74 UMul, /// (MetaArithmetic, uint a, uint b) -> uint
@@ -86,6 +87,7 @@ enum class OperationCode {
86 UBitfieldInsert, /// (MetaArithmetic, uint base, uint insert, int offset, int bits) -> uint 87 UBitfieldInsert, /// (MetaArithmetic, uint base, uint insert, int offset, int bits) -> uint
87 UBitfieldExtract, /// (MetaArithmetic, uint value, int offset, int offset) -> uint 88 UBitfieldExtract, /// (MetaArithmetic, uint value, int offset, int offset) -> uint
88 UBitCount, /// (MetaArithmetic, uint) -> uint 89 UBitCount, /// (MetaArithmetic, uint) -> uint
90 UBitMSB, /// (MetaArithmetic, uint) -> uint
89 91
90 HAdd, /// (MetaArithmetic, f16vec2 a, f16vec2 b) -> f16vec2 92 HAdd, /// (MetaArithmetic, f16vec2 a, f16vec2 b) -> f16vec2
91 HMul, /// (MetaArithmetic, f16vec2 a, f16vec2 b) -> f16vec2 93 HMul, /// (MetaArithmetic, f16vec2 a, f16vec2 b) -> f16vec2