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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
void setDepthAttachment();
|
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;
|
|
|
|
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-03-30 11:12:17 +00:00
|
|
|
void clearBuffer(bool _fullsize);
|
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
|
|
|
|
|
|
|
static DepthBufferList & get()
|
|
|
|
{
|
|
|
|
static DepthBufferList depthBufferList;
|
|
|
|
return depthBufferList;
|
|
|
|
}
|
|
|
|
|
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();
|
2014-09-08 07:46:42 +00:00
|
|
|
DepthBufferList(const FrameBufferList &);
|
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();
|
|
|
|
#endif
|