diff --git a/plugins/GSdx/GSLocalMemory.cpp b/plugins/GSdx/GSLocalMemory.cpp index cd6e28b49a..bca4e345ec 100644 --- a/plugins/GSdx/GSLocalMemory.cpp +++ b/plugins/GSdx/GSLocalMemory.cpp @@ -221,6 +221,7 @@ GSLocalMemory::GSLocalMemory() m_psm[i].pgs = GSVector2i(64, 32); for(int j = 0; j < 8; j++) m_psm[i].rowOffset[j] = rowOffset32; m_psm[i].blockOffset = blockOffset32; + m_psm[i].msk = 0xff; } m_psm[PSM_PSMCT16].pa = &GSLocalMemory::PixelAddress16; @@ -440,6 +441,12 @@ GSLocalMemory::GSLocalMemory() m_psm[PSM_PSMZ24].blockOffset = blockOffset32Z; m_psm[PSM_PSMZ16].blockOffset = blockOffset16Z; m_psm[PSM_PSMZ16S].blockOffset = blockOffset16SZ; + + m_psm[PSM_PSMCT24].msk = 0x3f; + m_psm[PSM_PSMZ24].msk = 0x3f; + m_psm[PSM_PSMT8H].msk = 0xc0; + m_psm[PSM_PSMT4HL].msk = 0x40; + m_psm[PSM_PSMT4HH].msk = 0x80; } GSLocalMemory::~GSLocalMemory() diff --git a/plugins/GSdx/GSLocalMemory.h b/plugins/GSdx/GSLocalMemory.h index 8cda1b73b2..9a32b01694 100644 --- a/plugins/GSdx/GSLocalMemory.h +++ b/plugins/GSdx/GSLocalMemory.h @@ -111,6 +111,7 @@ public: GSVector2i bs, pgs; int* rowOffset[8]; short* blockOffset; + uint8 msk; }; static psm_t m_psm[64]; diff --git a/plugins/GSdx/GSRendererSW.cpp b/plugins/GSdx/GSRendererSW.cpp index 3869b8faed..8209d5b815 100644 --- a/plugins/GSdx/GSRendererSW.cpp +++ b/plugins/GSdx/GSRendererSW.cpp @@ -426,21 +426,9 @@ void GSRendererSW::Draw() // - if(LOG) - { - fprintf(s_fp, "[%d] queue %05x %d (%d) %05x %d (%d) %05x %d %dx%d (%d %d %d) | %d %d %d\n", - sd->counter, - m_context->FRAME.Block(), m_context->FRAME.PSM, gd.sel.fwrite, - m_context->ZBUF.Block(), m_context->ZBUF.PSM, gd.sel.zwrite, - PRIM->TME ? m_context->TEX0.TBP0 : 0xfffff, m_context->TEX0.PSM, (int)m_context->TEX0.TW, (int)m_context->TEX0.TH, m_context->TEX0.CSM, m_context->TEX0.CPSM, m_context->TEX0.CSA, - PRIM->PRIM, sd->vertex_count, sd->index_count); - - fflush(s_fp); - } - if(s_dump) { - Sync(3); + Sync(2); uint64 frame = m_perfmon.GetFrame(); @@ -473,7 +461,7 @@ void GSRendererSW::Draw() Queue(data); - Sync(4); + Sync(3); if(s_save && s_n >= s_saven) { @@ -514,13 +502,34 @@ void GSRendererSW::Queue(shared_ptr& item) if(sd->m_syncpoint == SharedData::SyncSource) { - m_rl->Sync(); + Sync(4); } // update previously invalidated parts sd->UpdateSource(); + if(sd->m_syncpoint == SharedData::SyncTarget) + { + Sync(5); + } + + if(LOG) + { + GSScanlineGlobalData& gd = ((SharedData*)item.get())->global; + + fprintf(s_fp, "[%d] queue %05x %d (%d) %05x %d (%d) %05x %d %dx%d (%d %d %d) | %d %d %d\n", + sd->counter, + m_context->FRAME.Block(), m_context->FRAME.PSM, gd.sel.fwrite, + m_context->ZBUF.Block(), m_context->ZBUF.PSM, gd.sel.zwrite, + PRIM->TME ? m_context->TEX0.TBP0 : 0xfffff, m_context->TEX0.PSM, (int)m_context->TEX0.TW, (int)m_context->TEX0.TH, m_context->TEX0.CSM, m_context->TEX0.CPSM, m_context->TEX0.CSA, + PRIM->PRIM, sd->vertex_count, sd->index_count); + + fflush(s_fp); + } + + m_rl->Queue(item); + // invalidate new parts rendered onto if(sd->global.sel.fwrite) @@ -532,13 +541,6 @@ void GSRendererSW::Queue(shared_ptr& item) { m_tc->InvalidatePages(sd->m_zb_pages, sd->m_zpsm); } - - if(sd->m_syncpoint == SharedData::SyncTarget) - { - m_rl->Sync(); - } - - m_rl->Queue(item); } void GSRendererSW::Sync(int reason) @@ -597,7 +599,7 @@ void GSRendererSW::InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GS { if(m_fzb_pages[*p] | m_tex_pages[*p]) { - Sync(5); + Sync(6); break; } @@ -1066,12 +1068,6 @@ bool GSRendererSW::GetScanlineGlobalData(SharedData* data) static int s_counter = 0; - if(0) - //if(context->TEX0.TH > context->TEX0.TW) - //if(s_n >= s_saven && s_n < s_saven + 3) - //if(context->TEX0.TBP0 >= 0x2b80 && context->TEX0.TBW == 2 && context->TEX0.PSM == PSM_PSMT4) - t->Save(format("c:/temp1/%08d_%05x_0.bmp", s_counter, context->TEX0.TBP0)); - for(int i = 1, j = std::min((int)context->TEX1.MXL, 6); i <= j; i++) { switch(i) @@ -1473,21 +1469,37 @@ void GSRendererSW::SharedData::UpdateSource() global.sel.tfx = TFX_NONE; } + } - // TODO + // TODO - if(m_parent->s_dump) + if(m_parent->s_dump) + { + uint64 frame = m_parent->m_perfmon.GetFrame(); + + string s; + + if(m_parent->s_save && m_parent->s_n >= m_parent->s_saven) { - uint64 frame = m_parent->m_perfmon.GetFrame(); - - string s; - - if(m_parent->s_save && m_parent->s_n >= m_parent->s_saven) + for(size_t i = 0; m_tex[i].t != NULL; i++) { s = format("c:\\temp1\\_%05d_f%lld_tex%d_%05x_%d.bmp", m_parent->s_n - 2, frame, i, (int)m_parent->m_context->TEX0.TBP0, (int)m_parent->m_context->TEX0.PSM); m_tex[i].t->Save(s); } + + if(global.clut != NULL) + { + GSTextureSW* t = new GSTextureSW(0, 256, 1); + + t->Update(GSVector4i(0, 0, 256, 1), global.clut, sizeof(uint32) * 256); + + s = format("c:\\temp1\\_%05d_f%lld_texp_%05x_%d.bmp", m_parent->s_n - 2, frame, (int)m_parent->m_context->TEX0.TBP0, (int)m_parent->m_context->TEX0.PSM); + + t->Save(s); + + delete t; + } } } } diff --git a/plugins/GSdx/GSState.cpp b/plugins/GSdx/GSState.cpp index 78bbfc8f81..2ff94cc7fb 100644 --- a/plugins/GSdx/GSState.cpp +++ b/plugins/GSdx/GSState.cpp @@ -2518,10 +2518,10 @@ void GSState::GetTextureMinMax(GSVector4i& r, const GIFRegTEX0& TEX0, const GIFR if(linear) { - st += GSVector4(-0x8000, 0x8000).xxyy(); + st += GSVector4(-0.5f, 0.5f).xxyy(); } - GSVector4i uv = GSVector4i(st).sra32(16); + GSVector4i uv = GSVector4i(st); GSVector4i u, v; diff --git a/plugins/GSdx/GSTextureCacheSW.cpp b/plugins/GSdx/GSTextureCacheSW.cpp index 5f9fd5e1ba..ea71154a95 100644 --- a/plugins/GSdx/GSTextureCacheSW.cpp +++ b/plugins/GSdx/GSTextureCacheSW.cpp @@ -363,7 +363,7 @@ bool GSTextureCacheSW::Texture::Save(const string& fn, bool dds) const { for(int i = 0; i < w; i++) { - ((uint32*)m.bits)[i] = clut[((uint8*)src)[i]]; + ((uint32*)m.bits)[i] = clut[src[i]]; } } } diff --git a/plugins/GSdx/GSVertexTrace.cpp b/plugins/GSdx/GSVertexTrace.cpp index 955c1bc801..5d3e3b4828 100644 --- a/plugins/GSdx/GSVertexTrace.cpp +++ b/plugins/GSdx/GSVertexTrace.cpp @@ -455,11 +455,11 @@ void GSVertexTrace::FindMinMax(const void* vertex, const uint32* index, int coun { if(fst) { - s = GSVector4(1 << (16 - 4), 1).xxyy(); + s = GSVector4(1.0f / 16, 1.0f).xxyy(); } else { - s = GSVector4(0x10000 << context->TEX0.TW, 0x10000 << context->TEX0.TH, 1, 1); + s = GSVector4(1 << context->TEX0.TW, 1 << context->TEX0.TH, 1, 1); } m_min.t = tmin * s; diff --git a/plugins/GSdx/GSVertexTrace.h b/plugins/GSdx/GSVertexTrace.h index a5734fafc7..c7fd012286 100644 --- a/plugins/GSdx/GSVertexTrace.h +++ b/plugins/GSdx/GSVertexTrace.h @@ -32,7 +32,7 @@ class GSState; __aligned(class, 32) GSVertexTrace : public GSAlignedClass<32> { public: - struct Vertex {GSVector4i c; GSVector4 p, t;}; // t.xy * 0x10000 + struct Vertex {GSVector4i c; GSVector4 p, t;}; struct VertexAlpha {int min, max; bool valid;}; protected: