2013-04-05 06:13:26 +00:00
|
|
|
#ifndef DEPTHBUFFER_H
|
|
|
|
#define DEPTHBUFFER_H
|
|
|
|
|
|
|
|
#include "Types.h"
|
2013-11-27 10:08:48 +00:00
|
|
|
#include "Textures.h"
|
2017-01-21 11:55:14 +00:00
|
|
|
#include "Graphics/ObjectHandle.h"
|
|
|
|
#include "Graphics/Parameter.h"
|
2013-04-05 06:13:26 +00:00
|
|
|
|
2015-11-23 12:36:03 +00:00
|
|
|
struct FrameBuffer;
|
2017-01-21 11:55:14 +00:00
|
|
|
|
2013-04-05 06:13:26 +00:00
|
|
|
struct DepthBuffer
|
|
|
|
{
|
2014-09-08 11:00:13 +00:00
|
|
|
DepthBuffer();
|
|
|
|
DepthBuffer(DepthBuffer && _other);
|
|
|
|
~DepthBuffer();
|
2015-01-27 16:00:06 +00:00
|
|
|
void initDepthImageTexture(FrameBuffer * _pBuffer);
|
|
|
|
void initDepthBufferTexture(FrameBuffer * _pBuffer);
|
2015-02-13 12:06:59 +00:00
|
|
|
CachedTexture * resolveDepthBufferTexture(FrameBuffer * _pBuffer);
|
2016-05-08 11:25:22 +00:00
|
|
|
CachedTexture * copyDepthBufferTexture(FrameBuffer * _pBuffer);
|
2015-01-27 16:00:06 +00:00
|
|
|
|
2017-01-28 09:52:09 +00:00
|
|
|
void setDepthAttachment(graphics::ObjectHandle _fbo, graphics::BufferTargetParam _target);
|
2015-02-13 12:06:59 +00:00
|
|
|
void activateDepthBufferTexture(FrameBuffer * _pBuffer);
|
2015-01-27 16:00:06 +00:00
|
|
|
|
|
|
|
void bindDepthImageTexture();
|
2014-09-08 11:00:13 +00:00
|
|
|
|
|
|
|
u32 m_address, m_width;
|
2016-09-11 11:08:03 +00:00
|
|
|
u32 m_ulx, m_uly, m_lrx, m_lry; // Parameters of fillrect command.
|
2017-02-15 07:24:37 +00:00
|
|
|
CachedTexture *m_pDepthImageZTexture;
|
|
|
|
CachedTexture *m_pDepthImageDeltaZTexture;
|
2015-01-27 16:00:06 +00:00
|
|
|
CachedTexture *m_pDepthBufferTexture;
|
2017-01-21 11:55:14 +00:00
|
|
|
graphics::ObjectHandle m_depthRenderbuffer;
|
2016-06-21 18:57:18 +00:00
|
|
|
u32 m_depthRenderbufferWidth;
|
2015-02-17 16:10:44 +00:00
|
|
|
bool m_cleared;
|
2015-02-13 12:06:59 +00:00
|
|
|
// multisampling
|
|
|
|
CachedTexture *m_pResolveDepthBufferTexture;
|
|
|
|
bool m_resolved;
|
2016-05-08 11:25:22 +00:00
|
|
|
// render to depth buffer
|
2017-01-21 11:55:14 +00:00
|
|
|
graphics::ObjectHandle m_copyFBO;
|
2016-05-08 11:25:22 +00:00
|
|
|
CachedTexture *m_pDepthBufferCopyTexture;
|
|
|
|
bool m_copied;
|
2015-02-13 12:06:59 +00:00
|
|
|
|
|
|
|
private:
|
2017-02-17 08:50:55 +00:00
|
|
|
void _initDepthImageTexture(FrameBuffer * _pBuffer, CachedTexture& _cachedTexture);
|
2015-02-13 12:06:59 +00:00
|
|
|
void _initDepthBufferTexture(FrameBuffer * _pBuffer, CachedTexture *_pTexture, bool _multisample);
|
2016-06-21 18:57:18 +00:00
|
|
|
void _initDepthBufferRenderbuffer(FrameBuffer * _pBuffer);
|
2016-05-08 11:25:22 +00:00
|
|
|
void _DepthBufferTexture(FrameBuffer * _pBuffer);
|
2013-04-05 06:13:26 +00:00
|
|
|
};
|
|
|
|
|
2014-09-08 11:00:13 +00:00
|
|
|
class DepthBufferList
|
2013-04-05 06:13:26 +00:00
|
|
|
{
|
2014-09-08 11:00:13 +00:00
|
|
|
public:
|
|
|
|
void init();
|
|
|
|
void destroy();
|
|
|
|
void saveBuffer(u32 _address);
|
|
|
|
void removeBuffer(u32 _address);
|
2016-09-11 11:08:03 +00:00
|
|
|
void clearBuffer(u32 _ulx, u32 _uly, u32 _lrx, u32 _lry);
|
2015-02-17 16:10:44 +00:00
|
|
|
void setNotCleared();
|
2014-09-08 11:00:13 +00:00
|
|
|
DepthBuffer *findBuffer(u32 _address);
|
|
|
|
DepthBuffer * getCurrent() const {return m_pCurrent;}
|
2014-09-08 07:46:42 +00:00
|
|
|
|
2015-03-31 12:44:41 +00:00
|
|
|
static DepthBufferList & get();
|
2014-09-08 07:46:42 +00:00
|
|
|
|
2015-01-27 11:56:22 +00:00
|
|
|
const u16 * const getZLUT() const {return m_pzLUT;}
|
|
|
|
|
2014-09-08 07:46:42 +00:00
|
|
|
private:
|
2015-03-26 15:24:51 +00:00
|
|
|
DepthBufferList();
|
2015-11-22 08:28:51 +00:00
|
|
|
DepthBufferList(const DepthBufferList &);
|
2015-03-26 15:24:51 +00:00
|
|
|
~DepthBufferList();
|
2014-09-08 11:00:13 +00:00
|
|
|
|
|
|
|
typedef std::list<DepthBuffer> DepthBuffers;
|
|
|
|
DepthBuffers m_list;
|
|
|
|
DepthBuffer *m_pCurrent;
|
2015-01-27 11:56:22 +00:00
|
|
|
u16 * m_pzLUT;
|
2013-04-05 06:13:26 +00:00
|
|
|
};
|
|
|
|
|
2014-09-08 07:46:42 +00:00
|
|
|
inline
|
|
|
|
DepthBufferList & depthBufferList()
|
|
|
|
{
|
|
|
|
return DepthBufferList::get();
|
|
|
|
}
|
2013-04-05 06:13:26 +00:00
|
|
|
|
|
|
|
void DepthBuffer_Init();
|
|
|
|
void DepthBuffer_Destroy();
|
2015-05-04 09:40:17 +00:00
|
|
|
|
2013-04-05 06:13:26 +00:00
|
|
|
#endif
|