2021-05-05 05:19:08 +00:00
|
|
|
// Copyright 2021 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
2021-05-07 09:31:30 +00:00
|
|
|
#include <utility>
|
2021-05-19 00:04:09 +00:00
|
|
|
#include <vector>
|
2021-05-07 09:31:30 +00:00
|
|
|
|
|
|
|
#include <fmt/format.h>
|
2021-05-05 05:19:08 +00:00
|
|
|
|
|
|
|
#include "shader_recompiler/backend/glasm/reg_alloc.h"
|
2021-05-19 19:32:03 +00:00
|
|
|
#include "shader_recompiler/stage.h"
|
2021-05-05 05:19:08 +00:00
|
|
|
|
2021-05-19 00:04:09 +00:00
|
|
|
namespace Shader {
|
|
|
|
struct Info;
|
2021-05-19 19:32:03 +00:00
|
|
|
struct Profile;
|
|
|
|
} // namespace Shader
|
2021-05-19 00:04:09 +00:00
|
|
|
|
|
|
|
namespace Shader::Backend {
|
|
|
|
struct Bindings;
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:31:30 +00:00
|
|
|
namespace Shader::IR {
|
|
|
|
class Inst;
|
2021-05-08 19:28:52 +00:00
|
|
|
struct Program;
|
|
|
|
} // namespace Shader::IR
|
2021-05-07 09:31:30 +00:00
|
|
|
|
2021-05-05 05:19:08 +00:00
|
|
|
namespace Shader::Backend::GLASM {
|
|
|
|
|
|
|
|
class EmitContext {
|
|
|
|
public:
|
2021-05-19 19:32:03 +00:00
|
|
|
explicit EmitContext(IR::Program& program, Bindings& bindings, const Profile& profile_);
|
2021-05-05 05:19:08 +00:00
|
|
|
|
2021-05-07 09:31:30 +00:00
|
|
|
template <typename... Args>
|
2021-05-09 06:11:34 +00:00
|
|
|
void Add(const char* format_str, IR::Inst& inst, Args&&... args) {
|
|
|
|
code += fmt::format(format_str, reg_alloc.Define(inst), std::forward<Args>(args)...);
|
2021-05-07 09:31:30 +00:00
|
|
|
// TODO: Remove this
|
|
|
|
code += '\n';
|
|
|
|
}
|
|
|
|
|
2021-05-09 21:03:01 +00:00
|
|
|
template <typename... Args>
|
|
|
|
void LongAdd(const char* format_str, IR::Inst& inst, Args&&... args) {
|
|
|
|
code += fmt::format(format_str, reg_alloc.LongDefine(inst), std::forward<Args>(args)...);
|
|
|
|
// TODO: Remove this
|
|
|
|
code += '\n';
|
|
|
|
}
|
|
|
|
|
2021-05-07 09:31:30 +00:00
|
|
|
template <typename... Args>
|
2021-05-09 06:11:34 +00:00
|
|
|
void Add(const char* format_str, Args&&... args) {
|
|
|
|
code += fmt::format(format_str, std::forward<Args>(args)...);
|
2021-05-07 09:31:30 +00:00
|
|
|
// TODO: Remove this
|
|
|
|
code += '\n';
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string code;
|
|
|
|
RegAlloc reg_alloc{*this};
|
2021-05-19 00:04:09 +00:00
|
|
|
const Info& info;
|
2021-05-19 19:32:03 +00:00
|
|
|
const Profile& profile;
|
2021-05-19 00:04:09 +00:00
|
|
|
|
2021-05-19 05:05:24 +00:00
|
|
|
std::vector<u32> texture_buffer_bindings;
|
2021-05-19 00:04:09 +00:00
|
|
|
std::vector<u32> texture_bindings;
|
2021-05-10 21:21:28 +00:00
|
|
|
|
2021-05-19 19:32:03 +00:00
|
|
|
Stage stage{};
|
2021-05-10 21:21:28 +00:00
|
|
|
std::string_view stage_name = "invalid";
|
2021-05-05 05:19:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Shader::Backend::GLASM
|