gl_shader_decompiler: Make GetSwizzle constexpr
This commit is contained in:
parent
0adb54abc1
commit
ada79fa8ad
@ -31,6 +31,8 @@ using Tegra::Shader::IpaInterpMode;
|
|||||||
using Tegra::Shader::IpaMode;
|
using Tegra::Shader::IpaMode;
|
||||||
using Tegra::Shader::IpaSampleMode;
|
using Tegra::Shader::IpaSampleMode;
|
||||||
using Tegra::Shader::Register;
|
using Tegra::Shader::Register;
|
||||||
|
|
||||||
|
using namespace std::string_literals;
|
||||||
using namespace VideoCommon::Shader;
|
using namespace VideoCommon::Shader;
|
||||||
|
|
||||||
using Maxwell = Tegra::Engines::Maxwell3D::Regs;
|
using Maxwell = Tegra::Engines::Maxwell3D::Regs;
|
||||||
@ -96,11 +98,9 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Generates code to use for a swizzle operation.
|
/// Generates code to use for a swizzle operation.
|
||||||
std::string GetSwizzle(u32 elem) {
|
constexpr const char* GetSwizzle(u32 element) {
|
||||||
ASSERT(elem <= 3);
|
constexpr std::array<const char*, 4> swizzle = {".x", ".y", ".z", ".w"};
|
||||||
std::string swizzle = ".";
|
return swizzle.at(element);
|
||||||
swizzle += "xyzw"[elem];
|
|
||||||
return swizzle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Translate topology
|
/// Translate topology
|
||||||
@ -622,7 +622,7 @@ private:
|
|||||||
if (stage != ShaderStage::Fragment) {
|
if (stage != ShaderStage::Fragment) {
|
||||||
return GeometryPass("position") + GetSwizzle(element);
|
return GeometryPass("position") + GetSwizzle(element);
|
||||||
} else {
|
} else {
|
||||||
return element == 3 ? "1.0f" : "gl_FragCoord" + GetSwizzle(element);
|
return element == 3 ? "1.0f" : ("gl_FragCoord"s + GetSwizzle(element));
|
||||||
}
|
}
|
||||||
case Attribute::Index::PointCoord:
|
case Attribute::Index::PointCoord:
|
||||||
switch (element) {
|
switch (element) {
|
||||||
@ -909,7 +909,7 @@ private:
|
|||||||
target = [&]() -> std::string {
|
target = [&]() -> std::string {
|
||||||
switch (const auto attribute = abuf->GetIndex(); abuf->GetIndex()) {
|
switch (const auto attribute = abuf->GetIndex(); abuf->GetIndex()) {
|
||||||
case Attribute::Index::Position:
|
case Attribute::Index::Position:
|
||||||
return "position" + GetSwizzle(abuf->GetElement());
|
return "position"s + GetSwizzle(abuf->GetElement());
|
||||||
case Attribute::Index::PointSize:
|
case Attribute::Index::PointSize:
|
||||||
return "gl_PointSize";
|
return "gl_PointSize";
|
||||||
case Attribute::Index::ClipDistances0123:
|
case Attribute::Index::ClipDistances0123:
|
||||||
|
Loading…
Reference in New Issue
Block a user