summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2019-01-08 00:31:47 +0100
committerReinUsesLisp <reinuseslisp@airmail.cc>2019-01-15 21:54:53 +0100
commit51de4e00a60da8cd60d18be23b991acad62cb1ea (patch)
tree1fd1fa716a91e61c9690f68f6bf17281ffa1b236
parentshader_decode: Fixup XMAD (diff)
downloadyuzu-51de4e00a60da8cd60d18be23b991acad62cb1ea.tar
yuzu-51de4e00a60da8cd60d18be23b991acad62cb1ea.tar.gz
yuzu-51de4e00a60da8cd60d18be23b991acad62cb1ea.tar.bz2
yuzu-51de4e00a60da8cd60d18be23b991acad62cb1ea.tar.lz
yuzu-51de4e00a60da8cd60d18be23b991acad62cb1ea.tar.xz
yuzu-51de4e00a60da8cd60d18be23b991acad62cb1ea.tar.zst
yuzu-51de4e00a60da8cd60d18be23b991acad62cb1ea.zip
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp31
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:
}
std::string GenerateTexture(Operation operation, const std::string& func,
- std::string extra_cast(std::string) = nullptr) {
+ bool is_extra_int = false) {
constexpr std::array<const char*, 4> coord_constructors = {"float", "vec2", "vec3", "vec4"};
const auto& meta = std::get<MetaTexture>(operation.GetMeta());
@@ -706,15 +706,24 @@ private:
const bool is_extra = i >= meta.coords_count;
const bool is_array = i == meta.array_index;
- std::string operand = Visit(operation[i]);
- if (is_extra && extra_cast != nullptr) {
- operand = extra_cast(operand);
- }
+ std::string operand = [&]() {
+ if (is_extra && is_extra_int) {
+ if (const auto immediate = std::get_if<ImmediateNode>(operation[i])) {
+ return std::to_string(static_cast<s32>(immediate->GetValue()));
+ } else {
+ return "ftoi(" + Visit(operation[i]) + ')';
+ }
+ } else {
+ return Visit(operation[i]);
+ }
+ }();
if (is_array) {
ASSERT(!is_extra);
operand = "float(ftoi(" + operand + "))";
}
+
expr += operand;
+
if (i + 1 == meta.coords_count) {
expr += ')';
}
@@ -1118,16 +1127,8 @@ private:
std::string F4TextureGather(Operation operation) {
const auto meta = std::get<MetaTexture>(operation.GetMeta());
-
- std::string expr;
- if (meta.sampler.IsShadow()) {
- expr = GenerateTexture(operation, "textureGather",
- [](std::string ref_z) { return ref_z; });
- } else {
- expr = GenerateTexture(operation, "textureGather",
- [](std::string comp) { return "ftoi(" + comp + ')'; });
- }
- return expr + GetSwizzle(meta.element);
+ return GenerateTexture(operation, "textureGather", !meta.sampler.IsShadow()) +
+ GetSwizzle(meta.element);
}
std::string F4TextureQueryDimensions(Operation operation) {