mirror of
https://github.com/hedge-dev/XenosRecomp.git
synced 2025-10-30 07:12:17 +00:00
56 lines
1.7 KiB
C++
56 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include "shader.h"
|
|
#include "shader_code.h"
|
|
|
|
struct StringBuffer
|
|
{
|
|
std::string out;
|
|
|
|
template<class... Args>
|
|
void print(fmt::format_string<Args...> fmt, Args&&... args)
|
|
{
|
|
fmt::vformat_to(std::back_inserter(out), fmt.get(), fmt::make_format_args(args...));
|
|
}
|
|
|
|
template<class... Args>
|
|
void println(fmt::format_string<Args...> fmt, Args&&... args)
|
|
{
|
|
fmt::vformat_to(std::back_inserter(out), fmt.get(), fmt::make_format_args(args...));
|
|
out += '\n';
|
|
}
|
|
};
|
|
|
|
struct ShaderRecompiler : StringBuffer
|
|
{
|
|
uint32_t indentation = 0;
|
|
bool isPixelShader = false;
|
|
const uint8_t* constantTableData = nullptr;
|
|
std::unordered_map<uint32_t, VertexElement> vertexElements;
|
|
std::unordered_map<uint32_t, std::string> interpolators;
|
|
std::unordered_map<uint32_t, const ConstantInfo*> float4Constants;
|
|
std::unordered_map<uint32_t, const char*> boolConstants;
|
|
std::unordered_map<uint32_t, const char*> samplers;
|
|
std::unordered_map<uint32_t, uint32_t> ifEndLabels;
|
|
uint32_t specConstantsMask = 0;
|
|
|
|
#ifdef UNLEASHED_RECOMP
|
|
bool hasMtxProjection = false;
|
|
bool hasMtxPrevInvViewProjection = false;
|
|
#endif
|
|
|
|
void indent()
|
|
{
|
|
for (uint32_t i = 0; i < indentation; i++)
|
|
out += '\t';
|
|
}
|
|
|
|
uint32_t 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);
|
|
};
|