Just moving code around.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4312 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gabest11 2011-02-18 03:50:12 +00:00
parent d44def8c0b
commit d23d7e2617
16 changed files with 108 additions and 156 deletions

View File

@ -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<GSTexture*>::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;
}

View File

@ -52,8 +52,6 @@ class GSDevice : public GSAlignedClass<32>
{
list<GSTexture*> 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<class T> void PrepareShaderMacro(vector<T>& 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();
};

View File

@ -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);

View File

@ -121,7 +121,7 @@ public: // TODO
CComPtr<ID3D11BlendState> 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...

View File

@ -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

View File

@ -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...

View File

@ -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<class T> void PrepareShaderMacro(vector<T>& 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);
}
};

View File

@ -375,8 +375,6 @@ void GSRenderer::VSync(int field)
LeaveCriticalSection(&m_pGSsetTitle_Crit);
}
}
else
{

View File

@ -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);
}

View File

@ -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) \

View File

@ -717,6 +717,7 @@
<ClCompile Include="GSDevice.cpp" />
<ClCompile Include="GSDevice11.cpp" />
<ClCompile Include="GSDevice9.cpp" />
<ClCompile Include="GSDeviceDX.cpp" />
<ClCompile Include="GSDeviceNull.cpp" />
<ClCompile Include="GSDialog.cpp" />
<ClCompile Include="GSDirtyRect.cpp" />

View File

@ -276,6 +276,9 @@
<ClCompile Include="GPUState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSDeviceDX.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="GS.h">

View File

@ -1155,6 +1155,10 @@
RelativePath=".\GSDevice9.cpp"
>
</File>
<File
RelativePath=".\GSDeviceDX.cpp"
>
</File>
<File
RelativePath=".\GSDeviceNull.cpp"
>

View File

@ -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;

View File

@ -11,7 +11,7 @@
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4996;4995;4324;4100;4101;4201;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DisableSpecificWarnings>4996;4995;4324;4100;4101;4201;4556;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(DXSDK_DIR)include</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>

View File

@ -7,12 +7,12 @@
<Tool
Name="VCCLCompilerTool"
EnableIntrinsicFunctions="true"
PreprocessorDefinitions="WIN32;_WINDOWS;_WIN32_WINNT=0x500;GLEW_STATIC"
PreprocessorDefinitions="WIN32;_WINDOWS;_WIN32_WINNT=0x500"
FloatingPointModel="2"
RuntimeTypeInfo="false"
WarningLevel="4"
DebugInformationFormat="3"
DisableSpecificWarnings="4995;4324"
DisableSpecificWarnings="4996;4995;4324;4100;4101;4201;4556"
/>
<Tool
Name="VCLinkerTool"