#pragma once #include "shader.h" #include "shader_code.h" struct StringBuffer { std::string out; template void print(std::format_string fmt, Args&&... args) { std::vformat_to(std::back_inserter(out), fmt.get(), std::make_format_args(args...)); } template void println(std::format_string fmt, Args&&... args) { std::vformat_to(std::back_inserter(out), fmt.get(), std::make_format_args(args...)); out += '\n'; } }; struct ShaderRecompiler : StringBuffer { uint32_t indentation = 0; bool isPixelShader = false; const uint8_t* constantTableData = nullptr; std::unordered_map vertexElements; std::unordered_map interpolators; std::unordered_map float4Constants; std::unordered_map boolConstants; std::unordered_map samplers; std::unordered_map ifEndLabels; void indent() { for (uint32_t i = 0; i < indentation; i++) out += '\t'; } void printDstSwizzle(uint32_t dstSwizzle, bool operand); void printDstSwizzle01(uint32_t dstRegister, uint32_t dstSwizzle); void recompile(const VertexFetchInstruction& instr, uint32_t address); void recompile(const TextureFetchInstruction& instr, bool bicubic); void recompile(const AluInstruction& instr); void recompile(const uint8_t* shaderData, const std::string_view& include); };