diff --git a/plugins/GSdx/Renderers/DXCommon/GSRendererDX.cpp b/plugins/GSdx/Renderers/DXCommon/GSRendererDX.cpp index 011d761f47..620bc94c20 100644 --- a/plugins/GSdx/Renderers/DXCommon/GSRendererDX.cpp +++ b/plugins/GSdx/Renderers/DXCommon/GSRendererDX.cpp @@ -465,11 +465,10 @@ void GSRendererDX::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sourc if (DATE) { - GSVector4 s = GSVector4(rtscale.x / rtsize.x, rtscale.y / rtsize.y); - GSVector4 off = GSVector4(-1.0f, 1.0f); + GSVector4i dRect = ComputeBoundingBox(rtscale, rtsize); - GSVector4 src = ((m_vt.m_min.p.xyxy(m_vt.m_max.p) + off.xxyy()) * s.xyxy()).sat(off.zzyy()); - GSVector4 dst = src * 2.0f + off.xxxx(); + GSVector4 src = GSVector4(dRect) / GSVector4(rtsize.x, rtsize.y).xyxy(); + GSVector4 dst = src * 2.0f - 1.0f; GSVertexPT1 vertices[] = { @@ -488,8 +487,8 @@ void GSRendererDX::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sourc if (hdr_colclip) { // fprintf(stderr, "COLCLIP HDR mode ENABLED\n"); - GSVector4 sRect(0, 0, 1, 1); - GSVector4 dRect(0, 0, rtsize.x, rtsize.y); + GSVector4 dRect(ComputeBoundingBox(rtscale, rtsize)); + GSVector4 sRect = dRect / GSVector4(rtsize.x, rtsize.y).xyxy(); hdr_rt = dev->CreateRenderTarget(rtsize.x, rtsize.y, false, DXGI_FORMAT_R32G32B32A32_FLOAT); // Warning: StretchRect must be called before BeginScene otherwise // vertices will be overwritten. Trust me you don't want to do that. @@ -674,7 +673,7 @@ void GSRendererDX::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sourc const GSVector4& hacked_scissor = m_channel_shuffle ? GSVector4(0, 0, 1024, 1024) : m_context->scissor.in; GSVector4i scissor = GSVector4i(GSVector4(rtscale).xyxy() * hacked_scissor).rintersect(GSVector4i(rtsize).zwxy()); - if (hdr_colclip) + if (hdr_rt) dev->OMSetRenderTargets(hdr_rt, ds, &scissor); else dev->OMSetRenderTargets(rt, ds, &scissor); @@ -764,8 +763,8 @@ void GSRendererDX::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sourc // vertices will be overwritten. Trust me you don't want to do that. if (hdr_rt) { - GSVector4 sRect(0, 0, 1, 1); - GSVector4 dRect(0, 0, rtsize.x, rtsize.y); + GSVector4 dRect(ComputeBoundingBox(rtscale, rtsize)); + GSVector4 sRect = dRect / GSVector4(rtsize.x, rtsize.y).xyxy(); dev->StretchRect(hdr_rt, sRect, rt, dRect, ShaderConvert_MOD_256, false); dev->Recycle(hdr_rt); diff --git a/plugins/GSdx/Renderers/HW/GSRendererHW.cpp b/plugins/GSdx/Renderers/HW/GSRendererHW.cpp index a787916a48..7dd15cfb78 100644 --- a/plugins/GSdx/Renderers/HW/GSRendererHW.cpp +++ b/plugins/GSdx/Renderers/HW/GSRendererHW.cpp @@ -489,6 +489,14 @@ GSVector4 GSRendererHW::RealignTargetTextureCoordinate(const GSTextureCache::Sou return half_offset; } +GSVector4i GSRendererHW::ComputeBoundingBox(const GSVector2& rtscale, const GSVector2i& rtsize) +{ + GSVector4 scale = GSVector4(rtscale.x, rtscale.y); + GSVector4 offset = GSVector4(-1.0f, 1.0f); // Round value + GSVector4 box = m_vt.m_min.p.xyxy(m_vt.m_max.p) + offset.xxyy(); + return GSVector4i(box * scale.xyxy()).rintersect(GSVector4i(0, 0, rtsize.x, rtsize.y)); +} + void GSRendererHW::MergeSprite(GSTextureCache::Source* tex) { // Upscaling hack to avoid various line/grid issues diff --git a/plugins/GSdx/Renderers/HW/GSRendererHW.h b/plugins/GSdx/Renderers/HW/GSRendererHW.h index 28701d34df..419467cdb1 100644 --- a/plugins/GSdx/Renderers/HW/GSRendererHW.h +++ b/plugins/GSdx/Renderers/HW/GSRendererHW.h @@ -169,6 +169,7 @@ public: void SetScaling(); void Lines2Sprites(); GSVector4 RealignTargetTextureCoordinate(const GSTextureCache::Source* tex); + GSVector4i ComputeBoundingBox(const GSVector2& rtscale, const GSVector2i& rtsize); void MergeSprite(GSTextureCache::Source* tex); void Reset(); diff --git a/plugins/GSdx/Renderers/OpenGL/GSRendererOGL.cpp b/plugins/GSdx/Renderers/OpenGL/GSRendererOGL.cpp index 91060ab386..1bc08cefe1 100644 --- a/plugins/GSdx/Renderers/OpenGL/GSRendererOGL.cpp +++ b/plugins/GSdx/Renderers/OpenGL/GSRendererOGL.cpp @@ -964,14 +964,6 @@ GSRendererOGL::PRIM_OVERLAP GSRendererOGL::PrimitiveOverlap() return overlap; } -GSVector4i GSRendererOGL::ComputeBoundingBox(const GSVector2& rtscale, const GSVector2i& rtsize) -{ - GSVector4 scale = GSVector4(rtscale.x, rtscale.y); - GSVector4 offset = GSVector4(-1.0f, 1.0f); // Round value - GSVector4 box = m_vt.m_min.p.xyxy(m_vt.m_max.p) + offset.xxyy(); - return GSVector4i(box * scale.xyxy()).rintersect(GSVector4i(0, 0, rtsize.x, rtsize.y)); -} - void GSRendererOGL::SendDraw() { GSDeviceOGL* dev = (GSDeviceOGL*)m_dev; diff --git a/plugins/GSdx/Renderers/OpenGL/GSRendererOGL.h b/plugins/GSdx/Renderers/OpenGL/GSRendererOGL.h index 46827c30c1..d74d35caa7 100644 --- a/plugins/GSdx/Renderers/OpenGL/GSRendererOGL.h +++ b/plugins/GSdx/Renderers/OpenGL/GSRendererOGL.h @@ -59,8 +59,6 @@ class GSRendererOGL final : public GSRendererHW GSDeviceOGL::VSConstantBuffer vs_cb; GSDeviceOGL::PSConstantBuffer ps_cb; - GSVector4i ComputeBoundingBox(const GSVector2& rtscale, const GSVector2i& rtsize); - bool m_require_one_barrier; bool m_require_full_barrier;