summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
diff options
context:
space:
mode:
authorFernandoS27 <fsahmkow27@gmail.com>2018-11-23 03:51:25 +0100
committerFernandoS27 <fsahmkow27@gmail.com>2018-11-24 03:46:50 +0100
commit7668ef51d628dd932c0aae270e5029b035ba5d99 (patch)
treeb209aebf3b579fb1aa8da1ef4b2b15388cfdea2c /src/video_core/renderer_opengl/gl_shader_decompiler.cpp
parentFix one encoding in TEX Instruction (diff)
downloadyuzu-7668ef51d628dd932c0aae270e5029b035ba5d99.tar
yuzu-7668ef51d628dd932c0aae270e5029b035ba5d99.tar.gz
yuzu-7668ef51d628dd932c0aae270e5029b035ba5d99.tar.bz2
yuzu-7668ef51d628dd932c0aae270e5029b035ba5d99.tar.lz
yuzu-7668ef51d628dd932c0aae270e5029b035ba5d99.tar.xz
yuzu-7668ef51d628dd932c0aae270e5029b035ba5d99.tar.zst
yuzu-7668ef51d628dd932c0aae270e5029b035ba5d99.zip
Diffstat (limited to 'src/video_core/renderer_opengl/gl_shader_decompiler.cpp')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp70
1 files changed, 48 insertions, 22 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index 160329f19..3a7e82beb 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -2676,14 +2676,29 @@ private:
const bool depth_compare =
instr.texs.UsesMiscMode(Tegra::Shader::TextureMiscMode::DC);
u32 num_coordinates = TextureCoordinates(texture_type);
- if (depth_compare)
- num_coordinates += 1;
+ auto process_mode = instr.texs.GetTextureProcessMode();
+ std::string lod_value;
+ u32 lod_offset = 0;
+ if (process_mode == Tegra::Shader::TextureProcessMode::LL) {
+ if (num_coordinates > 2) {
+ lod_value = regs.GetRegisterAsFloat(instr.gpr20.Value() + 1);
+ lod_offset = 2;
+ } else {
+ lod_value = regs.GetRegisterAsFloat(instr.gpr20);
+ lod_offset = 1;
+ }
+ }
// Scope to avoid variable name overlaps.
shader.AddLine('{');
++shader.scope;
switch (num_coordinates) {
+ case 1: {
+ const std::string x = regs.GetRegisterAsFloat(instr.gpr8);
+ coord = "float coords = " + x + ';';
+ break;
+ }
case 2: {
if (is_array) {
const std::string index = regs.GetRegisterAsInteger(instr.gpr8);
@@ -2691,26 +2706,37 @@ private:
const std::string y = regs.GetRegisterAsFloat(instr.gpr20);
shader.AddLine("vec3 coords = vec3(" + x + ", " + y + ", " + index + ");");
} else {
- const std::string x = regs.GetRegisterAsFloat(instr.gpr8);
- const std::string y = regs.GetRegisterAsFloat(instr.gpr20);
- shader.AddLine("vec2 coords = vec2(" + x + ", " + y + ");");
+ if (lod_offset != 0) {
+ if (depth_compare) {
+ const std::string x = regs.GetRegisterAsFloat(instr.gpr8);
+ const std::string y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1);
+ const std::string z = regs.GetRegisterAsFloat(instr.gpr20.Value() + lod_offset);
+ coord = "vec3 coords = vec3(" + x + ", " + y + ", " + z + ");";
+ } else {
+ const std::string x = regs.GetRegisterAsFloat(instr.gpr8);
+ const std::string y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1);
+ coord = "vec2 coords = vec2(" + x + ", " + y + ");";
+ }
+ } else {
+ if (depth_compare) {
+ const std::string x = regs.GetRegisterAsFloat(instr.gpr8);
+ const std::string y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1);
+ const std::string z = regs.GetRegisterAsFloat(instr.gpr20);
+ coord = "vec3 coords = vec3(" + x + ", " + y + ", " + z + ");";
+ } else {
+ const std::string x = regs.GetRegisterAsFloat(instr.gpr8);
+ const std::string y = regs.GetRegisterAsFloat(instr.gpr20);
+ coord = "vec2 coords = vec2(" + x + ", " + y + ");";
+ }
+ }
}
break;
}
case 3: {
- if (is_array) {
- const std::string index = regs.GetRegisterAsInteger(instr.gpr8);
- const std::string x = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1);
- const std::string y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 2);
- const std::string z = regs.GetRegisterAsFloat(instr.gpr20);
- shader.AddLine("vec4 coords = vec4(" + x + ", " + y + ", " + z + ", " +
- index + ");");
- } else {
- const std::string x = regs.GetRegisterAsFloat(instr.gpr8);
- const std::string y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1);
- const std::string z = regs.GetRegisterAsFloat(instr.gpr20);
- shader.AddLine("vec3 coords = vec3(" + x + ", " + y + ", " + z + ");");
- }
+ const std::string x = regs.GetRegisterAsFloat(instr.gpr8);
+ const std::string y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1);
+ const std::string z = regs.GetRegisterAsFloat(instr.gpr20);
+ coord = "vec3 coords = vec3(" + x + ", " + y + ", " + z + ");";
break;
}
default:
@@ -2727,22 +2753,22 @@ private:
const std::string sampler =
GetSampler(instr.sampler, texture_type, is_array, depth_compare);
std::string texture;
- switch (instr.texs.GetTextureProcessMode()) {
+ switch (process_mode) {
case Tegra::Shader::TextureProcessMode::None: {
texture = "texture(" + sampler + ", coords)";
break;
}
case Tegra::Shader::TextureProcessMode::LZ: {
if (depth_compare && is_array) {
- texture = "texture(" + sampler + ", coords)";
+ // Since we got an OpenGL limitation, we set bias very high to enforce mipmap 0
+ texture = "texture(" + sampler + ", coords, 1000.0)";
} else {
texture = "textureLod(" + sampler + ", coords, 0.0)";
}
break;
}
case Tegra::Shader::TextureProcessMode::LL: {
- const std::string op_c = regs.GetRegisterAsFloat(instr.gpr20.Value() + 1);
- texture = "textureLod(" + sampler + ", coords, " + op_c + ')';
+ texture = "textureLod(" + sampler + ", coords, " + lod_value + ')';
break;
}
default: {