From d23d7e2617959fead2a7a8d971680a867ee5bc18 Mon Sep 17 00:00:00 2001 From: gabest11 Date: Fri, 18 Feb 2011 03:50:12 +0000 Subject: [PATCH] Just moving code around. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4312 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDevice.cpp | 53 --------------- plugins/GSdx/GSDevice.h | 30 +-------- plugins/GSdx/GSDevice11.cpp | 4 +- plugins/GSdx/GSDevice11.h | 2 +- plugins/GSdx/GSDevice9.cpp | 4 +- plugins/GSdx/GSDevice9.h | 2 +- plugins/GSdx/GSDeviceDX.h | 49 +++++++++----- plugins/GSdx/GSRenderer.cpp | 2 - plugins/GSdx/GSRendererDX.h | 101 +++++++++++++++------------- plugins/GSdx/GSState.h | 1 + plugins/GSdx/GSdx.vcxproj | 1 + plugins/GSdx/GSdx.vcxproj.filters | 3 + plugins/GSdx/GSdx_vs2008.vcproj | 4 ++ plugins/GSdx/stdafx.cpp | 2 +- plugins/GSdx/vsprops/common.props | 2 +- plugins/GSdx/vsprops/common.vsprops | 4 +- 16 files changed, 108 insertions(+), 156 deletions(-) diff --git a/plugins/GSdx/GSDevice.cpp b/plugins/GSdx/GSDevice.cpp index 02224a81fb..69d682ed00 100644 --- a/plugins/GSdx/GSDevice.cpp +++ b/plugins/GSdx/GSDevice.cpp @@ -35,11 +35,6 @@ GSDevice::GSDevice() , m_frame(0) { memset(&m_vertices, 0, sizeof(m_vertices)); - - m_msaa = theApp.GetConfig("msaa", 0); - - m_msaa_desc.Count = 1; - m_msaa_desc.Quality = 0; } GSDevice::~GSDevice() @@ -112,11 +107,6 @@ void GSDevice::Present(const GSVector4i& r, int shader) GSTexture* GSDevice::Fetch(int type, int w, int h, bool msaa, int format) { - if(m_msaa < 2) - { - msaa = false; - } - GSVector2i size(w, h); for(list::iterator i = m_pool.begin(); i != m_pool.end(); i++) @@ -307,46 +297,3 @@ bool GSDevice::ResizeTexture(GSTexture** t, int w, int h) return t2 != NULL; } - -bool GSDevice::SetFeatureLevel(D3D_FEATURE_LEVEL level, bool compat_mode) -{ - m_shader.level = level; - - switch(level) - { - case D3D_FEATURE_LEVEL_9_1: - case D3D_FEATURE_LEVEL_9_2: - m_shader.model = "0x200"; - m_shader.vs = compat_mode ? "vs_4_0_level_9_1" : "vs_2_0"; - m_shader.ps = compat_mode ? "ps_4_0_level_9_1" : "ps_2_0"; - break; - case D3D_FEATURE_LEVEL_9_3: - m_shader.model = "0x300"; - m_shader.vs = compat_mode ? "vs_4_0_level_9_3" : "vs_3_0"; - m_shader.ps = compat_mode ? "ps_4_0_level_9_3" : "ps_3_0"; - break; - case D3D_FEATURE_LEVEL_10_0: - m_shader.model = "0x400"; - m_shader.vs = "vs_4_0"; - m_shader.gs = "gs_4_0"; - m_shader.ps = "ps_4_0"; - break; - case D3D_FEATURE_LEVEL_10_1: - m_shader.model = "0x401"; - m_shader.vs = "vs_4_1"; - m_shader.gs = "gs_4_1"; - m_shader.ps = "ps_4_1"; - break; - case D3D_FEATURE_LEVEL_11_0: - m_shader.model = "0x500"; - m_shader.vs = "vs_5_0"; - m_shader.gs = "gs_5_0"; - m_shader.ps = "ps_5_0"; - break; - default: - ASSERT(0); - return false; - } - - return true; -} diff --git a/plugins/GSdx/GSDevice.h b/plugins/GSdx/GSDevice.h index 3c8e5f1733..3500db0e68 100644 --- a/plugins/GSdx/GSDevice.h +++ b/plugins/GSdx/GSDevice.h @@ -52,8 +52,6 @@ class GSDevice : public GSAlignedClass<32> { list m_pool; - GSTexture* Fetch(int type, int w, int h, bool msaa, int format); - protected: GSWnd* m_wnd; bool m_vsync; @@ -64,13 +62,11 @@ protected: GSTexture* m_blend; GSTexture* m_1x1; GSTexture* m_current; - struct {D3D_FEATURE_LEVEL level; string model, vs, gs, ps;} m_shader; struct {size_t stride, start, count, limit;} m_vertices; - uint32 m_msaa; - DXGI_SAMPLE_DESC m_msaa_desc; unsigned int m_frame; // for ageing the pool virtual GSTexture* Create(int type, int w, int h, bool msaa, int format) = 0; + virtual GSTexture* Fetch(int type, int w, int h, bool msaa, int format); virtual void DoMerge(GSTexture* st[2], GSVector4* sr, GSVector4* dr, GSTexture* dt, bool slbg, bool mmod, const GSVector4& c) = 0; virtual void DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linear, float yoffset) = 0; @@ -126,29 +122,5 @@ public: bool IsRBSwapped() {return m_rbswapped;} - template void PrepareShaderMacro(vector& dst, const T* src) - { - dst.clear(); - - while(src && src->Definition && src->Name) - { - dst.push_back(*src++); - } - - T m; - - m.Name = "SHADER_MODEL"; - m.Definition = m_shader.model.c_str(); - - dst.push_back(m); - - m.Name = NULL; - m.Definition = NULL; - - dst.push_back(m); - } - - bool SetFeatureLevel(D3D_FEATURE_LEVEL level, bool compat_mode); // TODO: GSDeviceDX - void AgePool(); }; diff --git a/plugins/GSdx/GSDevice11.cpp b/plugins/GSdx/GSDevice11.cpp index c989dd28cb..8a448460ad 100644 --- a/plugins/GSdx/GSDevice11.cpp +++ b/plugins/GSdx/GSDevice11.cpp @@ -713,7 +713,7 @@ void GSDevice11::DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool line StretchRect(st, sr, dt, dr, m_interlace.ps[shader], m_interlace.cb, linear); } -void GSDevice11::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1 (&iaVertices)[4], bool datm) +void GSDevice11::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* vertices, bool datm) { const GSVector2i& size = rt->GetSize(); @@ -733,7 +733,7 @@ void GSDevice11::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1 (&iaV // ia - IASetVertexBuffer(iaVertices, sizeof(iaVertices[0]), countof(iaVertices)); + IASetVertexBuffer(vertices, sizeof(vertices[0]), 4); IASetInputLayout(m_convert.il); IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); diff --git a/plugins/GSdx/GSDevice11.h b/plugins/GSdx/GSDevice11.h index 76b512a46f..9bc3325b73 100644 --- a/plugins/GSdx/GSDevice11.h +++ b/plugins/GSdx/GSDevice11.h @@ -121,7 +121,7 @@ public: // TODO CComPtr bs; } m_date; - void SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1 (&iaVertices)[4], bool datm); + void SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* vertices, bool datm); // Shaders... diff --git a/plugins/GSdx/GSDevice9.cpp b/plugins/GSdx/GSDevice9.cpp index 26d624c5ee..e327592f2a 100644 --- a/plugins/GSdx/GSDevice9.cpp +++ b/plugins/GSdx/GSDevice9.cpp @@ -800,7 +800,7 @@ void GSDevice9::DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linea StretchRect(st, sr, dt, dr, m_interlace.ps[shader], (const float*)&cb, 1, linear); } -void GSDevice9::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1 (&iaVertices)[4], bool datm) +void GSDevice9::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* vertices, bool datm) { const GSVector2i& size = rt->GetSize(); @@ -820,7 +820,7 @@ void GSDevice9::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1 (&iaVe // ia - IASetVertexBuffer(iaVertices, sizeof(iaVertices[0]), countof(iaVertices)); + IASetVertexBuffer(vertices, sizeof(vertices[0]), 4); IASetPrimitiveTopology(D3DPT_TRIANGLESTRIP); // vs diff --git a/plugins/GSdx/GSDevice9.h b/plugins/GSdx/GSDevice9.h index 056c8047f9..4c5ece5302 100644 --- a/plugins/GSdx/GSDevice9.h +++ b/plugins/GSdx/GSDevice9.h @@ -136,7 +136,7 @@ public: // TODO Direct3DBlendState9 bs; } m_date; - void SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1 (&iaVertices)[4], bool datm); + void SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* vertices, bool datm); // Shaders... diff --git a/plugins/GSdx/GSDeviceDX.h b/plugins/GSdx/GSDeviceDX.h index 9262416d77..d05ff44577 100644 --- a/plugins/GSdx/GSDeviceDX.h +++ b/plugins/GSdx/GSDeviceDX.h @@ -262,22 +262,19 @@ public: #pragma pack(pop) +protected: + + struct {D3D_FEATURE_LEVEL level; string model, vs, gs, ps;} m_shader; + uint32 m_msaa; + DXGI_SAMPLE_DESC m_msaa_desc; + + GSTexture* Fetch(int type, int w, int h, bool msaa, int format); + public: - GSDeviceDX() {}; - virtual ~GSDeviceDX() {} + GSDeviceDX(); + virtual ~GSDeviceDX(); - virtual bool Create(GSWnd* wnd) - { - return __super::Create( wnd ); - } - - virtual bool Reset(int w, int h) - { - return __super::Reset( w, h ); - } - - //virtual void Present(const GSVector4i& r, int shader); - //virtual void Flip() {} + bool SetFeatureLevel(D3D_FEATURE_LEVEL level, bool compat_mode); virtual void SetupIA(const void* vertices, int count, int prim) = 0; virtual void SetupVS(VSSelector sel, const VSConstantBuffer* cb) = 0; @@ -285,8 +282,30 @@ public: virtual void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel) = 0; virtual void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix) = 0; - virtual void SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1 (&iaVertices)[4], bool datm)=0; + virtual void SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* vertices, bool datm) = 0; virtual bool HasStencil() = 0; virtual bool HasDepth32() = 0; + + template void PrepareShaderMacro(vector& dst, const T* src) + { + dst.clear(); + + while(src && src->Definition && src->Name) + { + dst.push_back(*src++); + } + + T m; + + m.Name = "SHADER_MODEL"; + m.Definition = m_shader.model.c_str(); + + dst.push_back(m); + + m.Name = NULL; + m.Definition = NULL; + + dst.push_back(m); + } }; diff --git a/plugins/GSdx/GSRenderer.cpp b/plugins/GSdx/GSRenderer.cpp index 53b0a39261..ed8d0ffe8c 100644 --- a/plugins/GSdx/GSRenderer.cpp +++ b/plugins/GSdx/GSRenderer.cpp @@ -375,8 +375,6 @@ void GSRenderer::VSync(int field) LeaveCriticalSection(&m_pGSsetTitle_Crit); } - - } else { diff --git a/plugins/GSdx/GSRendererDX.h b/plugins/GSdx/GSRendererDX.h index af3f4ac1e1..fc794cc3f4 100644 --- a/plugins/GSdx/GSRendererDX.h +++ b/plugins/GSdx/GSRendererDX.h @@ -53,32 +53,26 @@ public: { } - bool CreateDevice(GSDevice* dev) - { - if(!__super::CreateDevice(dev)) - return false; - - return true; - } - - __forceinline void Draw(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex) + void Draw(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex) { GSDrawingEnvironment& env = m_env; GSDrawingContext* context = m_context; const GSVector2i& rtsize = rt->GetSize(); const GSVector2& rtscale = rt->GetScale(); + bool DATE = m_context->TEST.DATE && context->FRAME.PSM != PSM_PSMCT24; GSTexture *rtcopy = NULL; - assert(m_dev != NULL); + ASSERT(m_dev != NULL); - GSDeviceDX& dev = (GSDeviceDX&)*m_dev; + GSDeviceDX* dev = (GSDeviceDX*)m_dev; if(DATE) { - if (dev.HasStencil()) { + if(dev->HasStencil()) + { GSVector4 s = GSVector4(rtscale.x / rtsize.x, rtscale.y / rtsize.y); GSVector4 o = GSVector4(-1.0f, 1.0f); @@ -93,17 +87,21 @@ public: {GSVector4(dst.z, -dst.w, 0.5f, 1.0f), GSVector2(src.z, src.w)}, }; - dev.SetupDATE(rt, ds, vertices, m_context->TEST.DATM); - } else { - rtcopy = m_dev->CreateRenderTarget(rtsize.x, rtsize.y, false, rt->GetFormat()); + dev->SetupDATE(rt, ds, vertices, m_context->TEST.DATM); + } + else + { + rtcopy = dev->CreateRenderTarget(rtsize.x, rtsize.y, false, rt->GetFormat()); + // I'll use VertexTrace when I consider it more trustworthy - m_dev->CopyRect(rt, rtcopy, GSVector4i(rtsize).zwxy()); + + dev->CopyRect(rt, rtcopy, GSVector4i(rtsize).zwxy()); } } // - dev.BeginScene(); + dev->BeginScene(); // om @@ -160,12 +158,13 @@ public: vs_sel.tme = PRIM->TME; vs_sel.fst = PRIM->FST; - vs_sel.logz = dev.HasDepth32() ? 0 : m_logz ? 1 : 0; + vs_sel.logz = dev->HasDepth32() ? 0 : m_logz ? 1 : 0; vs_sel.rtcopy = !!rtcopy; // The real GS appears to do no masking based on the Z buffer format and writing larger Z values // than the buffer supports seems to be an error condition on the real GS, causing it to crash. // We are probably receiving bad coordinates from VU1 in these cases. + if(om_dssel.ztst >= ZTST_ALWAYS && om_dssel.zwe) { if(context->ZBUF.PSM == PSM_PSMZ24) @@ -210,10 +209,12 @@ public: // //The resulting shifted output aligns better with common blending / corona / blurring effects, //but introduces a few bad pixels on the edges. - if (rt->LikelyOffset == true) + + if(rt->LikelyOffset) { - //DX9 has pixelcenter set to 0.0, so give it some value here - if (m_pixelcenter.x == 0 && m_pixelcenter.y == 0) { ox2 = -0.0003f; oy2 = -0.0003f; } + // DX9 has pixelcenter set to 0.0, so give it some value here + + if(m_pixelcenter.x == 0 && m_pixelcenter.y == 0) { ox2 = -0.0003f; oy2 = -0.0003f; } ox2 *= rt->OffsetHack_modx; oy2 *= rt->OffsetHack_mody; @@ -221,6 +222,7 @@ public: vs_cb.VertexScale = GSVector4(sx, -sy, ldexpf(1, -32), 0.0f); vs_cb.VertexOffset = GSVector4(ox * sx + ox2 + 1, -(oy * sy + oy2 + 1), 0.0f, -1.0f); + // gs GSDeviceDX::GSSelector gs_sel; @@ -236,13 +238,18 @@ public: if(DATE) { - if (dev.HasStencil()) + if(dev->HasStencil()) + { om_dssel.date = 1; + } else + { ps_sel.date = 1 + context->TEST.DATM; + } } - if (env.COLCLAMP.CLAMP == 0) { + if(env.COLCLAMP.CLAMP == 0) + { ps_sel.colclip = 1; } @@ -250,7 +257,7 @@ public: ps_sel.fba = context->FBA.FBA; ps_sel.aout = context->FRAME.PSM == PSM_PSMCT16 || context->FRAME.PSM == PSM_PSMCT16S || (context->FRAME.FBMSK & 0xff000000) == 0x7f000000 ? 1 : 0; - if (UserHacks_AlphaHack) ps_sel.aout = 1; + if(UserHacks_AlphaHack) ps_sel.aout = 1; if(PRIM->FGE) { @@ -331,26 +338,26 @@ public: GSVector4i scissor = GSVector4i(GSVector4(rtscale).xyxy() * context->scissor.in).rintersect(GSVector4i(rtsize).zwxy()); - dev.OMSetRenderTargets(rt, ds, &scissor); - dev.PSSetShaderResource(0, tex ? tex->m_texture : NULL); - dev.PSSetShaderResource(1, tex ? tex->m_palette : NULL); - dev.PSSetShaderResource(2, rtcopy); + dev->OMSetRenderTargets(rt, ds, &scissor); + dev->PSSetShaderResource(0, tex ? tex->m_texture : NULL); + dev->PSSetShaderResource(1, tex ? tex->m_palette : NULL); + dev->PSSetShaderResource(2, rtcopy); uint8 afix = context->ALPHA.FIX; - dev.SetupOM(om_dssel, om_bsel, afix); - dev.SetupIA(m_vertices, m_count, m_topology); - dev.SetupVS(vs_sel, &vs_cb); - dev.SetupGS(gs_sel); - dev.SetupPS(ps_sel, &ps_cb, ps_ssel); + dev->SetupOM(om_dssel, om_bsel, afix); + dev->SetupIA(m_vertices, m_count, m_topology); + dev->SetupVS(vs_sel, &vs_cb); + dev->SetupGS(gs_sel); + dev->SetupPS(ps_sel, &ps_cb, ps_ssel); // draw if(context->TEST.DoFirstPass()) { - dev.DrawPrimitive(); + dev->DrawPrimitive(); - if (env.COLCLAMP.CLAMP == 0) + if(env.COLCLAMP.CLAMP == 0) { GSDeviceDX::OMBlendSelector om_bselneg(om_bsel); GSDeviceDX::PSSelector ps_selneg(ps_sel); @@ -358,10 +365,10 @@ public: om_bselneg.negative = 1; ps_selneg.colclip = 2; - dev.SetupOM(om_dssel, om_bselneg, afix); - dev.SetupPS(ps_selneg, &ps_cb, ps_ssel); + dev->SetupOM(om_dssel, om_bselneg, afix); + dev->SetupPS(ps_selneg, &ps_cb, ps_ssel); - dev.DrawPrimitive(); + dev->DrawPrimitive(); } } @@ -386,7 +393,7 @@ public: break; } - dev.SetupPS(ps_sel, &ps_cb, ps_ssel); + dev->SetupPS(ps_sel, &ps_cb, ps_ssel); bool z = om_dssel.zwe; bool r = om_bsel.wr; @@ -411,11 +418,11 @@ public: om_bsel.wb = b; om_bsel.wa = a; - dev.SetupOM(om_dssel, om_bsel, afix); + dev->SetupOM(om_dssel, om_bsel, afix); - dev.DrawPrimitive(); + dev->DrawPrimitive(); - if (env.COLCLAMP.CLAMP == 0) + if(env.COLCLAMP.CLAMP == 0) { GSDeviceDX::OMBlendSelector om_bselneg(om_bsel); GSDeviceDX::PSSelector ps_selneg(ps_sel); @@ -423,17 +430,17 @@ public: om_bselneg.negative = 1; ps_selneg.colclip = 2; - dev.SetupOM(om_dssel, om_bselneg, afix); - dev.SetupPS(ps_selneg, &ps_cb, ps_ssel); + dev->SetupOM(om_dssel, om_bselneg, afix); + dev->SetupPS(ps_selneg, &ps_cb, ps_ssel); - dev.DrawPrimitive(); + dev->DrawPrimitive(); } } } - dev.EndScene(); + dev->EndScene(); - m_dev->Recycle(rtcopy); + dev->Recycle(rtcopy); if(om_dssel.fba) UpdateFBA(rt); } diff --git a/plugins/GSdx/GSState.h b/plugins/GSdx/GSState.h index 49e55eab05..037039747b 100644 --- a/plugins/GSdx/GSState.h +++ b/plugins/GSdx/GSState.h @@ -149,6 +149,7 @@ protected: InitVertexKick2(T, GS_LINELIST) \ InitVertexKick2(T, GS_LINESTRIP) \ InitVertexKick2(T, GS_TRIANGLELIST) \ + InitVertexKick2(T, GS_TRIANGLESTRIP) \ InitVertexKick2(T, GS_TRIANGLEFAN) \ InitVertexKick2(T, GS_SPRITE) \ InitVertexKick2(T, GS_INVALID) \ diff --git a/plugins/GSdx/GSdx.vcxproj b/plugins/GSdx/GSdx.vcxproj index c0be26f4b9..ff72d15134 100644 --- a/plugins/GSdx/GSdx.vcxproj +++ b/plugins/GSdx/GSdx.vcxproj @@ -717,6 +717,7 @@ + diff --git a/plugins/GSdx/GSdx.vcxproj.filters b/plugins/GSdx/GSdx.vcxproj.filters index 2b1cf23e1d..793291c7e9 100644 --- a/plugins/GSdx/GSdx.vcxproj.filters +++ b/plugins/GSdx/GSdx.vcxproj.filters @@ -276,6 +276,9 @@ Source Files + + Source Files + diff --git a/plugins/GSdx/GSdx_vs2008.vcproj b/plugins/GSdx/GSdx_vs2008.vcproj index 0a5587138f..0d95c2ebff 100644 --- a/plugins/GSdx/GSdx_vs2008.vcproj +++ b/plugins/GSdx/GSdx_vs2008.vcproj @@ -1155,6 +1155,10 @@ RelativePath=".\GSDevice9.cpp" > + + diff --git a/plugins/GSdx/stdafx.cpp b/plugins/GSdx/stdafx.cpp index 81ff220e70..24e0d51c81 100644 --- a/plugins/GSdx/stdafx.cpp +++ b/plugins/GSdx/stdafx.cpp @@ -44,7 +44,7 @@ string format(const char* fmt, ...) void* pcsx2_aligned_malloc(size_t size, size_t alignment) { - assert(alignment <= 0x8000); + ASSERT(alignment <= 0x8000); uptr r = (uptr)malloc(size + --alignment + 2); uptr o = (r + 2 + alignment) & ~(uptr)alignment; if (!r) return NULL; diff --git a/plugins/GSdx/vsprops/common.props b/plugins/GSdx/vsprops/common.props index c941b44186..a5343af22f 100644 --- a/plugins/GSdx/vsprops/common.props +++ b/plugins/GSdx/vsprops/common.props @@ -11,7 +11,7 @@ false Level4 ProgramDatabase - 4996;4995;4324;4100;4101;4201;%(DisableSpecificWarnings) + 4996;4995;4324;4100;4101;4201;4556;%(DisableSpecificWarnings) $(DXSDK_DIR)include true diff --git a/plugins/GSdx/vsprops/common.vsprops b/plugins/GSdx/vsprops/common.vsprops index b02cc529b6..d81536421d 100644 --- a/plugins/GSdx/vsprops/common.vsprops +++ b/plugins/GSdx/vsprops/common.vsprops @@ -7,12 +7,12 @@