diff --git a/plugins/GSdx/GSDevice11.h b/plugins/GSdx/GSDevice11.h index 95ee6328df..92e7e05dfd 100644 --- a/plugins/GSdx/GSDevice11.h +++ b/plugins/GSdx/GSDevice11.h @@ -95,7 +95,7 @@ public: // TODO { CComPtr il; CComPtr vs; - CComPtr ps[10]; + CComPtr ps[18]; CComPtr ln; CComPtr pt; CComPtr dss; diff --git a/plugins/GSdx/GSTextureCache.cpp b/plugins/GSdx/GSTextureCache.cpp index 45de7a7afb..3e848b1f3b 100644 --- a/plugins/GSdx/GSTextureCache.cpp +++ b/plugins/GSdx/GSTextureCache.cpp @@ -23,6 +23,7 @@ #include "GSTextureCache.h" #include "GSUtil.h" +bool s_IS_DIRECT3D11 = false; bool s_IS_OPENGL = false; bool GSTextureCache::m_disable_partial_invalidation = false; bool GSTextureCache::m_wrap_gs_mem = false; @@ -30,6 +31,7 @@ bool GSTextureCache::m_wrap_gs_mem = false; GSTextureCache::GSTextureCache(GSRenderer* r) : m_renderer(r) { + s_IS_DIRECT3D11 = theApp.GetCurrentRendererType() == GSRendererType::DX1011_HW; s_IS_OPENGL = theApp.GetCurrentRendererType() == GSRendererType::OGL_HW; if (theApp.GetConfigB("UserHacks")) { @@ -1187,7 +1189,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con // TODO: clean up this mess int shader = dst->m_type != RenderTarget ? ShaderConvert_FLOAT32_TO_RGBA8 : ShaderConvert_COPY; - bool is_8bits = TEX0.PSM == PSM_PSMT8 && s_IS_OPENGL; + bool is_8bits = TEX0.PSM == PSM_PSMT8 && (s_IS_DIRECT3D11 || s_IS_OPENGL); if (is_8bits) { GL_INS("Reading RT as a packed-indexed 8 bits format"); diff --git a/plugins/GSdx/res/convert.fx b/plugins/GSdx/res/convert.fx index c482722391..c384f5ceaa 100644 --- a/plugins/GSdx/res/convert.fx +++ b/plugins/GSdx/res/convert.fx @@ -3,7 +3,7 @@ struct VS_INPUT { - float4 p : POSITION; + float4 p : POSITION; float2 t : TEXCOORD0; }; @@ -36,7 +36,7 @@ struct PS_OUTPUT struct VS_INPUT { - float4 p : POSITION; + float4 p : POSITION; float2 t : TEXCOORD0; }; @@ -219,6 +219,162 @@ PS_OUTPUT ps_main9(PS_INPUT input) // triangular return output; } +// DUMMY SHADERS START +PS_OUTPUT ps_main10(PS_INPUT input) +{ + PS_OUTPUT output; + + output.c = input.p; + + return output; +} + +PS_OUTPUT ps_main11(PS_INPUT input) +{ + PS_OUTPUT output; + + output.c = input.p; + + return output; +} + +PS_OUTPUT ps_main12(PS_INPUT input) +{ + PS_OUTPUT output; + + output.c = input.p; + + return output; +} + +PS_OUTPUT ps_main13(PS_INPUT input) +{ + PS_OUTPUT output; + + output.c = input.p; + + return output; +} + +PS_OUTPUT ps_main14(PS_INPUT input) +{ + PS_OUTPUT output; + + output.c = input.p; + + return output; +} + +PS_OUTPUT ps_main15(PS_INPUT input) +{ + PS_OUTPUT output; + + output.c = input.p; + + return output; +} + +PS_OUTPUT ps_main16(PS_INPUT input) +{ + PS_OUTPUT output; + + output.c = input.p; + + return output; +} +// DUMMY SHADERS END + +PS_OUTPUT ps_main17(PS_INPUT input) +{ + PS_OUTPUT output; + + // Potential speed optimization. There is a high probability that + // game only want to extract a single channel (blue). It will allow + // to remove most of the conditional operation and yield a +2/3 fps + // boost on MGS3 + // + // Hypothesis wrong in Prince of Persia ... Seriously WTF ! + //#define ONLY_BLUE; + + // Convert a RGBA texture into a 8 bits packed texture + // Input column: 8x2 RGBA pixels + // 0: 8 RGBA + // 1: 8 RGBA + // Output column: 16x4 Index pixels + // 0: 8 R | 8 B + // 1: 8 R | 8 B + // 2: 8 G | 8 A + // 3: 8 G | 8 A + float c; + + uint2 sel = uint2(input.p.xy) % uint2(16u, 16u); + int2 tb = ((int2(input.p.xy) & ~int2(15, 3)) >> 1); + + int ty = tb.y | (int(input.p.y) & 1); + int txN = tb.x | (int(input.p.x) & 7); + int txH = tb.x | ((int(input.p.x) + 4) & 7); + + //txN *= ScalingFactor.x; + //txH *= ScalingFactor.x; + //ty *= ScalingFactor.y; + + // TODO investigate texture gather + float4 cN = Texture.Load(int3(txN, ty, 0)); + float4 cH = Texture.Load(int3(txH, ty, 0)); + + + if ((sel.y & 4u) == 0u) + { +#ifdef ONLY_BLUE + c = cN.b; +#else + // Column 0 and 2 + if ((sel.y & 3u) < 2u) + { + // First 2 lines of the col + if (sel.x < 8u) + c = cN.r; + else + c = cN.b; + } + else + { + if (sel.x < 8u) + c = cH.g; + else + c = cH.a; + } +#endif + } + else + { +#ifdef ONLY_BLUE + c = cH.b; +#else + // Column 1 and 3 + if ((sel.y & 3u) < 2u) + { + // First 2 lines of the col + if (sel.x < 8u) + c = cH.r; + else + c = cH.b; + } + else + { + if (sel.x < 8u) + c = cN.g; + else + c = cN.a; + } +#endif + } + + output.c = (float4)(c); // Divide by something here? + + return output; +} + #elif SHADER_MODEL <= 0x300 PS_OUTPUT ps_main1(PS_INPUT input)