shader: GCC fmt 8.0.0 fixes

This commit is contained in:
lat9nq 2021-06-28 23:44:03 -04:00 committed by ameerj
parent b9069c7891
commit 2e5af95541
7 changed files with 19 additions and 16 deletions

View File

@ -37,21 +37,23 @@ public:
template <typename... Args> template <typename... Args>
void Add(const char* format_str, IR::Inst& inst, Args&&... args) { void Add(const char* format_str, IR::Inst& inst, Args&&... args) {
code += fmt::format(format_str, reg_alloc.Define(inst), std::forward<Args>(args)...); code += fmt::format(fmt::runtime(format_str), reg_alloc.Define(inst),
std::forward<Args>(args)...);
// TODO: Remove this // TODO: Remove this
code += '\n'; code += '\n';
} }
template <typename... Args> template <typename... Args>
void LongAdd(const char* format_str, IR::Inst& inst, Args&&... 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)...); code += fmt::format(fmt::runtime(format_str), reg_alloc.LongDefine(inst),
std::forward<Args>(args)...);
// TODO: Remove this // TODO: Remove this
code += '\n'; code += '\n';
} }
template <typename... Args> template <typename... Args>
void Add(const char* format_str, Args&&... args) { void Add(const char* format_str, Args&&... args) {
code += fmt::format(format_str, std::forward<Args>(args)...); code += fmt::format(fmt::runtime(format_str), std::forward<Args>(args)...);
// TODO: Remove this // TODO: Remove this
code += '\n'; code += '\n';
} }

View File

@ -597,7 +597,7 @@ std::string EmitContext::DefineGlobalMemoryFunctions() {
func += comparison; func += comparison;
const auto ssbo_name{fmt::format("{}_ssbo{}", stage_name, index)}; const auto ssbo_name{fmt::format("{}_ssbo{}", stage_name, index)};
func += fmt::format(return_statement, ssbo_name, ssbo_addr); func += fmt::format(fmt::runtime(return_statement), ssbo_name, ssbo_addr);
}}; }};
std::string write_func{"void WriteGlobal32(uint64_t addr,uint data){"}; std::string write_func{"void WriteGlobal32(uint64_t addr,uint data){"};
std::string write_func_64{"void WriteGlobal64(uint64_t addr,uvec2 data){"}; std::string write_func_64{"void WriteGlobal64(uint64_t addr,uvec2 data){"};

View File

@ -51,9 +51,9 @@ public:
const auto var_def{var_alloc.AddDefine(inst, type)}; const auto var_def{var_alloc.AddDefine(inst, type)};
if (var_def.empty()) { if (var_def.empty()) {
// skip assigment. // skip assigment.
code += fmt::format(format_str + 3, std::forward<Args>(args)...); code += fmt::format(fmt::runtime(format_str + 3), std::forward<Args>(args)...);
} else { } else {
code += fmt::format(format_str, var_def, std::forward<Args>(args)...); code += fmt::format(fmt::runtime(format_str), var_def, std::forward<Args>(args)...);
} }
// TODO: Remove this // TODO: Remove this
code += '\n'; code += '\n';
@ -131,7 +131,7 @@ public:
template <typename... Args> template <typename... Args>
void Add(const char* format_str, Args&&... args) { void Add(const char* format_str, Args&&... args) {
code += fmt::format(format_str, std::forward<Args>(args)...); code += fmt::format(fmt::runtime(format_str), std::forward<Args>(args)...);
// TODO: Remove this // TODO: Remove this
code += '\n'; code += '\n';
} }

View File

