From 55e6786254d33e3501002bf7fbdd52552a0df32a Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Sun, 23 Dec 2018 01:18:33 -0300 Subject: shader_decode: Implement TLDS (untested) --- src/video_core/shader/glsl_decompiler.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/video_core/shader/glsl_decompiler.cpp') diff --git a/src/video_core/shader/glsl_decompiler.cpp b/src/video_core/shader/glsl_decompiler.cpp index a513c0c4b..b93ea9ec6 100644 --- a/src/video_core/shader/glsl_decompiler.cpp +++ b/src/video_core/shader/glsl_decompiler.cpp @@ -635,8 +635,6 @@ private: result_type)); } -#pragma optimize("", off) - std::string GenerateTexture(Operation operation, const std::string& func, std::string extra_cast(std::string) = nullptr) { constexpr std::array coord_constructors = {"float", "vec2", "vec3", "vec4"}; @@ -1100,6 +1098,32 @@ private: return "vec4(itof(int(" + tmp + ".y)), utof(uint(" + tmp + ".x)), 0, 0)"; } + std::string F4TexelFetch(Operation operation) { + constexpr std::array constructors = {"int", "ivec2", "ivec3", "ivec4"}; + const auto& meta = std::get(operation.GetMeta()); + const auto count = static_cast(operation.GetOperandsCount()); + + std::string expr = "texelFetch("; + expr += GetSampler(meta.sampler); + expr += ", "; + + expr += constructors[meta.coords_count - 1]; + expr += '('; + for (u32 i = 0; i < count; ++i) { + expr += VisitOperand(operation, i, Type::Int); + expr += ", "; + + if (i + 1 == meta.coords_count) { + expr += ')'; + } + if (i + 1 < count) { + expr += ", "; + } + } + expr += ')'; + return expr; + } + std::string Ipa(Operation operation) { const auto& attribute = operation[0]; // TODO(Rodrigo): Special IPA attribute interactions @@ -1314,6 +1338,7 @@ private: &F4TextureGather, &F4TextureQueryDimensions, &F4TextureQueryLod, + &F4TexelFetch, &Ipa, -- cgit v1.2.3