mirror of
https://git.h3cjp.net/H3cJP/yuzu.git
synced 2024-11-14 13:12:50 +00:00
Fix TEXS Instruction encodings
This commit is contained in:
parent
9c2127d5eb
commit
7668ef51d6
|
@ -2676,14 +2676,29 @@ private:
|
||||||
const bool depth_compare =
|
const bool depth_compare =
|
||||||
instr.texs.UsesMiscMode(Tegra::Shader::TextureMiscMode::DC);
|
instr.texs.UsesMiscMode(Tegra::Shader::TextureMiscMode::DC);
|
||||||
u32 num_coordinates = TextureCoordinates(texture_type);
|
u32 num_coordinates = TextureCoordinates(texture_type);
|
||||||
if (depth_compare)
|
auto process_mode = instr.texs.GetTextureProcessMode();
|
||||||
num_coordinates += 1;
|
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.
|
// Scope to avoid variable name overlaps.
|
||||||
shader.AddLine('{');
|
shader.AddLine('{');
|
||||||
++shader.scope;
|
++shader.scope;
|
||||||
|
|
||||||
switch (num_coordinates) {
|
switch (num_coordinates) {
|
||||||
|
case 1: {
|
||||||
|
const std::string x = regs.GetRegisterAsFloat(instr.gpr8);
|
||||||
|
coord = "float coords = " + x + ';';
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
if (is_array) {
|
if (is_array) {
|
||||||
const std::string index = regs.GetRegisterAsInteger(instr.gpr8);
|
const std::string index = regs.GetRegisterAsInteger(instr.gpr8);
|
||||||
|
@ -2691,26 +2706,37 @@ private:
|
||||||
const std::string y = regs.GetRegisterAsFloat(instr.gpr20);
|
const std::string y = regs.GetRegisterAsFloat(instr.gpr20);
|
||||||
shader.AddLine("vec3 coords = vec3(" + x + ", " + y + ", " + index + ");");
|
shader.AddLine("vec3 coords = vec3(" + x + ", " + y + ", " + index + ");");
|
||||||
} else {
|
} else {
|
||||||
const std::string x = regs.GetRegisterAsFloat(instr.gpr8);
|
if (lod_offset != 0) {
|
||||||
const std::string y = regs.GetRegisterAsFloat(instr.gpr20);
|
if (depth_compare) {
|
||||||
shader.AddLine("vec2 coords = vec2(" + x + ", " + y + ");");
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case 3: {
|
case 3: {
|
||||||
if (is_array) {
|
const std::string x = regs.GetRegisterAsFloat(instr.gpr8);
|
||||||
const std::string index = regs.GetRegisterAsInteger(instr.gpr8);
|
const std::string y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1);
|
||||||
const std::string x = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1);
|
const std::string z = regs.GetRegisterAsFloat(instr.gpr20);
|
||||||
const std::string y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 2);
|
coord = "vec3 coords = vec3(" + x + ", " + y + ", " + z + ");";
|
||||||
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 + ");");
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -2727,22 +2753,22 @@ private:
|
||||||
const std::string sampler =
|
const std::string sampler =
|
||||||
GetSampler(instr.sampler, texture_type, is_array, depth_compare);
|
GetSampler(instr.sampler, texture_type, is_array, depth_compare);
|
||||||
std::string texture;
|
std::string texture;
|
||||||
switch (instr.texs.GetTextureProcessMode()) {
|
switch (process_mode) {
|
||||||
case Tegra::Shader::TextureProcessMode::None: {
|
case Tegra::Shader::TextureProcessMode::None: {
|
||||||
texture = "texture(" + sampler + ", coords)";
|
texture = "texture(" + sampler + ", coords)";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Tegra::Shader::TextureProcessMode::LZ: {
|
case Tegra::Shader::TextureProcessMode::LZ: {
|
||||||
if (depth_compare && is_array) {
|
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 {
|
} else {
|
||||||
texture = "textureLod(" + sampler + ", coords, 0.0)";
|
texture = "textureLod(" + sampler + ", coords, 0.0)";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Tegra::Shader::TextureProcessMode::LL: {
|
case Tegra::Shader::TextureProcessMode::LL: {
|
||||||
const std::string op_c = regs.GetRegisterAsFloat(instr.gpr20.Value() + 1);
|
texture = "textureLod(" + sampler + ", coords, " + lod_value + ')';
|
||||||
texture = "textureLod(" + sampler + ", coords, " + op_c + ')';
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
|
Loading…
Reference in a new issue