diff --git a/plugins/GSdx/GSDrawScanlineCodeGenerator.cpp b/plugins/GSdx/GSDrawScanlineCodeGenerator.cpp index 90c941638e..ce3e1b6801 100644 --- a/plugins/GSdx/GSDrawScanlineCodeGenerator.cpp +++ b/plugins/GSdx/GSDrawScanlineCodeGenerator.cpp @@ -100,6 +100,9 @@ GSDrawScanlineCodeGenerator::GSDrawScanlineCodeGenerator(void* param, uint64 key { m_sel.key = key; + if(m_sel.breakpoint) + int3(); + Generate(); } diff --git a/plugins/GSdx/GSFunctionMap.h b/plugins/GSdx/GSFunctionMap.h index ab2f065798..5b6cc281d9 100644 --- a/plugins/GSdx/GSFunctionMap.h +++ b/plugins/GSdx/GSFunctionMap.h @@ -26,6 +26,8 @@ #include "xbyak/xbyak.h" #include "xbyak/xbyak_util.h" +#include "GSScanlineEnvironment.h" + template class GSFunctionMap { protected: @@ -161,6 +163,7 @@ class GSCodeGeneratorFunctionMap : public GSFunctionMap void* m_param; hash_map 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(); diff --git a/plugins/GSdx/GSScanlineEnvironment.h b/plugins/GSdx/GSScanlineEnvironment.h index e9f0551e40..115c10a3db 100644 --- a/plugins/GSdx/GSScanlineEnvironment.h +++ b/plugins/GSdx/GSScanlineEnvironment.h @@ -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