summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp16
-rw-r--r--src/video_core/renderer_vulkan/vk_shader_decompiler.cpp18
-rw-r--r--src/video_core/shader/decode/other.cpp42
-rw-r--r--src/video_core/shader/shader_ir.h8
4 files changed, 69 insertions, 15 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index 713eded6d..d437afad1 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -1513,6 +1513,16 @@ private:
1513 return "uintBitsToFloat(config_pack[2])"; 1513 return "uintBitsToFloat(config_pack[2])";
1514 } 1514 }
1515 1515
1516 template <u32 element>
1517 std::string LocalInvocationId(Operation) {
1518 return "utof(gl_LocalInvocationID"s + GetSwizzle(element) + ')';
1519 }
1520
1521 template <u32 element>
1522 std::string WorkGroupId(Operation) {
1523 return "utof(gl_WorkGroupID"s + GetSwizzle(element) + ')';
1524 }
1525
1516 static constexpr OperationDecompilersArray operation_decompilers = { 1526 static constexpr OperationDecompilersArray operation_decompilers = {
1517 &GLSLDecompiler::Assign, 1527 &GLSLDecompiler::Assign,
1518 1528
@@ -1652,6 +1662,12 @@ private:
1652 &GLSLDecompiler::EndPrimitive, 1662 &GLSLDecompiler::EndPrimitive,
1653 1663
1654 &GLSLDecompiler::YNegate, 1664 &GLSLDecompiler::YNegate,
1665 &GLSLDecompiler::LocalInvocationId<0>,
1666 &GLSLDecompiler::LocalInvocationId<1>,
1667 &GLSLDecompiler::LocalInvocationId<2>,
1668 &GLSLDecompiler::WorkGroupId<0>,
1669 &GLSLDecompiler::WorkGroupId<1>,
1670 &GLSLDecompiler::WorkGroupId<2>,
1655 }; 1671 };
1656 1672
1657 std::string GetRegister(u32 index) const { 1673 std::string GetRegister(u32 index) const {
diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
index b61a6d170..a5b25aeff 100644
--- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
+++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
@@ -1035,6 +1035,18 @@ private:
1035 return {}; 1035 return {};
1036 } 1036 }
1037 1037
1038 template <u32 element>
1039 Id LocalInvocationId(Operation) {
1040 UNIMPLEMENTED();
1041 return {};
1042 }
1043
1044 template <u32 element>
1045 Id WorkGroupId(Operation) {
1046 UNIMPLEMENTED();
1047 return {};
1048 }
1049
1038 Id DeclareBuiltIn(spv::BuiltIn builtin, spv::StorageClass storage, Id type, 1050 Id DeclareBuiltIn(spv::BuiltIn builtin, spv::StorageClass storage, Id type,
1039 const std::string& name) { 1051 const std::string& name) {
1040 const Id id = OpVariable(type, storage); 1052 const Id id = OpVariable(type, storage);
@@ -1291,6 +1303,12 @@ private:
1291 &SPIRVDecompiler::EndPrimitive, 1303 &SPIRVDecompiler::EndPrimitive,
1292 1304
1293 &SPIRVDecompiler::YNegate, 1305 &SPIRVDecompiler::YNegate,
1306 &SPIRVDecompiler::LocalInvocationId<0>,
1307 &SPIRVDecompiler::LocalInvocationId<1>,
1308 &SPIRVDecompiler::LocalInvocationId<2>,
1309 &SPIRVDecompiler::WorkGroupId<0>,
1310 &SPIRVDecompiler::WorkGroupId<1>,
1311 &SPIRVDecompiler::WorkGroupId<2>,
1294 }; 1312 };
1295 1313
1296 const ShaderIR& ir; 1314 const ShaderIR& ir;
diff --git a/src/video_core/shader/decode/other.cpp b/src/video_core/shader/decode/other.cpp
index fa17c45b5..77c6f9951 100644
--- a/src/video_core/shader/decode/other.cpp
+++ b/src/video_core/shader/decode/other.cpp
@@ -13,6 +13,7 @@ using Tegra::Shader::ConditionCode;
13using Tegra::Shader::Instruction; 13using Tegra::Shader::Instruction;
14using Tegra::Shader::OpCode; 14using Tegra::Shader::OpCode;
15using Tegra::Shader::Register; 15using Tegra::Shader::Register;
16using Tegra::Shader::SystemVariable;
16 17
17u32 ShaderIR::DecodeOther(NodeBlock& bb, u32 pc) { 18u32 ShaderIR::DecodeOther(NodeBlock& bb, u32 pc) {
18 const Instruction instr = {program_code[pc]}; 19 const Instruction instr = {program_code[pc]};
@@ -58,20 +59,33 @@ u32 ShaderIR::DecodeOther(NodeBlock& bb, u32 pc) {
58 break; 59 break;
59 } 60 }
60 case OpCode::Id::MOV_SYS: { 61 case OpCode::Id::MOV_SYS: {
61 switch (instr.sys20) { 62 const Node value = [&]() {
62 case Tegra::Shader::SystemVariable::InvocationInfo: { 63 switch (instr.sys20) {
63 LOG_WARNING(HW_GPU, "MOV_SYS instruction with InvocationInfo is incomplete"); 64 case SystemVariable::Ydirection:
64 SetRegister(bb, instr.gpr0, Immediate(0u)); 65 return Operation(OperationCode::YNegate);
65 break; 66 case SystemVariable::InvocationInfo:
66 } 67 LOG_WARNING(HW_GPU, "MOV_SYS instruction with InvocationInfo is incomplete");
67 case Tegra::Shader::SystemVariable::Ydirection: { 68 return Immediate(0u);
68 // Config pack's third value is Y_NEGATE's state. 69 case SystemVariable::TidX:
69 SetRegister(bb, instr.gpr0, Operation(OperationCode::YNegate)); 70 return Operation(OperationCode::LocalInvocationIdX);
70 break; 71 case SystemVariable::TidY:
71 } 72 return Operation(OperationCode::LocalInvocationIdY);
72 default: 73 case SystemVariable::TidZ:
73 UNIMPLEMENTED_MSG("Unhandled system move: {}", static_cast<u32>(instr.sys20.Value())); 74 return Operation(OperationCode::LocalInvocationIdZ);
74 } 75 case SystemVariable::CtaIdX:
76 return Operation(OperationCode::WorkGroupIdX);
77 case SystemVariable::CtaIdY:
78 return Operation(OperationCode::WorkGroupIdY);
79 case SystemVariable::CtaIdZ:
80 return Operation(OperationCode::WorkGroupIdZ);
81 default:
82 UNIMPLEMENTED_MSG("Unhandled system move: {}",
83 static_cast<u32>(instr.sys20.Value()));
84 return Immediate(0u);
85 }
86 }();
87 SetRegister(bb, instr.gpr0, value);
88
75 break; 89 break;
76 } 90 }
77 case OpCode::Id::BRA: { 91 case OpCode::Id::BRA: {
diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h
index 0bf124252..f99300c1c 100644
--- a/src/video_core/shader/shader_ir.h
+++ b/src/video_core/shader/shader_ir.h
@@ -181,7 +181,13 @@ enum class OperationCode {
181 EmitVertex, /// () -> void 181 EmitVertex, /// () -> void
182 EndPrimitive, /// () -> void 182 EndPrimitive, /// () -> void
183 183
184 YNegate, /// () -> float 184 YNegate, /// () -> float
185 LocalInvocationIdX, /// () -> uint
186 LocalInvocationIdY, /// () -> uint
187 LocalInvocationIdZ, /// () -> uint
188 WorkGroupIdX, /// () -> uint
189 WorkGroupIdY, /// () -> uint
190 WorkGroupIdZ, /// () -> uint
185 191
186 Amount, 192 Amount,
187}; 193};