diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/engines/shader_bytecode.h | 24 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 48 |
2 files changed, 67 insertions, 5 deletions
diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.h index 6cfdb6e27..9176a8dbc 100644 --- a/src/video_core/engines/shader_bytecode.h +++ b/src/video_core/engines/shader_bytecode.h | |||
| @@ -536,6 +536,16 @@ union Instruction { | |||
| 536 | union { | 536 | union { |
| 537 | BitField<28, 1, u64> array; | 537 | BitField<28, 1, u64> array; |
| 538 | BitField<29, 2, TextureType> texture_type; | 538 | BitField<29, 2, TextureType> texture_type; |
| 539 | BitField<31, 4, u64> component_mask; | ||
| 540 | |||
| 541 | bool IsComponentEnabled(size_t component) const { | ||
| 542 | return ((1ull << component) & component_mask) != 0; | ||
| 543 | } | ||
| 544 | } tmml; | ||
| 545 | |||
| 546 | union { | ||
| 547 | BitField<28, 1, u64> array; | ||
| 548 | BitField<29, 2, TextureType> texture_type; | ||
| 539 | BitField<56, 2, u64> component; | 549 | BitField<56, 2, u64> component; |
| 540 | } tld4; | 550 | } tld4; |
| 541 | 551 | ||
| @@ -685,11 +695,13 @@ public: | |||
| 685 | LDG, // Load from global memory | 695 | LDG, // Load from global memory |
| 686 | STG, // Store in global memory | 696 | STG, // Store in global memory |
| 687 | TEX, | 697 | TEX, |
| 688 | TXQ, // Texture Query | 698 | TXQ, // Texture Query |
| 689 | TEXS, // Texture Fetch with scalar/non-vec4 source/destinations | 699 | TEXS, // Texture Fetch with scalar/non-vec4 source/destinations |
| 690 | TLDS, // Texture Load with scalar/non-vec4 source/destinations | 700 | TLDS, // Texture Load with scalar/non-vec4 source/destinations |
| 691 | TLD4, // Texture Load 4 | 701 | TLD4, // Texture Load 4 |
| 692 | TLD4S, // Texture Load 4 with scalar / non - vec4 source / destinations | 702 | TLD4S, // Texture Load 4 with scalar / non - vec4 source / destinations |
| 703 | TMML_B, // Texture Mip Map Level | ||
| 704 | TMML, // Texture Mip Map Level | ||
| 693 | EXIT, | 705 | EXIT, |
| 694 | IPA, | 706 | IPA, |
| 695 | FFMA_IMM, // Fused Multiply and Add | 707 | FFMA_IMM, // Fused Multiply and Add |
| @@ -914,6 +926,8 @@ private: | |||
| 914 | INST("1101101---------", Id::TLDS, Type::Memory, "TLDS"), | 926 | INST("1101101---------", Id::TLDS, Type::Memory, "TLDS"), |
| 915 | INST("110010----111---", Id::TLD4, Type::Memory, "TLD4"), | 927 | INST("110010----111---", Id::TLD4, Type::Memory, "TLD4"), |
| 916 | INST("1101111100------", Id::TLD4S, Type::Memory, "TLD4S"), | 928 | INST("1101111100------", Id::TLD4S, Type::Memory, "TLD4S"), |
| 929 | INST("110111110110----", Id::TMML_B, Type::Memory, "TMML_B"), | ||
| 930 | INST("1101111101011---", Id::TMML, Type::Memory, "TMML"), | ||
| 917 | INST("111000110000----", Id::EXIT, Type::Trivial, "EXIT"), | 931 | INST("111000110000----", Id::EXIT, Type::Trivial, "EXIT"), |
| 918 | INST("11100000--------", Id::IPA, Type::Trivial, "IPA"), | 932 | INST("11100000--------", Id::IPA, Type::Trivial, "IPA"), |
| 919 | INST("0011001-1-------", Id::FFMA_IMM, Type::Ffma, "FFMA_IMM"), | 933 | INST("0011001-1-------", Id::FFMA_IMM, Type::Ffma, "FFMA_IMM"), |
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 6d895bbb6..81a5dc95e 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -1940,6 +1940,54 @@ private: | |||
| 1940 | } | 1940 | } |
| 1941 | break; | 1941 | break; |
| 1942 | } | 1942 | } |
| 1943 | case OpCode::Id::TMML: { | ||
| 1944 | const std::string op_a = regs.GetRegisterAsFloat(instr.gpr8); | ||
| 1945 | const std::string op_b = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1); | ||
| 1946 | const bool is_array = instr.tmml.array != 0; | ||
| 1947 | auto texture_type = instr.tmml.texture_type.Value(); | ||
| 1948 | const std::string sampler = GetSampler(instr.sampler, texture_type, is_array); | ||
| 1949 | |||
| 1950 | // TODO: add coordinates for different samplers once other texture types are | ||
| 1951 | // implemented. | ||
| 1952 | std::string coord; | ||
| 1953 | switch (texture_type) { | ||
| 1954 | case Tegra::Shader::TextureType::Texture1D: { | ||
| 1955 | std::string x = regs.GetRegisterAsFloat(instr.gpr8); | ||
| 1956 | coord = "float coords = " + x + ';'; | ||
| 1957 | break; | ||
| 1958 | } | ||
| 1959 | case Tegra::Shader::TextureType::Texture2D: { | ||
| 1960 | std::string x = regs.GetRegisterAsFloat(instr.gpr8); | ||
| 1961 | std::string y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1); | ||
| 1962 | coord = "vec2 coords = vec2(" + x + ", " + y + ");"; | ||
| 1963 | break; | ||
| 1964 | } | ||
| 1965 | default: | ||
| 1966 | LOG_CRITICAL(HW_GPU, "Unhandled texture type {}", | ||
| 1967 | static_cast<u32>(texture_type)); | ||
| 1968 | UNREACHABLE(); | ||
| 1969 | |||
| 1970 | // Fallback to interpreting as a 2D texture for now | ||
| 1971 | std::string x = regs.GetRegisterAsFloat(instr.gpr8); | ||
| 1972 | std::string y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1); | ||
| 1973 | coord = "vec2 coords = vec2(" + x + ", " + y + ");"; | ||
| 1974 | texture_type = Tegra::Shader::TextureType::Texture2D; | ||
| 1975 | } | ||
| 1976 | // Add an extra scope and declare the texture coords inside to prevent | ||
| 1977 | // overwriting them in case they are used as outputs of the texs instruction. | ||
| 1978 | shader.AddLine('{'); | ||
| 1979 | ++shader.scope; | ||
| 1980 | shader.AddLine(coord); | ||
| 1981 | const std::string texture = "textureQueryLod(" + sampler + ", coords)"; | ||
| 1982 | const std::string tmp = "vec2 tmp = " + texture + "*vec2(256.0, 256.0);"; | ||
| 1983 | shader.AddLine(tmp); | ||
| 1984 | |||
| 1985 | regs.SetRegisterToInteger(instr.gpr0, true, 0, "int(tmp.y)", 1, 1); | ||
| 1986 | regs.SetRegisterToInteger(instr.gpr0.Value() + 1, false, 0, "uint(tmp.x)", 1, 1); | ||
| 1987 | --shader.scope; | ||
| 1988 | shader.AddLine('}'); | ||
| 1989 | break; | ||
| 1990 | } | ||
| 1943 | default: { | 1991 | default: { |
| 1944 | LOG_CRITICAL(HW_GPU, "Unhandled memory instruction: {}", opcode->GetName()); | 1992 | LOG_CRITICAL(HW_GPU, "Unhandled memory instruction: {}", opcode->GetName()); |
| 1945 | UNREACHABLE(); | 1993 | UNREACHABLE(); |