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"
|
2013-04-05 06:13:26 +00:00
|
|
|
|
2015-11-23 12:36:03 +00:00
|
|
|
struct FrameBuffer;
|
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);
|
2015-01-27 16:00:06 +00:00
|
|
|
|
2015-04-01 09:08:17 +00:00
|
|
|
void setDepthAttachment(GLenum _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;
|
2015-04-29 16:14:57 +00:00
|
|
|
u32 m_uly, m_lry; // Top and bottom bounds of fillrect command.
|
2014-09-08 11:00:13 +00:00
|
|
|
GLuint m_FBO;
|
2015-01-27 16:00:06 +00:00
|
|
|
CachedTexture *m_pDepthImageTexture;
|
|
|
|
CachedTexture *m_pDepthBufferTexture;
|
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;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void _initDepthBufferTexture(FrameBuffer * _pBuffer, CachedTexture *_pTexture, bool _multisample);
|
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);
|
2015-04-29 16:14:57 +00:00
|
|
|
void clearBuffer(u32 _uly, 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
|
|
|
|
2013-12-14 14:30:20 +00:00
|
|
|
extern const GLuint ZlutImageUnit;
|
|
|
|
extern const GLuint TlutImageUnit;
|
|
|
|
extern const GLuint depthImageUnit;
|
|
|
|
|
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
|