diff --git a/plugins/GSdx/Renderers/DX11/GSDevice11.cpp b/plugins/GSdx/Renderers/DX11/GSDevice11.cpp index 191ff29e5c..d0d8623b2f 100644 --- a/plugins/GSdx/Renderers/DX11/GSDevice11.cpp +++ b/plugins/GSdx/Renderers/DX11/GSDevice11.cpp @@ -411,6 +411,9 @@ bool GSDevice11::Create(const std::shared_ptr &wnd) SetExclusive(!theApp.GetConfigB("windowed")); } + GSVector2i tex_font = m_osd.get_texture_font_size(); + m_font = CreateSurface(GSTexture::Texture, tex_font.x, tex_font.y, false, DXGI_FORMAT_R8_UNORM); + return true; } @@ -808,6 +811,47 @@ void GSDevice11::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* PSSetShaderResources(NULL, NULL); } +void GSDevice11::RenderOsd(GSTexture* dt) +{ + BeginScene(); + + // om + OMSetDepthStencilState(m_convert.dss, 0); + OMSetBlendState(m_merge.bs, 0); + OMSetRenderTargets(dt, NULL); + + if(m_osd.m_texture_dirty) { + m_osd.upload_texture_atlas(m_font); + } + + // ps + PSSetShaderResource(0, m_font); + PSSetSamplerState(m_convert.pt, NULL); + PSSetShader(m_convert.ps[ShaderConvert_OSD], NULL); + + // ia + IASetInputLayout(m_convert.il); + IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + + // Note scaling could also be done in shader (require gl3/dx10) + size_t count = m_osd.Size(); + void* dst = NULL; + + IAMapVertexBuffer(&dst, sizeof(GSVertexPT1), count); + count = m_osd.GeneratePrimitives((GSVertexPT1*)dst, count); + IAUnmapVertexBuffer(); + + // vs + VSSetShader(m_convert.vs, NULL); + + // gs + GSSetShader(NULL, NULL); + + DrawPrimitive(); + + EndScene(); +} + void GSDevice11::DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, const GSRegPMODE& PMODE, const GSRegEXTBUF& EXTBUF, const GSVector4& c) { bool slbg = PMODE.SLBG; diff --git a/plugins/GSdx/Renderers/DX11/GSDevice11.h b/plugins/GSdx/Renderers/DX11/GSDevice11.h index 3e5db5d95a..55fb0aedec 100644 --- a/plugins/GSdx/Renderers/DX11/GSDevice11.h +++ b/plugins/GSdx/Renderers/DX11/GSDevice11.h @@ -39,7 +39,7 @@ class GSDevice11 : public GSDeviceDX void DoFXAA(GSTexture* sTex, GSTexture* dTex); void DoShadeBoost(GSTexture* sTex, GSTexture* dTex); void DoExternalFX(GSTexture* sTex, GSTexture* dTex); - + void RenderOsd(GSTexture* dt); void InitExternalFX(); void InitFXAA(); // Bug workaround! Stack corruption? Heap corruption? No idea @@ -94,7 +94,7 @@ public: // TODO { CComPtr il; CComPtr vs; - CComPtr ps[18]; + CComPtr ps[ShaderConvert_Count]; CComPtr ln; CComPtr pt; CComPtr dss; @@ -159,6 +159,8 @@ public: // TODO GSConstantBuffer m_gs_cb_cache; PSConstantBuffer m_ps_cb_cache; + GSTexture* m_font; + bool CreateTextureFX(); public: