mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-05-13 23:35:06 +12:00
Shader compiler: Simplify generated code for reading and faster compilation
This commit is contained in:
parent
d9f4f3736f
commit
2fc09223aa
1 changed files with 10 additions and 2 deletions
|
@ -163,6 +163,12 @@ std::string ShaderDecompiler::getDest(u32 dest) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ShaderDecompiler::getSwizzlePattern(u32 swizzle) const {
|
std::string ShaderDecompiler::getSwizzlePattern(u32 swizzle) const {
|
||||||
|
// If the swizzle field is this value then the swizzle pattern is .xyzw so we don't need a shuffle
|
||||||
|
static constexpr uint noSwizzle = 0x1B;
|
||||||
|
if (swizzle == noSwizzle) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
static constexpr std::array<char, 4> names = {'x', 'y', 'z', 'w'};
|
static constexpr std::array<char, 4> names = {'x', 'y', 'z', 'w'};
|
||||||
std::string ret(". ");
|
std::string ret(". ");
|
||||||
|
|
||||||
|
@ -211,8 +217,10 @@ void ShaderDecompiler::setDest(u32 operandDescriptor, const std::string& dest, c
|
||||||
decompiledShader += dest + destSwizzle + " = ";
|
decompiledShader += dest + destSwizzle + " = ";
|
||||||
if (writtenLaneCount == 1) {
|
if (writtenLaneCount == 1) {
|
||||||
decompiledShader += "float(" + value + ");\n";
|
decompiledShader += "float(" + value + ");\n";
|
||||||
} else {
|
} else if (writtenLaneCount <= 3) { // We don't need to cast for vec4, as we guarantee the rhs will be a vec4
|
||||||
decompiledShader += "vec" + std::to_string(writtenLaneCount) + "(" + value + ");\n";
|
decompiledShader += fmt::format("vec{}({});\n", writtenLaneCount, value);
|
||||||
|
} else if (writtenLaneCount == 4) {
|
||||||
|
decompiledShader += fmt::format("{};\n", value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue