fix num args 4 -> 5

This commit is contained in:
Frodo Baggins 2024-10-05 12:33:58 -07:00
commit 9fd59e256a
2 changed files with 10 additions and 4 deletions

View file

@ -5,9 +5,11 @@
#include <bit> #include <bit>
#include <source_location> #include <source_location>
#include <boost/container/small_vector.hpp> #include <boost/container/small_vector.hpp>
#include "common/assert.h"
#include "shader_recompiler/exception.h" #include "shader_recompiler/exception.h"
#include "shader_recompiler/ir/debug_print.h" #include "shader_recompiler/ir/debug_print.h"
#include "shader_recompiler/ir/ir_emitter.h" #include "shader_recompiler/ir/ir_emitter.h"
#include "shader_recompiler/ir/opcodes.h"
#include "shader_recompiler/ir/value.h" #include "shader_recompiler/ir/value.h"
namespace Shader::IR { namespace Shader::IR {
@ -1558,13 +1560,17 @@ void IREmitter::ImageWrite(const Value& handle, const Value& coords, const Value
void IREmitter::DebugPrint(std::string_view format, void IREmitter::DebugPrint(std::string_view format,
boost::container::small_vector<Value, 5> format_args) { boost::container::small_vector<Value, 5> format_args) {
std::array<Value, 5> args; constexpr size_t PRINT_MAX_ARGS = NumArgsOf(IR::Opcode::DebugPrint);
std::array<Value, PRINT_MAX_ARGS> args;
ASSERT_MSG(format_args.size() < PRINT_MAX_ARGS, "DebugPrint only supports up to {} format args",
PRINT_MAX_ARGS);
for (int i = 0; i < format_args.size(); i++) { for (int i = 0; i < format_args.size(); i++) {
args[i] = format_args[i]; args[i] = format_args[i];
} }
for (int i = format_args.size(); i < 4; i++) { for (int i = format_args.size(); i < PRINT_MAX_ARGS; i++) {
args[i] = Inst(Opcode::Void); args[i] = Inst(Opcode::Void);
} }

View file

@ -81,7 +81,7 @@ constexpr u8 NUM_ARGS[]{
} }
/// Get the number of arguments an opcode accepts /// Get the number of arguments an opcode accepts
[[nodiscard]] inline size_t NumArgsOf(Opcode op) noexcept { [[nodiscard]] constexpr inline size_t NumArgsOf(Opcode op) noexcept {
return static_cast<size_t>(Detail::NUM_ARGS[static_cast<size_t>(op)]); return static_cast<size_t>(Detail::NUM_ARGS[static_cast<size_t>(op)]);
} }