2013-04-18 03:29:41 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2013-01-31 22:11:53 +00:00
|
|
|
|
|
|
|
#ifndef STREAMBUFFER_H
|
|
|
|
#define STREAMBUFFER_H
|
|
|
|
|
|
|
|
#include "VideoCommon.h"
|
|
|
|
#include "FramebufferManager.h"
|
2013-02-01 14:15:25 +00:00
|
|
|
#include "GLUtil.h"
|
2013-01-31 22:11:53 +00:00
|
|
|
|
2013-03-04 11:40:23 +00:00
|
|
|
// glew < 1.8 doesn't support pinned memory
|
|
|
|
#ifndef GLEW_AMD_pinned_memory
|
|
|
|
#define GLEW_AMD_pinned_memory glewIsSupported("GL_AMD_pinned_memory")
|
|
|
|
#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160
|
|
|
|
#endif
|
|
|
|
|
2013-01-31 22:11:53 +00:00
|
|
|
namespace OGL
|
|
|
|
{
|
|
|
|
enum StreamType {
|
2013-03-23 20:37:01 +00:00
|
|
|
MAP_AND_ORPHAN = (1 << 1),
|
|
|
|
MAP_AND_SYNC = (1 << 2),
|
2014-01-15 22:16:10 +00:00
|
|
|
PINNED_MEMORY = (1 << 3),
|
|
|
|
BUFFERSUBDATA = (1 << 4),
|
|
|
|
BUFFERDATA = (1 << 5),
|
|
|
|
BUFFERSTORAGE = (1 << 6),
|
2013-01-31 22:11:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class StreamBuffer {
|
|
|
|
|
|
|
|
public:
|
2014-01-09 17:52:05 +00:00
|
|
|
StreamBuffer(u32 type, size_t size);
|
2013-01-31 22:11:53 +00:00
|
|
|
~StreamBuffer();
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2014-01-22 17:02:55 +00:00
|
|
|
u8* Map(size_t size, u32 stride = 0);
|
|
|
|
size_t Unmap(size_t used_size); // returns the offset of the beginning of the uploaded block
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2014-01-22 17:02:55 +00:00
|
|
|
inline u32 getBuffer() { return m_buffer; }
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2013-01-31 22:11:53 +00:00
|
|
|
private:
|
|
|
|
void Init();
|
|
|
|
void Shutdown();
|
2013-08-29 19:03:48 +00:00
|
|
|
void DeleteFences();
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2013-01-31 22:11:53 +00:00
|
|
|
StreamType m_uploadtype;
|
|
|
|
u32 m_buffer;
|
|
|
|
u32 m_buffertype;
|
|
|
|
size_t m_size;
|
|
|
|
u8 *pointer;
|
|
|
|
size_t m_iterator;
|
2013-02-01 15:43:08 +00:00
|
|
|
size_t m_used_iterator;
|
|
|
|
size_t m_free_iterator;
|
2013-02-01 14:15:25 +00:00
|
|
|
GLsync *fences;
|
2013-01-31 22:11:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // STREAMBUFFER_H
|