diff options
| author | 2019-01-07 20:31:47 -0300 | |
|---|---|---|
| committer | 2019-01-15 17:54:53 -0300 | |
| commit | 51de4e00a60da8cd60d18be23b991acad62cb1ea (patch) | |
| tree | 1fd1fa716a91e61c9690f68f6bf17281ffa1b236 | |
| parent | shader_decode: Fixup XMAD (diff) | |
| download | yuzu-51de4e00a60da8cd60d18be23b991acad62cb1ea.tar.gz yuzu-51de4e00a60da8cd60d18be23b991acad62cb1ea.tar.xz yuzu-51de4e00a60da8cd60d18be23b991acad62cb1ea.zip | |
gl_shader_decompiler: Inline textureGather component
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 31 |
1 files changed, 16 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 37c4856d2..e5e87221b 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -689,7 +689,7 @@ private: | |||
| 689 | } | 689 | } |
| 690 | 690 | ||
| 691 | std::string GenerateTexture(Operation operation, const std::string& func, | 691 | std::string GenerateTexture(Operation operation, const std::string& func, |
| 692 | std::string extra_cast(std::string) = nullptr) { | 692 | bool is_extra_int = false) { |
| 693 | constexpr std::array<const char*, 4> coord_constructors = {"float", "vec2", "vec3", "vec4"}; | 693 | constexpr std::array<const char*, 4> coord_constructors = {"float", "vec2", "vec3", "vec4"}; |
| 694 | 694 | ||
| 695 | const auto& meta = std::get<MetaTexture>(operation.GetMeta()); | 695 | const auto& meta = std::get<MetaTexture>(operation.GetMeta()); |
| @@ -706,15 +706,24 @@ private: | |||
| 706 | const bool is_extra = i >= meta.coords_count; | 706 | const bool is_extra = i >= meta.coords_count; |
| 707 | const bool is_array = i == meta.array_index; | 707 | const bool is_array = i == meta.array_index; |
| 708 | 708 | ||
| 709 | std::string operand = Visit(operation[i]); | 709 | std::string operand = [&]() { |
| 710 | if (is_extra && extra_cast != nullptr) { | 710 | if (is_extra && is_extra_int) { |
| 711 | operand = extra_cast(operand); | 711 | if (const auto immediate = std::get_if<ImmediateNode>(operation[i])) { |
| 712 | } | 712 | return std::to_string(static_cast<s32>(immediate->GetValue())); |
| 713 | } else { | ||
| 714 | return "ftoi(" + Visit(operation[i]) + ')'; | ||
| 715 | } | ||
| 716 | } else { | ||
| 717 | return Visit(operation[i]); | ||
| 718 | } | ||
| 719 | }(); | ||
| 713 | if (is_array) { | 720 | if (is_array) { |
| 714 | ASSERT(!is_extra); | 721 | ASSERT(!is_extra); |
| 715 | operand = "float(ftoi(" + operand + "))"; | 722 | operand = "float(ftoi(" + operand + "))"; |
| 716 | } | 723 | } |
| 724 | |||
| 717 | expr += operand; | 725 | expr += operand; |
| 726 | |||
| 718 | if (i + 1 == meta.coords_count) { | 727 | if (i + 1 == meta.coords_count) { |
| 719 | expr += ')'; | 728 | expr += ')'; |
| 720 | } | 729 | } |
| @@ -1118,16 +1127,8 @@ private: | |||
| 1118 | 1127 | ||
| 1119 | std::string F4TextureGather(Operation operation) { | 1128 | std::string F4TextureGather(Operation operation) { |
| 1120 | const auto meta = std::get<MetaTexture>(operation.GetMeta()); | 1129 | const auto meta = std::get<MetaTexture>(operation.GetMeta()); |
| 1121 | 1130 | return GenerateTexture(operation, "textureGather", !meta.sampler.IsShadow()) + | |
| 1122 | std::string expr; | 1131 | GetSwizzle(meta.element); |
| 1123 | if (meta.sampler.IsShadow()) { | ||
| 1124 | expr = GenerateTexture(operation, "textureGather", | ||
| 1125 | [](std::string ref_z) { return ref_z; }); | ||
| 1126 | } else { | ||
| 1127 | expr = GenerateTexture(operation, "textureGather", | ||
| 1128 | [](std::string comp) { return "ftoi(" + comp + ')'; }); | ||
| 1129 | } | ||
| 1130 | return expr + GetSwizzle(meta.element); | ||
| 1131 | } | 1132 | } |
| 1132 | 1133 | ||
| 1133 | std::string F4TextureQueryDimensions(Operation operation) { | 1134 | std::string F4TextureQueryDimensions(Operation operation) { |