gsdx-ogl: extend StretchRect to write in depth texture

It will allow to convert color texture to depth texture
This commit is contained in:
Gregory Hainaut 2015-06-05 23:26:03 +02:00
parent 0518aaedc9
commit 5bf5b5bca4
2 changed files with 18 additions and 4 deletions

View File

@ -101,6 +101,7 @@ GSDeviceOGL::~GSDeviceOGL()
for (size_t i = 0; i < countof(m_convert.ps); i++) for (size_t i = 0; i < countof(m_convert.ps); i++)
m_shader->Delete(m_convert.ps[i]); m_shader->Delete(m_convert.ps[i]);
delete m_convert.dss; delete m_convert.dss;
delete m_convert.dss_write;
delete m_convert.bs; delete m_convert.bs;
// Clean m_fxaa // Clean m_fxaa
@ -256,8 +257,11 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
bilinear.ltf = true; bilinear.ltf = true;
m_convert.ln = GetSamplerID(bilinear); m_convert.ln = GetSamplerID(bilinear);
m_convert.dss = new GSDepthStencilOGL();
m_convert.bs = new GSBlendStateOGL(); m_convert.bs = new GSBlendStateOGL();
m_convert.dss = new GSDepthStencilOGL();
m_convert.dss_write = new GSDepthStencilOGL();
m_convert.dss_write->EnableDepth();
m_convert.dss_write->SetDepth(GL_ALWAYS, true);
// **************************************************************** // ****************************************************************
// merge // merge
@ -734,6 +738,8 @@ void GSDeviceOGL::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture
return; return;
} }
bool draw_in_depth = (ps == m_convert.ps[12]);
// Performance optimization. It might be faster to use a framebuffer blit for standard case // Performance optimization. It might be faster to use a framebuffer blit for standard case
// instead to emulate it with shader // instead to emulate it with shader
// see https://www.opengl.org/wiki/Framebuffer#Blitting // see https://www.opengl.org/wiki/Framebuffer#Blitting
@ -760,9 +766,16 @@ void GSDeviceOGL::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture
// om // om
// ************************************ // ************************************
OMSetDepthStencilState(m_convert.dss, 0); if (draw_in_depth)
OMSetDepthStencilState(m_convert.dss_write, 0);
else
OMSetDepthStencilState(m_convert.dss, 0);
OMSetBlendState(bs, 0); OMSetBlendState(bs, 0);
OMSetRenderTargets(dTex, NULL); if (draw_in_depth)
OMSetRenderTargets(NULL, dTex);
else
OMSetRenderTargets(dTex, NULL);
OMSetColorMaskState(); OMSetColorMaskState();
// ************************************ // ************************************

View File

@ -122,7 +122,7 @@ class GSDepthStencilOGL {
public: public:
GSDepthStencilOGL() : m_depth_enable(false) GSDepthStencilOGL() : m_depth_enable(false)
, m_depth_func(0) , m_depth_func(GL_ALWAYS)
, m_depth_mask(0) , m_depth_mask(0)
, m_stencil_enable(false) , m_stencil_enable(false)
, m_stencil_func(0) , m_stencil_func(0)
@ -490,6 +490,7 @@ class GSDeviceOGL : public GSDevice
GLuint ln; // sampler object GLuint ln; // sampler object
GLuint pt; // sampler object GLuint pt; // sampler object
GSDepthStencilOGL* dss; GSDepthStencilOGL* dss;
GSDepthStencilOGL* dss_write;
GSBlendStateOGL* bs; GSBlendStateOGL* bs;
} m_convert; } m_convert;