diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/engines/shader_bytecode.h | 16 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 39 |
2 files changed, 29 insertions, 26 deletions
diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.h index 4eb507325..7a74771ce 100644 --- a/src/video_core/engines/shader_bytecode.h +++ b/src/video_core/engines/shader_bytecode.h | |||
| @@ -109,11 +109,6 @@ union Sampler { | |||
| 109 | u64 value{}; | 109 | u64 value{}; |
| 110 | }; | 110 | }; |
| 111 | 111 | ||
| 112 | union Uniform { | ||
| 113 | BitField<20, 14, u64> offset; | ||
| 114 | BitField<34, 5, u64> index; | ||
| 115 | }; | ||
| 116 | |||
| 117 | } // namespace Shader | 112 | } // namespace Shader |
| 118 | } // namespace Tegra | 113 | } // namespace Tegra |
| 119 | 114 | ||
| @@ -354,12 +349,21 @@ union Instruction { | |||
| 354 | } | 349 | } |
| 355 | } bra; | 350 | } bra; |
| 356 | 351 | ||
| 352 | union { | ||
| 353 | BitField<20, 14, u64> offset; | ||
| 354 | BitField<34, 5, u64> index; | ||
| 355 | } cbuf34; | ||
| 356 | |||
| 357 | union { | ||
| 358 | BitField<20, 16, s64> offset; | ||
| 359 | BitField<36, 5, u64> index; | ||
| 360 | } cbuf36; | ||
| 361 | |||
| 357 | BitField<61, 1, u64> is_b_imm; | 362 | BitField<61, 1, u64> is_b_imm; |
| 358 | BitField<60, 1, u64> is_b_gpr; | 363 | BitField<60, 1, u64> is_b_gpr; |
| 359 | BitField<59, 1, u64> is_c_gpr; | 364 | BitField<59, 1, u64> is_c_gpr; |
| 360 | 365 | ||
| 361 | Attribute attribute; | 366 | Attribute attribute; |
| 362 | Uniform uniform; | ||
| 363 | Sampler sampler; | 367 | Sampler sampler; |
| 364 | 368 | ||
| 365 | u64 value; | 369 | u64 value; |
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 7a59ecccf..94c4858ea 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -20,7 +20,6 @@ using Tegra::Shader::OpCode; | |||
| 20 | using Tegra::Shader::Register; | 20 | using Tegra::Shader::Register; |
| 21 | using Tegra::Shader::Sampler; | 21 | using Tegra::Shader::Sampler; |
| 22 | using Tegra::Shader::SubOp; | 22 | using Tegra::Shader::SubOp; |
| 23 | using Tegra::Shader::Uniform; | ||
| 24 | 23 | ||
| 25 | constexpr u32 PROGRAM_END = MAX_PROGRAM_CODE_LENGTH; | 24 | constexpr u32 PROGRAM_END = MAX_PROGRAM_CODE_LENGTH; |
| 26 | 25 | ||
| @@ -365,11 +364,9 @@ public: | |||
| 365 | } | 364 | } |
| 366 | 365 | ||
| 367 | /// Generates code representing a uniform (C buffer) register, interpreted as the input type. | 366 | /// Generates code representing a uniform (C buffer) register, interpreted as the input type. |
| 368 | std::string GetUniform(const Uniform& uniform, GLSLRegister::Type type) { | 367 | std::string GetUniform(u64 index, u64 offset, GLSLRegister::Type type) { |
| 369 | declr_const_buffers[uniform.index].MarkAsUsed(static_cast<unsigned>(uniform.index), | 368 | declr_const_buffers[index].MarkAsUsed(index, offset, stage); |
| 370 | static_cast<unsigned>(uniform.offset), stage); | 369 | std::string value = 'c' + std::to_string(index) + '[' + std::to_string(offset) + ']'; |
| 371 | std::string value = | ||
| 372 | 'c' + std::to_string(uniform.index) + '[' + std::to_string(uniform.offset) + ']'; | ||
| 373 | 370 | ||
| 374 | if (type == GLSLRegister::Type::Float) { | 371 | if (type == GLSLRegister::Type::Float) { |
| 375 | return value; | 372 | return value; |
| @@ -380,12 +377,6 @@ public: | |||
| 380 | } | 377 | } |
| 381 | } | 378 | } |
| 382 | 379 | ||
| 383 | /// Generates code representing a uniform (C buffer) register, interpreted as the type of the | ||
| 384 | /// destination register. | ||
| 385 | std::string GetUniform(const Uniform& uniform, const Register& dest_reg) { | ||
| 386 | return GetUniform(uniform, regs[dest_reg].GetActiveType()); | ||
| 387 | } | ||
| 388 | |||
| 389 | /// Add declarations for registers | 380 | /// Add declarations for registers |
| 390 | void GenerateDeclarations() { | 381 | void GenerateDeclarations() { |
| 391 | for (const auto& reg : regs) { | 382 | for (const auto& reg : regs) { |
| @@ -747,7 +738,8 @@ private: | |||
| 747 | if (instr.is_b_gpr) { | 738 | if (instr.is_b_gpr) { |
| 748 | op_b += regs.GetRegisterAsFloat(instr.gpr20); | 739 | op_b += regs.GetRegisterAsFloat(instr.gpr20); |
| 749 | } else { | 740 | } else { |
| 750 | op_b += regs.GetUniform(instr.uniform, instr.gpr0); | 741 | op_b += regs.GetUniform(instr.cbuf34.index, instr.cbuf34.offset, |
| 742 | GLSLRegister::Type::Float); | ||
| 751 | } | 743 | } |
| 752 | } | 744 | } |
| 753 | 745 | ||
| @@ -904,7 +896,8 @@ private: | |||
| 904 | if (instr.is_b_gpr) { | 896 | if (instr.is_b_gpr) { |
| 905 | op_b += regs.GetRegisterAsInteger(instr.gpr20); | 897 | op_b += regs.GetRegisterAsInteger(instr.gpr20); |
| 906 | } else { | 898 | } else { |
| 907 | op_b += regs.GetUniform(instr.uniform, GLSLRegister::Type::Integer); | 899 | op_b += regs.GetUniform(instr.cbuf34.index, instr.cbuf34.offset, |
| 900 | GLSLRegister::Type::Integer); | ||
| 908 | } | 901 | } |
| 909 | } | 902 | } |
| 910 | 903 | ||
| @@ -936,7 +929,8 @@ private: | |||
| 936 | if (instr.is_b_gpr) { | 929 | if (instr.is_b_gpr) { |
| 937 | op_b += regs.GetRegisterAsInteger(instr.gpr20); | 930 | op_b += regs.GetRegisterAsInteger(instr.gpr20); |
| 938 | } else { | 931 | } else { |
| 939 | op_b += regs.GetUniform(instr.uniform, GLSLRegister::Type::Integer); | 932 | op_b += regs.GetUniform(instr.cbuf34.index, instr.cbuf34.offset, |
| 933 | GLSLRegister::Type::Integer); | ||
| 940 | } | 934 | } |
| 941 | } | 935 | } |
| 942 | 936 | ||
| @@ -953,7 +947,8 @@ private: | |||
| 953 | 947 | ||
| 954 | switch (opcode->GetId()) { | 948 | switch (opcode->GetId()) { |
| 955 | case OpCode::Id::FFMA_CR: { | 949 | case OpCode::Id::FFMA_CR: { |
| 956 | op_b += regs.GetUniform(instr.uniform, instr.gpr0); | 950 | op_b += regs.GetUniform(instr.cbuf34.index, instr.cbuf34.offset, |
| 951 | GLSLRegister::Type::Float); | ||
| 957 | op_c += regs.GetRegisterAsFloat(instr.gpr39); | 952 | op_c += regs.GetRegisterAsFloat(instr.gpr39); |
| 958 | break; | 953 | break; |
| 959 | } | 954 | } |
| @@ -964,7 +959,8 @@ private: | |||
| 964 | } | 959 | } |
| 965 | case OpCode::Id::FFMA_RC: { | 960 | case OpCode::Id::FFMA_RC: { |
| 966 | op_b += regs.GetRegisterAsFloat(instr.gpr39); | 961 | op_b += regs.GetRegisterAsFloat(instr.gpr39); |
| 967 | op_c += regs.GetUniform(instr.uniform, instr.gpr0); | 962 | op_c += regs.GetUniform(instr.cbuf34.index, instr.cbuf34.offset, |
| 963 | GLSLRegister::Type::Float); | ||
| 968 | break; | 964 | break; |
| 969 | } | 965 | } |
| 970 | case OpCode::Id::FFMA_IMM: { | 966 | case OpCode::Id::FFMA_IMM: { |
| @@ -1175,7 +1171,8 @@ private: | |||
| 1175 | if (instr.is_b_gpr) { | 1171 | if (instr.is_b_gpr) { |
| 1176 | op_b += regs.GetRegisterAsFloat(instr.gpr20); | 1172 | op_b += regs.GetRegisterAsFloat(instr.gpr20); |
| 1177 | } else { | 1173 | } else { |
| 1178 | op_b += regs.GetUniform(instr.uniform, GLSLRegister::Type::Float); | 1174 | op_b += regs.GetUniform(instr.cbuf34.index, instr.cbuf34.offset, |
| 1175 | GLSLRegister::Type::Float); | ||
| 1179 | } | 1176 | } |
| 1180 | } | 1177 | } |
| 1181 | 1178 | ||
| @@ -1216,7 +1213,8 @@ private: | |||
| 1216 | if (instr.is_b_gpr) { | 1213 | if (instr.is_b_gpr) { |
| 1217 | op_b += regs.GetRegisterAsInteger(instr.gpr20, 0, instr.isetp.is_signed); | 1214 | op_b += regs.GetRegisterAsInteger(instr.gpr20, 0, instr.isetp.is_signed); |
| 1218 | } else { | 1215 | } else { |
| 1219 | op_b += regs.GetUniform(instr.uniform, GLSLRegister::Type::Integer); | 1216 | op_b += regs.GetUniform(instr.cbuf34.index, instr.cbuf34.offset, |
| 1217 | GLSLRegister::Type::Integer); | ||
| 1220 | } | 1218 | } |
| 1221 | 1219 | ||
| 1222 | using Tegra::Shader::Pred; | 1220 | using Tegra::Shader::Pred; |
| @@ -1262,7 +1260,8 @@ private: | |||
| 1262 | if (instr.is_b_gpr) { | 1260 | if (instr.is_b_gpr) { |
| 1263 | op_b += regs.GetRegisterAsFloat(instr.gpr20); | 1261 | op_b += regs.GetRegisterAsFloat(instr.gpr20); |
| 1264 | } else { | 1262 | } else { |
| 1265 | op_b += regs.GetUniform(instr.uniform, GLSLRegister::Type::Float); | 1263 | op_b += regs.GetUniform(instr.cbuf34.index, instr.cbuf34.offset, |
| 1264 | GLSLRegister::Type::Float); | ||
| 1266 | } | 1265 | } |
| 1267 | } | 1266 | } |
| 1268 | 1267 | ||