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-07-27 00:40:16 +00:00
|
|
|
DETECT_MASK = 0x7F,
|
2013-03-23 20:37:01 +00:00
|
|
|
STREAM_DETECT = (1 << 0),
|
|
|
|
MAP_AND_ORPHAN = (1 << 1),
|
|
|
|
MAP_AND_SYNC = (1 << 2),
|
|
|
|
MAP_AND_RISK = (1 << 3),
|
|
|
|
PINNED_MEMORY = (1 << 4),
|
2013-07-27 00:40:16 +00:00
|
|
|
BUFFERSUBDATA = (1 << 5),
|
|
|
|
BUFFERDATA = (1 << 6)
|
2013-01-31 22:11:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class StreamBuffer {
|
|
|
|
|
|
|
|
public:
|
2013-03-23 20:37:01 +00:00
|
|
|
StreamBuffer(u32 type, size_t size, StreamType uploadType = DETECT_MASK);
|
2013-01-31 22:11:53 +00:00
|
|
|
~StreamBuffer();
|
|
|
|
|
2013-02-01 14:15:25 +00:00
|
|
|
void Alloc(size_t size, u32 stride = 0);
|
2013-01-31 22:11:53 +00:00
|
|
|
size_t Upload(u8 *data, size_t size);
|
|
|
|
|
|
|
|
u32 getBuffer() { return m_buffer; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
void Init();
|
|
|
|
void Shutdown();
|
|
|
|
|
|
|
|
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
|