From 1837001e754d4e4fc3dead97af82cd0a67b3cfe1 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Tue, 19 May 2015 12:42:14 +0200 Subject: [PATCH] gsdx: extend CopyOffscreen with a new shader parameter Currently we're trying to infer the conversion shader based on the output format It only works if the input data is RGBA8. It might not be true in the future --- plugins/GSdx/GSDevice.h | 2 +- plugins/GSdx/GSDevice11.cpp | 2 +- plugins/GSdx/GSDevice11.h | 2 +- plugins/GSdx/GSDevice9.cpp | 2 +- plugins/GSdx/GSDevice9.h | 2 +- plugins/GSdx/GSDeviceOGL.cpp | 12 ++++++------ plugins/GSdx/GSDeviceOGL.h | 2 +- plugins/GSdx/GSDeviceSW.cpp | 2 +- plugins/GSdx/GSDeviceSW.h | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/plugins/GSdx/GSDevice.h b/plugins/GSdx/GSDevice.h index 04ddafb23d..0a5b629bec 100644 --- a/plugins/GSdx/GSDevice.h +++ b/plugins/GSdx/GSDevice.h @@ -141,7 +141,7 @@ public: virtual GSTexture* Resolve(GSTexture* t) {return NULL;} - virtual GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format = 0) {return NULL;} + virtual GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format = 0, int ps_shader = 0) {return NULL;} virtual void CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r) {} virtual void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, int shader = 0, bool linear = true) {} diff --git a/plugins/GSdx/GSDevice11.cpp b/plugins/GSdx/GSDevice11.cpp index 2d97d52636..c4f4a77190 100644 --- a/plugins/GSdx/GSDevice11.cpp +++ b/plugins/GSdx/GSDevice11.cpp @@ -565,7 +565,7 @@ GSTexture* GSDevice11::Resolve(GSTexture* t) return NULL; } -GSTexture* GSDevice11::CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format) +GSTexture* GSDevice11::CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format, int ps_shader) { GSTexture* dst = NULL; diff --git a/plugins/GSdx/GSDevice11.h b/plugins/GSdx/GSDevice11.h index a4332b4a6a..0783c46329 100644 --- a/plugins/GSdx/GSDevice11.h +++ b/plugins/GSdx/GSDevice11.h @@ -184,7 +184,7 @@ public: GSTexture* Resolve(GSTexture* t); - GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format = 0); + GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format = 0, int ps_shader = 0); void CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r); diff --git a/plugins/GSdx/GSDevice9.cpp b/plugins/GSdx/GSDevice9.cpp index 5731203154..9ce70ba87a 100644 --- a/plugins/GSdx/GSDevice9.cpp +++ b/plugins/GSdx/GSDevice9.cpp @@ -768,7 +768,7 @@ GSTexture* GSDevice9::Resolve(GSTexture* t) return NULL; } -GSTexture* GSDevice9::CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format) +GSTexture* GSDevice9::CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format, int ps_shader) { GSTexture* dst = NULL; diff --git a/plugins/GSdx/GSDevice9.h b/plugins/GSdx/GSDevice9.h index b39ffcc0ab..8c4a17598e 100644 --- a/plugins/GSdx/GSDevice9.h +++ b/plugins/GSdx/GSDevice9.h @@ -209,7 +209,7 @@ public: GSTexture* Resolve(GSTexture* t); - GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format = 0); + GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format = 0, int ps_shader = 0); void CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r); diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 829edc3540..9b091a5cf9 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -666,19 +666,19 @@ GSTexture* GSDeviceOGL::CreateOffscreen(int w, int h, int format) } // blit a texture into an offscreen buffer -GSTexture* GSDeviceOGL::CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format) +GSTexture* GSDeviceOGL::CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format, int ps_shader) { + if (format == 0) + format = GL_RGBA8; + ASSERT(src); ASSERT(format == GL_RGBA8 || format == GL_R16UI); - if(format == 0) format = GL_RGBA8; - - if(format != GL_RGBA8 && format != GL_R16UI) return NULL; - GSTexture* dst = CreateOffscreen(w, h, format); + GSVector4 dRect(0, 0, w, h); - StretchRect(src, sRect, dst, dRect, m_convert.ps[format == GL_R16UI ? 1 : 0]); + StretchRect(src, sRect, dst, dRect, m_convert.ps[ps_shader]); return dst; } diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index 716ac987bf..532ded2a63 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -585,7 +585,7 @@ class GSDeviceOGL : public GSDevice void InitPrimDateTexture(GSTexture* rt); void RecycleDateTexture(); - GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format = 0); + GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format = 0, int ps_shader = 0); void CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r); void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, int shader = 0, bool linear = true); diff --git a/plugins/GSdx/GSDeviceSW.cpp b/plugins/GSdx/GSDeviceSW.cpp index 0916f1ed2c..5518e5eecd 100644 --- a/plugins/GSdx/GSDeviceSW.cpp +++ b/plugins/GSdx/GSDeviceSW.cpp @@ -90,7 +90,7 @@ void GSDeviceSW::ClearStencil(GSTexture* t, uint8 c) Clear(t, c); } -GSTexture* GSDeviceSW::CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format) +GSTexture* GSDeviceSW::CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format, int ps_shader) { GSTexture* dst = CreateOffscreen(w, h, format); diff --git a/plugins/GSdx/GSDeviceSW.h b/plugins/GSdx/GSDeviceSW.h index 4d398a8f18..2488ec974e 100644 --- a/plugins/GSdx/GSDeviceSW.h +++ b/plugins/GSdx/GSDeviceSW.h @@ -50,7 +50,7 @@ public: void ClearDepth(GSTexture* t, float c); void ClearStencil(GSTexture* t, uint8 c); - GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format = 0); + GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format = 0, int ps_shader = 0); void CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r); void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, int shader = 0, bool linear = true);