gsdx: SW JIT debug helper

Allow to compare 32/64 bits (and all ISAs too)
Allow to breakpoint (int3)
Print selector info
Print size of buffer and start (disabled by default)
This commit is contained in:
Gregory Hainaut 2016-11-15 19:12:31 +01:00
parent 633f7a1db9
commit e31ce87bb3
3 changed files with 40 additions and 1 deletions

View File

@ -100,6 +100,9 @@ GSDrawScanlineCodeGenerator::GSDrawScanlineCodeGenerator(void* param, uint64 key
{
m_sel.key = key;
if(m_sel.breakpoint)
int3();
Generate();
}

View File

@ -26,6 +26,8 @@
#include "xbyak/xbyak.h"
#include "xbyak/xbyak_util.h"
#include "GSScanlineEnvironment.h"
template<class KEY, class VALUE> class GSFunctionMap
{
protected:
@ -161,6 +163,7 @@ class GSCodeGeneratorFunctionMap : public GSFunctionMap<KEY, VALUE>
void* m_param;
hash_map<uint64, VALUE> m_cgmap;
GSCodeBuffer m_cb;
size_t m_total_code_size;
enum {MAX_SIZE = 8192};
@ -168,9 +171,15 @@ public:
GSCodeGeneratorFunctionMap(const char* name, void* param)
: m_name(name)
, m_param(param)
, m_total_code_size(0)
{
}
~GSCodeGeneratorFunctionMap()
{
fprintf(stderr, "%s generated %zu bytes of instruction\n", m_name.c_str(), m_total_code_size);
}
VALUE GetDefaultFunction(KEY key)
{
VALUE ret = NULL;
@ -183,10 +192,19 @@ public:
}
else
{
CG* cg = new CG(m_param, key, m_cb.GetBuffer(MAX_SIZE), MAX_SIZE);
void* code_ptr = m_cb.GetBuffer(MAX_SIZE);
CG* cg = new CG(m_param, key, code_ptr, MAX_SIZE);
ASSERT(cg->getSize() < MAX_SIZE);
#if 0
fprintf(stderr, "%s Location:%p Size:%zu Key:%llx\n", m_name.c_str(), code_ptr, cg->getSize(), (uint64)key);
GSScanlineSelector sel(key);
sel.Print();
#endif
m_total_code_size += cg->getSize();
m_cb.ReleaseBuffer(cg->getSize());
ret = (VALUE)cg->getCode();

View File

@ -69,6 +69,8 @@ union GSScanlineSelector
uint32 mmin:2; // 53
uint32 notest:1; // 54 (no ztest, no atest, no date, no scissor test, and horizontally aligned to 4 pixels)
// TODO: 1D texture flag? could save 2 texture reads and 4 lerps with bilinear, and also the texture coordinate clamp/wrap code in one direction
uint32 breakpoint:1; // Insert a trap to stop the program, helpful to stop debugger on a program
};
struct
@ -76,6 +78,7 @@ union GSScanlineSelector
uint32 _pad1:22;
uint32 ababcd:8;
uint32 _pad2:2;
uint32 fb:2;
uint32 _pad3:1;
uint32 zb:2;
@ -89,6 +92,9 @@ union GSScanlineSelector
uint64 key;
GSScanlineSelector() = default;
GSScanlineSelector(uint64 k) : key(k) {}
operator uint32() const {return lo;}
operator uint64() const {return key;}
@ -103,6 +109,18 @@ union GSScanlineSelector
&& date == 0
&& fge == 0;
}
void Print() const
{
fprintf(stderr, "fpsm:%d zpsm:%d ztst:%d ztest:%d atst:%d afail:%d iip:%d rfb:%d fb:%d zb:%d zw:%d "
"tfx:%d tcc:%d fst:%d ltf:%d tlu:%d wms:%d wmt:%d mmin:%d lcm:%d tw:%d "
"fba:%d cclamp:%d date:%d datm:%d "
"prim:%d abe:%d %d%d%d%d fge:%d dthe:%d notest:%d\n",
fpsm, zpsm, ztst, ztest, atst, afail, iip, rfb, fb, zb, zwrite,
tfx, tcc, fst, ltf, tlu, wms, wmt, mmin, lcm, tw,
fba, colclamp, date, datm,
prim, abe, aba, abb, abc, abd , fge, dthe, notest);
}
};
struct alignas(32) GSScanlineGlobalData // per batch variables, this is like a pixel shader constant buffer