Make it possible to view vertex decoders through the shader viewing mechanism (even though they aren't strictly shaders, they fit the model).

This commit is contained in:
Henrik Rydgard 2015-10-21 23:06:32 +02:00
parent c63ed2f701
commit 6a373fe09a
12 changed files with 100 additions and 28 deletions

View file

@ -27,6 +27,8 @@
#include "Core/MemMap.h"
#include "Core/HDRemaster.h"
#include "Core/Reporting.h"
#include "Core/MIPS/JitCommon/JitCommon.h"
#include "GPU/Common/ShaderCommon.h"
#include "GPU/GPUState.h"
#include "GPU/ge_constants.h"
#include "GPU/Math3D.h"
@ -136,7 +138,7 @@ void PrintDecodedVertex(VertexReader &vtx) {
printf("P: %f %f %f\n", pos[0], pos[1], pos[2]);
}
VertexDecoder::VertexDecoder() : jitted_(0), decoded_(nullptr), ptr_(nullptr) {
VertexDecoder::VertexDecoder() : jitted_(0), jittedSize_(0), decoded_(nullptr), ptr_(nullptr) {
}
void VertexDecoder::Step_WeightsU8() const
@ -1069,7 +1071,7 @@ void VertexDecoder::SetVertexType(u32 fmt, const VertexDecoderOptions &options,
// Attempt to JIT as well
if (jitCache && g_Config.bVertexDecoderJit) {
jitted_ = jitCache->Compile(*this);
jitted_ = jitCache->Compile(*this, &jittedSize_);
if (!jitted_) {
WARN_LOG(G3D, "Vertex decoder JIT failed! fmt = %08x", fmt_);
}
@ -1128,6 +1130,38 @@ int VertexDecoder::ToString(char *output) const {
return output - start;
}
std::string VertexDecoder::GetString(DebugShaderStringType stringType) {
char buffer[256];
switch (stringType) {
case SHADER_STRING_SHORT_DESC:
ToString(buffer);
return std::string(buffer);
case SHADER_STRING_SOURCE_CODE:
{
if (!jitted_)
return "Not compiled";
std::vector<std::string> lines;
#if defined(ARM64)
lines = DisassembleArm64((const u8 *)jitted_, jittedSize_);
#elif defined(ARM)
lines = DisassembleArm2((const u8 *)jitted_, jittedSize_);
#else
lines = DisassembleX86((const u8 *)jitted_, jittedSize_);
#endif
std::string buffer;
for (auto line : lines) {
buffer += line;
buffer += "\n";
}
return buffer;
}
default:
return "N/A";
}
}
VertexDecoderJitCache::VertexDecoderJitCache()
#ifdef ARM64
: fp(this)