2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

Merge pull request #2864 from ReinUsesLisp/fix-clang-decompiler

gl_shader_decompiler: Fix clang build issues
This commit is contained in:
bunnei 2019-09-25 17:46:02 -04:00 committed by GitHub
commit da07373599
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -242,6 +242,26 @@ constexpr const char* GetTypeString(Type type) {
} }
} }
constexpr const char* GetImageTypeDeclaration(Tegra::Shader::ImageType image_type) {
switch (image_type) {
case Tegra::Shader::ImageType::Texture1D:
return "1D";
case Tegra::Shader::ImageType::TextureBuffer:
return "Buffer";
case Tegra::Shader::ImageType::Texture1DArray:
return "1DArray";
case Tegra::Shader::ImageType::Texture2D:
return "2D";
case Tegra::Shader::ImageType::Texture2DArray:
return "2DArray";
case Tegra::Shader::ImageType::Texture3D:
return "3D";
default:
UNREACHABLE();
return "1D";
}
}
/// Generates code to use for a swizzle operation. /// Generates code to use for a swizzle operation.
constexpr const char* GetSwizzle(u32 element) { constexpr const char* GetSwizzle(u32 element) {
constexpr std::array swizzle = {".x", ".y", ".z", ".w"}; constexpr std::array swizzle = {".x", ".y", ".z", ".w"};
@ -721,26 +741,6 @@ private:
void DeclareImages() { void DeclareImages() {
const auto& images{ir.GetImages()}; const auto& images{ir.GetImages()};
for (const auto& [offset, image] : images) { for (const auto& [offset, image] : images) {
const char* image_type = [&] {
switch (image.GetType()) {
case Tegra::Shader::ImageType::Texture1D:
return "1D";
case Tegra::Shader::ImageType::TextureBuffer:
return "Buffer";
case Tegra::Shader::ImageType::Texture1DArray:
return "1DArray";
case Tegra::Shader::ImageType::Texture2D:
return "2D";
case Tegra::Shader::ImageType::Texture2DArray:
return "2DArray";
case Tegra::Shader::ImageType::Texture3D:
return "3D";
default:
UNREACHABLE();
return "1D";
}
}();
std::string qualifier = "coherent volatile"; std::string qualifier = "coherent volatile";
if (image.IsRead() && !image.IsWritten()) { if (image.IsRead() && !image.IsWritten()) {
qualifier += " readonly"; qualifier += " readonly";
@ -748,13 +748,10 @@ private:
qualifier += " writeonly"; qualifier += " writeonly";
} }
std::string format; const char* format = image.IsAtomic() ? "r32ui, " : "";
if (image.IsAtomic()) { const char* type_declaration = GetImageTypeDeclaration(image.GetType());
format = "r32ui, ";
}
code.AddLine("layout ({}binding = IMAGE_BINDING_{}) {} uniform uimage{} {};", format, code.AddLine("layout ({}binding = IMAGE_BINDING_{}) {} uniform uimage{} {};", format,
image.GetIndex(), qualifier, image_type, GetImage(image)); image.GetIndex(), qualifier, type_declaration, GetImage(image));
} }
if (!images.empty()) { if (!images.empty()) {
code.AddNewLine(); code.AddNewLine();
@ -1494,6 +1491,8 @@ private:
case Tegra::Shader::HalfType::H1_H1: case Tegra::Shader::HalfType::H1_H1:
return {fmt::format("vec2({}[1])", operand.AsHalfFloat()), Type::HalfFloat}; return {fmt::format("vec2({}[1])", operand.AsHalfFloat()), Type::HalfFloat};
} }
UNREACHABLE();
return {"0", Type::Int};
} }
Expression HMergeF32(Operation operation) { Expression HMergeF32(Operation operation) {