@ -61,14 +61,14 @@ void GetCbuf(EmitContext& ctx, std::string_view ret, const IR::Value& binding,
: fmt ::format("bitfieldExtract({},int({}),{})", cbuf_cast, : fmt ::format("bitfieldExtract({},int({}),{})", cbuf_cast,
bit_offset, num_bits)}; bit_offset, num_bits)};
if (!component_indexing_bug) { if (!component_indexing_bug) {
const auto result{fmt::format(extraction, swizzle)}; const auto result{fmt::format(fmt::runtime(extraction), swizzle)};
ctx.Add("{}={};", ret, result); ctx.Add("{}={};", ret, result);
return; return;
} }
const auto cbuf_offset{fmt::format("{}>>2", offset_var)}; const auto cbuf_offset{fmt::format("{}>>2", offset_var)};
for (u32 i = 0; i < 4; ++i) { for (u32 i = 0; i < 4; ++i) {
const auto swizzle_string{fmt::format(".{}", "xyzw"[i])}; const auto swizzle_string{fmt::format(".{}", "xyzw"[i])};
const auto result{fmt::format(extraction, swizzle_string)}; const auto result{fmt::format(fmt::runtime(extraction), swizzle_string)};
ctx.Add("if(({}&3)=={}){}={};", cbuf_offset, i, ret, result); ctx.Add("if(({}&3)=={}){}={};", cbuf_offset, i, ret, result);
} }
} }

View File

@ -244,8 +244,9 @@ std::string_view StageName(Stage stage) {
template <typename... Args> template <typename... Args>
void Name(EmitContext& ctx, Id object, std::string_view format_str, Args&&... args) { void Name(EmitContext& ctx, Id object, std::string_view format_str, Args&&... args) {
ctx.Name(object, ctx.Name(object, fmt::format(fmt::runtime(format_str), StageName(ctx.stage),
fmt::format(format_str, StageName(ctx.stage), std::forward<Args>(args)...).c_str()); std::forward<Args>(args)...)
.c_str());
} }
void DefineConstBuffers(EmitContext& ctx, const Info& info, Id UniformDefinitions::*member_type, void DefineConstBuffers(EmitContext& ctx, const Info& info, Id UniformDefinitions::*member_type,

View File

@ -37,21 +37,21 @@ class LogicError : public Exception {
public: public:
template <typename... Args> template <typename... Args>
LogicError(const char* message, Args&&... args) LogicError(const char* message, Args&&... args)
: Exception{fmt::format(message, std::forward<Args>(args)...)} {} : Exception{fmt::format(fmt::runtime(message), std::forward<Args>(args)...)} {}
}; };
class RuntimeError : public Exception { class RuntimeError : public Exception {
public: public:
template <typename... Args> template <typename... Args>
RuntimeError(const char* message, Args&&... args) RuntimeError(const char* message, Args&&... args)
: Exception{fmt::format(message, std::forward<Args>(args)...)} {} : Exception{fmt::format(fmt::runtime(message), std::forward<Args>(args)...)} {}
}; };
class NotImplementedException : public Exception { class NotImplementedException : public Exception {
public: public:
template <typename... Args> template <typename... Args>
NotImplementedException(const char* message, Args&&... args) NotImplementedException(const char* message, Args&&... args)
: Exception{fmt::format(message, std::forward<Args>(args)...)} { : Exception{fmt::format(fmt::runtime(message), std::forward<Args>(args)...)} {
Append(" is not implemented"); Append(" is not implemented");
} }
}; };
@ -60,7 +60,7 @@ class InvalidArgument : public Exception {
public: public:
template <typename... Args> template <typename... Args>
InvalidArgument(const char* message, Args&&... args) InvalidArgument(const char* message, Args&&... args)
: Exception{fmt::format(message, std::forward<Args>(args)...)} {} : Exception{fmt::format(fmt::runtime(message), std::forward<Args>(args)...)} {}
}; };
} // namespace Shader } // namespace Shader

View File

@ -174,7 +174,7 @@ std::string DumpTree(const Tree& tree, u32 indentation = 0) {
switch (stmt->type) { switch (stmt->type) {
case StatementType::Code: case StatementType::Code:
ret += fmt::format("{} Block {:04x} -> {:04x} (0x{:016x});\n", indent, ret += fmt::format("{} Block {:04x} -> {:04x} (0x{:016x});\n", indent,
stmt->block->begin, stmt->block->end, stmt->block->begin.Offset(), stmt->block->end.Offset(),
reinterpret_cast<uintptr_t>(stmt->block)); reinterpret_cast<uintptr_t>(stmt->block));
break; break;
case StatementType::Goto: case StatementType::Goto: