diff --git a/plugins/GSdx/GPUSettingsDlg.cpp b/plugins/GSdx/GPUSettingsDlg.cpp index bfc1871367..815a6d77f8 100644 --- a/plugins/GSdx/GPUSettingsDlg.cpp +++ b/plugins/GSdx/GPUSettingsDlg.cpp @@ -30,7 +30,8 @@ GSSetting GPUSettingsDlg::g_renderers[] = {0, "Direct3D7 (Software)", NULL}, {1, "Direct3D9 (Software)", NULL}, {2, "Direct3D10 (Software)", NULL}, -// {3, "Null (Null)", NULL}, + {3, "Direct3D11 (Software)", NULL}, +// {4, "Null (Null)", NULL}, }; GSSetting GPUSettingsDlg::g_filter[] = @@ -105,12 +106,14 @@ void GPUSettingsDlg::OnInit() } bool isdx10avail = GSUtil::IsDirect3D10Available(); + bool isdx11avail = GSUtil::IsDirect3D11Available(); vector renderers; for(size_t i = 0; i < countof(g_renderers); i++) { if(i >= 3 && i <= 5 && !isdx10avail) continue; + if(i >= 6 && i <= 8 && !isdx11avail) continue; renderers.push_back(g_renderers[i]); } @@ -186,10 +189,12 @@ void GPUSettingsDlg::UpdateControls() { bool dx9 = i == 1; bool dx10 = i == 2; - bool sw = i >= 0 && i <= 2; + bool dx11 = i == 3; + bool sw = i >= 0 && i <= 3; ShowWindow(GetDlgItem(m_hWnd, IDC_LOGO9), dx9 ? SW_SHOW : SW_HIDE); ShowWindow(GetDlgItem(m_hWnd, IDC_LOGO10), dx10 ? SW_SHOW : SW_HIDE); + // TODO: ShowWindow(GetDlgItem(m_hWnd, IDC_LOGO11), dx11 ? SW_SHOW : SW_HIDE); EnableWindow(GetDlgItem(m_hWnd, IDC_SCALE), sw); EnableWindow(GetDlgItem(m_hWnd, IDC_SWTHREADS_EDIT), sw); diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index bf7ce343c9..430bb23407 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -23,6 +23,7 @@ #include "GSUtil.h" #include "GSRendererHW9.h" #include "GSRendererHW10.h" +#include "GSRendererHW11.h" #include "GSRendererOGL.h" #include "GSRendererSW.h" #include "GSRendererNull.h" @@ -126,13 +127,16 @@ static INT32 GSopen(void* dsp, char* title, int mt, int renderer) case 3: s_gs = new GSRendererHW10(s_basemem, !!mt, s_irq); break; case 4: s_gs = new GSRendererSW(s_basemem, !!mt, s_irq, new GSDevice10()); break; case 5: s_gs = new GSRendererNull(s_basemem, !!mt, s_irq, new GSDevice10()); break; + case 6: s_gs = new GSRendererHW11(s_basemem, !!mt, s_irq); break; + case 7: s_gs = new GSRendererSW(s_basemem, !!mt, s_irq, new GSDevice11()); break; + case 8: s_gs = new GSRendererNull(s_basemem, !!mt, s_irq, new GSDevice11()); break; #if 0 - case 6: s_gs = new GSRendererOGL(s_basemem, !!mt, s_irq); break; - case 7: s_gs = new GSRendererSW(s_basemem, !!mt, s_irq, new GSDeviceOGL()); break; - case 8: s_gs = new GSRendererNull(s_basemem, !!mt, s_irq, new GSDeviceOGL()); break; + case 9: s_gs = new GSRendererOGL(s_basemem, !!mt, s_irq); break; + case 10: s_gs = new GSRendererSW(s_basemem, !!mt, s_irq, new GSDeviceOGL()); break; + case 11: s_gs = new GSRendererNull(s_basemem, !!mt, s_irq, new GSDeviceOGL()); break; #endif - case 9: s_gs = new GSRendererSW(s_basemem, !!mt, s_irq, new GSDeviceNull()); break; - case 10: s_gs = new GSRendererNull(s_basemem, !!mt, s_irq, new GSDeviceNull()); break; + case 12: s_gs = new GSRendererSW(s_basemem, !!mt, s_irq, new GSDeviceNull()); break; + case 13: s_gs = new GSRendererNull(s_basemem, !!mt, s_irq, new GSDeviceNull()); break; } if(!s_gs->Create(title)) diff --git a/plugins/GSdx/GSDevice.h b/plugins/GSdx/GSDevice.h index d512fd37b5..59799e814d 100644 --- a/plugins/GSdx/GSDevice.h +++ b/plugins/GSdx/GSDevice.h @@ -103,4 +103,26 @@ public: void Merge(GSTexture* st[2], GSVector4* sr, GSVector4* dr, const GSVector2i& fs, bool slbg, bool mmod, const GSVector4& c); void Interlace(const GSVector2i& ds, int field, int mode, float yoffset); + + template void PrepareShaderMacro(vector& dst, const T* src, const char* model) + { + dst.clear(); + + while(src && src->Definition && src->Name) + { + dst.push_back(*src++); + } + + T m; + + m.Name = "SHADER_MODEL"; + m.Definition = model; + + dst.push_back(m); + + m.Name = NULL; + m.Definition = NULL; + + dst.push_back(m); + } }; diff --git a/plugins/GSdx/GSDevice10.cpp b/plugins/GSdx/GSDevice10.cpp index 084b8d191a..7f3fbf2791 100644 --- a/plugins/GSdx/GSDevice10.cpp +++ b/plugins/GSdx/GSDevice10.cpp @@ -96,16 +96,6 @@ bool GSDevice10::Create(GSWnd* wnd, bool vsync) if(FAILED(hr)) return false; - // font -/* - // TODO: the driver crashes on alt-enter when using a font... - - D3DX10_FONT_DESC fd; - memset(&fd, 0, sizeof(fd)); - _tcscpy(fd.FaceName, _T("Arial")); - fd.Height = 20; - D3DX10CreateFontIndirect(m_dev, &fd, &m_font); -*/ // convert D3D10_INPUT_ELEMENT_DESC il_convert[] = @@ -114,11 +104,11 @@ bool GSDevice10::Create(GSWnd* wnd, bool vsync) {"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 16, D3D10_INPUT_PER_VERTEX_DATA, 0}, }; - hr = CompileShader(IDR_CONVERT10_FX, "vs_main", NULL, &m_convert.vs, il_convert, countof(il_convert), &m_convert.il); + hr = CompileShader(IDR_CONVERT_FX, "vs_main", NULL, &m_convert.vs, il_convert, countof(il_convert), &m_convert.il); for(int i = 0; i < countof(m_convert.ps); i++) { - hr = CompileShader(IDR_CONVERT10_FX, format("ps_main%d", i), NULL, &m_convert.ps[i]); + hr = CompileShader(IDR_CONVERT_FX, format("ps_main%d", i), NULL, &m_convert.ps[i]); } memset(&dsd, 0, sizeof(dsd)); @@ -142,14 +132,12 @@ bool GSDevice10::Create(GSWnd* wnd, bool vsync) bd.ByteWidth = sizeof(MergeConstantBuffer); bd.Usage = D3D10_USAGE_DEFAULT; bd.BindFlags = D3D10_BIND_CONSTANT_BUFFER; - bd.CPUAccessFlags = 0; - bd.MiscFlags = 0; hr = m_dev->CreateBuffer(&bd, NULL, &m_merge.cb); for(int i = 0; i < countof(m_merge.ps); i++) { - hr = CompileShader(IDR_MERGE10_FX, format("ps_main%d", i), NULL, &m_merge.ps[i]); + hr = CompileShader(IDR_MERGE_FX, format("ps_main%d", i), NULL, &m_merge.ps[i]); } memset(&bsd, 0, sizeof(bsd)); @@ -172,14 +160,12 @@ bool GSDevice10::Create(GSWnd* wnd, bool vsync) bd.ByteWidth = sizeof(InterlaceConstantBuffer); bd.Usage = D3D10_USAGE_DEFAULT; bd.BindFlags = D3D10_BIND_CONSTANT_BUFFER; - bd.CPUAccessFlags = 0; - bd.MiscFlags = 0; hr = m_dev->CreateBuffer(&bd, NULL, &m_interlace.cb); for(int i = 0; i < countof(m_interlace.ps); i++) { - hr = CompileShader(IDR_INTERLACE10_FX, format("ps_main%d", i), NULL, &m_interlace.ps[i]); + hr = CompileShader(IDR_INTERLACE_FX, format("ps_main%d", i), NULL, &m_interlace.ps[i]); } // @@ -743,13 +729,17 @@ void GSDevice10::OMSetRenderTargets(GSTexture* rt, GSTexture* ds) } } -HRESULT GSDevice10::CompileShader(uint32 id, const string& entry, D3D10_SHADER_MACRO* macro, ID3D10VertexShader** ps, D3D10_INPUT_ELEMENT_DESC* layout, int count, ID3D10InputLayout** il) +HRESULT GSDevice10::CompileShader(uint32 id, const string& entry, D3D10_SHADER_MACRO* macro, ID3D10VertexShader** vs, D3D10_INPUT_ELEMENT_DESC* layout, int count, ID3D10InputLayout** il) { HRESULT hr; + vector m; + + PrepareShaderMacro(m, macro, "0x400"); + CComPtr shader, error; - hr = D3DX10CompileFromResource(theApp.GetModuleHandle(), MAKEINTRESOURCE(id), NULL, macro, NULL, entry.c_str(), "vs_4_0", 0, 0, NULL, &shader, &error, NULL); + hr = D3DX10CompileFromResource(theApp.GetModuleHandle(), MAKEINTRESOURCE(id), NULL, &m[0], NULL, entry.c_str(), "vs_4_0", 0, 0, NULL, &shader, &error, NULL); if(error) { @@ -761,7 +751,7 @@ HRESULT GSDevice10::CompileShader(uint32 id, const string& entry, D3D10_SHADER_M return hr; } - hr = m_dev->CreateVertexShader((void*)shader->GetBufferPointer(), shader->GetBufferSize(), ps); + hr = m_dev->CreateVertexShader((void*)shader->GetBufferPointer(), shader->GetBufferSize(), vs); if(FAILED(hr)) { @@ -782,9 +772,13 @@ HRESULT GSDevice10::CompileShader(uint32 id, const string& entry, D3D10_SHADER_M { HRESULT hr; + vector m; + + PrepareShaderMacro(m, macro, "0x400"); + CComPtr shader, error; - hr = D3DX10CompileFromResource(theApp.GetModuleHandle(), MAKEINTRESOURCE(id), NULL, macro, NULL, entry.c_str(), "gs_4_0", 0, 0, NULL, &shader, &error, NULL); + hr = D3DX10CompileFromResource(theApp.GetModuleHandle(), MAKEINTRESOURCE(id), NULL, &m[0], NULL, entry.c_str(), "gs_4_0", 0, 0, NULL, &shader, &error, NULL); if(error) { @@ -810,9 +804,13 @@ HRESULT GSDevice10::CompileShader(uint32 id, const string& entry, D3D10_SHADER_M { HRESULT hr; + vector m; + + PrepareShaderMacro(m, macro, "0x400"); + CComPtr shader, error; - hr = D3DX10CompileFromResource(theApp.GetModuleHandle(), MAKEINTRESOURCE(id), NULL, macro, NULL, entry.c_str(), "ps_4_0", 0, 0, NULL, &shader, &error, NULL); + hr = D3DX10CompileFromResource(theApp.GetModuleHandle(), MAKEINTRESOURCE(id), NULL, &m[0], NULL, entry.c_str(), "ps_4_0", 0, 0, NULL, &shader, &error, NULL); if(error) { diff --git a/plugins/GSdx/GSDevice9.cpp b/plugins/GSdx/GSDevice9.cpp index a88a24f97e..37ef14415c 100644 --- a/plugins/GSdx/GSDevice9.cpp +++ b/plugins/GSdx/GSDevice9.cpp @@ -133,11 +133,11 @@ bool GSDevice9::Create(GSWnd* wnd, bool vsync) D3DDECL_END() }; - CompileShader(IDR_CONVERT9_FX, "vs_main", NULL, &m_convert.vs, il_convert, countof(il_convert), &m_convert.il); + CompileShader(IDR_CONVERT_FX, "vs_main", NULL, &m_convert.vs, il_convert, countof(il_convert), &m_convert.il); for(int i = 0; i < countof(m_convert.ps); i++) { - CompileShader(IDR_CONVERT9_FX, format("ps_main%d", i), NULL, &m_convert.ps[i]); + CompileShader(IDR_CONVERT_FX, format("ps_main%d", i), NULL, &m_convert.ps[i]); } m_convert.dss.DepthEnable = false; @@ -164,7 +164,7 @@ bool GSDevice9::Create(GSWnd* wnd, bool vsync) for(int i = 0; i < countof(m_merge.ps); i++) { - CompileShader(IDR_MERGE9_FX, format("ps_main%d", i), NULL, &m_merge.ps[i]); + CompileShader(IDR_MERGE_FX, format("ps_main%d", i), NULL, &m_merge.ps[i]); } m_merge.bs.BlendEnable = true; @@ -180,7 +180,7 @@ bool GSDevice9::Create(GSWnd* wnd, bool vsync) for(int i = 0; i < countof(m_interlace.ps); i++) { - CompileShader(IDR_INTERLACE9_FX, format("ps_main%d", i), NULL, &m_interlace.ps[i]); + CompileShader(IDR_INTERLACE_FX, format("ps_main%d", i), NULL, &m_interlace.ps[i]); } // @@ -952,25 +952,32 @@ static HRESULT LoadShader(uint32 id, LPCSTR& data, uint32& size) HRESULT GSDevice9::CompileShader(uint32 id, const string& entry, const D3DXMACRO* macro, IDirect3DVertexShader9** vs, const D3DVERTEXELEMENT9* layout, int count, IDirect3DVertexDeclaration9** il) { const char* target; + const char* model; if(m_d3dcaps.VertexShaderVersion >= D3DVS_VERSION(3, 0)) { target = "vs_3_0"; + model = "0x300"; } else if(m_d3dcaps.VertexShaderVersion >= D3DVS_VERSION(2, 0)) { target = "vs_2_0"; + model = "0x200"; } else { return E_FAIL; } + vector m; + + PrepareShaderMacro(m, macro, model); + HRESULT hr; CComPtr shader, error; - // FIXME: hr = D3DXCompileShaderFromResource(theApp.GetModuleHandle(), MAKEINTRESOURCE(id), macro, NULL, entry.c_str(), target, 0, &shader, &error, NULL); + // FIXME: hr = D3DXCompileShaderFromResource(theApp.GetModuleHandle(), MAKEINTRESOURCE(id), &m[0], NULL, entry.c_str(), target, 0, &shader, &error, NULL); LPCSTR data; uint32 size; @@ -979,7 +986,7 @@ HRESULT GSDevice9::CompileShader(uint32 id, const string& entry, const D3DXMACRO if(FAILED(hr)) return E_FAIL; - hr = D3DXCompileShader(data, size, macro, NULL, entry.c_str(), target, 0, &shader, &error, NULL); + hr = D3DXCompileShader(data, size, &m[0], NULL, entry.c_str(), target, 0, &shader, &error, NULL); if(SUCCEEDED(hr)) { @@ -1010,27 +1017,34 @@ HRESULT GSDevice9::CompileShader(uint32 id, const string& entry, const D3DXMACRO HRESULT GSDevice9::CompileShader(uint32 id, const string& entry, const D3DXMACRO* macro, IDirect3DPixelShader9** ps) { const char* target = NULL; + const char* model; uint32 flags = 0; if(m_d3dcaps.PixelShaderVersion >= D3DPS_VERSION(3, 0)) { target = "ps_3_0"; + model = "0x300"; flags |= D3DXSHADER_AVOID_FLOW_CONTROL; } else if(m_d3dcaps.PixelShaderVersion >= D3DPS_VERSION(2, 0)) { target = "ps_2_0"; + model = "0x200"; } else { return false; } + vector m; + + PrepareShaderMacro(m, macro, model); + HRESULT hr; CComPtr shader, error; - // FIXME: hr = D3DXCompileShaderFromResource(theApp.GetModuleHandle(), MAKEINTRESOURCE(id), macro, NULL, entry.c_str(), target, flags, &shader, &error, NULL); + // FIXME: hr = D3DXCompileShaderFromResource(theApp.GetModuleHandle(), MAKEINTRESOURCE(id), &m[0], NULL, entry.c_str(), target, flags, &shader, &error, NULL); LPCSTR data; uint32 size; @@ -1039,7 +1053,7 @@ HRESULT GSDevice9::CompileShader(uint32 id, const string& entry, const D3DXMACRO if(FAILED(hr)) return E_FAIL; - hr = D3DXCompileShader(data, size, macro, NULL, entry.c_str(), target, 0, &shader, &error, NULL); + hr = D3DXCompileShader(data, size, &m[0], NULL, entry.c_str(), target, 0, &shader, &error, NULL); if(SUCCEEDED(hr)) { diff --git a/plugins/GSdx/GSRenderer.cpp b/plugins/GSdx/GSRenderer.cpp index 03a96686c9..8af6720dfc 100644 --- a/plugins/GSdx/GSRenderer.cpp +++ b/plugins/GSdx/GSRenderer.cpp @@ -251,7 +251,6 @@ bool GSRenderer::Merge(int field) return true; } - void GSRenderer::VSync(int field) { GSPerfMonAutoTimer pmat(m_perfmon); diff --git a/plugins/GSdx/GSSettingsDlg.cpp b/plugins/GSdx/GSSettingsDlg.cpp index 3142679119..002c5ae1e7 100644 --- a/plugins/GSdx/GSSettingsDlg.cpp +++ b/plugins/GSdx/GSSettingsDlg.cpp @@ -33,13 +33,16 @@ GSSetting GSSettingsDlg::g_renderers[] = {3, "Direct3D10 (Hardware)", NULL}, {4, "Direct3D10 (Software)", NULL}, {5, "Direct3D10 (Null)", NULL}, + {6, "Direct3D11 (Hardware)", NULL}, + {7, "Direct3D11 (Software)", NULL}, + {8, "Direct3D11 (Null)", NULL}, #if 0 - {6, "OpenGL (Hardware)", NULL}, - {7, "OpenGL (Software)", NULL}, - {8, "OpenGL (Null)", NULL}, + {9, "OpenGL (Hardware)", NULL}, + {10, "OpenGL (Software)", NULL}, + {11, "OpenGL (Null)", NULL}, #endif - {9, "Null (Software)", NULL}, - {10, "Null (Null)", NULL}, + {12, "Null (Software)", NULL}, + {13, "Null (Null)", NULL}, }; GSSetting GSSettingsDlg::g_interlace[] = @@ -101,12 +104,14 @@ void GSSettingsDlg::OnInit() } bool isdx10avail = GSUtil::IsDirect3D10Available(); + bool isdx11avail = GSUtil::IsDirect3D11Available(); vector renderers; for(size_t i = 0; i < countof(g_renderers); i++) { if(i >= 3 && i <= 5 && !isdx10avail) continue; + if(i >= 6 && i <= 8 && !isdx11avail) continue; renderers.push_back(g_renderers[i]); } @@ -197,13 +202,16 @@ void GSSettingsDlg::UpdateControls() { bool dx9 = i >= 0 && i <= 2; bool dx10 = i >= 3 && i <= 5; - bool ogl = i >= 6 && i <= 8; - bool hw = i == 0 || i == 3 || i == 6; - bool sw = i == 1 || i == 4 || i == 7; + bool dx11 = i >= 6 && i <= 8; + bool ogl = i >= 9 && i <= 12; + bool hw = i == 0 || i == 3 || i == 6 || i == 9; + bool sw = i == 1 || i == 4 || i == 7 || i == 10; bool native = !!IsDlgButtonChecked(m_hWnd, IDC_NATIVERES); ShowWindow(GetDlgItem(m_hWnd, IDC_LOGO9), dx9 ? SW_SHOW : SW_HIDE); ShowWindow(GetDlgItem(m_hWnd, IDC_LOGO10), dx10 ? SW_SHOW : SW_HIDE); + // TODO: ShowWindow(GetDlgItem(m_hWnd, IDC_LOGO11), dx11 ? SW_SHOW : SW_HIDE); + // TODO: ShowWindow(GetDlgItem(m_hWnd, IDC_LOGO_OGL), ogl ? SW_SHOW : SW_HIDE); EnableWindow(GetDlgItem(m_hWnd, IDC_RESOLUTION), dx9); EnableWindow(GetDlgItem(m_hWnd, IDC_RESX), hw && !native); diff --git a/plugins/GSdx/GSTextureFX10.cpp b/plugins/GSdx/GSTextureFX10.cpp index a3b04e1cc9..3005ca5918 100644 --- a/plugins/GSdx/GSTextureFX10.cpp +++ b/plugins/GSdx/GSTextureFX10.cpp @@ -72,7 +72,7 @@ bool GSTextureFX10::Create(GSDevice10* dev) memset(&sd, 0, sizeof(sd)); - sd.Filter = D3D10_ENCODE_BASIC_FILTER(D3D10_FILTER_TYPE_POINT, D3D10_FILTER_TYPE_POINT, D3D10_FILTER_TYPE_POINT, false); + sd.Filter = D3D10_FILTER_MIN_MAG_MIP_POINT; sd.AddressU = D3D10_TEXTURE_ADDRESS_CLAMP; sd.AddressV = D3D10_TEXTURE_ADDRESS_CLAMP; sd.AddressW = D3D10_TEXTURE_ADDRESS_CLAMP; @@ -133,7 +133,7 @@ bool GSTextureFX10::SetupVS(VSSelector sel, const VSConstantBuffer* cb) CComPtr il; CComPtr vs; - m_dev->CompileShader(IDR_TFX10_FX, "vs_main", macro, &vs, layout, countof(layout), &il); + m_dev->CompileShader(IDR_TFX_FX, "vs_main", macro, &vs, layout, countof(layout), &il); if(m_il == NULL) { @@ -178,12 +178,12 @@ bool GSTextureFX10::SetupGS(GSSelector sel) D3D10_SHADER_MACRO macro[] = { - {"IIP", str[0].c_str()}, - {"PRIM", str[1].c_str()}, + {"GS_IIP", str[0].c_str()}, + {"GS_PRIM", str[1].c_str()}, {NULL, NULL}, }; - hr = m_dev->CompileShader(IDR_TFX10_FX, "gs_main", macro, &gs); + hr = m_dev->CompileShader(IDR_TFX_FX, "gs_main", macro, &gs); m_gs[sel] = gs; } @@ -230,26 +230,26 @@ void GSTextureFX10::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSampl D3D10_SHADER_MACRO macro[] = { - {"FST", str[0].c_str()}, - {"WMS", str[1].c_str()}, - {"WMT", str[2].c_str()}, - {"BPP", str[3].c_str()}, - {"AEM", str[4].c_str()}, - {"TFX", str[5].c_str()}, - {"TCC", str[6].c_str()}, - {"ATE", str[7].c_str()}, - {"ATST", str[8].c_str()}, - {"FOG", str[9].c_str()}, - {"CLR1", str[10].c_str()}, - {"FBA", str[11].c_str()}, - {"AOUT", str[12].c_str()}, - {"LTF", str[13].c_str()}, + {"PS_FST", str[0].c_str()}, + {"PS_WMS", str[1].c_str()}, + {"PS_WMT", str[2].c_str()}, + {"PS_BPP", str[3].c_str()}, + {"PS_AEM", str[4].c_str()}, + {"PS_TFX", str[5].c_str()}, + {"PS_TCC", str[6].c_str()}, + {"PS_ATE", str[7].c_str()}, + {"PS_ATST", str[8].c_str()}, + {"PS_FOG", str[9].c_str()}, + {"PS_CLR1", str[10].c_str()}, + {"PS_FBA", str[11].c_str()}, + {"PS_AOUT", str[12].c_str()}, + {"PS_LTF", str[13].c_str()}, {NULL, NULL}, }; CComPtr ps; - hr = m_dev->CompileShader(IDR_TFX10_FX, "ps_main", macro, &ps); + hr = m_dev->CompileShader(IDR_TFX_FX, "ps_main", macro, &ps); m_ps[sel] = ps; diff --git a/plugins/GSdx/GSTextureFX9.cpp b/plugins/GSdx/GSTextureFX9.cpp index c303db9652..24694a33ca 100644 --- a/plugins/GSdx/GSTextureFX9.cpp +++ b/plugins/GSdx/GSTextureFX9.cpp @@ -126,7 +126,7 @@ bool GSTextureFX9::SetupVS(VSSelector sel, const VSConstantBuffer* cb) CComPtr il; CComPtr vs; - m_dev->CompileShader(IDR_TFX9_FX, "vs_main", macro, &vs, layout, countof(layout), &il); + m_dev->CompileShader(IDR_TFX_FX, "vs_main", macro, &vs, layout, countof(layout), &il); if(m_il == NULL) { @@ -215,7 +215,7 @@ void GSTextureFX9::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSample CComPtr ps; - hr = m_dev->CompileShader(IDR_TFX9_FX, "ps_main", macro, &ps); + hr = m_dev->CompileShader(IDR_TFX_FX, "ps_main", macro, &ps); m_ps[sel] = ps; diff --git a/plugins/GSdx/GSUtil.cpp b/plugins/GSdx/GSUtil.cpp index 64ce305c5d..4b38666b5c 100644 --- a/plugins/GSdx/GSUtil.cpp +++ b/plugins/GSdx/GSUtil.cpp @@ -172,6 +172,25 @@ bool GSUtil::IsDirect3D10Available() return false; } +bool GSUtil::IsDirect3D11Available() +{ + if(HMODULE hModule = LoadLibrary(_T("d3d11.dll"))) + { + FreeLibrary(hModule); + + return true; + } + + if(HMODULE hModule = LoadLibrary(_T("d3d11_beta.dll"))) + { + FreeLibrary(hModule); + + return true; + } + + return false; +} + char* GSUtil::GetLibName() { static string str; diff --git a/plugins/GSdx/GSUtil.h b/plugins/GSdx/GSUtil.h index bd3f580c6b..f7d81539b4 100644 --- a/plugins/GSdx/GSUtil.h +++ b/plugins/GSdx/GSUtil.h @@ -60,6 +60,7 @@ public: static bool CheckSSE(); static bool IsDirect3D10Available(); + static bool IsDirect3D11Available(); static char* GetLibName(); }; diff --git a/plugins/GSdx/GSVertexHW.h b/plugins/GSdx/GSVertexHW.h index 2e49cd2d20..76a84ed74d 100644 --- a/plugins/GSdx/GSVertexHW.h +++ b/plugins/GSdx/GSVertexHW.h @@ -80,6 +80,8 @@ __declspec(align(16)) union GSVertexHW10 float GetQ() {return q;} }; +typedef GSVertexHW10 GSVertexHW11; // TODO + typedef GSVertexHW9 GSVertexOGL; // TODO #pragma pack(pop) diff --git a/plugins/GSdx/GSdx_vs2010.vcxproj b/plugins/GSdx/GSdx_vs2010.vcxproj index d4e7a8e2b2..8a7fc45bba 100644 --- a/plugins/GSdx/GSdx_vs2010.vcxproj +++ b/plugins/GSdx/GSdx_vs2010.vcxproj @@ -1303,6 +1303,7 @@ + @@ -1320,6 +1321,7 @@ + @@ -1331,14 +1333,17 @@ + + + @@ -1419,6 +1424,7 @@ + @@ -1438,6 +1444,7 @@ + @@ -1450,14 +1457,17 @@ + + + @@ -1481,17 +1491,13 @@ - - + - - + - - - - + + diff --git a/plugins/GSdx/GSdx_vs2010.vcxproj.filters b/plugins/GSdx/GSdx_vs2010.vcxproj.filters index 5cfd89b885..32c080fcf0 100644 --- a/plugins/GSdx/GSdx_vs2010.vcxproj.filters +++ b/plugins/GSdx/GSdx_vs2010.vcxproj.filters @@ -150,6 +150,9 @@ Source Files + + Source Files + Source Files @@ -201,6 +204,9 @@ Source Files + + Source Files + Source Files @@ -234,6 +240,9 @@ Source Files + + Source Files + Source Files @@ -246,6 +255,9 @@ Source Files + + Source Files + Source Files @@ -258,6 +270,9 @@ Source Files + + Source Files + Source Files @@ -443,6 +458,9 @@ Header Files + + Header Files + Header Files @@ -500,6 +518,9 @@ Header Files + + Header Files + Header Files @@ -536,6 +557,9 @@ Header Files + + Header Files + Header Files @@ -548,6 +572,9 @@ Header Files + + Header Files + Header Files @@ -560,6 +587,9 @@ Header Files + + Header Files + Header Files @@ -625,19 +655,13 @@ Source Files - - Shaders - - + Shaders Resource Files - - Shaders - - + Shaders @@ -646,16 +670,10 @@ Resource Files - + Shaders - - Shaders - - - Shaders - - + Shaders diff --git a/plugins/GSdx/res/GSdx.rc2 b/plugins/GSdx/res/GSdx.rc2 index 45a9aad126..793e0342dd 100644 --- a/plugins/GSdx/res/GSdx.rc2 +++ b/plugins/GSdx/res/GSdx.rc2 @@ -10,13 +10,9 @@ ///////////////////////////////////////////////////////////////////////////// // Add manually edited resources here... -IDR_CONVERT9_FX RCDATA "res\\convert9.fx" -IDR_TFX9_FX RCDATA "res\\tfx9.fx" -IDR_MERGE9_FX RCDATA "res\\merge9.fx" -IDR_INTERLACE9_FX RCDATA "res\\interlace9.fx" -IDR_CONVERT10_FX RCDATA "res\\convert10.fx" -IDR_TFX10_FX RCDATA "res\\tfx10.fx" -IDR_MERGE10_FX RCDATA "res\\merge10.fx" -IDR_INTERLACE10_FX RCDATA "res\\interlace10.fx" +IDR_CONVERT_FX RCDATA "res\\convert.fx" +IDR_TFX_FX RCDATA "res\\tfx.fx" +IDR_MERGE_FX RCDATA "res\\merge.fx" +IDR_INTERLACE_FX RCDATA "res\\interlace.fx" ///////////////////////////////////////////////////////////////////////////// diff --git a/plugins/GSdx/res/convert10.fx b/plugins/GSdx/res/convert.fx similarity index 51% rename from plugins/GSdx/res/convert10.fx rename to plugins/GSdx/res/convert.fx index bcdfb22d7a..9749476e6d 100644 --- a/plugins/GSdx/res/convert10.fx +++ b/plugins/GSdx/res/convert.fx @@ -1,3 +1,5 @@ +#if SHADER_MODEL >= 0x400 + struct VS_INPUT { float4 p : POSITION; @@ -92,4 +94,91 @@ float4 ps_main6(PS_INPUT input) : SV_Target0 // diagonal uint4 p = (uint4)input.p; return ps_crt(input, (p.x + (p.y % 3)) % 3); -} \ No newline at end of file +} + +#elif SHADER_MODEL <= 0x300 + +struct VS_INPUT +{ + float4 p : POSITION; + float2 t : TEXCOORD0; +}; + +struct VS_OUTPUT +{ + float4 p : POSITION; + float2 t : TEXCOORD0; +}; + +VS_OUTPUT vs_main(VS_INPUT input) +{ + VS_OUTPUT output; + + output.p = input.p; + output.t = input.t; + + return output; +} + +sampler Texture : register(s0); + +float4 ps_main0(float2 t : TEXCOORD0) : COLOR +{ + return tex2D(Texture, t); +} + +float4 ps_main1(float2 t : TEXCOORD0) : COLOR +{ + float4 c = tex2D(Texture, t); + c.a *= 128.0f / 255; // *= 0.5f is no good here, need to do this in order to get 0x80 for 1.0f (instead of 0x7f) + return c; +} + +float4 ps_main2(float2 t : TEXCOORD0) : COLOR +{ + clip(tex2D(Texture, t).a - (1.0f - 0.9f/256)); + + return 0; +} + +float4 ps_main3(float2 t : TEXCOORD0) : COLOR +{ + clip((1.0f - 0.9f/256) - tex2D(Texture, t).a); + + return 0; +} + +float4 ps_main4() : COLOR +{ + return 1; +} + +float4 ps_crt(float2 t, int i) +{ + float4 mask[4] = + { + float4(1, 0, 0, 0), + float4(0, 1, 0, 0), + float4(0, 0, 1, 0), + float4(1, 1, 1, 0) + }; + + return tex2D(Texture, t) * saturate(mask[i] + 0.5f); +} + +float4 ps_main5(float2 t : TEXCOORD0, float4 vPos : VPOS) : COLOR // triangular +{ + int4 p = (int4)vPos; + + // return ps_crt(t, ((p.x + (p.y % 2) * 3) / 2) % 3); + return ps_crt(t, ((p.x + ((p.y / 2) % 2) * 3) / 2) % 3); +} + +float4 ps_main6(float2 t : TEXCOORD0, float4 vPos : VPOS) : COLOR // diagonal +{ + int4 p = (int4)vPos; + + return ps_crt(t, (p.x + (p.y % 3)) % 3); +} + +#endif \ No newline at end of file diff --git a/plugins/GSdx/res/convert9.fx b/plugins/GSdx/res/convert9.fx deleted file mode 100644 index 1341091681..0000000000 --- a/plugins/GSdx/res/convert9.fx +++ /dev/null @@ -1,82 +0,0 @@ -struct VS_INPUT -{ - float4 p : POSITION; - float2 t : TEXCOORD0; -}; - -struct VS_OUTPUT -{ - float4 p : POSITION; - float2 t : TEXCOORD0; -}; - -VS_OUTPUT vs_main(VS_INPUT input) -{ - VS_OUTPUT output; - - output.p = input.p; - output.t = input.t; - - return output; -} - -sampler Texture : register(s0); - -float4 ps_main0(float2 t : TEXCOORD0) : COLOR -{ - return tex2D(Texture, t); -} - -float4 ps_main1(float2 t : TEXCOORD0) : COLOR -{ - float4 c = tex2D(Texture, t); - c.a *= 128.0f / 255; // *= 0.5f is no good here, need to do this in order to get 0x80 for 1.0f (instead of 0x7f) - return c; -} - -float4 ps_main2(float2 t : TEXCOORD0) : COLOR -{ - clip(tex2D(Texture, t).a - (1.0f - 0.9f/256)); - - return 0; -} - -float4 ps_main3(float2 t : TEXCOORD0) : COLOR -{ - clip((1.0f - 0.9f/256) - tex2D(Texture, t).a); - - return 0; -} - -float4 ps_main4() : COLOR -{ - return 1; -} - -float4 ps_crt(float2 t, int i) -{ - float4 mask[4] = - { - float4(1, 0, 0, 0), - float4(0, 1, 0, 0), - float4(0, 0, 1, 0), - float4(1, 1, 1, 0) - }; - - return tex2D(Texture, t) * saturate(mask[i] + 0.5f); -} - -float4 ps_main5(float2 t : TEXCOORD0, float4 vPos : VPOS) : COLOR // triangular -{ - int4 p = (int4)vPos; - - // return ps_crt(t, ((p.x + (p.y % 2) * 3) / 2) % 3); - return ps_crt(t, ((p.x + ((p.y / 2) % 2) * 3) / 2) % 3); -} - -float4 ps_main6(float2 t : TEXCOORD0, float4 vPos : VPOS) : COLOR // diagonal -{ - int4 p = (int4)vPos; - - return ps_crt(t, (p.x + (p.y % 3)) % 3); -} diff --git a/plugins/GSdx/res/interlace10.fx b/plugins/GSdx/res/interlace.fx similarity index 50% rename from plugins/GSdx/res/interlace10.fx rename to plugins/GSdx/res/interlace.fx index 86fa44dd75..f726051260 100644 --- a/plugins/GSdx/res/interlace10.fx +++ b/plugins/GSdx/res/interlace.fx @@ -1,3 +1,4 @@ +#if SHADER_MODEL >= 0x400 Texture2D Texture; SamplerState Sampler; @@ -41,3 +42,42 @@ float4 ps_main3(PS_INPUT input) : SV_Target0 { return Texture.Sample(Sampler, input.t); } + +#elif SHADER_MODEL <= 0x300 + +sampler s0 : register(s0); + +float4 Params1 : register(c0); + +#define ZrH (Params1.xy) +#define hH (Params1.z) + +float4 ps_main0(float2 tex : TEXCOORD0) : COLOR +{ + clip(frac(tex.y * hH) - 0.5); + + return tex2D(s0, tex); +} + +float4 ps_main1(float2 tex : TEXCOORD0) : COLOR +{ + clip(0.5 - frac(tex.y * hH)); + + return tex2D(s0, tex); +} + +float4 ps_main2(float2 tex : TEXCOORD0) : COLOR +{ + float4 c0 = tex2D(s0, tex - ZrH); + float4 c1 = tex2D(s0, tex); + float4 c2 = tex2D(s0, tex + ZrH); + + return (c0 + c1 * 2 + c2) / 4; +} + +float4 ps_main3(float2 tex : TEXCOORD0) : COLOR +{ + return tex2D(s0, tex); +} + +#endif diff --git a/plugins/GSdx/res/interlace9.fx b/plugins/GSdx/res/interlace9.fx deleted file mode 100644 index 5f5db8bf9c..0000000000 --- a/plugins/GSdx/res/interlace9.fx +++ /dev/null @@ -1,35 +0,0 @@ - -sampler s0 : register(s0); - -float4 Params1 : register(c0); - -#define ZrH (Params1.xy) -#define hH (Params1.z) - -float4 ps_main0(float2 tex : TEXCOORD0) : COLOR -{ - clip(frac(tex.y * hH) - 0.5); - - return tex2D(s0, tex); -} - -float4 ps_main1(float2 tex : TEXCOORD0) : COLOR -{ - clip(0.5 - frac(tex.y * hH)); - - return tex2D(s0, tex); -} - -float4 ps_main2(float2 tex : TEXCOORD0) : COLOR -{ - float4 c0 = tex2D(s0, tex - ZrH); - float4 c1 = tex2D(s0, tex); - float4 c2 = tex2D(s0, tex + ZrH); - - return (c0 + c1 * 2 + c2) / 4; -} - -float4 ps_main3(float2 tex : TEXCOORD0) : COLOR -{ - return tex2D(s0, tex); -} diff --git a/plugins/GSdx/res/merge.fx b/plugins/GSdx/res/merge.fx new file mode 100644 index 0000000000..fc014c4a4e --- /dev/null +++ b/plugins/GSdx/res/merge.fx @@ -0,0 +1,58 @@ +#if SHADER_MODEL >= 0x400 + +Texture2D Texture; +SamplerState Sampler; + +cbuffer cb0 +{ + float4 BGColor; +}; + +struct PS_INPUT +{ + float4 p : SV_Position; + float2 t : TEXCOORD0; +}; + +float4 ps_main0(PS_INPUT input) : SV_Target0 +{ + float4 c = Texture.Sample(Sampler, input.t); + c.a = min(c.a * 2, 1); + return c; +} + +float4 ps_main1(PS_INPUT input) : SV_Target0 +{ + float4 c = Texture.Sample(Sampler, input.t); + c.a = BGColor.a; + return c; +} + +#elif SHADER_MODEL <= 0x300 + +sampler Texture : register(s0); + +float4 g_params[1]; + +#define BGColor (g_params[0]) + +struct PS_INPUT +{ + float2 t : TEXCOORD0; +}; + +float4 ps_main0(PS_INPUT input) : COLOR +{ + float4 c = tex2D(Texture, input.t); + // a = ; + return c.bgra; +} + +float4 ps_main1(PS_INPUT input) : COLOR +{ + float4 c = tex2D(Texture, input.t); + c.a = BGColor.a; + return c.bgra; +} + +#endif \ No newline at end of file diff --git a/plugins/GSdx/res/merge10.fx b/plugins/GSdx/res/merge10.fx deleted file mode 100644 index 1f91fe3e8f..0000000000 --- a/plugins/GSdx/res/merge10.fx +++ /dev/null @@ -1,27 +0,0 @@ -Texture2D Texture; -SamplerState Sampler; - -cbuffer cb0 -{ - float4 BGColor; -}; - -struct PS_INPUT -{ - float4 p : SV_Position; - float2 t : TEXCOORD0; -}; - -float4 ps_main0(PS_INPUT input) : SV_Target0 -{ - float4 c = Texture.Sample(Sampler, input.t); - c.a = min(c.a * 2, 1); - return c; -} - -float4 ps_main1(PS_INPUT input) : SV_Target0 -{ - float4 c = Texture.Sample(Sampler, input.t); - c.a = BGColor.a; - return c; -} \ No newline at end of file diff --git a/plugins/GSdx/res/merge9.fx b/plugins/GSdx/res/merge9.fx deleted file mode 100644 index dbb210660f..0000000000 --- a/plugins/GSdx/res/merge9.fx +++ /dev/null @@ -1,25 +0,0 @@ -sampler Texture : register(s0); - -float4 g_params[1]; - -#define BGColor (g_params[0]) - -struct PS_INPUT -{ - float2 t : TEXCOORD0; -}; - -float4 ps_main0(PS_INPUT input) : COLOR -{ - float4 c = tex2D(Texture, input.t); - // a = ; - return c.bgra; -} - -float4 ps_main1(PS_INPUT input) : COLOR -{ - float4 c = tex2D(Texture, input.t); - c.a = BGColor.a; - return c.bgra; -} - diff --git a/plugins/GSdx/res/tfx.fx b/plugins/GSdx/res/tfx.fx new file mode 100644 index 0000000000..ebd24e290b --- /dev/null +++ b/plugins/GSdx/res/tfx.fx @@ -0,0 +1,717 @@ +#if SHADER_MODEL >= 0x400 + +#ifndef VS_BPPZ +#define VS_BPPZ 0 +#define VS_TME 1 +#define VS_FST 1 +#define VS_PRIM 0 +#endif + +#ifndef GS_IIP +#define GS_IIP 0 +#define GS_PRIM 3 +#endif + +#ifndef PS_FST +#define PS_FST 0 +#define PS_WMS 3 +#define PS_WMT 3 +#define PS_BPP 0 +#define PS_AEM 0 +#define PS_TFX 0 +#define PS_TCC 1 +#define PS_ATE 0 +#define PS_ATST 4 +#define PS_FOG 0 +#define PS_CLR1 0 +#define PS_FBA 0 +#define PS_AOUT 0 +#define PS_LTF 1 +#endif + +struct VS_INPUT +{ + uint2 p : POSITION0; + uint z : POSITION1; + float2 t : TEXCOORD0; + float q : TEXCOORD1; + float4 c : COLOR0; + float4 f : COLOR1; +}; + +struct VS_OUTPUT +{ + float4 p : SV_Position; + float4 t : TEXCOORD0; + float4 c : COLOR0; +}; + +struct PS_INPUT +{ + float4 p : SV_Position; + float4 t : TEXCOORD0; + float4 c : COLOR0; +}; + +struct PS_OUTPUT +{ + float4 c0 : SV_Target0; + float4 c1 : SV_Target1; +}; + +Texture2D Texture; +Texture2D Palette; +SamplerState TextureSampler; +SamplerState PaletteSampler; + +cbuffer cb0 +{ + float4 VertexScale; + float4 VertexOffset; + float2 TextureScale; +}; + +cbuffer cb1 +{ + float3 FogColor; + float AREF; + float4 HalfTexel; + float2 WH; + float2 TA; + float4 MinMax; + float4 MinMaxF; + uint4 MskFix; +}; + +#elif SHADER_MODEL <= 0x300 + +#ifndef VS_BPPZ +#define VS_BPPZ 0 +#define VS_TME 1 +#define VS_FST 1 +#define VS_LOGZ 1 +#endif + +#ifndef PS_FST +#define PS_FST 0 +#define PS_WMS 3 +#define PS_WMT 3 +#define PS_BPP 0 +#define PS_AEM 0 +#define PS_TFX 0 +#define PS_TCC 1 +#define PS_ATE 0 +#define PS_ATST 4 +#define PS_FOG 0 +#define PS_CLR1 0 +#define PS_RT 0 +#define PS_LTF 0 +#endif + +struct VS_INPUT +{ + float4 p : POSITION0; + float2 t : TEXCOORD0; + float4 c : COLOR0; + float4 f : COLOR1; +}; + +struct VS_OUTPUT +{ + float4 p : POSITION; + float4 t : TEXCOORD0; + float4 c : COLOR0; +}; + +struct PS_INPUT +{ + float4 t : TEXCOORD0; + float4 c : COLOR0; +}; + +sampler Texture : register(s0); +sampler1D Palette : register(s1); +sampler1D UMSKFIX : register(s2); +sampler1D VMSKFIX : register(s3); + +float4 vs_params[3]; + +#define VertexScale vs_params[0] +#define VertexOffset vs_params[1] +#define TextureScale vs_params[2].xy + +float4 ps_params[5]; + +#define FogColor ps_params[0].bgr +#define AREF ps_params[0].a +#define HalfTexel ps_params[1] +#define WH ps_params[2].xy +#define TA0 ps_params[2].z +#define TA1 ps_params[2].w +#define MinMax ps_params[3] +#define MinMaxF ps_params[4] + +#endif + +float4 wrapuv(float4 uv) +{ + if(PS_WMS == PS_WMT) + { + if(PS_WMS == 0) + { + uv = frac(uv); + } + else if(PS_WMS == 1) + { + uv = saturate(uv); + } + else if(PS_WMS == 2) + { + uv = clamp(uv, MinMax.xyxy, MinMax.zwzw); + } + else if(PS_WMS == 3) + { + #if SHADER_MODEL >= 0x400 + uv = (float4)(((int4)(uv * WH.xyxy) & MskFix.xyxy) | MskFix.zwzw) / WH.xyxy; + #elif SHADER_MODEL <= 0x300 + uv.x = tex1D(UMSKFIX, uv.x); + uv.y = tex1D(VMSKFIX, uv.y); + uv.z = tex1D(UMSKFIX, uv.z); + uv.w = tex1D(VMSKFIX, uv.w); + #endif + } + } + else + { + if(PS_WMS == 0) + { + uv.xz = frac(uv.xz); + } + else if(PS_WMS == 1) + { + uv.xz = saturate(uv.xz); + } + else if(PS_WMS == 2) + { + uv.xz = clamp(uv.xz, MinMax.xx, MinMax.zz); + } + else if(PS_WMS == 3) + { + #if SHADER_MODEL >= 0x400 + uv.xz = (float2)(((int2)(uv * WH.xyxy).xz & MskFix.xx) | MskFix.zz) / WH; + #elif SHADER_MODEL <= 0x300 + uv.x = tex1D(UMSKFIX, uv.x); + uv.z = tex1D(UMSKFIX, uv.z); + #endif + } + + if(PS_WMT == 0) + { + uv.yw = frac(uv.yw); + } + else if(PS_WMT == 1) + { + uv.yw = saturate(uv.yw); + } + else if(PS_WMT == 2) + { + uv.yw = clamp(uv.yw, MinMax.yy, MinMax.ww); + } + else if(PS_WMT == 3) + { + #if SHADER_MODEL >= 0x400 + uv.yw = (float2)(((int2)(uv * WH.xyxy).yw & MskFix.yy) | MskFix.ww) / WH; + #elif SHADER_MODEL <= 0x300 + uv.y = tex1D(VMSKFIX, uv.y); + uv.w = tex1D(VMSKFIX, uv.w); + #endif + } + } + + return uv; +} + +float2 clampuv(float2 uv) +{ + if(PS_WMS == 2 && PS_WMT == 2) + { + uv = clamp(uv, MinMaxF.xy, MinMaxF.zw); + } + else if(PS_WMS == 2) + { + uv.x = clamp(uv.x, MinMaxF.x, MinMaxF.z); + } + else if(PS_WMT == 2) + { + uv.y = clamp(uv.y, MinMaxF.y, MinMaxF.w); + } + + return uv; +} + +float4 tfx(float4 t, float4 c) +{ + if(PS_TFX == 0) + { + if(PS_TCC == 0) + { + c.rgb = c.rgb * t.rgb * 255.0f / 128; + } + else + { + c = c * t * 255.0f / 128; + } + } + else if(PS_TFX == 1) + { + if(PS_TCC == 0) + { + c.rgb = t.rgb; + } + else + { + c = t; + } + } + else if(PS_TFX == 2) + { + c.rgb = c.rgb * t.rgb * 255.0f / 128 + c.a; + + if(PS_TCC == 1) + { + c.a += t.a; + } + } + else if(PS_TFX == 3) + { + c.rgb = c.rgb * t.rgb * 255.0f / 128 + c.a; + + if(PS_TCC == 1) + { + c.a = t.a; + } + } + + return saturate(c); +} + +void atst(float4 c) +{ + if(PS_ATE == 1) + { + if(PS_ATST == 0) + { + discard; + } + else if(PS_ATST == 2 || PS_ATST == 3) // l, le + { + clip(AREF - c.a); + } + else if(PS_ATST == 4) // e + { + clip(0.6f / 255 - abs(c.a - AREF)); // FIXME: 0.5f is too small + } + else if(PS_ATST == 5 || PS_ATST == 6) // ge, g + { + clip(c.a - AREF); + } + else if(PS_ATST == 7) // ne + { + clip(abs(c.a - AREF) - 0.4f / 255); // FIXME: 0.5f is too much + } + } +} + +float4 fog(float4 c, float f) +{ + if(PS_FOG == 1) + { + c.rgb = lerp(FogColor, c.rgb, f); + } + + return c; +} + +#if SHADER_MODEL >= 0x400 + +VS_OUTPUT vs_main(VS_INPUT input) +{ + if(VS_BPPZ == 1) // 24 + { + input.z = input.z & 0xffffff; + } + else if(VS_BPPZ == 2) // 16 + { + input.z = input.z & 0xffff; + } + + if(VS_PRIM == 6) // sprite + { + //input.p.xy = (input.p.xy + 15) & ~15; // HACK + } + + VS_OUTPUT output; + + // pos -= 0.05 (1/320 pixel) helps avoiding rounding problems (integral part of pos is usually 5 digits, 0.05 is about as low as we can go) + // example: ceil(afterseveralvertextransformations(y = 133)) => 134 => line 133 stays empty + // input granularity is 1/16 pixel, anything smaller than that won't step drawing up/left by one pixel + // example: 133.0625 (133 + 1/16) should start from line 134, ceil(133.0625 - 0.05) still above 133 + + float4 p = float4(input.p, input.z, 0) - float4(0.05f, 0.05f, 0, 0); + + output.p = p * VertexScale - VertexOffset; + + if(VS_TME == 1) + { + if(VS_FST == 1) + { + output.t.xy = input.t * TextureScale; + output.t.w = 1.0f; + } + else + { + output.t.xy = input.t; + output.t.w = input.q; + } + } + else + { + output.t.xy = 0; + output.t.w = 1.0f; + } + + output.c = input.c; + output.t.z = input.f.a; + + return output; +} + +#if GS_PRIM == 0 + +[maxvertexcount(1)] +void gs_main(point VS_OUTPUT input[1], inout PointStream stream) +{ + stream.Append(input[0]); +} + +#elif GS_PRIM == 1 + +[maxvertexcount(2)] +void gs_main(line VS_OUTPUT input[2], inout LineStream stream) +{ + #if GS_IIP == 0 + input[0].c = input[1].c; + #endif + + stream.Append(input[0]); + stream.Append(input[1]); +} + +#elif GS_PRIM == 2 + +[maxvertexcount(3)] +void gs_main(triangle VS_OUTPUT input[3], inout TriangleStream stream) +{ + #if GS_IIP == 0 + input[0].c = input[2].c; + input[1].c = input[2].c; + #endif + + stream.Append(input[0]); + stream.Append(input[1]); + stream.Append(input[2]); +} + +#elif GS_PRIM == 3 + +[maxvertexcount(4)] +void gs_main(line VS_OUTPUT input[2], inout TriangleStream stream) +{ + input[0].p.z = input[1].p.z; + input[0].t.zw = input[1].t.zw; + + #if GS_IIP == 0 + input[0].c = input[1].c; + #endif + + VS_OUTPUT lb = input[1]; + + lb.p.x = input[0].p.x; + lb.t.x = input[0].t.x; + + VS_OUTPUT rt = input[1]; + + rt.p.y = input[0].p.y; + rt.t.y = input[0].t.y; + + stream.Append(input[0]); + stream.Append(lb); + stream.Append(rt); + stream.Append(input[1]); +} + +#endif + +float4 sample(float2 tc, float w) +{ + if(PS_FST == 0) + { + tc /= w; + } + + float4 t; +/* + if(PS_BPP < 3 && PS_WMS < 2 && PS_WMT < 2) + { + t = Texture.Sample(TextureSampler, tc); + } +*/ + if(PS_BPP < 3 && PS_WMS < 3 && PS_WMT < 3) + { + t = Texture.Sample(TextureSampler, clampuv(tc)); + } + else + { + float w, h; + Texture.GetDimensions(w, h); + + float4 uv2 = tc.xyxy + HalfTexel; + float2 dd = frac(uv2.xy * float2(w, h)); + float4 uv = wrapuv(uv2); + + float4 t00, t01, t10, t11; + + if(PS_BPP == 3) // 8HP + { + float4 a; + + a.x = Texture.Sample(TextureSampler, uv.xy).a; + a.y = Texture.Sample(TextureSampler, uv.zy).a; + a.z = Texture.Sample(TextureSampler, uv.xw).a; + a.w = Texture.Sample(TextureSampler, uv.zw).a; + + t00 = Palette.Sample(PaletteSampler, a.x); + t01 = Palette.Sample(PaletteSampler, a.y); + t10 = Palette.Sample(PaletteSampler, a.z); + t11 = Palette.Sample(PaletteSampler, a.w); + } + else + { + t00 = Texture.Sample(TextureSampler, uv.xy); + t01 = Texture.Sample(TextureSampler, uv.zy); + t10 = Texture.Sample(TextureSampler, uv.xw); + t11 = Texture.Sample(TextureSampler, uv.zw); + } + + if(PS_LTF) + { + t = lerp(lerp(t00, t01, dd.x), lerp(t10, t11, dd.x), dd.y); + } + else + { + t = t00; + } + } + + if(PS_BPP == 1) // 24 + { + t.a = PS_AEM == 0 || any(t.rgb) ? TA.x : 0; + } + else if(PS_BPP == 2) // 16 + { + // a bit incompatible with up-scaling because the 1 bit alpha is interpolated + + t.a = t.a >= 0.5 ? TA.y : PS_AEM == 0 || any(t.rgb) ? TA.x : 0; + } + + return t; +} + +PS_OUTPUT ps_main(PS_INPUT input) +{ + float4 t = sample(input.t.xy, input.t.w); + + float4 c = tfx(t, input.c); + + atst(c); + + c = fog(c, input.t.z); + + if(PS_CLR1 == 1) // needed for Cd * (As/Ad/F + 1) blending modes + { + c.rgb = 1; + } + + PS_OUTPUT output; + + output.c1 = c.a * 2; // used for alpha blending + + if(PS_AOUT == 1) // 16 bit output + { + float a = 128.0f / 255; // alpha output will be 0x80 + + c.a = PS_FBA == 1 ? a : step(0.5, c.a) * a; + } + else if(PS_FBA == 1) + { + if(c.a < 0.5) c.a += 0.5; + } + + output.c0 = c; + + return output; +} + +#elif SHADER_MODEL <= 0x300 + +VS_OUTPUT vs_main(VS_INPUT input) +{ + if(VS_BPPZ == 1) // 24 + { + input.p.z = fmod(input.p.z, 0x1000000); + } + else if(VS_BPPZ == 2) // 16 + { + input.p.z = fmod(input.p.z, 0x10000); + } + + VS_OUTPUT output; + + // pos -= 0.05 (1/320 pixel) helps avoiding rounding problems (integral part of pos is usually 5 digits, 0.05 is about as low as we can go) + // example: ceil(afterseveralvertextransformations(y = 133)) => 134 => line 133 stays empty + // input granularity is 1/16 pixel, anything smaller than that won't step drawing up/left by one pixel + // example: 133.0625 (133 + 1/16) should start from line 134, ceil(133.0625 - 0.05) still above 133 + + float4 p = input.p - float4(0.05f, 0.05f, 0, 0); + + output.p = p * VertexScale - VertexOffset; + + if(VS_LOGZ == 1) + { + output.p.z = log2(1.0f + input.p.z) / 32; + } + + if(VS_TME == 1) + { + if(VS_FST == 1) + { + output.t.xy = input.t * TextureScale; + output.t.w = 1.0f; + } + else + { + output.t.xy = input.t; + output.t.w = input.p.w; + } + } + else + { + output.t.xy = 0; + output.t.w = 1.0f; + } + + output.c = input.c; + output.t.z = input.f.a; + + return output; +} + +float4 sample(float2 tc, float w) +{ + if(PS_FST == 0) + { + tc /= w; + } + + float4 t; +/* + if(PS_BPP < 3 && PS_WMS < 2 && PS_WMT < 2) + { + t = tex2D(Texture, tc); + } +*/ + if(PS_BPP < 3 && PS_WMS < 3 && PS_WMT < 3) + { + t = tex2D(Texture, clampuv(tc)); + } + else + { + float4 uv2 = tc.xyxy + HalfTexel; + float2 dd = frac(uv2.xy * WH); + float4 uv = wrapuv(uv2); + + float4 t00, t01, t10, t11; + + if(PS_BPP == 3) // 8HP + { + float4 a; + + a.x = tex2D(Texture, uv.xy).a; + a.y = tex2D(Texture, uv.zy).a; + a.z = tex2D(Texture, uv.xw).a; + a.w = tex2D(Texture, uv.zw).a; + + if(PS_RT == 1) a *= 0.5; + + t00 = tex1D(Palette, a.x); + t01 = tex1D(Palette, a.y); + t10 = tex1D(Palette, a.z); + t11 = tex1D(Palette, a.w); + } + else + { + t00 = tex2D(Texture, uv.xy); + t01 = tex2D(Texture, uv.zy); + t10 = tex2D(Texture, uv.xw); + t11 = tex2D(Texture, uv.zw); + } + + if(PS_LTF) + { + t = lerp(lerp(t00, t01, dd.x), lerp(t10, t11, dd.x), dd.y); + } + else + { + t = t00; + } + } + + if(PS_BPP == 0) // 32 + { + if(PS_RT == 1) t.a *= 0.5; + } + else if(PS_BPP == 1) // 24 + { + t.a = PS_AEM == 0 || any(t.rgb) ? TA0 : 0; + } + else if(PS_BPP == 2) // 16 + { + // a bit incompatible with up-scaling because the 1 bit alpha is interpolated + + t.a = t.a >= 0.5 ? TA1 : PS_AEM == 0 || any(t.rgb) ? TA0 : 0; + } + + return t; +} + +float4 ps_main(PS_INPUT input) : COLOR +{ + float4 t = sample(input.t.xy, input.t.w); + + float4 c = tfx(t, input.c); + + atst(c); + + c = fog(c, input.t.z); + + if(PS_CLR1 == 1) // needed for Cd * (As/Ad/F + 1) blending modes + { + c.rgb = 1; + } + + c.a *= 2; + + return c; +} + +#endif \ No newline at end of file diff --git a/plugins/GSdx/res/tfx10.fx b/plugins/GSdx/res/tfx10.fx deleted file mode 100644 index c0a3a87906..0000000000 --- a/plugins/GSdx/res/tfx10.fx +++ /dev/null @@ -1,472 +0,0 @@ -cbuffer cb0 -{ - float4 VertexScale; - float4 VertexOffset; - float2 TextureScale; -}; - -struct VS_INPUT -{ - uint2 p : POSITION0; - uint z : POSITION1; - float2 t : TEXCOORD0; - float q : TEXCOORD1; - float4 c : COLOR0; - float4 f : COLOR1; -}; - -struct VS_OUTPUT -{ - float4 p : SV_Position; - float4 t : TEXCOORD0; - float4 c : COLOR0; -}; - -#ifndef VS_BPPZ -#define VS_BPPZ 0 -#define VS_TME 1 -#define VS_FST 1 -#define VS_PRIM 0 -#endif - -VS_OUTPUT vs_main(VS_INPUT input) -{ - if(VS_BPPZ == 1) // 24 - { - input.z = input.z & 0xffffff; - } - else if(VS_BPPZ == 2) // 16 - { - input.z = input.z & 0xffff; - } - - if(VS_PRIM == 6) // sprite - { - //input.p.xy = (input.p.xy + 15) & ~15; // HACK - } - - VS_OUTPUT output; - - // pos -= 0.05 (1/320 pixel) helps avoiding rounding problems (integral part of pos is usually 5 digits, 0.05 is about as low as we can go) - // example: ceil(afterseveralvertextransformations(y = 133)) => 134 => line 133 stays empty - // input granularity is 1/16 pixel, anything smaller than that won't step drawing up/left by one pixel - // example: 133.0625 (133 + 1/16) should start from line 134, ceil(133.0625 - 0.05) still above 133 - - float4 p = float4(input.p, input.z, 0) - float4(0.05f, 0.05f, 0, 0); - - output.p = p * VertexScale - VertexOffset; - - if(VS_TME == 1) - { - if(VS_FST == 1) - { - output.t.xy = input.t * TextureScale; - output.t.w = 1.0f; - } - else - { - output.t.xy = input.t; - output.t.w = input.q; - } - } - else - { - output.t.xy = 0; - output.t.w = 1.0f; - } - - output.c = input.c; - output.t.z = input.f.a; - - return output; -} - -#ifndef IIP -#define IIP 0 -#define PRIM 3 -#endif - -#if PRIM == 0 - -[maxvertexcount(1)] -void gs_main(point VS_OUTPUT input[1], inout PointStream stream) -{ - stream.Append(input[0]); -} - -#elif PRIM == 1 - -[maxvertexcount(2)] -void gs_main(line VS_OUTPUT input[2], inout LineStream stream) -{ - #if IIP == 0 - input[0].c = input[1].c; - #endif - - stream.Append(input[0]); - stream.Append(input[1]); -} - -#elif PRIM == 2 - -[maxvertexcount(3)] -void gs_main(triangle VS_OUTPUT input[3], inout TriangleStream stream) -{ - #if IIP == 0 - input[0].c = input[2].c; - input[1].c = input[2].c; - #endif - - stream.Append(input[0]); - stream.Append(input[1]); - stream.Append(input[2]); -} - -#elif PRIM == 3 - -[maxvertexcount(4)] -void gs_main(line VS_OUTPUT input[2], inout TriangleStream stream) -{ - input[0].p.z = input[1].p.z; - input[0].t.zw = input[1].t.zw; - - #if IIP == 0 - input[0].c = input[1].c; - #endif - - VS_OUTPUT lb = input[1]; - - lb.p.x = input[0].p.x; - lb.t.x = input[0].t.x; - - VS_OUTPUT rt = input[1]; - - rt.p.y = input[0].p.y; - rt.t.y = input[0].t.y; - - stream.Append(input[0]); - stream.Append(lb); - stream.Append(rt); - stream.Append(input[1]); -} - -#endif - -Texture2D Texture; -Texture2D Palette; -SamplerState TextureSampler; -SamplerState PaletteSampler; - -cbuffer cb1 -{ - float3 FogColor; - float AREF; - float4 HalfTexel; - float2 WH; - float2 TA; - float4 MinMax; - float4 MinMaxF; - uint4 MskFix; -}; - -struct PS_INPUT -{ - float4 p : SV_Position; - float4 t : TEXCOORD0; - float4 c : COLOR0; -}; - -struct PS_OUTPUT -{ - float4 c0 : SV_Target0; - float4 c1 : SV_Target1; -}; - -#ifndef FST -#define FST 0 -#define WMS 3 -#define WMT 3 -#define BPP 0 -#define AEM 0 -#define TFX 0 -#define TCC 1 -#define ATE 0 -#define ATST 4 -#define FOG 0 -#define CLR1 0 -#define FBA 0 -#define AOUT 0 -#define LTF 1 -#endif - -float4 wrapuv(float4 uv) -{ - if(WMS == WMT) - { - if(WMS == 0) - { - uv = frac(uv); - } - else if(WMS == 1) - { - uv = saturate(uv); - } - else if(WMS == 2) - { - uv = clamp(uv, MinMax.xyxy, MinMax.zwzw); - } - else if(WMS == 3) - { - uv = (float4)(((int4)(uv * WH.xyxy) & MskFix.xyxy) | MskFix.zwzw) / WH.xyxy; - } - } - else - { - if(WMS == 0) - { - uv.xz = frac(uv.xz); - } - else if(WMS == 1) - { - uv.xz = saturate(uv.xz); - } - else if(WMS == 2) - { - uv.xz = clamp(uv.xz, MinMax.xx, MinMax.zz); - } - else if(WMS == 3) - { - uv.xz = (float2)(((int2)(uv * WH.xyxy).xz & MskFix.xx) | MskFix.zz) / WH; - } - - if(WMT == 0) - { - uv.yw = frac(uv.yw); - } - else if(WMT == 1) - { - uv.yw = saturate(uv.yw); - } - else if(WMT == 2) - { - uv.yw = clamp(uv.yw, MinMax.yy, MinMax.ww); - } - else if(WMT == 3) - { - uv.yw = (float2)(((int2)(uv * WH.xyxy).yw & MskFix.yy) | MskFix.ww) / WH; - } - } - - return uv; -} - -float2 clampuv(float2 uv) -{ - if(WMS == 2 && WMT == 2) - { - uv = clamp(uv, MinMaxF.xy, MinMaxF.zw); - } - else if(WMS == 2) - { - uv.x = clamp(uv.x, MinMaxF.x, MinMaxF.z); - } - else if(WMT == 2) - { - uv.y = clamp(uv.y, MinMaxF.y, MinMaxF.w); - } - - return uv; -} - -float4 sample(float2 tc, float w) -{ - if(FST == 0) - { - tc /= w; - } - - float4 t; -/* - if(BPP < 3 && WMS < 2 && WMT < 2) - { - t = Texture.Sample(TextureSampler, tc); - } -*/ - if(BPP < 3 && WMS < 3 && WMT < 3) - { - t = Texture.Sample(TextureSampler, clampuv(tc)); - } - else - { - float w, h; - Texture.GetDimensions(w, h); - - float4 uv2 = tc.xyxy + HalfTexel; - float2 dd = frac(uv2.xy * float2(w, h)); - float4 uv = wrapuv(uv2); - - float4 t00, t01, t10, t11; - - if(BPP == 3) // 8HP - { - float4 a; - - a.x = Texture.Sample(TextureSampler, uv.xy).a; - a.y = Texture.Sample(TextureSampler, uv.zy).a; - a.z = Texture.Sample(TextureSampler, uv.xw).a; - a.w = Texture.Sample(TextureSampler, uv.zw).a; - - t00 = Palette.Sample(PaletteSampler, a.x); - t01 = Palette.Sample(PaletteSampler, a.y); - t10 = Palette.Sample(PaletteSampler, a.z); - t11 = Palette.Sample(PaletteSampler, a.w); - } - else - { - t00 = Texture.Sample(TextureSampler, uv.xy); - t01 = Texture.Sample(TextureSampler, uv.zy); - t10 = Texture.Sample(TextureSampler, uv.xw); - t11 = Texture.Sample(TextureSampler, uv.zw); - } - - if(LTF) - { - t = lerp(lerp(t00, t01, dd.x), lerp(t10, t11, dd.x), dd.y); - } - else - { - t = t00; - } - } - - if(BPP == 1) // 24 - { - t.a = AEM == 0 || any(t.rgb) ? TA.x : 0; - } - else if(BPP == 2) // 16 - { - // a bit incompatible with up-scaling because the 1 bit alpha is interpolated - - t.a = t.a >= 0.5 ? TA.y : AEM == 0 || any(t.rgb) ? TA.x : 0; - } - - return t; -} - -float4 tfx(float4 t, float4 c) -{ - if(TFX == 0) - { - if(TCC == 0) - { - c.rgb = c.rgb * t.rgb * 255.0f / 128; - } - else - { - c = c * t * 255.0f / 128; - } - } - else if(TFX == 1) - { - if(TCC == 0) - { - c.rgb = t.rgb; - } - else - { - c = t; - } - } - else if(TFX == 2) - { - c.rgb = c.rgb * t.rgb * 255.0f / 128 + c.a; - - if(TCC == 1) - { - c.a += t.a; - } - } - else if(TFX == 3) - { - c.rgb = c.rgb * t.rgb * 255.0f / 128 + c.a; - - if(TCC == 1) - { - c.a = t.a; - } - } - - return saturate(c); -} - -void atst(float4 c) -{ - if(ATE == 1) - { - if(ATST == 0) - { - discard; - } - else if(ATST == 2 || ATST == 3) // l, le - { - clip(AREF - c.a); - } - else if(ATST == 4) // e - { - clip(0.6f / 255 - abs(c.a - AREF)); // FIXME: 0.5f is too small - } - else if(ATST == 5 || ATST == 6) // ge, g - { - clip(c.a - AREF); - } - else if(ATST == 7) // ne - { - clip(abs(c.a - AREF) - 0.4f / 255); // FIXME: 0.5f is too much - } - } -} - -float4 fog(float4 c, float f) -{ - if(FOG == 1) - { - c.rgb = lerp(FogColor.rgb, c.rgb, f); - } - - return c; -} - -PS_OUTPUT ps_main(PS_INPUT input) -{ - float4 t = sample(input.t.xy, input.t.w); - - float4 c = tfx(t, input.c); - - atst(c); - - c = fog(c, input.t.z); - - if(CLR1 == 1) // needed for Cd * (As/Ad/F + 1) blending modes - { - c.rgb = 1; - } - - PS_OUTPUT output; - - output.c1 = c.a * 2; // used for alpha blending - - if(AOUT == 1) // 16 bit output - { - float a = 128.0f / 255; // alpha output will be 0x80 - - c.a = FBA == 1 ? a : step(0.5, c.a) * a; - } - else if(FBA == 1) - { - if(c.a < 0.5) c.a += 0.5; - } - - output.c0 = c; - - return output; -} diff --git a/plugins/GSdx/res/tfx9.fx b/plugins/GSdx/res/tfx9.fx deleted file mode 100644 index 0c1062fec8..0000000000 --- a/plugins/GSdx/res/tfx9.fx +++ /dev/null @@ -1,382 +0,0 @@ -struct VS_INPUT -{ - float4 p : POSITION0; - float2 t : TEXCOORD0; - float4 c : COLOR0; - float4 f : COLOR1; -}; - -struct VS_OUTPUT -{ - float4 p : POSITION; - float4 t : TEXCOORD0; - float4 c : COLOR0; -}; - -float4 vs_params[3]; - -#define VertexScale vs_params[0] -#define VertexOffset vs_params[1] -#define TextureScale vs_params[2].xy - -#ifndef VS_BPPZ -#define VS_BPPZ 0 -#define VS_TME 1 -#define VS_FST 1 -#define VS_LOGZ 1 -#endif - -VS_OUTPUT vs_main(VS_INPUT input) -{ - if(VS_BPPZ == 1) // 24 - { - input.p.z = fmod(input.p.z, 0x1000000); - } - else if(VS_BPPZ == 2) // 16 - { - input.p.z = fmod(input.p.z, 0x10000); - } - - VS_OUTPUT output; - - // pos -= 0.05 (1/320 pixel) helps avoiding rounding problems (integral part of pos is usually 5 digits, 0.05 is about as low as we can go) - // example: ceil(afterseveralvertextransformations(y = 133)) => 134 => line 133 stays empty - // input granularity is 1/16 pixel, anything smaller than that won't step drawing up/left by one pixel - // example: 133.0625 (133 + 1/16) should start from line 134, ceil(133.0625 - 0.05) still above 133 - - float4 p = input.p - float4(0.05f, 0.05f, 0, 0); - - output.p = p * VertexScale - VertexOffset; - - if(VS_LOGZ == 1) - { - output.p.z = log2(1.0f + input.p.z) / 32; - } - - if(VS_TME == 1) - { - if(VS_FST == 1) - { - output.t.xy = input.t * TextureScale; - output.t.w = 1.0f; - } - else - { - output.t.xy = input.t; - output.t.w = input.p.w; - } - } - else - { - output.t.xy = 0; - output.t.w = 1.0f; - } - - output.c = input.c; - output.t.z = input.f.a; - - return output; -} - -float4 ps_params[5]; - -#define FogColor ps_params[0].bgr -#define AREF ps_params[0].a -#define HalfTexel ps_params[1] -#define WH ps_params[2].xy -#define TA0 ps_params[2].z -#define TA1 ps_params[2].w -#define MinMax ps_params[3] -#define MinMaxF ps_params[4] - -struct PS_INPUT -{ - float4 t : TEXCOORD0; - float4 c : COLOR0; -}; - -#ifndef FST -#define FST 0 -#define WMS 3 -#define WMT 3 -#define BPP 0 -#define AEM 0 -#define TFX 0 -#define TCC 1 -#define ATE 0 -#define ATST 4 -#define FOG 0 -#define CLR1 0 -#define RT 0 -#define LTF 0 -#endif - -sampler Texture : register(s0); -sampler1D Palette : register(s1); -sampler1D UMSKFIX : register(s2); -sampler1D VMSKFIX : register(s3); - -float4 wrapuv(float4 uv) -{ - if(WMS == WMT) - { - if(WMS == 0) - { - uv = frac(uv); - } - else if(WMS == 1) - { - uv = saturate(uv); - } - else if(WMS == 2) - { - uv = clamp(uv, MinMax.xyxy, MinMax.zwzw); - } - else if(WMS == 3) - { - uv.x = tex1D(UMSKFIX, uv.x); - uv.y = tex1D(VMSKFIX, uv.y); - uv.z = tex1D(UMSKFIX, uv.z); - uv.w = tex1D(VMSKFIX, uv.w); - } - } - else - { - if(WMS == 0) - { - uv.xz = frac(uv.xz); - } - else if(WMS == 1) - { - uv.xz = saturate(uv.xz); - } - else if(WMS == 2) - { - uv.xz = clamp(uv.xz, MinMax.xx, MinMax.zz); - } - else if(WMS == 3) - { - uv.x = tex1D(UMSKFIX, uv.x); - uv.z = tex1D(UMSKFIX, uv.z); - } - - if(WMT == 0) - { - uv.yw = frac(uv.yw); - } - else if(WMT == 1) - { - uv.yw = saturate(uv.yw); - } - else if(WMT == 2) - { - uv.yw = clamp(uv.yw, MinMax.yy, MinMax.ww); - } - else if(WMT == 3) - { - uv.y = tex1D(VMSKFIX, uv.y); - uv.w = tex1D(VMSKFIX, uv.w); - } - } - - return uv; -} - -float2 clampuv(float2 uv) -{ - if(WMS == 2 && WMT == 2) - { - uv = clamp(uv, MinMaxF.xy, MinMaxF.zw); - } - else if(WMS == 2) - { - uv.x = clamp(uv.x, MinMaxF.x, MinMaxF.z); - } - else if(WMT == 2) - { - uv.y = clamp(uv.y, MinMaxF.y, MinMaxF.w); - } - - return uv; -} - -float4 sample(float2 tc, float w) -{ - if(FST == 0) - { - tc /= w; - } - - float4 t; -/* - if(BPP < 3 && WMS < 2 && WMT < 2) - { - t = tex2D(Texture, tc); - } -*/ - if(BPP < 3 && WMS < 3 && WMT < 3) - { - t = tex2D(Texture, clampuv(tc)); - } - else - { - float4 uv2 = tc.xyxy + HalfTexel; - float2 dd = frac(uv2.xy * WH); - float4 uv = wrapuv(uv2); - - float4 t00, t01, t10, t11; - - if(BPP == 3) // 8HP - { - float4 a; - - a.x = tex2D(Texture, uv.xy).a; - a.y = tex2D(Texture, uv.zy).a; - a.z = tex2D(Texture, uv.xw).a; - a.w = tex2D(Texture, uv.zw).a; - - if(RT == 1) a *= 0.5; - - t00 = tex1D(Palette, a.x); - t01 = tex1D(Palette, a.y); - t10 = tex1D(Palette, a.z); - t11 = tex1D(Palette, a.w); - } - else - { - t00 = tex2D(Texture, uv.xy); - t01 = tex2D(Texture, uv.zy); - t10 = tex2D(Texture, uv.xw); - t11 = tex2D(Texture, uv.zw); - } - - if(LTF) - { - t = lerp(lerp(t00, t01, dd.x), lerp(t10, t11, dd.x), dd.y); - } - else - { - t = t00; - } - } - - if(BPP == 0) // 32 - { - if(RT == 1) t.a *= 0.5; - } - else if(BPP == 1) // 24 - { - t.a = AEM == 0 || any(t.rgb) ? TA0 : 0; - } - else if(BPP == 2) // 16 - { - // a bit incompatible with up-scaling because the 1 bit alpha is interpolated - - t.a = t.a >= 0.5 ? TA1 : AEM == 0 || any(t.rgb) ? TA0 : 0; - } - - return t; -} - -float4 tfx(float4 t, float4 c) -{ - if(TFX == 0) - { - if(TCC == 0) - { - c.rgb = c.rgb * t.rgb * 255.0f / 128; - } - else - { - c = c * t * 255.0f / 128; - } - } - else if(TFX == 1) - { - if(TCC == 0) - { - c.rgb = t.rgb; - } - else - { - c = t; - } - } - else if(TFX == 2) - { - c.rgb = c.rgb * t.rgb * 255.0f / 128 + c.a; - - if(TCC == 1) - { - c.a += t.a; - } - } - else if(TFX == 3) - { - c.rgb = c.rgb * t.rgb * 255.0f / 128 + c.a; - - if(TCC == 1) - { - c.a = t.a; - } - } - - return saturate(c); -} - -void atst(float4 c) -{ - if(ATE == 1) - { - if(ATST == 0) - { - discard; - } - else if(ATST == 2 || ATST == 3) // l, le - { - clip(AREF - c.a); - } - else if(ATST == 4) // e - { - clip(0.6f / 255 - abs(c.a - AREF)); // FIXME: 0.5f is too small - } - else if(ATST == 5 || ATST == 6) // ge, g - { - clip(c.a - AREF); - } - else if(ATST == 7) // ne - { - clip(abs(c.a - AREF) - 0.4f / 255); // FIXME: 0.5f is too much - } - } -} - -float4 fog(float4 c, float f) -{ - if(FOG == 1) - { - c.rgb = lerp(FogColor, c.rgb, f); - } - - return c; -} - -float4 ps_main(PS_INPUT input) : COLOR -{ - float4 t = sample(input.t.xy, input.t.w); - - float4 c = tfx(t, input.c); - - atst(c); - - c = fog(c, input.t.z); - - if(CLR1 == 1) // needed for Cd * (As/Ad/F + 1) blending modes - { - c.rgb = 1; - } - - c.a *= 2; - - return c; -} diff --git a/plugins/GSdx/resource.h b/plugins/GSdx/resource.h index 2083fa82ee..409840b67e 100644 --- a/plugins/GSdx/resource.h +++ b/plugins/GSdx/resource.h @@ -40,20 +40,16 @@ #define IDC_WIDTH 2036 #define IDC_HEIGHT 2037 #define IDC_CONFIGURE 2038 -#define IDR_CONVERT9_FX 10000 -#define IDR_TFX9_FX 10001 -#define IDR_MERGE9_FX 10002 -#define IDR_INTERLACE9_FX 10003 -#define IDR_CONVERT10_FX 10004 -#define IDR_TFX10_FX 10005 -#define IDR_MERGE10_FX 10006 -#define IDR_INTERLACE10_FX 10007 +#define IDR_CONVERT_FX 10000 +#define IDR_TFX_FX 10001 +#define IDR_MERGE_FX 10002 +#define IDR_INTERLACE_FX 10003 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 10009 +#define _APS_NEXT_RESOURCE_VALUE 10004 #define _APS_NEXT_COMMAND_VALUE 32771 #define _APS_NEXT_CONTROL_VALUE 2039 #define _APS_NEXT_SYMED_VALUE 5000 diff --git a/plugins/GSdx/stdafx.h b/plugins/GSdx/stdafx.h index ddc67531b0..375fb8d206 100644 --- a/plugins/GSdx/stdafx.h +++ b/plugins/GSdx/stdafx.h @@ -90,6 +90,7 @@ typedef signed long long int64; #endif #if defined(_DEBUG) && defined(_MSC_VER) + #include #define ASSERT assert #else #define ASSERT(exp) ((void)0) @@ -104,13 +105,19 @@ typedef signed long long int64; // directx #include -#include -#include +#include +#include #include #include +#include +#include #define D3DCOLORWRITEENABLE_RGBA (D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_ALPHA) +// dxsdk beta missing these: +#define D3D11_SHADER_MACRO D3D10_SHADER_MACRO +#define ID3D11Blob ID3D10Blob + #endif // opengl diff --git a/plugins/GSdx/vsprops/common.props b/plugins/GSdx/vsprops/common.props index 357fe0d1b6..0edc67dee6 100644 --- a/plugins/GSdx/vsprops/common.props +++ b/plugins/GSdx/vsprops/common.props @@ -15,9 +15,9 @@ 4995;4324;%(DisableSpecificWarnings) - JITProfiling.lib;d3d10.lib;d3dx10.lib;d3d9.lib;d3dx9.lib;ddraw.lib;dxguid.lib;winmm.lib;strmiids.lib;xinput.lib;cg.lib;cgGL.lib;glut32.lib;glew32.lib;%(AdditionalDependencies) + JITProfiling.lib;d3d11_beta.lib;d3dx11.lib;d3d10.lib;d3dx10.lib;d3d9.lib;d3dx9.lib;ddraw.lib;dxguid.lib;winmm.lib;strmiids.lib;xinput.lib;cg.lib;cgGL.lib;glut32.lib;glew32.lib;%(AdditionalDependencies) ./vtune;%(AdditionalLibraryDirectories) - d3d9.dll;d3dx9_41.dll;d3d10.dll;d3dx10_41.dll;%(DelayLoadDLLs) + d3d9.dll;d3dx9_41.dll;d3d10.dll;d3dx10_41.dll;d3d11.dll;d3d11_beta.dll;d3dx11_41.dll;%(DelayLoadDLLs) true Windows false