diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2018-12-22 05:20:57 +0100 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-01-15 21:54:52 +0100 |
commit | 03e088a4f44af1212da0c7c23f95293a6e129a35 (patch) | |
tree | 4c5b87cabf709f6ca3a839b7dff7c75b7ced2a4c /src/video_core/shader/glsl_decompiler.cpp | |
parent | shader_decode: Fixup FSET (diff) | |
download | yuzu-03e088a4f44af1212da0c7c23f95293a6e129a35.tar yuzu-03e088a4f44af1212da0c7c23f95293a6e129a35.tar.gz yuzu-03e088a4f44af1212da0c7c23f95293a6e129a35.tar.bz2 yuzu-03e088a4f44af1212da0c7c23f95293a6e129a35.tar.lz yuzu-03e088a4f44af1212da0c7c23f95293a6e129a35.tar.xz yuzu-03e088a4f44af1212da0c7c23f95293a6e129a35.tar.zst yuzu-03e088a4f44af1212da0c7c23f95293a6e129a35.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/shader/glsl_decompiler.cpp | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/video_core/shader/glsl_decompiler.cpp b/src/video_core/shader/glsl_decompiler.cpp index 3ca3fae6d..a513c0c4b 100644 --- a/src/video_core/shader/glsl_decompiler.cpp +++ b/src/video_core/shader/glsl_decompiler.cpp @@ -635,8 +635,10 @@ private: result_type)); } +#pragma optimize("", off) + std::string GenerateTexture(Operation operation, const std::string& func, - const std::string& extra_cast = "") { + std::string extra_cast(std::string) = nullptr) { constexpr std::array<const char*, 4> coord_constructors = {"float", "vec2", "vec3", "vec4"}; const auto& meta = std::get<MetaTexture>(operation.GetMeta()); @@ -651,15 +653,17 @@ private: expr += '('; for (u32 i = 0; i < count; ++i) { const bool is_extra = i >= meta.coords_count; - const bool do_cast = is_extra && !extra_cast.empty(); - if (do_cast) { - expr += extra_cast; - expr += '('; + const bool is_array = i == meta.array_index; + + std::string operand = Visit(operation[i]); + if (is_extra && extra_cast != nullptr) { + operand = extra_cast(operand); } - expr += Visit(operation[i]); - if (do_cast) { - expr += ')'; + if (is_array) { + ASSERT(!is_extra); + operand = "float(ftoi(" + operand + "))"; } + expr += operand; if (i + 1 == meta.coords_count) { expr += ')'; } @@ -1065,7 +1069,14 @@ private: } std::string F4TextureGather(Operation operation) { - return GenerateTexture(operation, "textureGather", "int"); + const bool is_shadow = std::get<MetaTexture>(operation.GetMeta()).sampler.IsShadow(); + if (is_shadow) { + return GenerateTexture(operation, "textureGather", + [](std::string ref_z) { return ref_z; }); + } else { + return GenerateTexture(operation, "textureGather", + [](std::string comp) { return "ftoi(" + comp + ')'; }); + } } std::string F4TextureQueryDimensions(Operation operation) { |